public ClassPathLoader(boolean excludeTCCL, File workingDir) { this.excludeTCCL = excludeTCCL; this.jarDeployer = new JarDeployer(workingDir); rebuildClassLoaderForDeployedJars(); }
public ClassPathLoader(boolean excludeTCCL) { this.excludeTCCL = excludeTCCL; this.jarDeployer = new JarDeployer(); rebuildClassLoaderForDeployedJars(); }
public List<DeployedJar> registerNewVersions(List<DeployedJar> deployedJars) throws ClassNotFoundException { lock.lock(); try { Map<DeployedJar, DeployedJar> newVersionToOldVersion = new HashMap<>(); for (DeployedJar deployedJar : deployedJars) { if (deployedJar != null) { logger.info("Registering new version of jar: {}", deployedJar); DeployedJar oldJar = this.deployedJars.put(deployedJar.getJarName(), deployedJar); newVersionToOldVersion.put(deployedJar, oldJar); } } ClassPathLoader.getLatest().rebuildClassLoaderForDeployedJars(); // Finally, unregister functions that were removed for (Map.Entry<DeployedJar, DeployedJar> entry : newVersionToOldVersion.entrySet()) { DeployedJar newjar = entry.getKey(); DeployedJar oldJar = entry.getValue(); newjar.registerFunctions(); if (oldJar != null) { oldJar.cleanUp(newjar); } } } finally { lock.unlock(); } return deployedJars; }
/** * Undeploy the given JAR file. * * @param jarName The name of the JAR file to undeploy * @return The path to the location on disk where the JAR file had been deployed * @throws IOException If there's a problem deleting the file */ public String undeploy(final String jarName) throws IOException { lock.lock(); try { DeployedJar deployedJar = deployedJars.remove(jarName); if (deployedJar == null) { throw new IllegalArgumentException("JAR not deployed"); } ClassPathLoader.getLatest().rebuildClassLoaderForDeployedJars(); deployedJar.cleanUp(null); deleteAllVersionsOfJar(jarName); return deployedJar.getFileCanonicalPath(); } finally { lock.unlock(); } }