Module org.snmp4j

Class CipherPool


  • public class CipherPool
    extends java.lang.Object
    The CipherPool class provides service to share and reuse Cipher instances, across different threads. The maximum number of Ciphers in the pool might temporarily exceed the maxPoolSize to minimize waiting time.
    Since:
    2.2.2
    Author:
    Frank Fock
    • Constructor Summary

      Constructors 
      Constructor Description
      CipherPool()
      Creates a new cipher pool with a pool size of Runtime.availableProcessors().
      CipherPool​(int maxPoolSize)
      Creates a new cipher pool with a given pool size.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getMaxPoolSize()  
      void offerCipher​(javax.crypto.Cipher cipher)
      Offers a Cipher to the pool (thus returns it to the pool).
      javax.crypto.Cipher reuseCipher()
      Gets a Cipher from the pool.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CipherPool

        public CipherPool()
        Creates a new cipher pool with a pool size of Runtime.availableProcessors().
      • CipherPool

        public CipherPool​(int maxPoolSize)
        Creates a new cipher pool with a given pool size.
        Parameters:
        maxPoolSize - the maximum number of ciphers in the pool.
    • Method Detail

      • getMaxPoolSize

        public int getMaxPoolSize()
      • reuseCipher

        public javax.crypto.Cipher reuseCipher()
        Gets a Cipher from the pool. It must be returned to the pool by calling offerCipher(Cipher) when one of its Cipher.doFinal() methods have been called and it is not needed anymore.
        Returns:
        a Cipher from the pool, or null if the pool currently does not contain any cipher.
      • offerCipher

        public void offerCipher​(javax.crypto.Cipher cipher)
        Offers a Cipher to the pool (thus returns it to the pool).
        Parameters:
        cipher - a Cipher instance previously acquired by reuseCipher() or created externally.