plugin managers.
A plugin manager handles the registration, un-registration, and persistence of plugins for and on behalf of a service.
- Author:
- Fabio Simeoni (University of Strathclyde)
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
logger
protected GCUBELog logger
- Class logger.
PLUGINS_DIRECTORY_NAME
public static final String PLUGINS_DIRECTORY_NAME
- Plugin directory name
- See Also:
- Constant Field Values
context
protected GCUBEServiceContext context
- The context of the associated service.
plugins
protected Map<String,PLUGINCONTEXT extends GCUBEPluginContext> plugins
- The list of registered plugins.
PLUGIN_PROFILE_SUFFIX
protected static final String PLUGIN_PROFILE_SUFFIX
- Suffix of plugin serialisations
- See Also:
- Constant Field Values
producer
protected GCUBEProducer<GCUBEPluginManager.PluginTopic,PLUGINCONTEXT extends GCUBEPluginContext> producer
- The inner producer of plugin management event.
GCUBEPluginManager
public GCUBEPluginManager()
setLogger
public void setLogger(GCUBELog logger)
- Sets the instance logger.
- Parameters:
logger - the logger.
initialise
public void initialise(GCUBEServiceContext context,
GCUBEPluginManagerProfile managerProfile)
throws Exception
- Initialises the manager with the context of the associated service.
- Parameters:
context - the context.managerProfile - the profile of the plugin manager.
- Throws:
Exception - if the manager could not be initialised.
getMainClass
protected abstract Class<PLUGINCONTEXT> getMainClass()
- Returns the type of
GCUBEPluginContext expected by the associated service.
- Returns:
- the type.
validateMainClass
public PLUGINCONTEXT validateMainClass(Class<?> contextClass)
throws Exception
- Validates and instantiate the main class of the plugin.
By default, the class is valid if it is compatible with GCUBEPluginContext and can be reflectively instantiated.
Subclasses may extend the default implementation to guarantee that further constraints are met (e.g. that it implements required interfaces).
- Returns:
- an instance of the main class
true if the main class is valid, false otherwise.
- Throws:
Exception - if the class is not valid.
getPlugins
public Map<String,PLUGINCONTEXT> getPlugins()
- Returns the contexts of all the plugins that are currently registered with the manager.
- Returns:
- the plugin contexts, indexed by name.
registerPlugin
public void registerPlugin(GCUBEService plugin,
boolean... persisted)
throws GCUBEPluginManager.PluginAlreadyRegisteredException,
Exception
- Register a plugin with the manager.
- Parameters:
plugin - the GCUBEService resource that models the plugin.persisted - (optional) true if the plugin ought to be persisted (default), false otherwise.
- Throws:
GCUBEPluginManager.PluginAlreadyRegisteredException - if the plugin is already registered
Exception - if the plugin could not be registered.
deregisterPlugin
public void deregisterPlugin(String name)
throws Exception
- DeRegister a plugin from the manager.
- Parameters:
name - the name of the plugin.
- Throws:
Exception - if the plugin did not exist or could not be deregistered.
getPortTypeContexts
protected abstract GCUBEPortTypeContext[] getPortTypeContexts()
- Returns the contexts of the port-types of the associated service,
so as to configure type mappings for them if any are provided by
plugins via the associated
GCUBEPluginContext).
- Returns:
- the contexts.
subscribe
public void subscribe(GCUBEPluginManager.PluginConsumer<PLUGINCONTEXT> c,
GCUBEPluginManager.PluginTopic... topics)
- Subscribes a consumer to one or more registration events.
- Parameters:
c - the consumer.topics - (optional) topics the topics, all if omitted.
unsubscribe
public void unsubscribe(GCUBEPluginManager.PluginConsumer<PLUGINCONTEXT> c,
GCUBEPluginManager.PluginTopic... topics)
- Unsubscribes a consumer from one or more registration events.
- Parameters:
c - the consumer.topics - (optional) topics the topics, all if omitted.
Copyright © 2012. All Rights Reserved.