public interface Module
Modifier and Type | Method and 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 listener
|
void |
detach()
Detach this module from its registry.
|
void |
dumpState(PrintStream writer) |
ClassLoader |
getClassLoader()
Return the
ClassLoader instance associated with this module. |
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 instance
|
String |
getName()
Short-cut for
getModuleDefinition().getName() . |
<T> Iterable<Class<? extends T>> |
getProvidersClass(Class<T> serviceClass) |
Iterable<Class> |
getProvidersClass(String name) |
ModulesRegistry |
getRegistry()
Returns the registry owning this module
|
ModuleState |
getState()
Returns the module's state
|
boolean |
hasProvider(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 listener
|
void |
resolve()
Ensure that this module is
resolved . |
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.
|
ModuleDefinition getModuleDefinition()
String getName()
getModuleDefinition().getName()
.ModulesRegistry getRegistry()
ModuleState getState()
void resolve() throws ResolveError
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
.
ResolveError
- if any of the declared dependency of this module
cannot be satisfiedvoid start() throws ResolveError
ModuleState.READY
, the
Lifecycle.start
method will be invoked.ResolveError
boolean stop()
LifecyclePolicy
for this module is defined, the
Lifecycle.stop(Module)
method will be called and finally the module state will be
returned to ModuleState.NEW
.void detach()
void refresh()
ModuleMetadata getMetadata()
void addListener(ModuleChangeListener listener)
listener
- the listenervoid removeListener(ModuleChangeListener listener)
listener
- the listener to unregisterClassLoader getClassLoader()
ClassLoader
instance associated with this module.
Only designated public interfaces will be loaded and returned by
this classloaderClassLoader
List<Module> getImports()
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.
void addImport(Module module)
Module addImport(ModuleDependency dependency)
dependency
- new module's definitionboolean isShared()
boolean isSticky()
void setSticky(boolean sticky)
sticky
- true if the module should stick aroundboolean hasProvider(Class serviceClass)
void dumpState(PrintStream writer)
void uninstall()
Copyright © 2009–2023 Oracle Corporation. All rights reserved.