diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginManager.java b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginManager.java index 22f899d..62a7a6d 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginManager.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/DefaultPluginManager.java @@ -411,11 +411,7 @@ public class DefaultPluginManager implements PluginManager { // remove the classloader if (pluginClassLoaders.containsKey(pluginId)) { PluginClassLoader classLoader = pluginClassLoaders.remove(pluginId); - try { - classLoader.close(); - } catch (IOException e) { - log.error(e.getMessage(), e); - } + classLoader.dispose(); } return true; @@ -803,6 +799,7 @@ public class DefaultPluginManager implements PluginManager { unzip.setDestination(pluginDirectory); unzip.extract(); } + return pluginDirectory; } diff --git a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginClassLoader.java b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginClassLoader.java index 4b3f137..5573703 100644 --- a/pf4j/src/main/java/ro/fortsoft/pf4j/PluginClassLoader.java +++ b/pf4j/src/main/java/ro/fortsoft/pf4j/PluginClassLoader.java @@ -12,6 +12,10 @@ */ package ro.fortsoft.pf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; import java.net.URL; import java.net.URLClassLoader; import java.util.List; @@ -23,6 +27,8 @@ import java.util.List; */ public class PluginClassLoader extends URLClassLoader { + private static final Logger log = LoggerFactory.getLogger(PluginClassLoader.class); + // private static final String JAVA_PACKAGE_PREFIX = "java."; // private static final String JAVAX_PACKAGE_PREFIX = "javax."; private static final String PLUGIN_PACKAGE_PREFIX = "ro.fortsoft.pf4j."; @@ -90,4 +96,19 @@ public class PluginClassLoader extends URLClassLoader { // use the standard URLClassLoader (which follows normal parent delegation) return super.loadClass(className); } + + /** + * Release all resources acquired by this class loader. + * The current implementation is incomplete. + * For now, this instance can no longer be used to load + * new classes or resources that are defined by this loader. + */ + public void dispose() { + try { + close(); + } catch (IOException e) { + log.error(e.getMessage(), e); + } + } + }