From aa6971e04d84c045e9eac0552abf4e6dfab0e2a5 Mon Sep 17 00:00:00 2001 From: Decebal Suiu Date: Sun, 8 Oct 2017 22:51:14 +0300 Subject: [PATCH] Resolve #174 --- README.md | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index c50199b..eef5f5a 100644 --- a/README.md +++ b/README.md @@ -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**. -- 2.39.5