Class EnvironmentCache

java.lang.Object
org.apache.commons.discovery.tools.EnvironmentCache

public class EnvironmentCache extends Object
Cache by a 'key' unique to the environment: - ClassLoader::groupContext::Object Cache Cache : HashMap Key : Thread Context Class Loader (ClassLoader) Value : groupContext::SPI Cache (HashMap) //- groupContext::Object Cache // Cache : HashMap // Key : groupContext (String) // Value : Object When we 'release', it is expected that the caller of the 'release' have the same thread context class loader... as that will be used to identify cached entries to be released.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Initial hash size for SPI's, default just seem TO big today..
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Map<String,Object>
    get(ClassLoader classLoader)
    Get object keyed by classLoader.
    static void
    put(ClassLoader classLoader, Map<String,Object> spis)
    Put service keyed by spi invalid input: '&' classLoader.
    static void
    Release all internal references to previously created service instances associated with the current thread context class loader.
    static void
    release(ClassLoader classLoader)
    Release any internal references to a previously created service instance associated with the current thread context class loader.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • get

      public static Map<String,Object> get(ClassLoader classLoader)
      Get object keyed by classLoader.
      Parameters:
      classLoader - The class loader key
      Returns:
      The SPI name/instance cache
    • put

      public static void put(ClassLoader classLoader, Map<String,Object> spis)
      Put service keyed by spi invalid input: '&' classLoader.
      Parameters:
      classLoader - The class loader key
      spis - The SPI name/instance cache
    • release

      public static void release()
      Release all internal references to previously created service instances associated with the current thread context class loader. The release() method is called for service instances that implement the Service interface. This is useful in environments like servlet containers, which implement application reloading by throwing away a ClassLoader. Dangling references to objects in that class loader would prevent garbage collection.
    • release

      public static void release(ClassLoader classLoader)
      Release any internal references to a previously created service instance associated with the current thread context class loader. If the SPI instance implements Service, then call release().
      Parameters:
      classLoader - The class loader key