Class ContainerAdapter
 The application descriptor file (coherence-application.xml) contains the
 location of a cache configuration file and (optionally) a POF configuration file.
 It may also specify the name of a ConfigurableCacheFactory class to be
 used to create caches instead of the system-wide default
 (Note that this class must implement ExtensibleConfigurableCacheFactory).
 
 After creating an instance of ContainerAdapter. the container should call
 activate() to start the application and deactivate() to stop it.
- Since:
- Coherence 12.1.2
- Author:
- cf 2011.05.24
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic interfaceA factory for producing aCoherenceinstance.protected classContainerCacheFactoryBuilder creates aConfigurableCacheFactoryinstance using the knowledge from this ContainerAdapter instance.static classA default implementation of aContainerAdapter.CoherenceFactory.static classTheContainerAdapter.DefaultContextrepresents the context for an application.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected static final StringInternally used "default" URI identifier.protected final ServiceMonitorTheServiceMonitorto use.TheContainerAdapter.ContainerCacheFactoryBuilderused to create aConfigurableCacheFactoryfor the application.protected CoherenceThe Coherence instance.protected ContainerContextThe ContainerContext.protected ContainerAdapter.DefaultContextTheContextfor the application.protected booleanIndicates whether the ContainerAdapter has been activated or not.protected ExtensibleConfigurableCacheFactoryTheConfigurableCacheFactoryfor the application.protected booleanIndicates whether the ServiceMonitor has been exclusively created for this ContainerAdapter.protected LifecycleListenerTheLifecycleListenerused for lifecycle callbacks to the application.protected List<LifecycleListener> TheLifecycleListeners to be notified of lifecycle events for thisContainerAdapter.protected ClassLoaderTheClassLoaderfor the application.protected ClassLoaderThe caller's thread contextClassLoader.protected StringThe URI to the coherence-application.xml file.protected StringThe name of the application.protected XmlElementTheXmlElementrepresenting the application descriptor.
- 
Constructor SummaryConstructorsConstructorDescriptionContainerAdapter(ClassLoader loader, String sAppDescriptorURI, String sAppName) Construct the ContainerAdapter.ContainerAdapter(ClassLoader loader, String sAppDescriptorURI, String sAppName, CacheFactoryBuilder builder, XmlElement xmlAppDescriptor, ServiceMonitor serviceMonitor) Construct the ContainerAdapter.ContainerAdapter(ClassLoader loader, String sAppDescriptorURI, String sAppName, XmlElement xmlAppDescriptor) Construct the ContainerAdapter.
- 
Method SummaryModifier and TypeMethodDescriptionvoidactivate()Initialize and start the application that is hosted by this ContainerAdapter.voidassociateWithClassLoader(ClassLoader[] aClassLoaders) Associates the application hosted by this ContainerAdapter with specifiedClassLoaders.voidDeactivate the application hosted by this ContainerAdapter.voiddeactivate(boolean fShutdown) Deactivate the application hosted by this ContainerAdapter.protected voidEnsure that the thread context ClassLoader is set to the ContainerAdapter's ClassLoader; save the current thread context ClassLoader if necessary.protected static XmlElementextractFactoryConfig(XmlElement xmlAppDescriptor) Extract theXmlElementrepresenting the factory for theConfigurableCacheFactoryinstance.Return theContextfor the application.Return theCoherenceinstance used by this ContainerAdapter.Return theContainerContextused by this ContainerAdapter.Return the ClassLoader used by this ContainerAdapter.protected List<LifecycleListener> Returns an unmodifiable list ofLifecycleListeners registered for thisContainerAdapter.protected voidRestore the thread contextClassLoaderfor the caller.voidSet theContainerAdapter.CoherenceFactoryto use to createCoherenceinstances.voidSet the ContainerContext associated with this ContainerAdapter instance.
- 
Field Details- 
CACHE_URI_DEFAULTInternally used "default" URI identifier.- See Also:
 
- 
f_serviceMonitorTheServiceMonitorto use.
- 
m_builderTheContainerAdapter.ContainerCacheFactoryBuilderused to create aConfigurableCacheFactoryfor the application.
- 
m_factoryTheConfigurableCacheFactoryfor the application.
- 
m_coherenceThe Coherence instance.
- 
m_loaderTheClassLoaderfor the application.
- 
m_sAppDescriptorURIThe URI to the coherence-application.xml file.
- 
m_xmlAppDescriptorTheXmlElementrepresenting the application descriptor.
- 
m_sAppNameThe name of the application.
- 
m_containerCtxThe ContainerContext.
- 
m_listenerTheLifecycleListenerused for lifecycle callbacks to the application.
- 
m_listLifecycleListenerTheLifecycleListeners to be notified of lifecycle events for thisContainerAdapter.The LifecycleListeners will be discovered and loaded using theServiceLoader.
- 
m_contextTheContextfor the application.
- 
m_loaderCtxThe caller's thread contextClassLoader.
- 
m_fActivatedprotected boolean m_fActivatedIndicates whether the ContainerAdapter has been activated or not.
- 
m_fExclusiveMonitorprotected boolean m_fExclusiveMonitorIndicates whether the ServiceMonitor has been exclusively created for this ContainerAdapter.
 
- 
- 
Constructor Details- 
ContainerAdapterConstruct the ContainerAdapter.- Parameters:
- loader- the- ClassLoaderfor the application
- sAppDescriptorURI- the URI to coherence-application.xml
- sAppName- the name of the application
 
- 
ContainerAdapterpublic ContainerAdapter(ClassLoader loader, String sAppDescriptorURI, String sAppName, XmlElement xmlAppDescriptor) Construct the ContainerAdapter.- Parameters:
- loader- the- ClassLoaderfor the application
- sAppDescriptorURI- the URI to coherence-application.xml
- sAppName- the name of the application
- xmlAppDescriptor- the- XmlElementcontaining the application descriptor; if not null it will be used instead of the configuration specified by sAppDescriptorURI
 
- 
ContainerAdapterpublic ContainerAdapter(ClassLoader loader, String sAppDescriptorURI, String sAppName, CacheFactoryBuilder builder, XmlElement xmlAppDescriptor, ServiceMonitor serviceMonitor) Construct the ContainerAdapter.- Parameters:
- loader- the- ClassLoaderfor the application
- sAppDescriptorURI- the URI to the application configuration descriptor
- sAppName- the name of the application
- builder- the- CacheFactoryBuilderto use
- xmlAppDescriptor- the- XmlElementcontaining the application descriptor; if not null it will be used instead of the configuration specified by sAppDescriptorURI
- serviceMonitor- the- ServiceMonitorto use for the application
 
 
- 
- 
Method Details- 
setContainerContextSet the ContainerContext associated with this ContainerAdapter instance.This method must be called before the adapter is activated.- Parameters:
- ctx- the ContainerContext reference
 
- 
activatepublic void activate()Initialize and start the application that is hosted by this ContainerAdapter.If this method throws an exception, the caller is NOT required to call deactivate().- Throws:
- IllegalStateException- if the application has already been activated
 
- 
deactivatepublic void deactivate()Deactivate the application hosted by this ContainerAdapter. This method will shut down any resources / Coherence services that were used by the application.- Throws:
- IllegalStateException- if the application is not active
 
- 
deactivatepublic void deactivate(boolean fShutdown) Deactivate the application hosted by this ContainerAdapter. IffShutdownis true shutdown any resources / Coherence services that were used by the application otherwise clear local references.- Parameters:
- fShutdown- whether to shut down the resources, incl. any services, that were started as a part of this application
- Throws:
- IllegalStateException- if the application is not active
 
- 
associateWithClassLoaderAssociates the application hosted by this ContainerAdapter with specifiedClassLoaders.- Parameters:
- aClassLoaders- an array of- ClassLoaders to associate this adapter with
 
- 
getContextClassLoaderReturn the ClassLoader used by this ContainerAdapter.- Returns:
- the ClassLoader used by this ContainerAdapter
 
- 
getApplicationContextReturn theContextfor the application.- Returns:
- the Contextfor the application
 
- 
getContainerContextReturn theContainerContextused by this ContainerAdapter.- Returns:
- the ContainerContextused by this ContainerAdapter.
 
- 
getCoherenceReturn theCoherenceinstance used by this ContainerAdapter.- Returns:
- the Coherenceinstance used by this ContainerAdapter.
 
- 
setCoherenceFactorySet theContainerAdapter.CoherenceFactoryto use to createCoherenceinstances.- Parameters:
- factory- the- ContainerAdapter.CoherenceFactoryto use to create- Coherenceinstances
 
- 
getLifecycleListenersReturns an unmodifiable list ofLifecycleListeners registered for thisContainerAdapter.If the list of listeners does not yet exist it will be created and initially populated using the ServiceLoaderto discover and load listeners.- Returns:
- the list of LifecycleListeners registered for thisContainerAdapter
 
- 
extractFactoryConfigExtract theXmlElementrepresenting the factory for theConfigurableCacheFactoryinstance.- Parameters:
- xmlAppDescriptor- the application descriptor XML element
- Returns:
- the XmlElementrepresenting the factory or null if no element exists.
 
- 
ensureContextClassLoaderprotected void ensureContextClassLoader()Ensure that the thread context ClassLoader is set to the ContainerAdapter's ClassLoader; save the current thread context ClassLoader if necessary.
- 
restoreContextClassLoaderprotected void restoreContextClassLoader()Restore the thread contextClassLoaderfor the caller.
 
-