diff options
author | Decebal Suiu <decebal.suiu@gmail.com> | 2017-10-08 22:51:14 +0300 |
---|---|---|
committer | Decebal Suiu <decebal.suiu@gmail.com> | 2017-10-08 22:51:14 +0300 |
commit | aa6971e04d84c045e9eac0552abf4e6dfab0e2a5 (patch) | |
tree | 8238f7bb1aa88dc6af34c87f920dc7ae889ef055 | |
parent | 46cb21cea6bff290f356fed2b547922c0938fc23 (diff) | |
download | pf4j-aa6971e04d84c045e9eac0552abf4e6dfab0e2a5.tar.gz pf4j-aa6971e04d84c045e9eac0552abf4e6dfab0e2a5.zip |
Resolve #174
-rw-r--r-- | README.md | 36 |
1 files changed, 26 insertions, 10 deletions
@@ -308,29 +308,45 @@ public abstract class AbstractPluginManager implements PluginManager { ``` `DefaultPluginManager` contributes with "default" components (`DefaultExtensionFactory`, `DefaultPluginFactory`, `DefaultPluginLoader`, ...) to `AbstractPluginManager`. -Most of the times it's enough to extends `DefaultPluginManager` and to supply your custom components. As example, I will show you the implementation for `JarPluginManager`: +Most of the times it's enough to extends `DefaultPluginManager` and to supply your custom components. + +Starting with version 2.0 it's possible to coexist multiple plugins types (jar, zip, directory) in the same `PluginManager`. +For example, `DefaultPluginManager` works out of the box with zip and jar plugins. The idea is that `DefaultPluginManager` uses a compound version for: +- `PluginDescriptorFinder` (`CompoundPluginDescriptorFinder`) +- `PluginLoader` (`CompoundPluginLoader`) +- `PluginRepository` (`CompoundPluginRepository`) ```java -public class JarPluginManager extends DefaultPluginManager { - +public class DefaultPluginManager extends AbstractPluginManager { + + ... + @Override - protected PluginRepository createPluginRepository() { - return new JarPluginRepository(getPluginsRoot(), isDevelopment()); + protected PluginDescriptorFinder createPluginDescriptorFinder() { + return new CompoundPluginDescriptorFinder() + .add(new PropertiesPluginDescriptorFinder()) + .add(new ManifestPluginDescriptorFinder()); } - + @Override - protected PluginDescriptorFinder createPluginDescriptorFinder() { - return isDevelopment() ? new PropertiesPluginDescriptorFinder() : new JarPluginDescriptorFinder(); + protected PluginRepository createPluginRepository() { + return new CompoundPluginRepository() + .add(new DefaultPluginRepository(getPluginsRoot(), isDevelopment())) + .add(new JarPluginRepository(getPluginsRoot())); } - + @Override protected PluginLoader createPluginLoader() { - return new JarPluginLoader(this, pluginClasspath); + return new CompoundPluginLoader() + .add(new DefaultPluginLoader(this, pluginClasspath)) + .add(new JarPluginLoader(this)); } } ``` +So, it's very easy to add new strategies for plugin descriptor finder, plugin loader and plugin repository. + Development mode -------------------------- PF4J can run in two modes: **DEVELOPMENT** and **DEPLOYMENT**. |