public final class ModuleManager extends Modules
ModuleManager.mutex()
to access its important methods.Modifier and Type | Field and Description |
---|---|
static String |
PROP_CLASS_LOADER |
static String |
PROP_ENABLED_MODULES |
static String |
PROP_MODULES |
Constructor and Description |
---|
ModuleManager(ModuleInstaller installer,
Events ev)
Create a manager, initially with no managed modules.
|
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener l)
Add a change listener.
|
Module |
create(File jar,
Object history,
boolean reloadable,
boolean autoload)
Deprecated.
since org.netbeans.core/1 1.3
|
Module |
create(File jar,
Object history,
boolean reloadable,
boolean autoload,
boolean eager)
Create a module from a JAR and add it to the managed set.
|
Module |
createBundle(File jar,
Object history,
boolean reloadable,
boolean autoload,
boolean eager,
int startLevel)
Create a module from a JAR representing an OSGi bundle
and adds it to the managed set.
|
Module |
createFixed(Manifest mani,
Object history,
ClassLoader loader)
Create a fixed module (e.g.
|
Module |
createFixed(Manifest mani,
Object history,
ClassLoader loader,
boolean autoload,
boolean eager)
Create a fixed module (e.g.
|
void |
delete(Module m)
Remove a module from the managed set.
|
void |
disable(Module m)
Disable a single module.
|
void |
disable(Set<Module> modules)
Disable a set of modules together.
|
void |
enable(Module m)
Enable a single module.
|
void |
enable(Set<Module> modules)
Enable a set of modules together.
|
ModuleInfo |
findCodeNameBase(String cnb) |
Module |
get(String codeNameBase)
Convenience method to find a module by name.
|
Collection<Module> |
getAttachedFragments(Module m) |
ClassLoader |
getClassLoader()
Get a classloader capable of loading from any
of the enabled modules or their declared extensions.
|
Set<Module> |
getEnabledModules()
Get a set of modules managed which are currently enabled.
|
Events |
getEvents()
Access for ManifestSection.
|
Set<Module> |
getModuleInterdependencies(Module m,
boolean reverse,
boolean transitive)
Deprecated.
|
Set<Module> |
getModuleInterdependencies(Module m,
boolean reverse,
boolean transitive,
boolean considerNeeds)
Get a set of modules depended upon or depending on this module.
|
Lookup |
getModuleLookup()
Retrieve set of modules in Lookup form.
|
Set<Module> |
getModules()
Get a set of
Module s being managed. |
boolean |
hasToEnableCompatModules(Set<Module> modules)
Determines if enabling compat modules is disruptive.
|
boolean |
isOrWillEnable(Module m)
Checks if the module is enabled or WILL be enabled by the current enable operation.
|
Mutex |
mutex()
Get a locking mutex for this module installer.
|
Mutex.Privileged |
mutexPrivileged()
Classes in this package can, if careful, use the privileged form.
|
ModuleInfo |
ownerOf(Class<?> clazz) |
ClassLoader |
refineClassLoader(Module m,
List<? extends ClassLoader> parents)
Used by Module to communicate with the ModuleInstaller re.
|
void |
releaseModuleManifests()
Release storage for all module manifests.
|
void |
reload(Module m)
Reload a module.
|
void |
removePropertyChangeListener(PropertyChangeListener l)
Remove a change listener.
|
boolean |
shouldDelegateResource(Module m,
Module parent,
String pkg)
|
boolean |
shouldDelegateResource(Module m,
Module parent,
String pkg,
ClassLoader ldr)
Determines if module `m' should delegate loading resources from package `p' to the
`parent'.
|
boolean |
shutDown()
Try to shut down the system.
|
boolean |
shutDown(Runnable midHook)
Try to shut down the system.
|
Future<Boolean> |
shutDownAsync(Runnable midHook)
Partially asynchronous support for shutdown of the system.
|
List<Module> |
simulateDisable(Set<Module> modules)
Simulate what would happen if a set of modules were to be disabled.
|
List<Module> |
simulateEnable(Set<Module> modules)
Simulate what would happen if a set of modules were to be enabled.
|
getDefault
public static final String PROP_MODULES
public static final String PROP_ENABLED_MODULES
public static final String PROP_CLASS_LOADER
public ModuleManager(ModuleInstaller installer, Events ev)
public final Events getEvents()
public final Mutex mutex()
public final Mutex.Privileged mutexPrivileged()
public void releaseModuleManifests()
Module.releaseManifest()
public final void addPropertyChangeListener(PropertyChangeListener l)
public final void removePropertyChangeListener(PropertyChangeListener l)
public Lookup getModuleLookup()
public Set<Module> getModules()
Module
s being managed.
No two contained modules may at any time share the same code name base.ModuleManager.PROP_MODULES
public final Set<Module> getEnabledModules()
ModuleManager.PROP_ENABLED_MODULES
public final Module get(String codeNameBase)
public ModuleInfo findCodeNameBase(String cnb)
findCodeNameBase
in class Modules
public ModuleInfo ownerOf(Class<?> clazz)
@Deprecated public Set<Module> getModuleInterdependencies(Module m, boolean reverse, boolean transitive)
ModuleManager.getModuleInterdependencies(Module, boolean, boolean, boolean)
instead.public Set<Module> getModuleInterdependencies(Module m, boolean reverse, boolean transitive, boolean considerNeeds)
Note that provide-require/need dependencies are listed alongside direct dependencies; a module with a required token is considered to depend on all modules providing that token (though in fact only one is needed to enable it).
Illegal cyclic dependencies are omitted.
m
- a module to start from; may be enabled or not, but must be owned by this managerreverse
- if true, find modules depending on this module; if false, find
modules this module depends upontransitive
- if true, these dependencies are considered transitively as wellconsiderNeeds
- if true, dependencies of type Dependency.TYPE_NEEDS
are consideredpublic ClassLoader getClassLoader()
Thread.getContextClassLoader()
.
Thread-safe.ModuleManager.PROP_CLASS_LOADER
@Deprecated public Module create(File jar, Object history, boolean reloadable, boolean autoload) throws IOException, DuplicateException
public Module create(File jar, Object history, boolean reloadable, boolean autoload, boolean eager) throws IOException, DuplicateException
Will initially be disabled.
To make sure all available eager modules get enabled, just call:
ModuleManager.enable(org.netbeans.Module)
(Collections.emptySet()
)
May throw an IOException if the JAR file cannot be opened for some reason, or is malformed.
If there is already a module of the same name managed, throws a duplicate exception. In this case you may wish to delete the original and try again.
You must give it some history object which can be used to provide context for where the module came from and whether it has been here before.
You cannot request that a module be both autoload and eager.
IOException
DuplicateException
public Module createBundle(File jar, Object history, boolean reloadable, boolean autoload, boolean eager, int startLevel) throws IOException, DuplicateException
ModuleManager.create(java.io.File, java.lang.Object, boolean, boolean, boolean)
just adds additional start level info.startLevel
- an OSGi start level. Zero indicates, no changes to default level.InvalidException
- if the JAR does not represent an OSGi bundleIOException
DuplicateException
public Module createFixed(Manifest mani, Object history, ClassLoader loader) throws InvalidException, DuplicateException
InvalidException
DuplicateException
public Module createFixed(Manifest mani, Object history, ClassLoader loader, boolean autoload, boolean eager) throws InvalidException, DuplicateException
InvalidException
DuplicateException
public ClassLoader refineClassLoader(Module m, List<? extends ClassLoader> parents)
public Collection<Module> getAttachedFragments(Module m)
@Deprecated public boolean shouldDelegateResource(Module m, Module parent, String pkg)
ModuleManager.shouldDelegateResource(org.netbeans.Module, org.netbeans.Module, java.lang.String, java.lang.ClassLoader)
.public boolean shouldDelegateResource(Module m, Module parent, String pkg, ClassLoader ldr)
null
, since
boostrap classloaders load more modules together.
If both `parent' and `ldr' are null
, access to system/application classpath will be checked.
m
- module that attempts to load resources.parent
- parent classloader which may eventually load the resource, could be null
to indicate bootstrap or system classpkg
- package (folder) with the resourceldr
- the classloader which should load the resource; may be null
public void delete(Module m) throws IllegalArgumentException
IllegalArgumentException
public void reload(Module m) throws IllegalArgumentException, IOException
IllegalArgumentException
IOException
public final void enable(Module m) throws IllegalArgumentException, InvalidException
IllegalArgumentException
InvalidException
ModuleManager.enable(Set)
public final void disable(Module m) throws IllegalArgumentException
IllegalArgumentException
ModuleManager.disable(Set)
public void enable(Set<Module> modules) throws IllegalArgumentException, InvalidException
Must have satisfied their dependencies (possibly with one another).
Must not contain autoload nor eager modules.
Might contain fixed modules (they can only be installed once of course).
Other modules may become enabled automatically according to ModuleManager.simulateEnable(java.util.Set<org.netbeans.Module>)
.
It is permissible to pass in modules which in fact at runtime cannot
satisfy their package dependencies, or which ModuleInstaller.prepare(org.netbeans.Module)
rejects on the basis of missing contents. In such a case InvalidException
will be thrown and nothing will be installed. The InvalidException
in such
a case should contain a reference to the offending module.
public boolean isOrWillEnable(Module m)
m
- module to checkpublic void disable(Set<Module> modules) throws IllegalArgumentException
Must not be required by any enabled modules (except one another).
Must not contain autoload nor eager modules.
Must not contain fixed modules.
Other modules may become disabled automatically according to ModuleManager.simulateDisable(java.util.Set<org.netbeans.Module>)
.
IllegalArgumentException
public List<Module> simulateEnable(Set<Module> modules) throws IllegalArgumentException
ModuleInstaller.prepare(org.netbeans.Module)
indicates that the modules are not in a valid format to install; or
creating the module classloader fails unexpectedly.IllegalArgumentException
public boolean hasToEnableCompatModules(Set<Module> modules) throws IllegalArgumentException
modules
- initial set of modulesIllegalArgumentException
public List<Module> simulateDisable(Set<Module> modules) throws IllegalArgumentException
IllegalArgumentException
public boolean shutDown()
public boolean shutDown(Runnable midHook)
midHook
- a hook to run before closing modules if they agree to closepublic Future<Boolean> shutDownAsync(Runnable midHook)
OnStop
runnables are executed in asynchronously and
one can wait for the result of such execution by observing the
returned Future
.midHook
- a hook to run before closing modules if they agree to closefalse
when they didn't.
As soon as the get()
method returns true
the module system is properly shut down.