public abstract class PluginManager extends Object
Usage example. Somewhere in the beginning of your application:
manager = factory.createManager(); manager.publishPlugins(getLocations(dir));Later on, before accessing plug-in:
manager.activatePlugin(pluginId);
ObjectFactory.createManager()
Modifier and Type | Class and Description |
---|---|
static interface |
PluginManager.EventListener
Plug-ins life-cycle events callback interface.
|
static class |
PluginManager.EventListenerAdapter
An abstract adapter class for receiving plug-ins life-cycle events.
|
static interface |
PluginManager.PluginLocation
Simple callback interface to hold info about plug-in manifest and plug-in
data locations.
|
Modifier and Type | Field and Description |
---|---|
static String |
VERSION
JPF version number.
|
static String |
VERSION_PROPERTY
JPF version system property name.
|
Constructor and Description |
---|
PluginManager() |
Modifier and Type | Method and Description |
---|---|
abstract void |
activatePlugin(String id)
Activates plug-in with given ID if it is not activated yet.
|
abstract void |
deactivatePlugin(String id)
Deactivates plug-in with given ID if it has been successfully activated
before.
|
abstract PluginDescriptor[] |
disablePlugin(PluginDescriptor descr)
Disables plug-in (with dependencies) in this manager instance.
|
protected void |
disposeClassLoader(PluginClassLoader cl)
Forwards call to
PluginClassLoader.dispose() method. |
abstract PluginDescriptor[] |
enablePlugin(PluginDescriptor descr,
boolean includeDependings)
Enables plug-in (or plug-ins) in this manager instance.
|
abstract PathResolver |
getPathResolver() |
abstract Plugin |
getPlugin(String id)
Looks for plug-in with given ID and activates it if it is not activated
yet.
|
abstract PluginClassLoader |
getPluginClassLoader(PluginDescriptor descr)
Returns instance of plug-in's class loader and not tries to activate
plug-in.
|
abstract Plugin |
getPluginFor(Object obj)
Looks for plug-in, given object belongs to.
|
abstract PluginRegistry |
getRegistry() |
protected void |
initPlugin(Plugin plugin,
PluginDescriptor descr)
Initializes given plug-in with this manager instance and given
descriptor.
|
abstract boolean |
isBadPlugin(PluginDescriptor descr) |
abstract boolean |
isPluginActivated(PluginDescriptor descr) |
abstract boolean |
isPluginActivating(PluginDescriptor descr) |
abstract boolean |
isPluginEnabled(PluginDescriptor descr) |
static PluginManager |
lookup(Object obj)
Looks for plug-in manager instance for given object.
|
protected void |
notifyClassLoader(PluginClassLoader cl)
Forwards call to
PluginClassLoader.pluginsSetChanged() method. |
abstract Map<String,Identity> |
publishPlugins(PluginManager.PluginLocation[] locations)
Registers plug-ins and their locations with this plug-in manager.
|
abstract void |
registerListener(PluginManager.EventListener listener)
Registers plug-in manager event listener.
|
abstract void |
shutdown()
Shuts down the framework.
|
protected void |
startPlugin(Plugin plugin)
Starts given plug-in.
|
protected void |
stopPlugin(Plugin plugin)
Stops given plug-in.
|
abstract void |
unregisterListener(PluginManager.EventListener listener)
Unregisters manager event listener.
|
public static final String VERSION
public static final String VERSION_PROPERTY
public static PluginManager lookup(Object obj)
obj
- any object that may be managed by some plug-in managernull
if 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.public abstract PluginRegistry getRegistry()
public abstract PathResolver getPathResolver()
public abstract Map<String,Identity> publishPlugins(PluginManager.PluginLocation[] locations) throws JpfException
PluginRegistry.register(URL[])
method that just makes plug-in's
meta-data available for reading and doesn't "know" where are things
actually located).
Note that this method only load plug-ins to this manager but not activate
them. Call activatePlugin(String)
method to make plug-in
activated. It is recommended to do this immediately before first plug-in
use.
locations
- plug-in locations dataJpfException
- if given plug-ins can't be registered or published (optional
behavior)PluginDescriptor
,
PluginFragment
public abstract Plugin getPlugin(String id) throws PluginLifecycleException
null
.id
- plug-in IDPluginLifecycleException
- if plug-in can't be found or activatedpublic abstract void activatePlugin(String id) throws PluginLifecycleException
Plugin.doStart()
method. This
method will effectively activate all depending plug-ins. It is safe to
call this method more than once.id
- plug-in IDPluginLifecycleException
- if plug-in can't be found or activatedpublic abstract Plugin getPluginFor(Object obj)
obj
- any object that maybe belongs to some plug-innull
if 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 indirectlypublic abstract boolean isPluginActivated(PluginDescriptor descr)
descr
- plug-in descriptortrue
if plug-in with given descriptor is activatedpublic abstract boolean isBadPlugin(PluginDescriptor descr)
descr
- plug-in descriptortrue
if plug-in disabled as it's activation failspublic abstract boolean isPluginActivating(PluginDescriptor descr)
descr
- plug-in descriptortrue
if plug-in is currently activatingpublic abstract PluginClassLoader getPluginClassLoader(PluginDescriptor descr)
descr
- plug-in descriptorpublic abstract void shutdown()
public abstract void deactivatePlugin(String id)
Plugin.doStop()
method. Note that this method will effectively
deactivate all depending plug-ins.id
- plug-in IDpublic abstract PluginDescriptor[] disablePlugin(PluginDescriptor descr)
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.
descr
- descriptor of plug-in to be disabledpublic abstract PluginDescriptor[] enablePlugin(PluginDescriptor descr, boolean includeDependings)
descr
- descriptor of plug-in to be enabledincludeDependings
- if true
, depending plug-ins will be also
enableddisablePlugin(PluginDescriptor)
public abstract boolean isPluginEnabled(PluginDescriptor descr)
descr
- plug-in descriptortrue
if given plug-in is disabled in this managerpublic abstract void registerListener(PluginManager.EventListener listener)
IllegalArgumentException
.listener
- new manager event listenerpublic abstract void unregisterListener(PluginManager.EventListener listener)
IllegalArgumentException
.listener
- registered listenerprotected final void initPlugin(Plugin plugin, PluginDescriptor descr)
plugin
- plug-in instance to be initializeddescr
- plug-in descriptorprotected final void startPlugin(Plugin plugin) throws Exception
Plugin.doStart()
method.plugin
- plug-in to be startedException
- if any error has occurred during plug-in startprotected final void stopPlugin(Plugin plugin) throws Exception
Plugin.doStop()
method.plugin
- plug-in to be stoppedException
- if any error has occurred during plug-in stopprotected final void disposeClassLoader(PluginClassLoader cl)
PluginClassLoader.dispose()
method.cl
- plug-in class loader to be disposedprotected final void notifyClassLoader(PluginClassLoader cl)
PluginClassLoader.pluginsSetChanged()
method.cl
- plug-in class loader to be notifiedCopyright © 2020. All Rights Reserved.