Top Methods
com.sun.enterprise.module

public Interface HK2Module

Known Direct Implementers
com.sun.enterprise.module.impl.ModuleImpl, com.sun.enterprise.module.single.ProxyModule
Imports
java.io.PrintStream, java.util.List

Author
[email protected]

Method Summary

Modifier and TypeMethod and Description
public void
public HK2Module
addImport(ModuleDependency
new module's definition
dependency
)

Create and add a new module to this module's list of imports.

public void
addListener(ModuleChangeListener
the listener
listener
)

Add a new module change listener

public void
detach()

Detach this module from its registry.

public void
public ClassLoader

Returns:

the public ClassLoader
getClassLoader
()

Return the ClassLoader instance associated with this module.

public List<HK2Module>

Returns:

Can be empty but never null. Read-only.
getImports
()

Returns the list of imported modules.

public ModuleMetadata
getMetadata()

Gets the metadata of this module.

public ModuleDefinition

Returns:

the module definition
getModuleDefinition
()

Returns the module definition for this module instance

public String
getName()

Short-cut for getModuleDefinition().getName().

public <T> Iterable<Class<? extends T>>
getProvidersClass(Class<T> serviceClass)

public Iterable<Class<T>>
public ModulesRegistry

Returns:

the registry owning the module
getRegistry
()

Returns the registry owning this module

public ModuleState

Returns:

the module's state
getState
()

Returns the module's state

public boolean
hasProvider(Class<T> serviceClass)

Returns true if this module has any provider for the given service class.

public boolean

Returns:

true if this module is sharable.
isShared
()

Returns true if this module is sharable.

public boolean

Returns:

true is the module is sticky
isSticky
()

Returns true if the module is sticky.

public void
refresh()

Trigger manual refresh mechanism, the module will check all its URLs and generate change events if any of them has changed.

public void
removeListener(ModuleChangeListener
the listener to unregister
listener
)

Unregister a module change listener

public void
resolve()

Ensure that this module is resolved.

public void
setSticky(boolean
true if the module should stick around
sticky
)

Sets the sticky flag.

public void
start()

Forces module startup.

public boolean

Returns:

true if unloading was successful
stop
()

Forces module stop.

public void
uninstall()

Removes the module from the registry backing store, the module will need be reinstalled to be loaded.

Method Detail

addImportback to summary
public void addImport(HK2Module module)
addImportback to summary
public HK2Module addImport(ModuleDependency dependency)

Create and add a new module to this module's list of imports.

Parameters
dependency:ModuleDependency

new module's definition

addListenerback to summary
public void addListener(ModuleChangeListener listener)

Add a new module change listener

Parameters
listener:ModuleChangeListener

the listener

detachback to summary
public 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.

dumpStateback to summary
public void dumpState(PrintStream writer)
getClassLoaderback to summary
public ClassLoader getClassLoader()

Return the ClassLoader instance associated with this module. Only designated public interfaces will be loaded and returned by this classloader

Returns:ClassLoader

the public ClassLoader

getImportsback to summary
public List<HK2Module> 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 HK2Module 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:List<HK2Module>

Can be empty but never null. Read-only.

getMetadataback to summary
public ModuleMetadata getMetadata()

Gets the metadata of this module.

getModuleDefinitionback to summary
public ModuleDefinition getModuleDefinition()

Returns the module definition for this module instance

Returns:ModuleDefinition

the module definition

getNameback to summary
public String getName()

Short-cut for getModuleDefinition().getName().

getProvidersClassback to summary
public <T> Iterable<Class<? extends T>> getProvidersClass(Class<T> serviceClass)
getProvidersClassback to summary
public Iterable<Class<T>> getProvidersClass(String name)
getRegistryback to summary
public ModulesRegistry getRegistry()

Returns the registry owning this module

Returns:ModulesRegistry

the registry owning the module

getStateback to summary
public ModuleState getState()

Returns the module's state

Returns:ModuleState

the module's state

hasProviderback to summary
public boolean hasProvider(Class<T> serviceClass)

Returns true if this module has any provider for the given service class.

isSharedback to summary
public 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:boolean

true if this module is sharable.

isStickyback to summary
public 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:boolean

true is the module is sticky

refreshback to summary
public 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.

removeListenerback to summary
public void removeListener(ModuleChangeListener listener)

Unregister a module change listener

Parameters
listener:ModuleChangeListener

the listener to unregister

resolveback to summary
public void resolve() throws ResolveError

Ensure that this module is resolved.

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 is ModuleState#RESOLVED.

Exceptions
ResolveError:
if any of the declared dependency of this module cannot be satisfied
setStickyback to summary
public void setSticky(boolean sticky)

Sets the sticky flag.

Parameters
sticky:boolean

true if the module should stick around

startback to summary
public 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 the ModuleState.READY, the Lifecycle.start method will be invoked.

stopback to summary
public 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 a LifecyclePolicy for this module is defined, the Lifecycle.stop(HK2Module) method will be called and finally the module state will be returned to ModuleState.NEW.

Returns:boolean

true if unloading was successful

uninstallback to summary
public void uninstall()

Removes the module from the registry backing store, the module will need be reinstalled to be loaded.