/** {@inheritDoc} */ @Override public Collection<GridDeployment> getDeployments() { Collection<GridDeployment> deps = new ArrayList<GridDeployment>(); synchronized (mux) { for (List<GridDeployment> depList : cache.values()) { for (GridDeployment d : depList) { if (!deps.contains(d)) { deps.add(d); } } } return deps; } }
/** * @param ldr Class loader to undeploy. * @param recEvt Whether or not to record the event. */ private void undeploy(ClassLoader ldr, boolean recEvt) { Collection<GridDeployment> doomed = new HashSet<GridDeployment>(); synchronized (mux) { for (Iterator<LinkedList<GridDeployment>> i1 = cache.values().iterator(); i1.hasNext(); ) { LinkedList<GridDeployment> deps = i1.next(); for (Iterator<GridDeployment> i2 = deps.iterator(); i2.hasNext(); ) { GridDeployment dep = i2.next(); if (dep.classLoader() == ldr) { dep.undeploy(); i2.remove(); doomed.add(dep); if (log.isInfoEnabled()) { log.info("Removed undeployed class: " + dep); } } } if (deps.isEmpty()) { i1.remove(); } } } for (GridDeployment dep : doomed) { if (dep.isObsolete()) { // Resource cleanup. ctx.resource().onUndeployed(dep); } if (recEvt) { recordUndeploy(dep, true); } } }