Class EnvironmentCache
java.lang.Object
org.apache.commons.discovery.tools.EnvironmentCache
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
FieldsModifier and TypeFieldDescriptionprivate static final Map<ClassLoader,Map<String, Object>> Allows null key, important as default groupContext is null.static final intInitial hash size for SPI's, default just seem TO big today.. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionget(ClassLoader classLoader) Get object keyed by classLoader.static voidput(ClassLoader classLoader, Map<String, Object> spis) Put service keyed by spi & classLoader.static voidrelease()Release all internal references to previously created service instances associated with the current thread context class loader.static voidrelease(ClassLoader classLoader) Release any internal references to a previously created service instance associated with the current thread context class loader.
-
Field Details
-
root_cache
Allows null key, important as default groupContext is null. We will manage synchronization directly, so all caches are implemented as HashMap (unsynchronized). -
smallHashSize
public static final int smallHashSizeInitial hash size for SPI's, default just seem TO big today..- See Also:
-
-
Constructor Details
-
EnvironmentCache
public EnvironmentCache()
-
-
Method Details
-
get
Get object keyed by classLoader.- Parameters:
classLoader- The class loader key- Returns:
- The SPI name/instance cache
-
put
Put service keyed by spi & classLoader.- Parameters:
classLoader- The class loader keyspis- 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. Therelease()method is called for service instances that implement theServiceinterface. 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
Release any internal references to a previously created service instance associated with the current thread context class loader. If the SPI instance implementsService, then callrelease().- Parameters:
classLoader- The class loader key
-