Class Plugin
A Riskscape Plugin. So far, a riskscape plugin is used to help initialize an engine, the expectation being that the plugin can supply an engine with types, functions and models etc.
Derived from the Nutch project's plugin system
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
finalize()
List<Class<? extends PluginFeature>>
Returns a list ofPluginFeature
classes advertised by thisPlugin
as possible extension points.getId()
initializeEngine
(Engine engine) Initialize theEngine
with any services that are provided by this Plugin.void
initializeEngine
(Engine engine, ProblemSink problemSink) Initialize theEngine
with any services that are provided by this Plugin.initializeProject
(Project project, Engine engine) Fill aProject
with goodies, usually by scanning through the Project's Config.void
shutDown()
Shutdown the plugin.protected void
Will be invoked on plugin start up and beforeinitializeEngine(Engine, ProblemSink)
is called.void
<T> Optional<T>
supportsFeature
(Class<T> spi) Deprecated.use the new ExtensionPoint API instead.
-
Constructor Details
-
Plugin
-
-
Method Details
-
getId
-
startUp
Will be invoked on plugin start up and before
initializeEngine(Engine, ProblemSink)
is called. Gives plugins a change to bootstrap some expensive global state.- Throws:
PluginRuntimeException
-
startUp
-
shutDown
Shutdown the plugin. Might be called when the engine is destroyed.
- Throws:
PluginRuntimeException
-
finalize
-
initializeEngine
Initialize the
Engine
with any services that are provided by this Plugin. For example: -Model
s -BookmarkResolver
s -ResourceLoader
s- Parameters:
engine
- the engine to populate with things.- Returns:
- any non-fatal warnings or errors generated that can be shown to the user
-
initializeEngine
Initialize the
Engine
with any services that are provided by this Plugin. For example: -Model
s -BookmarkResolver
s -ResourceLoader
sUse this method over
initializeEngine(Engine)
to report problems immediately, which can be a better way to give feedback for the user, especially where things can happen over a greater period of time.- Parameters:
engine
- the engine to populate with things.problemSink
- a place to report any non-fatal warnings or errors generated that can be shown to the user
-
initializeProject
Fill a
Project
with goodies, usually by scanning through the Project's Config. For example: -Type
s -IdentifiedFunction
s - etc- Parameters:
project
- the project to populateengine
- containing services that may be required.- Returns:
- any non-fatal warnings or errors generated that can be shown to the user
-
supportsFeature
Deprecated.use the new ExtensionPoint API instead. We should start moving Features across to that as and when we touch them.Query a
Plugin
to see if it supports the given 'service provider interface'. Support is currently limited to interfaces defined by the core engine classes - there is no support for plugins defining their own (yet) as this requires some class loader magic that we don't yet need.The current implementation, which isn't likely to last, queries the Plugin object itself to see if it implements the given interface.
The plan for the future might be to move things like resolvers and models etc in to SPI specific things to more precisely control the way the engine is built/augmented
- Parameters:
spi
- the interface to look for in this plugin- Returns:
- an object implementing the spi if it is supported, or
Optional.empty()
if this spi is not supported by thePlugin
.
-
getI18nClassLoader
- Returns:
- the classloader this plugin provides for loading i18n resources. This method should be used in preference to the descriptor's default implementation in case the plugin wants to customize the class loader in someway.
-
getExtensionPoints
Returns a list of
PluginFeature
classes advertised by thisPlugin
as possible extension points. While most extension points will be implemented in the core of the engine, it is possible for plugins to advertise their own for other dependent plugins to implement. -
getFeatures
- Returns:
- a list of
PluginFeature
s implemented by thisPlugin
-
getDescriptor
-