com.ibm.commerce.registry

Class AbstractManagedDynamicCacheRegistry

  • java.lang.Object
    • com.ibm.commerce.registry.AbstractManagedDynamicCacheRegistry
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String COPYRIGHT
      IBM copyright notice field.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method and Description
      void addElement(java.lang.Object key, java.lang.Object cacheObject)
      This method adds an element to the cache.
      abstract java.lang.Object createKey(java.lang.String strKey)
      This method creates a cache key for this registry based on a string representation of the key.
      abstract java.lang.String createKeyString(TypedProperty prop)
      This method creates a string representation of a cache key for this registry based on the input properties.
      java.lang.Object findObject(java.lang.Object key)
      This method gets an object from the registry.
      com.ibm.commerce.registry.LRUDynamicHashtable getCache()
      This method gets the cache.
      int getCacheSize()
      This method returns the total number of cache entries.
      java.lang.Object getElement(java.lang.Object key)
      This method gets an element from the cache.
      int getElementCount()
      This method gets the current number of cached elements.
      java.util.Enumeration getElements()
      This method gets an enumeration of all cached elements.
      long getEvictions()
      This method returns the number of entries that have been removed from the cache by an LRU (least-recently-used) algorithm.
      long getHits()
      This method returns the number of cache hits.
      java.util.Enumeration getKeys()
      This method gets an enumeration of all cached keys.
      long getMisses()
      This method returns the number of cache misses.
      int getUsedCacheSize()
      This method returns the number of currently contained cache entries.
      void initialize()
      This method initializes the registry.
      abstract void populate(com.ibm.commerce.registry.LRUDynamicHashtable aCache)
      This method populates the cache object.
      void refresh()
      This method refreshes all the elements in the cache.
      void removeAllElements()
      This method removes all cached elements.
      void removeElement(java.lang.Object key)
      This method removes an element from the cache.
      abstract java.lang.Object retrieve(java.lang.Object key)
      This method retrieves an object from the database and adds it to the registry.
      void setCache(com.ibm.commerce.registry.LRUDynamicHashtable cache)
      This method sets the cache.
      void setCacheSize(int size)
      This method specifies the maximum cache size.
      void setInitialCapacity(int initialCapacity)
      This method sets the initial capacity of the registry.
      void setLoadFactor(float loadFactor)
      This method sets the load factor of the registry.
      void update(java.lang.String action, java.lang.Object key)
      This method updates a cached element.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        IBM copyright notice field.
        See Also:
        Constant Field Values
    • Constructor Detail

      • AbstractManagedDynamicCacheRegistry

        public AbstractManagedDynamicCacheRegistry()
    • Method Detail

      • retrieve

        public abstract java.lang.Object retrieve(java.lang.Object key)
                                           throws java.lang.Exception
        This method retrieves an object from the database and adds it to the registry.
        Parameters:
        key - A key used to identify the object to be retrieved.
        Returns:
        The object associated with the key.
        Throws:
        java.lang.Exception - Thrown if the object cannot be retrieved from database.
      • populate

        public abstract void populate(com.ibm.commerce.registry.LRUDynamicHashtable aCache)
                               throws java.lang.Exception
        This method populates the cache object. This method should be a no op if this registry supports lazy fetch.
        Parameters:
        key - A key used to identify the object to be retrieved.
        Throws:
        java.lang.Exception - Thrown if the object cannot be found in the database and populated to the cache.
      • createKeyString

        public abstract java.lang.String createKeyString(TypedProperty prop)
                                                  throws java.lang.Exception
        This method creates a string representation of a cache key for this registry based on the input properties.
        Specified by:
        createKeyString in interface ElementUpdate
        Parameters:
        prop - The input properties used to construct the string cache key
        Returns:
        The string representation of the cache key
        Throws:
        java.lang.Exception
      • createKey

        public abstract java.lang.Object createKey(java.lang.String strKey)
                                            throws java.lang.Exception
        This method creates a cache key for this registry based on a string representation of the key.
        Specified by:
        createKey in interface ElementUpdate
        Parameters:
        strKey - The string representation of the cache key.
        Returns:
        The cache key.
        Throws:
        java.lang.Exception
      • addElement

        public void addElement(java.lang.Object key,
                               java.lang.Object cacheObject)
        This method adds an element to the cache.
        Parameters:
        key - The cache key.
        cacheObject - An object to be cached.
      • getElement

        public java.lang.Object getElement(java.lang.Object key)
        This method gets an element from the cache.
        Specified by:
        getElement in interface ElementUpdate
        Parameters:
        key - The cache key.
        Returns:
        A cached element.
      • getElements

        public java.util.Enumeration getElements()
        This method gets an enumeration of all cached elements.
        Returns:
        An enumeration of all cached elements.
      • getKeys

        public java.util.Enumeration getKeys()
        This method gets an enumeration of all cached keys.
        Returns:
        An enumeration of all cached keys.
      • getElementCount

        public int getElementCount()
        This method gets the current number of cached elements.
        Returns:
        The number of cached elements.
      • findObject

        public java.lang.Object findObject(java.lang.Object key)
                                    throws java.lang.Exception
        This method gets an object from the registry. It will first look for the object in the cache. If the object is not in the cache, then it will retrieve it from the database and add it to the cache.
        Parameters:
        key - The cache key.
        Returns:
        The object associated with the key.
        Throws:
        java.lang.Exception - Thrown if the object cannot be found in database.
      • initialize

        public void initialize()
                        throws java.lang.Exception
        This method initializes the registry. The cache size and/or the initialCapacity (if set) will be used to construct the dynamic cache. The registry will then be populated by calling the populate method.
        Specified by:
        initialize in interface Registry
        Throws:
        java.lang.Exception - during initialization.
      • refresh

        public void refresh()
                     throws java.lang.Exception
        This method refreshes all the elements in the cache.
        Specified by:
        refresh in interface Registry
        Throws:
        java.lang.Exception
      • update

        public void update(java.lang.String action,
                           java.lang.Object key)
                    throws java.lang.Exception
        This method updates a cached element.
        Specified by:
        update in interface ElementUpdate
        Parameters:
        action - The action performed on the registry. For example, a delete or an update.
        key - The cache key.
        Throws:
        java.lang.Exception
      • removeAllElements

        public void removeAllElements()
        This method removes all cached elements.
      • removeElement

        public void removeElement(java.lang.Object key)
        This method removes an element from the cache.
        Parameters:
        key - The cache key.
      • getCacheSize

        public int getCacheSize()
        This method returns the total number of cache entries.
        Specified by:
        getCacheSize in interface ManagedDynamicCache
        Returns:
        The maximum size of the cache.
      • getMisses

        public long getMisses()
        This method returns the number of cache misses.
        Specified by:
        getMisses in interface ManagedDynamicCache
        Returns:
        The number of cache misses.
      • getEvictions

        public long getEvictions()
        This method returns the number of entries that have been removed from the cache by an LRU (least-recently-used) algorithm.
        Specified by:
        getEvictions in interface ManagedDynamicCache
        Returns:
        The number of entries that have been removed from the cache.
      • getHits

        public long getHits()
        This method returns the number of cache hits.
        Specified by:
        getHits in interface ManagedDynamicCache
        Returns:
        The number of cache hits.
      • getUsedCacheSize

        public int getUsedCacheSize()
        This method returns the number of currently contained cache entries.
        Specified by:
        getUsedCacheSize in interface ManagedDynamicCache
        Returns:
        The number of cached entries.
      • setCacheSize

        public void setCacheSize(int size)
        This method specifies the maximum cache size.
        Parameters:
        The - size of the cache.
      • setInitialCapacity

        public void setInitialCapacity(int initialCapacity)
        This method sets the initial capacity of the registry.
        Specified by:
        setInitialCapacity in interface ManagedDynamicCache
        Parameters:
        The - initial capacity of the registry.
      • setLoadFactor

        public void setLoadFactor(float loadFactor)
        This method sets the load factor of the registry.
        Parameters:
        The - load factor of the registry.
      • getCache

        public com.ibm.commerce.registry.LRUDynamicHashtable getCache()
        This method gets the cache.
        Returns:
        An LRUDynamicHashtable object.
      • setCache

        public void setCache(com.ibm.commerce.registry.LRUDynamicHashtable cache)
        This method sets the cache.
        Parameters:
        cache - The cache to set.