summaryrefslogtreecommitdiffstats
path: root/pf4j
diff options
context:
space:
mode:
authorDecebal Suiu <decebal.suiu@gmail.com>2014-04-10 11:54:01 +0300
committerDecebal Suiu <decebal.suiu@gmail.com>2014-04-10 11:54:01 +0300
commit66caaa34f439f6f498da0c5e57438b2627df6dac (patch)
treef7979dd9a289a40bb095aebb8adb838a6bdcd05a /pf4j
parent7e00f212b15a07584bf0130272761675302c1116 (diff)
parente80ae328688cac8876cea441e6f36fc053373979 (diff)
downloadpf4j-66caaa34f439f6f498da0c5e57438b2627df6dac.tar.gz
pf4j-66caaa34f439f6f498da0c5e57438b2627df6dac.zip
Merge pull request #10 from gitblit/resource_loading
Allow inspection of disabled plugins by not stopping resource loading
Diffstat (limited to 'pf4j')
-rw-r--r--pf4j/src/main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java16
-rw-r--r--pf4j/src/main/java/ro/fortsoft/pf4j/PluginClassLoader.java26
2 files changed, 12 insertions, 30 deletions
diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java
index 295d5c8..5da04b6 100644
--- a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java
+++ b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultExtensionFinder.java
@@ -56,6 +56,12 @@ public class DefaultExtensionFinder implements ExtensionFinder, PluginStateListe
List<ExtensionWrapper<T>> result = new ArrayList<ExtensionWrapper<T>>();
for (Map.Entry<String, Set<String>> entry : entries.entrySet()) {
String pluginId = entry.getKey();
+
+ PluginWrapper pluginWrapper = pluginManager.getPlugin(pluginId);
+ if (PluginState.STARTED != pluginWrapper.getPluginState()) {
+ continue;
+ }
+
Set<String> extensionClassNames = entry.getValue();
for (String className : extensionClassNames) {
@@ -92,10 +98,12 @@ public class DefaultExtensionFinder implements ExtensionFinder, PluginStateListe
@Override
public Set<String> findClassNames(String pluginId) {
+ readIndexFiles();
return entries.get(pluginId);
}
- public void pluginStateChanged(PluginStateEvent event) {
+ @Override
+ public void pluginStateChanged(PluginStateEvent event) {
// TODO optimize (do only for some transitions)
// clear cache
entries = null;
@@ -134,8 +142,8 @@ public class DefaultExtensionFinder implements ExtensionFinder, PluginStateListe
entries = new HashMap<String, Set<String>>();
- List<PluginWrapper> startedPlugins = pluginManager.getStartedPlugins();
- for (PluginWrapper plugin : startedPlugins) {
+ List<PluginWrapper> plugins = pluginManager.getPlugins();
+ for (PluginWrapper plugin : plugins) {
String pluginId = plugin.getDescriptor().getPluginId();
log.debug("Reading extensions index file for plugin '{}'", pluginId);
Set<String> entriesPerPlugin = new HashSet<String>();
@@ -164,7 +172,7 @@ public class DefaultExtensionFinder implements ExtensionFinder, PluginStateListe
return entries;
}
- private boolean isExtensionPoint(Class type) {
+ private boolean isExtensionPoint(Class<?> type) {
return ExtensionPoint.class.isAssignableFrom(type);
}
diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginClassLoader.java b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginClassLoader.java
index 3fd7572..4b3f137 100644
--- a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginClassLoader.java
+++ b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginClassLoader.java
@@ -12,11 +12,8 @@
*/
package ro.fortsoft.pf4j;
-import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
-import java.util.Collections;
-import java.util.Enumeration;
import java.util.List;
/**
@@ -93,27 +90,4 @@ public class PluginClassLoader extends URLClassLoader {
// use the standard URLClassLoader (which follows normal parent delegation)
return super.loadClass(className);
}
-
- @Override
- public URL getResource(String name) {
- if (PluginState.DISABLED == getPlugin().getPluginState()) {
- return null;
- }
-
- return super.getResource(name);
- }
-
- @Override
- public Enumeration<URL> getResources(String name) throws IOException {
- if (PluginState.DISABLED == getPlugin().getPluginState()) {
- return Collections.emptyEnumeration();
- }
-
- return super.getResources(name);
- }
-
- private PluginWrapper getPlugin() {
- return pluginManager.getPlugin(pluginDescriptor.getPluginId());
- }
-
}