Package org.java.plugin.standard
Class StandardPluginManager
java.lang.Object
org.java.plugin.PluginManager
org.java.plugin.standard.StandardPluginManager
Standard implementation of plug-in manager.
- Version:
- $Id: StandardPluginManager.java,v 1.8 2007/04/07 12:41:01 ddimon Exp $
-
Nested Class Summary
Nested classes/interfaces inherited from class org.java.plugin.PluginManager
PluginManager.EventListener, PluginManager.EventListenerAdapter, PluginManager.PluginLocation -
Field Summary
Fields inherited from class org.java.plugin.PluginManager
VERSION, VERSION_PROPERTY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedStandardPluginManager(PluginRegistry aRegistry, PathResolver aPathResolver, PluginLifecycleHandler aLifecycleHandler) Creates instance of plug-in manager for given registry, path resolver and life cycle handler. -
Method Summary
Modifier and TypeMethodDescriptionvoidactivatePlugin(String id) Activates plug-in with given ID if it is not activated yet.voidDeactivates plug-in with given ID if it has been successfully activated before.disablePlugin(PluginDescriptor descr) Disables plug-in (with dependencies) in this manager instance.enablePlugin(PluginDescriptor descr, boolean includeDependings) Enables plug-in (or plug-ins) in this manager instance.Looks for plug-in with given ID and activates it if it is not activated yet.Returns instance of plug-in's class loader and not tries to activate plug-in.getPluginFor(Object obj) Looks for plug-in, given object belongs to.booleanisBadPlugin(PluginDescriptor descr) booleanbooleanbooleanisPluginEnabled(PluginDescriptor descr) publishPlugins(PluginManager.PluginLocation[] locations) Registers plug-ins and their locations with this plug-in manager.voidregisterListener(PluginManager.EventListener listener) Registers plug-in manager event listener.voidshutdown()Shuts down the framework.voidUnregisters manager event listener.Methods inherited from class org.java.plugin.PluginManager
disposeClassLoader, initPlugin, lookup, notifyClassLoader, startPlugin, stopPlugin
-
Constructor Details
-
StandardPluginManager
protected StandardPluginManager(PluginRegistry aRegistry, PathResolver aPathResolver, PluginLifecycleHandler aLifecycleHandler) Creates instance of plug-in manager for given registry, path resolver and life cycle handler.- Parameters:
aRegistry- some implementation of plug-in registry interfaceaPathResolver- some implementation of path resolver interfaceaLifecycleHandler- an implementation of plug-in life cycle handler- See Also:
-
-
Method Details
-
getRegistry
- Specified by:
getRegistryin classPluginManager- Returns:
- registry, used by this manager
- See Also:
-
getPathResolver
- Specified by:
getPathResolverin classPluginManager- Returns:
- path resolver
- See Also:
-
publishPlugins
public Map<String,Identity> publishPlugins(PluginManager.PluginLocation[] locations) throws JpfException Registers plug-ins and their locations with this plug-in manager. You should use this method to register new plug-ins to make them available for activation with this manager instance (compare this toPluginRegistry.register(URL[])method that just makes plug-in's meta-data available for reading and doesn't "know" where are things actually located).- Specified by:
publishPluginsin classPluginManager- Parameters:
locations- plug-in locations data- Returns:
- map where keys are manifest URL's and values are registered plug-ins or plug-in fragments, URL's for unprocessed manifests are not included
- Throws:
JpfException- if given plug-ins can't be registered or published (optional behavior)- See Also:
-
getPlugin
Looks for plug-in with given ID and activates it if it is not activated yet. Note that this method will never returnnull.- Specified by:
getPluginin classPluginManager- Parameters:
id- plug-in ID- Returns:
- found plug-in
- Throws:
PluginLifecycleException- if plug-in can't be found or activated
-
activatePlugin
Activates plug-in with given ID if it is not activated yet.- Specified by:
activatePluginin classPluginManager- Parameters:
id- plug-in ID- Throws:
PluginLifecycleException- if plug-in can't be found or activated
-
getPluginFor
Looks for plug-in, given object belongs to.- Specified by:
getPluginForin classPluginManager- Parameters:
obj- any object that maybe belongs to some plug-in- Returns:
- plug-in or
nullif given object doesn't belong to any plug-in (possibly it is part of "host" application) and thus doesn't managed by the Framework directly or indirectly
-
isPluginActivated
- Specified by:
isPluginActivatedin classPluginManager- Parameters:
descr- plug-in descriptor- Returns:
trueif plug-in with given descriptor is activated
-
isBadPlugin
- Specified by:
isBadPluginin classPluginManager- Parameters:
descr- plug-in descriptor- Returns:
trueif plug-in disabled as it's activation fails
-
isPluginActivating
- Specified by:
isPluginActivatingin classPluginManager- Parameters:
descr- plug-in descriptor- Returns:
trueif plug-in is currently activating
-
getPluginClassLoader
Returns instance of plug-in's class loader and not tries to activate plug-in. Use this method if you need to get access to plug-in resources and don't want to cause plug-in activation.- Specified by:
getPluginClassLoaderin classPluginManager- Parameters:
descr- plug-in descriptor- Returns:
- class loader instance for plug-in with given descriptor
-
shutdown
public void shutdown()Shuts down the framework.
Calling this method will deactivate all active plug-ins in order, reverse to the order they was activated. It also releases all resources allocated by this manager (class loaders, plug-in descriptors etc.). All disabled plug-ins will be marked as "enabled", all registered event listeners will be unregistered.- Specified by:
shutdownin classPluginManager
-
deactivatePlugin
Deactivates plug-in with given ID if it has been successfully activated before. Note that this method will effectively deactivate all plug-ins that depend on the given plug-in.- Specified by:
deactivatePluginin classPluginManager- Parameters:
id- plug-in ID
-
disablePlugin
Disables plug-in (with dependencies) in this manager instance. Disabled plug-in can't be activated although it may be valid and successfully registered with plug-in registry. Before disabling, plug-in will be deactivated if it was successfully activated.
Be careful with this method as it can effectively disable large set of inter-depending plug-ins and your application may become unstable or even disabled as whole.- Specified by:
disablePluginin classPluginManager- Parameters:
descr- descriptor of plug-in to be disabled- Returns:
- descriptors of plug-ins that was actually disabled
-
enablePlugin
Enables plug-in (or plug-ins) in this manager instance.- Specified by:
enablePluginin classPluginManager- Parameters:
descr- descriptor of plug-in to be enabledincludeDependings- iftrue, depending plug-ins will be also enabled- Returns:
- descriptors of plug-ins that was actually enabled
- See Also:
-
isPluginEnabled
- Specified by:
isPluginEnabledin classPluginManager- Parameters:
descr- plug-in descriptor- Returns:
trueif given plug-in is disabled in this manager
-
registerListener
Registers plug-in manager event listener. If given listener has been registered before, this method will throw anIllegalArgumentException.- Specified by:
registerListenerin classPluginManager- Parameters:
listener- new manager event listener
-
unregisterListener
Unregisters manager event listener. If given listener hasn't been registered before, this method will throw anIllegalArgumentException.- Specified by:
unregisterListenerin classPluginManager- Parameters:
listener- registered listener
-