public void undeploy(Archive<?> archive) throws DeploymentException {
LOG.info("Undeploying " + archive + " from PluginContainer " + container.get().getName());
try {
switchPcInstance();
} catch (Exception e) {
throw new DeploymentException("Failed to switch plugin container.", e);
}
RhqAgentPluginArchive plugin = archive.as(RhqAgentPluginArchive.class);
boolean wasStarted = stopPc();
File pluginDeploymentPath = getDeploymentPath(plugin);
if (pluginDeploymentPath.exists() && !pluginDeploymentPath.delete()) {
if (File.separatorChar == '/') {
// Unix
throw new DeploymentException("Could not delete the RHQ plugin jar " + plugin.getName());
} else {
// Windows
// TODO: file locking, probably due to
// http://management-platform.blogspot.com/2009/01/classloaders-keeping-jar-files-open.html,
// is not allowing deletion. Perhaps this can be fixed at some point.