public class ComponentAccessUtil
extends java.lang.Object
Features:
| Modifier and Type | Class and Description |
|---|---|
protected static class |
ComponentAccessUtil.CompRefHelper
Component reference plus synchronization support for other threads
that request the same component reference but must wait until the shared component
has been activated.
|
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<java.lang.String,ComponentAccessUtil.CompRefHelper> |
compName2Comp
key = component instance name,
value = component reference + sync support for other threads that request the same component.
|
protected ContainerServices |
contSrv |
protected java.util.logging.Logger |
logger |
| Constructor and Description |
|---|
ComponentAccessUtil(ContainerServices contSrv) |
| Modifier and Type | Method and Description |
|---|---|
java.util.List<java.lang.String> |
getCachedComponentNames()
Lists the names of the component instances that have already been retrieved.
|
java.util.List<ACSComponentOperations> |
getCachedComponents() |
<T extends ACSComponentOperations> |
getDynamicComponent(ComponentSpec compSpec,
java.lang.Class<T> idlOpInterface)
Returns the cached reference or the component retrieved from the container services
|
protected <T extends ACSComponentOperations> |
getDynamicComponentFromContainerServices(ComponentSpec compSpec,
java.lang.Class<T> idlOpInterface)
Gets the component via
contSrv, without using the cache. |
protected <T,U extends ACSComponentOperations & ComponentLifecycle> |
initCompImpl(U compImpl,
java.lang.Class<T> idlOpInterface)
Convenience method for subclasses created by unit tests,
that override
#getComponentFromContainerServices(String, Class)
and need to create and initialize component implementation classes locally inside the test. |
void |
logInfo() |
void |
releaseAllComponents(boolean waitForCompsRelease)
Should be called when none of the components are needed any more.
|
void |
releaseComponent(java.lang.String compName,
boolean waitForCompRelease)
Should be called when a component is no longer needed.
|
void |
releaseComponents(java.util.Collection<java.lang.String> componentNames,
boolean waitForCompsRelease)
Releases a set of components sequentially.
|
protected final java.util.logging.Logger logger
protected final ContainerServices contSrv
protected final java.util.Map<java.lang.String,ComponentAccessUtil.CompRefHelper> compName2Comp
This map must be protected from concurrent access.
public ComponentAccessUtil(ContainerServices contSrv)
public <T extends ACSComponentOperations> T getDynamicComponent(ComponentSpec compSpec,
java.lang.Class<T> idlOpInterface)
throws AcsJContainerServicesEx
T - The IDL-derived component interfacecompSpec - idlOpInterface - AcsJContainerServicesExprotected <T extends ACSComponentOperations> T getDynamicComponentFromContainerServices(ComponentSpec compSpec,
java.lang.Class<T> idlOpInterface)
throws AcsJContainerServicesEx
contSrv, without using the cache.
Can be overridden for tests, to bypass the container services.AcsJContainerServicesExpublic java.util.List<java.lang.String> getCachedComponentNames()
public java.util.List<ACSComponentOperations> getCachedComponents()
public void releaseComponent(java.lang.String compName,
boolean waitForCompRelease)
waitForCompRelease - If true this method waits for the complete component release
otherwise returns immediatelypublic void releaseAllComponents(boolean waitForCompsRelease)
waitForCompsRelease - If true this method waits for the complete components release, otherwise returns immediately.public void releaseComponents(java.util.Collection<java.lang.String> componentNames,
boolean waitForCompsRelease)
Subclasses may override this method, see for example ConcurrentComponentAccessUtil.releaseComponents(Collection, boolean),
to implement concurrent component release calls, which then also affects releaseAllComponents(boolean).
componentNames - The name of the components to releasewaitForCompsRelease - If true this method waits for the complete components release
otherwise returns immediatelypublic void logInfo()
protected <T,U extends ACSComponentOperations & ComponentLifecycle> T initCompImpl(U compImpl, java.lang.Class<T> idlOpInterface) throws ComponentLifecycleException
#getComponentFromContainerServices(String, Class)
and need to create and initialize component implementation classes locally inside the test.ComponentLifecycleException