Package com.sun.enterprise.module
Interface Module
-
- All Known Implementing Classes:
ModuleImpl
,ProxyModule
public interface Module
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addImport(Module module)
Module
addImport(ModuleDependency dependency)
Create and add a new module to this module's list of imports.void
addListener(ModuleChangeListener listener)
Add a new module change listenervoid
detach()
Detach this module from its registry.void
dumpState(java.io.PrintStream writer)
java.lang.ClassLoader
getClassLoader()
Return theClassLoader
instance associated with this module.java.util.List<Module>
getImports()
Returns the list of imported modules.ModuleMetadata
getMetadata()
Gets the metadata of this module.ModuleDefinition
getModuleDefinition()
Returns the module definition for this module instancejava.lang.String
getName()
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)
ModulesRegistry
getRegistry()
Returns the registry owning this moduleModuleState
getState()
Returns the module's stateboolean
hasProvider(java.lang.Class serviceClass)
Returns true if this module has any provider for the given service class.boolean
isShared()
Returns true if this module is sharable.boolean
isSticky()
Returns true if the module is sticky.void
refresh()
Trigger manual refresh mechanism, the module will check all its URLs and generate change events if any of them has changed.void
removeListener(ModuleChangeListener listener)
Unregister a module change listenervoid
resolve()
Ensure that this module isresolved
.void
setSticky(boolean sticky)
Sets the sticky flag.void
start()
Forces module startup.boolean
stop()
Forces module stop.void
uninstall()
Removes the module from the registry backing store, the module will need be reinstalled to be loaded.
-
-
-
Method Detail
-
getModuleDefinition
ModuleDefinition getModuleDefinition()
Returns the module definition for this module instance- Returns:
- the module definition
-
getName
java.lang.String getName()
Short-cut forgetModuleDefinition().getName()
.
-
getRegistry
ModulesRegistry getRegistry()
Returns the registry owning this module- Returns:
- the registry owning the module
-
getState
ModuleState getState()
Returns the module's state- Returns:
- the module's state
-
resolve
void resolve() throws ResolveError
Ensure 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
ModuleRegistry
to resolve it. After successful completion of this method, the module state isModuleState.RESOLVED
.- Throws:
ResolveError
- if any of the declared dependency of this module cannot be satisfied
-
start
void start() throws ResolveError
Forces 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.start
method will be invoked.- Throws:
ResolveError
-
stop
boolean stop()
Forces 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 aLifecyclePolicy
for this module is defined, theLifecycle.stop(Module)
method will be called and finally the module state will be returned toModuleState.NEW
.- Returns:
- true if unloading was successful
-
detach
void detach()
Detach 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
void refresh()
Trigger 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
ModuleMetadata getMetadata()
Gets the metadata of this module.
-
addListener
void addListener(ModuleChangeListener listener)
Add a new module change listener- Parameters:
listener
- the listener
-
removeListener
void removeListener(ModuleChangeListener listener)
Unregister a module change listener- Parameters:
listener
- the listener to unregister
-
getClassLoader
java.lang.ClassLoader getClassLoader()
Return theClassLoader
instance associated with this module. Only designated public interfaces will be loaded and returned by this classloader- Returns:
- the public
ClassLoader
-
getImports
java.util.List<Module> getImports()
Returns the list of imported modules.This is the module version of
ModuleDefinition.getDependencies()
, but after fully resolved.To enforce the stable class visibility, once
Module
is created, dependencies cannot be changed — that is, we don't want "a.b.C" to suddenly mean something different once the code starts running.- Returns:
- Can be empty but never null. Read-only.
-
addImport
void addImport(Module module)
-
addImport
Module addImport(ModuleDependency dependency)
Create and add a new module to this module's list of imports.- Parameters:
dependency
- new module's definition
-
isShared
boolean isShared()
Returns true if this module is sharable. A sharable module means that onlu one instance of the module classloader will be used by all users.- Returns:
- true if this module is sharable.
-
isSticky
boolean isSticky()
Returns 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.- Returns:
- true is the module is sticky
-
setSticky
void setSticky(boolean sticky)
Sets the sticky flag.- Parameters:
sticky
- true if the module should stick around
-
getProvidersClass
<T> java.lang.Iterable<java.lang.Class<? extends T>> getProvidersClass(java.lang.Class<T> serviceClass)
-
getProvidersClass
java.lang.Iterable<java.lang.Class> getProvidersClass(java.lang.String name)
-
hasProvider
boolean hasProvider(java.lang.Class serviceClass)
Returns true if this module has any provider for the given service class.
-
dumpState
void dumpState(java.io.PrintStream writer)
-
uninstall
void uninstall()
Removes the module from the registry backing store, the module will need be reinstalled to be loaded.
-
-