Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 84613 invoked from network); 14 Oct 2010 06:52:01 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 14 Oct 2010 06:52:01 -0000 Received: (qmail 19078 invoked by uid 500); 14 Oct 2010 06:52:01 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 18950 invoked by uid 500); 14 Oct 2010 06:51:59 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 18940 invoked by uid 99); 14 Oct 2010 06:51:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Oct 2010 06:51:59 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Oct 2010 06:51:58 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 97E01238899C; Thu, 14 Oct 2010 06:51:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1022388 - /geronimo/devtools/eclipse-plugin/branches/2.1.7/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/internal/DependencyHelper.java Date: Thu, 14 Oct 2010 06:51:02 -0000 To: scm@geronimo.apache.org From: delos@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20101014065102.97E01238899C@eris.apache.org> Author: delos Date: Thu Oct 14 06:51:02 2010 New Revision: 1022388 URL: http://svn.apache.org/viewvc?rev=1022388&view=rev Log: GERONIMODEVTOOLS-608 reduce time-consuming in DependencyHelper with cache. Thanks Boes and Chris for the patch Modified: geronimo/devtools/eclipse-plugin/branches/2.1.7/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/internal/DependencyHelper.java Modified: geronimo/devtools/eclipse-plugin/branches/2.1.7/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/internal/DependencyHelper.java URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.1.7/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/internal/DependencyHelper.java?rev=1022388&r1=1022387&r2=1022388&view=diff ============================================================================== --- geronimo/devtools/eclipse-plugin/branches/2.1.7/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/internal/DependencyHelper.java (original) +++ geronimo/devtools/eclipse-plugin/branches/2.1.7/plugins/org.apache.geronimo.st.core/src/main/java/org/apache/geronimo/st/core/internal/DependencyHelper.java Thu Oct 14 06:51:02 2010 @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import javax.xml.bind.JAXBElement; @@ -66,6 +67,9 @@ public class DependencyHelper { private List reorderedKinds = new ArrayList(); private List inputJAXBElements = new ArrayList(); private List reorderedJAXBElements = new ArrayList(); + + //provide a cache + private ConcurrentHashMap environmentCache = new ConcurrentHashMap(); /** @@ -78,6 +82,9 @@ public class DependencyHelper { */ public List reorderModules(IServer server, List modules, List deltaKind ) { Trace.tracePoint("Entry", "DependencyHelper.reorderModules", modules, deltaKind); + + //provide a cache + ConcurrentHashMap verifiedModules = new ConcurrentHashMap(); if (modules.size() == 0) { List reorderedLists = new ArrayList(2); @@ -125,8 +132,23 @@ public class DependencyHelper { if (dep.getType()!=null) configId.append(dep.getType()); - if (!DeploymentUtils.isInstalledModule(server,configId.toString())) - dm.addDependency( child, parent ); + //get install flag from the cache + Boolean isInstalledModule = verifiedModules + .get(configId.toString()); + if (isInstalledModule == null) { + // not in the cache, invoke + // isInstalledModule() method + isInstalledModule = DeploymentUtils + .isInstalledModule(server, + configId.toString()); + // put install flag into the cache for next + // retrieve + verifiedModules.put(configId.toString(), + isInstalledModule); + } + + if (!isInstalledModule) + dm.addDependency( child, parent ); } } } @@ -375,6 +397,11 @@ public class DependencyHelper { private Environment getEnvironment(IModule module) { Trace.tracePoint("Enter", "DependencyHelper.getEnvironment", module); + //if module's environment is in the cache, get it from the cache + if (environmentCache.containsKey(module)) { + return environmentCache.get(module); + } + Environment environment = null; if (GeronimoUtils.isWebModule(module)) { if (getWebDeploymentPlan(module) != null) { @@ -411,6 +438,9 @@ public class DependencyHelper { } } + //put module's environment into the cache for next retrieve + environmentCache.put(module, environment); + Trace.tracePoint("Exit ", "DependencyHelper.getEnvironment", environment); return environment; }