import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
+import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
/**
* One instance of this class should be created by plugin manager for every available plug-in.
private PluginDescriptor pluginDescriptor;
private boolean parentFirst;
+ private Set<String> loadedClasses;
+
public PluginClassLoader(PluginManager pluginManager, PluginDescriptor pluginDescriptor, ClassLoader parent) {
this(pluginManager, pluginDescriptor, parent, false);
}
this.pluginManager = pluginManager;
this.pluginDescriptor = pluginDescriptor;
this.parentFirst = parentFirst;
+
+ loadedClasses = new HashSet<>();
}
@Override
try {
loadedClass = findClass(className);
log.trace("Found class '{}' in plugin classpath", className);
+ loadedClasses.add(className);
return loadedClass;
} catch (ClassNotFoundException e) {
// try next step
try {
loadedClass = findClass(className);
log.trace("Found class '{}' in plugin classpath", className);
+ loadedClasses.add(className);
return loadedClass;
} catch (ClassNotFoundException e) {
// try next step
}
}
+ /**
+ * Returns all classes loaded by this class loader.
+ */
+ public Set<String> getLoadedClasses() {
+ return Collections.unmodifiableSet(loadedClasses);
+ }
+
+ public boolean isClassLoaded(String className) {
+// return findLoadedClass(className) != null;
+ return loadedClasses.contains(className);
+ }
+
private Class<?> loadClassFromDependencies(String className) {
log.trace("Search in dependencies for class '{}'", className);
List<PluginDependency> dependencies = pluginDescriptor.getDependencies();