The base interface for flexive plugins. A plugin acts as a singleton that is attached
to one (or more)
ExtensionPoint ExtensionPoints . The extension point is parameterized
with a concrete interface or implementation of a
PluginExecutor . When some code
wants to use the plugins registered with an ExtensionPoint, it creates a PluginExecutor
matching the ExtensionPoint's type parameter, and calls each registered plugin passing its
PluginExecutor.
A basic example, taken from the plugin test cases:
// PluginExecutor interface
private static interface TestExecutor extends PluginExecutor {
void pushResult(int result);
}
// TestExecutor implementation
private static class TestExecutorImpl implements TestExecutor {
private final Stack<Integer> results = new Stack<Integer>();
public void pushResult(int result) {
results.push(result);
}
public int popResult() {
return results.isEmpty() ? -1 : results.pop();
}
}
// An extension point
public static final ExtensionPoint<TestExecutor> EXTENSIONPOINT =
new ExtensionPoint<TestExecutor>("Unique extension point name") { };
// A sample plugin, provided by the plugin developer
private static class TestPlugin implements Plugin<TestExecutor> {
public void apply(TestExecutor executor) {
executor.pushResult(42);
}
}
author: Daniel Lichtenberger (daniel.lichtenberger@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at) version: $Rev: 1 $ |