@Override public void classpathUndeployed(Classpath classpath) { if (classpath.hasDeployName()) { removePlugin(classpath.getDeployName()); } }
if (classpath.hasDeployName()) { message = String.format("Error while accessing plugin %s for plugin interface %s in deployment %s.", classname, pluginInterface.getName(), classpath.getDeployName());
deploymentMap.remove(classpath); if (classpath.hasDeployName()) { deploynames.remove(classpath.getDeployName()); if (classpath.hasDeployName()) { log.info("Undeploy process started for plugin classpath {}.", classpath.getDeployName()); } else {
private void _deployPlugin(Classpath classpath, Set<Permission> permissions) throws LimbusException { if (deploymentMap.containsKey(classpath)) { return; } log.info("Deploy process started for plugin classpath."); LimbusUtil.logClasspath("plugin", classpath, log); LimbusUtil.logPermissions("plugin", permissions, log); PluginClassLoader pluginClassLoader = new PluginClassLoader(filesystem, sharedClassLoader, classpath.getClasspath()); pluginClassLoader.setPermissions(permissions); Deployment deployment = new Deployment(classpath, pluginClassLoader); deploymentMap.put(classpath, deployment); _deployClasspath(deployment); log.info("Deploy process finished successfully."); if (classpath.hasDeployName()) { deploynames.put(classpath.getDeployName(), classpath); } // Notify deployment subscribers deploymentListeners.multicastSilently() .classpathDeployed(classpath); }
private void _undeployClasspath(Deployment deployment) { // Close the logging environment for this classpath if this classpath is not anonymous // Get the classloader before finishing the deployment (this will erase the reference) URLClassLoader classloader = deployment.getClassloader(); // Enqueue the classloader reference to the reference observer this.referenceObserver.observeReferenceTo(classloader); try { // Finish the deploy context and delete references deployment.finish(); } finally { // Close logTarget for plugin Classpath classpath = deployment.getClasspath(); if (classpath.hasDeployName()) { logTarget.closeChannel(classloader); } // Try to ad-hoc garbage collect the classloadfer. WeakReference<Object> classloaderWeakRef = new WeakReference<Object>(classloader); classloader = null; boolean garbageCollected = LimbusUtil.isGarbageCollected(classloaderWeakRef); if (garbageCollected) { log.info("Classloader was unloaded - the ad-hoc garbage collection was successful!"); } else { log.info( "The ad-hoc garbage collection was not successful - see log output of LimbusReferenceObserver to get long-term garbage collection notifications."); } } }
if (classpath.hasDeployName()) { String deployName = classpath.getDeployName(); logTarget.openChannel(classLoader, deployName);