geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From de...@apache.org
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 GMT
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<JAXBElement> inputJAXBElements = new ArrayList();
     private List<JAXBElement> reorderedJAXBElements = new ArrayList();
+    
+    //provide a cache
+    private ConcurrentHashMap<IModule, Environment> environmentCache = new ConcurrentHashMap<IModule,
Environment>();
 
 
     /**
@@ -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<String,Boolean> verifiedModules = new ConcurrentHashMap<String,Boolean>();
 
         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;
     }



Mime
View raw message