public abstract class GCUBEPluginManager<PLUGINCONTEXT extends GCUBEPluginContext> extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
GCUBEPluginManager.PluginAlreadyRegisteredException
Plugin already registered exception
|
static class |
GCUBEPluginManager.PluginConsumer<PLUGINCONTEXT extends GCUBEPluginContext>
Base class for consumers of plugin management events.
|
class |
GCUBEPluginManager.PluginEvent
A model of plugin management events with a plugin context payload.
|
static class |
GCUBEPluginManager.PluginTopic
Enumeration of plugin management topics.
|
| Modifier and Type | Field and Description |
|---|---|
protected GCUBEServiceContext |
context
The context of the associated service.
|
protected GCUBELog |
logger
Class logger.
|
protected static String |
PLUGIN_PROFILE_SUFFIX
Suffix of plugin serialisations
|
protected Map<String,PLUGINCONTEXT> |
plugins
The list of registered plugins.
|
static String |
PLUGINS_DIRECTORY_NAME
Plugin directory name
|
protected GCUBEProducer<GCUBEPluginManager.PluginTopic,PLUGINCONTEXT> |
producer
The inner producer of plugin management event.
|
| Constructor and Description |
|---|
GCUBEPluginManager() |
| Modifier and Type | Method and Description |
|---|---|
void |
deregisterPlugin(String name)
DeRegister a plugin from the manager.
|
protected abstract Class<PLUGINCONTEXT> |
getMainClass()
Returns the type of
GCUBEPluginContext expected by the associated service. |
Map<String,PLUGINCONTEXT> |
getPlugins()
Returns the contexts of all the plugins that are currently registered with the manager.
|
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). |
void |
initialise(GCUBEServiceContext context,
GCUBEPluginManagerProfile managerProfile)
Initialises the manager with the context of the associated service.
|
void |
registerPlugin(GCUBEService plugin,
boolean... persisted)
Register a plugin with the manager.
|
void |
setLogger(GCUBELog logger)
Sets the instance logger.
|
void |
subscribe(GCUBEPluginManager.PluginConsumer<PLUGINCONTEXT> c,
GCUBEPluginManager.PluginTopic... topics)
Subscribes a consumer to one or more registration events.
|
void |
unsubscribe(GCUBEPluginManager.PluginConsumer<PLUGINCONTEXT> c,
GCUBEPluginManager.PluginTopic... topics)
Unsubscribes a consumer from one or more registration events.
|
PLUGINCONTEXT |
validateMainClass(Class<?> contextClass)
Validates and instantiate the main class of the plugin.
|
protected GCUBELog logger
public static final String PLUGINS_DIRECTORY_NAME
protected GCUBEServiceContext context
protected Map<String,PLUGINCONTEXT extends GCUBEPluginContext> plugins
protected static final String PLUGIN_PROFILE_SUFFIX
protected GCUBEProducer<GCUBEPluginManager.PluginTopic,PLUGINCONTEXT extends GCUBEPluginContext> producer
public void setLogger(GCUBELog logger)
logger - the logger.public void initialise(GCUBEServiceContext context, GCUBEPluginManagerProfile managerProfile) throws Exception
context - the context.managerProfile - the profile of the plugin manager.Exception - if the manager could not be initialised.protected abstract Class<PLUGINCONTEXT> getMainClass()
GCUBEPluginContext expected by the associated service.public PLUGINCONTEXT validateMainClass(Class<?> contextClass) throws Exception
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).
true if the main class is valid, false otherwise.Exception - if the class is not valid.public Map<String,PLUGINCONTEXT> getPlugins()
public void registerPlugin(GCUBEService plugin, boolean... persisted) throws GCUBEPluginManager.PluginAlreadyRegisteredException, Exception
plugin - the GCUBEService resource that models the plugin.persisted - (optional) true if the plugin ought to be persisted (default), false otherwise.GCUBEPluginManager.PluginAlreadyRegisteredException - if the plugin is already registeredException - if the plugin could not be registered.public void deregisterPlugin(String name) throws Exception
name - the name of the plugin.Exception - if the plugin did not exist or could not be deregistered.protected abstract GCUBEPortTypeContext[] getPortTypeContexts()
GCUBEPluginContext).public void subscribe(GCUBEPluginManager.PluginConsumer<PLUGINCONTEXT> c, GCUBEPluginManager.PluginTopic... topics)
c - the consumer.topics - (optional) topics the topics, all if omitted.public void unsubscribe(GCUBEPluginManager.PluginConsumer<PLUGINCONTEXT> c, GCUBEPluginManager.PluginTopic... topics)
c - the consumer.topics - (optional) topics the topics, all if omitted.Copyright © 2015. All Rights Reserved.