geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From de...@apache.org
Subject svn commit: r1022395 - in /geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins: org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/internal/ org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/in...
Date Thu, 14 Oct 2010 07:21:20 GMT
Author: delos
Date: Thu Oct 14 07:21:19 2010
New Revision: 1022395

URL: http://svn.apache.org/viewvc?rev=1022395&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.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/internal/DependencyHelper.java
    geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/DependencyHelper.java

Modified: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/internal/DependencyHelper.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/internal/DependencyHelper.java?rev=1022395&r1=1022394&r2=1022395&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/internal/DependencyHelper.java
(original)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/internal/DependencyHelper.java
Thu Oct 14 07:21:19 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;
 
@@ -34,9 +35,9 @@ import org.apache.geronimo.j2ee.deployme
 import org.apache.geronimo.j2ee.deployment.ObjectFactory;
 import org.apache.geronimo.j2ee.openejb_jar.OpenejbJarType;
 import org.apache.geronimo.j2ee.web.WebAppType;
+import org.apache.geronimo.st.core.jaxb.JAXBUtils;
 import org.apache.geronimo.st.v11.core.DeploymentUtils;
 import org.apache.geronimo.st.v11.core.GeronimoUtils;
-import org.apache.geronimo.st.core.jaxb.JAXBUtils;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
 import org.eclipse.wst.server.core.IModule;
@@ -67,6 +68,8 @@ public class DependencyHelper {
     private List<JAXBElement> inputJAXBElements = new ArrayList();
     private List<JAXBElement> reorderedJAXBElements = new ArrayList();
 
+    //provide a cache
+    private ConcurrentHashMap<IModule, EnvironmentType> environmentCache = new ConcurrentHashMap<IModule,
EnvironmentType>();
 
     /**
      * Reorder the publish order of the modules based on any discovered dependencies
@@ -78,6 +81,9 @@ public class DependencyHelper {
      */
     public List reorderModules(IServer server, List modules, List deltaKind ) {
         Trace.tracePoint("Entry", "DependencyTypeHelper.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 +131,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 +396,11 @@ public class DependencyHelper {
     private EnvironmentType getEnvironment(IModule module) {
         Trace.tracePoint("Enter", "DependencyTypeHelper.getEnvironment", module);
 
+		// if module's environment is in the cache, get it from the cache
+		if (environmentCache.containsKey(module)) {
+			return environmentCache.get(module);
+		}
+        
         EnvironmentType environment = null;
         if (GeronimoUtils.isWebModule(module)) {
             if (getWebDeploymentPlan(module) != null) {
@@ -410,6 +436,9 @@ public class DependencyHelper {
                     environment = plan.getServerEnvironment();
             }
         }
+        
+        //put module's environment into the cache for next retrieve
+        environmentCache.put(module, environment);
 
         Trace.tracePoint("Exit ", "DependencyTypeHelper.getEnvironment", environment);
         return environment;

Modified: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/DependencyHelper.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/DependencyHelper.java?rev=1022395&r1=1022394&r2=1022395&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/DependencyHelper.java
(original)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/internal/DependencyHelper.java
Thu Oct 14 07:21:19 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;
 
@@ -68,6 +69,8 @@ public class DependencyHelper {
     private List<JAXBElement> inputJAXBElements = new ArrayList();
     private List<JAXBElement> reorderedJAXBElements = new ArrayList();
 
+    //provide a cache
+    private ConcurrentHashMap<IModule, Environment> environmentCache = new ConcurrentHashMap<IModule,
Environment>();
 
     /**
      * Reorder the publish order of the modules based on any discovered dependencies
@@ -79,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);
@@ -126,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);
 	                        }
 	                    }
 	                }
@@ -376,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) {
@@ -412,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