aboutsummaryrefslogtreecommitdiffstats
path: root/pf4j/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'pf4j/src/main/java/org')
-rw-r--r--pf4j/src/main/java/org/pf4j/AbstractPluginManager.java73
-rw-r--r--pf4j/src/main/java/org/pf4j/PluginManager.java4
2 files changed, 33 insertions, 44 deletions
diff --git a/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java b/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java
index a7333ca..478149d 100644
--- a/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java
+++ b/pf4j/src/main/java/org/pf4j/AbstractPluginManager.java
@@ -525,60 +525,25 @@ public abstract class AbstractPluginManager implements PluginManager {
return extensionClasses;
}
- @SuppressWarnings("unchecked")
- @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) {
- Class<T> c = (Class<T>) extensionWrapper.getDescriptor().extensionClass;
- extensionClasses.add(c);
- }
- return extensionClasses;
+ @Override
+ public <T> List<Class<? extends T>> getExtensionClasses(Class<T> type) {
+ return getExtensionClasses(extensionFinder.find(type));
}
- @SuppressWarnings("unchecked")
@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) {
- Class<T> c = (Class<T>) extensionWrapper.getDescriptor().extensionClass;
- extensionClasses.add(c);
- }
-
- return extensionClasses;
+ public <T> List<Class<? extends T>> getExtensionClasses(Class<T> type, String pluginId) {
+ return getExtensionClasses(extensionFinder.find(type, pluginId));
}
@Override
public <T> List<T> getExtensions(Class<T> type) {
- List<ExtensionWrapper<T>> extensionsWrapper = extensionFinder.find(type);
- List<T> extensions = new ArrayList<>(extensionsWrapper.size());
- for (ExtensionWrapper<T> extensionWrapper : extensionsWrapper) {
- try {
- extensions.add(extensionWrapper.getExtension());
- } catch (PluginException e) {
- log.error("Cannot retrieve extension", e);
- }
- }
-
- return extensions;
+ return getExtensions(extensionFinder.find(type));
}
@Override
public <T> List<T> getExtensions(Class<T> type, String pluginId) {
- List<ExtensionWrapper<T>> extensionsWrapper = extensionFinder.find(type, pluginId);
- List<T> extensions = new ArrayList<>(extensionsWrapper.size());
- for (ExtensionWrapper<T> extensionWrapper : extensionsWrapper) {
- try {
- extensions.add(extensionWrapper.getExtension());
- } catch (PluginException e) {
- log.error("Cannot retrieve extension", e);
- }
- }
-
- return extensions;
+ return getExtensions(extensionFinder.find(type, pluginId));
}
@Override
@@ -943,4 +908,28 @@ public abstract class AbstractPluginManager implements PluginManager {
return pluginDescriptor.getPluginId() + "@" + pluginDescriptor.getVersion();
}
+ @SuppressWarnings("unchecked")
+ private <T> List<Class<? extends T>> getExtensionClasses(List<ExtensionWrapper<T>> extensionsWrapper) {
+ List<Class<? extends T>> extensionClasses = new ArrayList<>(extensionsWrapper.size());
+ for (ExtensionWrapper<T> extensionWrapper : extensionsWrapper) {
+ Class<T> c = (Class<T>) extensionWrapper.getDescriptor().extensionClass;
+ extensionClasses.add(c);
+ }
+
+ return extensionClasses;
+ }
+
+ private <T> List<T> getExtensions(List<ExtensionWrapper<T>> extensionsWrapper) {
+ List<T> extensions = new ArrayList<>(extensionsWrapper.size());
+ for (ExtensionWrapper<T> extensionWrapper : extensionsWrapper) {
+ try {
+ extensions.add(extensionWrapper.getExtension());
+ } catch (PluginException e) {
+ log.error("Cannot retrieve extension", e);
+ }
+ }
+
+ return extensions;
+ }
+
}
diff --git a/pf4j/src/main/java/org/pf4j/PluginManager.java b/pf4j/src/main/java/org/pf4j/PluginManager.java
index a283738..badba28 100644
--- a/pf4j/src/main/java/org/pf4j/PluginManager.java
+++ b/pf4j/src/main/java/org/pf4j/PluginManager.java
@@ -135,9 +135,9 @@ public interface PluginManager {
List<Class<?>> getExtensionClasses(String pluginId);
- <T> List<Class<T>> getExtensionClasses(Class<T> type);
+ <T> List<Class<? extends T>> getExtensionClasses(Class<T> type);
- <T> List<Class<T>> getExtensionClasses(Class<T> type, String pluginId);
+ <T> List<Class<? extends T>> getExtensionClasses(Class<T> type, String pluginId);
<T> List<T> getExtensions(Class<T> type);