// build our empty class loader manager - we use it to create and manage our plugin's classloaders
Map<String, URL> pluginNamesUrls = new HashMap<String, URL>();
// Save descriptors for later use, so we don't need to parse them twice.
Map<URL, PluginDescriptor> descriptors = new HashMap<URL, PluginDescriptor>();
PluginDependencyGraph graph = new PluginDependencyGraph();
boolean createResourceCL = pluginContainerConfiguration.isCreateResourceClassloaders();
this.classLoaderManager = new ClassLoaderManager(pluginNamesUrls, graph, rootCL, tmpDir, createResourceCL);
if (finder == null) {
log.warn("No plugin finder was specified in the plugin container configuration - this should only occur within test environments.");
return;
}
try {
Collection<URL> pluginUrls = finder.findPlugins();
// first, we need to parse all descriptors so we can build the dependency graph
for (URL url : pluginUrls) {
log.debug("Plugin found at: " + url);
try {
PluginDescriptor descriptor = AgentPluginDescriptorUtil.loadPluginDescriptorFromUrl(url);
if (!disabledPlugins.contains(descriptor.getName())) {
AgentPluginDescriptorUtil.addPluginToDependencyGraph(graph, descriptor);
pluginNamesUrls.put(descriptor.getName(), url);
descriptors.put(url, descriptor);
} else {
log.info("Not loading disabled plugin: " + url);
}
} catch (Throwable t) {
// probably due to invalid XML syntax in the deployment descriptor - the plugin will be ignored
log.error("Plugin at [" + url + "] could not be loaded and will therefore not be deployed.", t);
continue;
}
}
// our graph is complete, get the order that we have to deploy the plugins
List<String> deploymentOrder = graph.getDeploymentOrder();
// now deploy the plugins in the proper order, making sure we build the proper classloaders
for (String nextPlugin : deploymentOrder) {
URL pluginUrl = pluginNamesUrls.get(nextPlugin);