| java.lang.Object org.netbeans.ModuleManager
ModuleManager | final public class ModuleManager (Code) | | Manages a collection of modules.
Must use
ModuleManager.mutex to access its important methods.
author: Jesse Glick |
Method Summary | |
final public void | addPropertyChangeListener(PropertyChangeListener l) Add a change listener.
Only the declared properties will be fired, and they are
not guaranteed to be fired synchronously with the change
(currently they are not in fact, for safety). | void | assertWritable() Assert that the current thread state permits writing. | public Module | create(File jar, Object history, boolean reloadable, boolean autoload) | public 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.
Will initially be disabled, unless it is eager and can
be enabled immediately.
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. | public Module | createFixed(Manifest mani, Object history, ClassLoader loader) Create a fixed module (e.g. | public Module | createFixed(Manifest mani, Object history, ClassLoader loader, boolean autoload, boolean eager) Create a fixed module (e.g. | public void | delete(Module m) Remove a module from the managed set. | final public void | disable(Module m) Disable a single module. | public void | disable(Set<Module> modules) Disable a set of modules together. | final public void | enable(Module m) Enable a single module. | public void | enable(Set<Module> modules) Enable a set of modules together.
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).
It is permissible to pass in modules which in fact at runtime cannot
satisfy their package dependencies, or which
ModuleInstaller.prepare rejects on the basis of missing contents. | final void | fireModulesCreatedDeleted(Set created, Set deleted) | final void | firePropertyChange(String prop, Object old, Object nue) | final void | fireReloadable(Module m) For access from Module. | final public Module | get(String codeNameBase) Convenience method to find a module by name. | public ClassLoader | getClassLoader() Get a classloader capable of loading from any
of the enabled modules or their declared extensions. | final public Set<Module> | getEnabledModules() Get a set of modules managed which are currently enabled. | final public Events | getEvents() Access for ManifestSection. | public Set<Module> | getModuleInterdependencies(Module m, boolean reverse, boolean transitive) Get a set of modules depended upon or depending on this module. | public Lookup | getModuleLookup() Retrieve set of modules in Lookup form.
The core top manager should install this into the set of
available lookups. | public Set<Module> | getModules() Get a set of
Module s being managed. | Manifest | loadManifest(File jar) | Set<Union2<Dependency, InvalidException>> | missingDependencies(Module probed) | final public Mutex | mutex() Get a locking mutex for this module installer.
All calls other than adding or removing property change
listeners, or getting the module lookup, called on this
class must be done within the scope of this mutex
(with read or write access as appropriate). | final public Mutex.Privileged | mutexPrivileged() Classes in this package can, if careful, use the privileged form. | void | readOnly(boolean ro) Sets the r/o flag. | public void | refineClassLoader(Module m, List parents) Used by Module to communicate with the ModuleInstaller re. | void | refineDependencies(Module m, Set<Dependency> dependencies) Used by Module to communicate with the ModuleInstaller re. | String[] | refineProvides(Module m) | public void | releaseModuleManifests() Release storage for all module manifests. | public void | reload(Module m) Reload a module. | final public void | removePropertyChangeListener(PropertyChangeListener l) Remove a change listener. | public boolean | shouldDelegateResource(Module m, Module parent, String pkg) Use by OneModuleClassLoader to communicate with the ModuleInstaller re. | public boolean | shutDown() Try to shut down the system. | public boolean | shutDown(Runnable midHook) Try to shut down the system. | public List<Module> | simulateDisable(Set<Module> modules) Simulate what would happen if a set of modules were to be disabled. | public List<Module> | simulateEnable(Set<Module> modules) Simulate what would happen if a set of modules were to be enabled. |
PRINT_TOPOLOGICAL_EXCEPTION_STACK_TRACES | static boolean PRINT_TOPOLOGICAL_EXCEPTION_STACK_TRACES(Code) | | |
PROP_CLASS_LOADER | final public static String PROP_CLASS_LOADER(Code) | | |
PROP_ENABLED_MODULES | final public static String PROP_ENABLED_MODULES(Code) | | |
ModuleManager | public ModuleManager(ModuleInstaller installer, Events ev)(Code) | | Create a manager, initially with no managed modules.
The handler for installing modules is given.
Also the sink for event messages must be given.
|
addPropertyChangeListener | final public void addPropertyChangeListener(PropertyChangeListener l)(Code) | | Add a change listener.
Only the declared properties will be fired, and they are
not guaranteed to be fired synchronously with the change
(currently they are not in fact, for safety). The change
events are not guaranteed to provide an old and new value,
so you will need to use the proper
getter methods. When the changes are fired, you are inside
the mutex with read access.
|
assertWritable | void assertWritable() throws IllegalThreadStateException(Code) | | Assert that the current thread state permits writing.
Currently does not check that there is a write mutex!
(Pending #13352.)
But does check that I am not firing changes.
throws: IllegalThreadStateException - if currently firing changes |
create | public Module create(File jar, Object history, boolean reloadable, boolean autoload, boolean eager) throws IOException, DuplicateException(Code) | | Create a module from a JAR and add it to the managed set.
Will initially be disabled, unless it is eager and can
be enabled immediately.
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.
|
disable | final public void disable(Module m) throws IllegalArgumentException(Code) | | Disable a single module.
Must not be required by any enabled modules.
Must not be an autoload module, when supported.
|
disable | public void disable(Set<Module> modules) throws IllegalArgumentException(Code) | | Disable a set of modules together.
Must not be required by any enabled
modules (except one another).
Must not contain autoload nor eager modules.
Must not contain fixed modules.
|
enable | public void enable(Set<Module> modules) throws IllegalArgumentException, InvalidException(Code) | | Enable a set of modules together.
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).
It is permissible to pass in modules which in fact at runtime cannot
satisfy their package dependencies, or which
ModuleInstaller.prepare 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.
|
fireModulesCreatedDeleted | final void fireModulesCreatedDeleted(Set created, Set deleted)(Code) | | |
fireReloadable | final void fireReloadable(Module m)(Code) | | For access from Module.
|
get | final public Module get(String codeNameBase)(Code) | | Convenience method to find a module by name.
Returns null if there is no such managed module.
|
getClassLoader | public ClassLoader getClassLoader()(Code) | | Get a classloader capable of loading from any
of the enabled modules or their declared extensions.
Should be used as the result of TopManager.systemClassLoader.
Thread-safe.
See Also: ModuleManager.PROP_CLASS_LOADER |
getEvents | final public Events getEvents()(Code) | | Access for ManifestSection.
since: JST-PENDING needed by ManifestSection |
getModuleInterdependencies | public Set<Module> getModuleInterdependencies(Module m, boolean reverse, boolean transitive)(Code) | | Get a set of modules depended upon or depending on this module.
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.
Parameters: m - a module to start from; may be enabled or not, but must be owned by this manager Parameters: reverse - if true, find modules depending on this module; if false, findmodules this module depends upon Parameters: transitive - if true, these dependencies are considered transitively as well a set (possibly empty) of modules managed by this manager, never including m since: org.netbeans.core/1 > 1.17 |
getModuleLookup | public Lookup getModuleLookup()(Code) | | Retrieve set of modules in Lookup form.
The core top manager should install this into the set of
available lookups. Will fire lookup events when the
set of modules changes (not for enabling/disabling/etc.).
No other subsystem should make any attempt to provide an instance of
ModuleInfo via lookup, so an optimization could be to jump
straight to this lookup when ModuleInfo/Module is requested.
|
mutex | final public Mutex mutex()(Code) | | Get a locking mutex for this module installer.
All calls other than adding or removing property change
listeners, or getting the module lookup, called on this
class must be done within the scope of this mutex
(with read or write access as appropriate). Methods
on ModuleInfo need not be called within it; methods
specifically on Module do need to be called within it
(read access is sufficient). Note that property changes
are fired with read access already held for convenience.
Please avoid entering the mutex from "sensitive" threads
such as the event thread, the folder recognizer/lookup
thread, etc., or with other locks held (such as the Children
mutex), especially when entering the mutex as a writer:
actions such as enabling modules in particular can call
arbitrary foreign module code which may do a number of
strange things (including consuming a significant amount of
time and waiting for other tasks such as lookup or data
object recognition). Use the request processor or the IDE's
main startup thread or the execution engine to be safe.
|
mutexPrivileged | final public Mutex.Privileged mutexPrivileged()(Code) | | Classes in this package can, if careful, use the privileged form.
since: JST-PENDING this had to be made public as the package is now split in two |
readOnly | void readOnly(boolean ro)(Code) | | Sets the r/o flag. Access from ChangeFirer.
Parameters: ro - if true, cannot make any changes until set to false again |
refineClassLoader | public void refineClassLoader(Module m, List parents)(Code) | | Used by Module to communicate with the ModuleInstaller re. classloader.
|
refineDependencies | void refineDependencies(Module m, Set<Dependency> dependencies)(Code) | | Used by Module to communicate with the ModuleInstaller re. dependencies.
|
refineProvides | String[] refineProvides(Module m)(Code) | | Allows the installer to add provides (used to provide name of platform we run on)
|
reload | public void reload(Module m) throws IllegalArgumentException, IOException(Code) | | Reload a module.
This could make a fresh copy of its JAR file preparing
to enable it with different contents; at least it will
rescan the manifest.
It must currently be disabled and not "fixed", and it will
stay disabled after this call; to actually reinstall it
requires a separate call.
It may or may not actually be marked "reloadable", but
for greatest reliability it should be.
Besides actually reloading the contents, any cached information
about failed dependencies or runtime problems with the module
is cleared so it may be tried again.
|
shouldDelegateResource | public boolean shouldDelegateResource(Module m, Module parent, String pkg)(Code) | | Use by OneModuleClassLoader to communicate with the ModuleInstaller re. masking.
|
shutDown | public boolean shutDown()(Code) | | Try to shut down the system.
First all modules are asked if they wish to close, in the proper order.
Assuming they say yes, then they are informed of the close.
Returns true if they all said yes.
|
shutDown | public boolean shutDown(Runnable midHook)(Code) | | Try to shut down the system.
First all modules are asked if they wish to close, in the proper order.
Assuming they say yes, a hook is run, then they are informed of the close.
If they did not agree to close, the hook is not run.
Parameters: midHook - a hook to run before closing modules if they agree to close true if they all said yes and the module system is now shut down since: org.netbeans.core/1 1.11 |
simulateDisable | public List<Module> simulateDisable(Set<Module> modules) throws IllegalArgumentException(Code) | | Simulate what would happen if a set of modules were to be disabled.
None of the listed modules may be autoload modules, nor eager, nor currently disabled, nor fixed.
The returned set will list all modules that would actually be disabled,
meaning the listed modules, plus any currently enabled but unlisted modules
(including autoloads) that require some listed modules, plus any autoloads
which would no longer be needed as they were only required by modules
otherwise disabled.
Provide-require pairs count for purposes of disablement: if the set of
requested modules includes all remaining enabled providers of some token,
and modules requiring that token will need to be disabled as well.
Modules are returned in an order in which they could be disabled (where
dependent modules are always disabled before base modules).
|
simulateEnable | public List<Module> simulateEnable(Set<Module> modules) throws IllegalArgumentException(Code) | | Simulate what would happen if a set of modules were to be enabled.
None of the listed modules may be autoload modules, nor eager, nor currently enabled,
though they may be fixed (if they have not yet been enabled).
It may happen that some of them do not satisfy their dependencies.
It may also happen that some of them require other, currently disabled,
modules to be enabled in order for them to be enabled.
It may further happen that some currently disabled eager modules could
be enabled as a result of these modules being enabled.
The returned set is the set of all modules that actually could be enabled.
It will include the requested modules, minus any that cannot satisfy
their dependencies (even on each other), plus any managed but currently
disabled modules that would need to be enabled (including autoload modules
required by some listed module but not by any currently enabled module),
plus any eager modules which can be enabled with the other enablements
(and possibly any autoloads needed by those eager modules).
Where a requested module requires some token, either it will not be included
in the result (in case the dependency cannot be satisfied), or it will, and
all modules providing that token which can be included will be included, even
if it would suffice to choose only one - unless a module providing that token
is already enabled or in the requested list,
in which case just the requested module will be listed.
Modules are returned in an order in which they could be enabled (where
base modules are always enabled before dependent modules).
Note that the returned list might include modules which in fact cannot be
enabled either because some package dependencies (which are checked only
on a live classloader) cannot be met; or
ModuleInstaller.prepare indicates that the modules are not in a valid format to install; or
creating the module classloader fails unexpectedly.
|
|
|