Package com.sun.enterprise.module.single
Class ProxyModule
- java.lang.Object
-
- com.sun.enterprise.module.single.ProxyModule
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.lang.ClassLoaderclassLoader(package private) ModuleDefinitionmoduleDef(package private) ModulesRegistrymodulesRegistry
-
Constructor Summary
Constructors Constructor Description ProxyModule(ModulesRegistry registry, ModuleDefinition moduleDef, java.lang.ClassLoader cl)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddImport(Module module)ModuleaddImport(ModuleDependency dependency)Create and add a new module to this module's list of imports.voidaddListener(ModuleChangeListener listener)Add a new module change listenervoiddetach()Detach this module from its registry.voiddumpState(java.io.PrintStream writer)java.lang.ClassLoadergetClassLoader()Return theClassLoaderinstance associated with this module.java.util.List<Module>getImports()Returns the list of imported modules.ModuleMetadatagetMetadata()Gets the metadata of this module.ModuleDefinitiongetModuleDefinition()Returns the module definition for this module instancejava.lang.StringgetName()Short-cut forgetModuleDefinition().getName().<T> java.lang.Iterable<java.lang.Class<? extends T>>getProvidersClass(java.lang.Class<T> serviceClass)java.lang.Iterable<java.lang.Class>getProvidersClass(java.lang.String name)ModulesRegistrygetRegistry()Returns the registry owning this moduleModuleStategetState()Returns the module's statebooleanhasProvider(java.lang.Class serviceClass)Returns true if this module has any provider for the given service class.booleanisShared()Returns true if this module is sharable.booleanisSticky()Returns true if the module is sticky.voidrefresh()Trigger manual refresh mechanism, the module will check all its URLs and generate change events if any of them has changed.voidremoveListener(ModuleChangeListener listener)Unregister a module change listenervoidresolve()Ensure that this module isresolved.voidsetSticky(boolean sticky)Sets the sticky flag.voidstart()Forces module startup.booleanstop()Forces module stop.voiduninstall()Removes the module from the registry backing store, the module will need be reinstalled to be loaded.
-
-
-
Field Detail
-
classLoader
final java.lang.ClassLoader classLoader
-
moduleDef
final ModuleDefinition moduleDef
-
modulesRegistry
final ModulesRegistry modulesRegistry
-
-
Constructor Detail
-
ProxyModule
public ProxyModule(ModulesRegistry registry, ModuleDefinition moduleDef, java.lang.ClassLoader cl)
-
-
Method Detail
-
getModuleDefinition
public ModuleDefinition getModuleDefinition()
Description copied from interface:ModuleReturns the module definition for this module instance- Specified by:
getModuleDefinitionin interfaceModule- Returns:
- the module definition
-
getName
public java.lang.String getName()
Description copied from interface:ModuleShort-cut forgetModuleDefinition().getName().
-
getRegistry
public ModulesRegistry getRegistry()
Description copied from interface:ModuleReturns the registry owning this module- Specified by:
getRegistryin interfaceModule- Returns:
- the registry owning the module
-
getState
public ModuleState getState()
Description copied from interface:ModuleReturns the module's state
-
resolve
public void resolve() throws ResolveErrorDescription copied from interface:ModuleEnsure that this module isresolved.If the module is already resolved, this method does nothing. Otherwise, iterate over all declared ModuleDependency instances and use the associated
ModuleRegistryto resolve it. After successful completion of this method, the module state isModuleState.RESOLVED.- Specified by:
resolvein interfaceModule- Throws:
ResolveError- if any of the declared dependency of this module cannot be satisfied
-
start
public void start() throws ResolveErrorDescription copied from interface:ModuleForces module startup. In most cases, the runtime will take care of starting modules when they are first used. There could be cases where code need to manually start a sub module. Invoking this method will move the module to theModuleState.READY, theLifecycle.startmethod will be invoked.- Specified by:
startin interfaceModule- Throws:
ResolveError
-
stop
public boolean stop()
Description copied from interface:ModuleForces module stop. In most cases, the runtime will take care of stopping modules when the last module user released its interest. However, in certain cases, it may be interesting to manually stop the module. Stopping the module means that the module is removed from the registry, the class loader references are released (note : the class loaders will only be released if all instances of any class loaded by them are gc'ed). If aLifecyclePolicyfor this module is defined, theLifecycle.stop(Module)method will be called and finally the module state will be returned toModuleState.NEW.
-
detach
public void detach()
Description copied from interface:ModuleDetach this module from its registry. This does not free any of the loaded resources. Only proper release of all references to the public class loader will ensure module being garbage collected. Detached modules are orphan and will be garbage collected if resources are properly disposed.
-
refresh
public void refresh()
Description copied from interface:ModuleTrigger manual refresh mechanism, the module will check all its URLs and generate change events if any of them has changed. This will allow the owning registry to force a module upgrade at next module request.
-
getMetadata
public ModuleMetadata getMetadata()
Description copied from interface:ModuleGets the metadata of this module.- Specified by:
getMetadatain interfaceModule
-
addListener
public void addListener(ModuleChangeListener listener)
Description copied from interface:ModuleAdd a new module change listener- Specified by:
addListenerin interfaceModule- Parameters:
listener- the listener
-
removeListener
public void removeListener(ModuleChangeListener listener)
Description copied from interface:ModuleUnregister a module change listener- Specified by:
removeListenerin interfaceModule- Parameters:
listener- the listener to unregister
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
Description copied from interface:ModuleReturn theClassLoaderinstance associated with this module. Only designated public interfaces will be loaded and returned by this classloader- Specified by:
getClassLoaderin interfaceModule- Returns:
- the public
ClassLoader
-
getImports
public java.util.List<Module> getImports()
Description copied from interface:ModuleReturns the list of imported modules.This is the module version of
ModuleDefinition.getDependencies(), but after fully resolved.To enforce the stable class visibility, once
Moduleis created, dependencies cannot be changed — that is, we don't want "a.b.C" to suddenly mean something different once the code starts running.- Specified by:
getImportsin interfaceModule- Returns:
- Can be empty but never null. Read-only.
-
addImport
public Module addImport(ModuleDependency dependency)
Description copied from interface:ModuleCreate and add a new module to this module's list of imports.
-
isShared
public boolean isShared()
Description copied from interface:ModuleReturns true if this module is sharable. A sharable module means that onlu one instance of the module classloader will be used by all users.
-
isSticky
public boolean isSticky()
Description copied from interface:ModuleReturns true if the module is sticky. A sticky module cannot be stopped or unloaded. Once a sticky module is loaded or started, it will stay in the JVM until it exists.
-
setSticky
public void setSticky(boolean sticky)
Description copied from interface:ModuleSets the sticky flag.
-
getProvidersClass
public <T> java.lang.Iterable<java.lang.Class<? extends T>> getProvidersClass(java.lang.Class<T> serviceClass)
- Specified by:
getProvidersClassin interfaceModule
-
getProvidersClass
public java.lang.Iterable<java.lang.Class> getProvidersClass(java.lang.String name)
- Specified by:
getProvidersClassin interfaceModule
-
hasProvider
public boolean hasProvider(java.lang.Class serviceClass)
Description copied from interface:ModuleReturns true if this module has any provider for the given service class.- Specified by:
hasProviderin interfaceModule
-
dumpState
public void dumpState(java.io.PrintStream writer)
-
-