aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demo/app/src/main/java/org/pf4j/demo/Boot.java6
-rw-r--r--pf4j/src/main/java/org/pf4j/AbstractPluginManager.java26
-rw-r--r--pf4j/src/main/java/org/pf4j/PluginManager.java4
3 files changed, 35 insertions, 1 deletions
diff --git a/demo/app/src/main/java/org/pf4j/demo/Boot.java b/demo/app/src/main/java/org/pf4j/demo/Boot.java
index ba5396e..a4e32dd 100644
--- a/demo/app/src/main/java/org/pf4j/demo/Boot.java
+++ b/demo/app/src/main/java/org/pf4j/demo/Boot.java
@@ -61,6 +61,12 @@ public class Boot {
System.out.println(" " + extension);
}
+ System.out.println("Extension classes by classpath:");
+ List<Class<Greeting>> greetingsClasses = pluginManager.getExtensionClasses(Greeting.class);
+ for (Class<Greeting> greeting : greetingsClasses) {
+ System.out.println(" Class: " + greeting.getCanonicalName());
+ }
+
// print extensions ids for each started plugin
List<PluginWrapper> startedPlugins = pluginManager.getStartedPlugins();
for (PluginWrapper plugin : startedPlugins) {
diff --git a/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java b/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java
index 21df9c0..711d764 100644
--- a/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java
+++ b/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java
@@ -45,7 +45,7 @@ public abstract class AbstractPluginManager implements PluginManager {
private Path pluginsRoot;
- private ExtensionFinder extensionFinder;
+ protected ExtensionFinder extensionFinder;
private PluginDescriptorFinder pluginDescriptorFinder;
@@ -526,6 +526,30 @@ public abstract class AbstractPluginManager implements PluginManager {
}
@Override
+ public <T> List<Class<T>> getExtensionClasses(Class<T> type) {
+ List<ExtensionWrapper<T>> extensionsWrapper = extensionFinder.find(type);
+ List<Class<T>> extensionClasses = new ArrayList<>(extensionsWrapper.size());
+ for (ExtensionWrapper<T> extensionWrapper : extensionsWrapper) {
+ @SuppressWarnings("unchecked")
+ Class<T> c = (Class<T>)extensionWrapper.getDescriptor().extensionClass;
+ extensionClasses.add(c);
+ }
+ return extensionClasses;
+ }
+
+ @Override
+ public <T> List<Class<T>> getExtensionClasses(Class<T> type, String pluginId) {
+ List<ExtensionWrapper<T>> extensionsWrapper = extensionFinder.find(type, pluginId);
+ List<Class<T>> extensionClasses = new ArrayList<>(extensionsWrapper.size());
+ for (ExtensionWrapper<T> extensionWrapper : extensionsWrapper) {
+ @SuppressWarnings("unchecked")
+ Class<T> c = (Class<T>)extensionWrapper.getDescriptor().extensionClass;
+ extensionClasses.add(c);
+ }
+ return extensionClasses;
+ }
+
+ @Override
public <T> List<T> getExtensions(Class<T> type) {
List<ExtensionWrapper<T>> extensionsWrapper = extensionFinder.find(type);
List<T> extensions = new ArrayList<>(extensionsWrapper.size());
diff --git a/pf4j/src/main/java/org/pf4j/PluginManager.java b/pf4j/src/main/java/org/pf4j/PluginManager.java
index 06fc68e..2523870 100644
--- a/pf4j/src/main/java/org/pf4j/PluginManager.java
+++ b/pf4j/src/main/java/org/pf4j/PluginManager.java
@@ -131,6 +131,10 @@ public interface PluginManager {
ClassLoader getPluginClassLoader(String pluginId);
+ <T> List<Class<T>> getExtensionClasses(Class<T> type);
+
+ <T> List<Class<T>> getExtensionClasses(Class<T> type, String pluginId);
+
<T> List<T> getExtensions(Class<T> type);
<T> List<T> getExtensions(Class<T> type, String pluginId);