diff options
-rw-r--r-- | pf4j/src/main/java/org/pf4j/CompoundPluginLoader.java | 33 | ||||
-rw-r--r-- | pf4j/src/main/java/org/pf4j/CompoundPluginRepository.java | 22 |
2 files changed, 47 insertions, 8 deletions
diff --git a/pf4j/src/main/java/org/pf4j/CompoundPluginLoader.java b/pf4j/src/main/java/org/pf4j/CompoundPluginLoader.java index c20e4bb..4158533 100644 --- a/pf4j/src/main/java/org/pf4j/CompoundPluginLoader.java +++ b/pf4j/src/main/java/org/pf4j/CompoundPluginLoader.java @@ -24,14 +24,25 @@ import java.util.List; import java.util.function.BooleanSupplier; /** + * A {@link PluginLoader} that delegates to a list of {@link PluginLoader}s. + * The first applicable {@link PluginLoader} is used to load the plugin. + * If no {@link PluginLoader} is applicable, a {@link RuntimeException} is thrown. + * The order of the {@link PluginLoader}s is important. + * * @author Decebal Suiu */ public class CompoundPluginLoader implements PluginLoader { private static final Logger log = LoggerFactory.getLogger(CompoundPluginLoader.class); - private List<PluginLoader> loaders = new ArrayList<>(); + private final List<PluginLoader> loaders = new ArrayList<>(); + /** + * Add a {@link PluginLoader}. + * + * @param loader the {@link PluginLoader} to add + * @return this {@link CompoundPluginLoader} + */ public CompoundPluginLoader add(PluginLoader loader) { if (loader == null) { throw new IllegalArgumentException("null not allowed"); @@ -45,9 +56,9 @@ public class CompoundPluginLoader implements PluginLoader { /** * Add a {@link PluginLoader} only if the {@code condition} is satisfied. * - * @param loader - * @param condition - * @return + * @param loader the {@link PluginLoader} to add + * @param condition the condition to be satisfied + * @return this {@link CompoundPluginLoader} */ public CompoundPluginLoader add(PluginLoader loader, BooleanSupplier condition) { if (condition.getAsBoolean()) { @@ -57,6 +68,11 @@ public class CompoundPluginLoader implements PluginLoader { return this; } + /** + * Get the list of {@link PluginLoader}s. + * + * @return the list of {@link PluginLoader}s + */ public int size() { return loaders.size(); } @@ -94,4 +110,13 @@ public class CompoundPluginLoader implements PluginLoader { throw new RuntimeException("No PluginLoader for plugin '" + pluginPath + "' and descriptor '" + pluginDescriptor + "'"); } + /** + * Get the list of {@link PluginLoader}s. + * + * @return the list of {@link PluginLoader}s + */ + public List<PluginLoader> getLoaders() { + return loaders; + } + } diff --git a/pf4j/src/main/java/org/pf4j/CompoundPluginRepository.java b/pf4j/src/main/java/org/pf4j/CompoundPluginRepository.java index a36b00a..ecb60cd 100644 --- a/pf4j/src/main/java/org/pf4j/CompoundPluginRepository.java +++ b/pf4j/src/main/java/org/pf4j/CompoundPluginRepository.java @@ -23,12 +23,17 @@ import java.util.Set; import java.util.function.BooleanSupplier; /** + * A {@link PluginRepository} that delegates to a list of {@link PluginRepository}s. + * The first applicable {@link PluginRepository} is used to get the plugin paths. + * If no {@link PluginRepository} is applicable, a {@link RuntimeException} is thrown. + * The order of the {@link PluginRepository}s is important. + * * @author Decebal Suiu * @author Mário Franco */ public class CompoundPluginRepository implements PluginRepository { - private List<PluginRepository> repositories = new ArrayList<>(); + private final List<PluginRepository> repositories = new ArrayList<>(); public CompoundPluginRepository add(PluginRepository repository) { if (repository == null) { @@ -43,9 +48,9 @@ public class CompoundPluginRepository implements PluginRepository { /** * Add a {@link PluginRepository} only if the {@code condition} is satisfied. * - * @param repository - * @param condition - * @return + * @param repository the {@link PluginRepository} to add + * @param condition the condition to be satisfied + * @return this {@link CompoundPluginRepository} */ public CompoundPluginRepository add(PluginRepository repository, BooleanSupplier condition) { if (condition.getAsBoolean()) { @@ -76,4 +81,13 @@ public class CompoundPluginRepository implements PluginRepository { return false; } + /** + * Get the list of {@link PluginRepository}s. + * + * @return the list of {@link PluginRepository}s + */ + public List<PluginRepository> getRepositories() { + return repositories; + } + } |