geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hanhongf...@apache.org
Subject svn commit: r1086871 - in /geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core: GeronimoServerBehaviourDelegate.java SynchronizeProjectOnServerTask.java
Date Wed, 30 Mar 2011 08:49:50 GMT
Author: hanhongfang
Date: Wed Mar 30 08:49:50 2011
New Revision: 1086871

URL: http://svn.apache.org/viewvc?rev=1086871&view=rev
Log:
GERONIMODEVTOOLS-730 Synchronize the module state between GEP and geronimo server

Modified:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/SynchronizeProjectOnServerTask.java

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java?rev=1086871&r1=1086870&r2=1086871&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
Wed Mar 30 08:49:50 2011
@@ -1408,4 +1408,8 @@ abstract public class GeronimoServerBeha
             return false;
         }
      }
+    
+    public void setModulesState(IModule[] module, int state) {
+        setModuleState(module, state);
+    }
 }

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/SynchronizeProjectOnServerTask.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/SynchronizeProjectOnServerTask.java?rev=1086871&r1=1086870&r2=1086871&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/SynchronizeProjectOnServerTask.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/SynchronizeProjectOnServerTask.java
Wed Mar 30 08:49:50 2011
@@ -28,8 +28,10 @@ import java.util.TimerTask;
 import java.util.TreeSet;
 
 import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.Target;
 import javax.enterprise.deploy.spi.TargetModuleID;
 
+import org.apache.geronimo.st.v30.core.GeronimoServerBehaviourDelegate;
 import org.apache.geronimo.st.v30.core.commands.DeploymentCommandFactory;
 import org.apache.geronimo.st.v30.core.internal.Trace;
 import org.eclipse.core.resources.IProject;
@@ -41,8 +43,6 @@ import org.eclipse.wst.server.core.IModu
 import org.eclipse.wst.server.core.IServer;
 import org.eclipse.wst.server.core.IServerWorkingCopy;
 import org.eclipse.wst.server.core.ServerCore;
-import org.eclipse.wst.server.core.internal.ModuleFactory;
-import org.eclipse.wst.server.core.internal.ServerPlugin;
 
 public class SynchronizeProjectOnServerTask extends TimerTask {
 
@@ -74,18 +74,37 @@ public class SynchronizeProjectOnServerT
                         List<IModule> removedModules = new ArrayList<IModule>();
                         
                         DeploymentManager dm = DeploymentCommandFactory.getDeploymentManager(server);
-                        TargetModuleID[] ids = dm.getAvailableModules(null, dm.getTargets());
+                        Target[] targets = dm.getTargets();
+                        TargetModuleID[] ids = dm.getAvailableModules(null, targets);
+                        
+                        TargetModuleID[] runningIds = dm.getRunningModules(null, targets);
+                        TargetModuleID[] nonRunningIds = dm.getNonRunningModules(null, targets);
+                        TreeSet<String> runningConfigIds = new TreeSet<String>();
+                        TreeSet<String> nonRunningConfigIds = new TreeSet<String>();
                       
+                        for (TargetModuleID running : runningIds) {
+                            runningConfigIds.add(running.getModuleID());
+                        }
+                        for (TargetModuleID nonRunning : nonRunningIds) {
+                            nonRunningConfigIds.add(nonRunning.getModuleID());
+                        }
                         
                         for ( ; projectsIterator.hasNext(); ) {
                             String projectName = (String) projectsIterator.next();
                             String configID = (String) projectsOnServer.get(projectName);
+                            IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+                            IModule[] modules = GeronimoUtils.getModules(project);
+
                             if (!isInstalledModule(ids, configID)) {
                                 removedConfigIds.add(configID);
-                                IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
-                                IModule[] modules = GeronimoUtils.getModules(project);
                                 for (IModule module : modules) {
                                     removedModules.add(module);
                                 }
+                            } else { 
+                                if (runningConfigIds.contains(configID)) {
+                                    setModuleState(modules, IServer.STATE_STARTED);
+                                } else if (nonRunningConfigIds.contains(configID)){
+                                    setModuleState(modules, IServer.STATE_STOPPED);
+                                }
                             }
                         }
                         
@@ -111,6 +130,11 @@ public class SynchronizeProjectOnServerT
         Trace.tracePoint("Exist ", "SynchronizeProjectOnServerTask.run");
     }
 
+    private void setModuleState(IModule[] modules, int state) {
+        GeronimoServerBehaviourDelegate d = (GeronimoServerBehaviourDelegate) this.delegate;
+        d.setModulesState(modules, state);        
+    }
+
     private boolean isInstalledModule(TargetModuleID[] ids, String configId) {
         
         if(ids == null) {           



Mime
View raw message