You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by de...@apache.org on 2010/06/08 06:40:28 UTC

svn commit: r952535 [14/26] - in /geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins: org.apache.geronimo.j2ee.v11.jaxbmodel/ org.apache.geronimo.j2ee.v11.jaxbmodel/META-INF/ org.apache.geronimo.j2ee.v11.jaxbmodel/src/main/java/org/apache/geronimo...

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/GeronimoServerInfo.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/GeronimoServerInfo.java?rev=952535&r1=952534&r2=952535&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/GeronimoServerInfo.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/GeronimoServerInfo.java Tue Jun  8 04:40:16 2010
@@ -37,11 +37,11 @@ import org.apache.geronimo.kernel.Kernel
 import org.apache.geronimo.kernel.NoSuchAttributeException;
 import org.apache.geronimo.kernel.NoSuchOperationException;
 import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.st.core.GeronimoServerBehaviourDelegate;
+import org.apache.geronimo.st.v11.core.GeronimoServerBehaviourDelegate;
 import org.apache.geronimo.st.v11.core.internal.Trace;
 import org.apache.geronimo.system.jmx.KernelDelegate;
-import org.apache.geronimo.xml.ns.deployment_1.DependencyType;
-import org.apache.geronimo.xml.ns.naming_1.PatternType;
+import org.apache.geronimo.j2ee.deployment.DependencyType;
+import org.apache.geronimo.j2ee.naming.PatternType;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
@@ -63,7 +63,7 @@ public class GeronimoServerInfo {
     private ArrayList<PatternType> jmsDestinations;
     private ArrayList<PatternType> jdbcConnectionPools;
     private ArrayList<PatternType> javaMailResources;
-    private ArrayList<org.apache.geronimo.xml.ns.deployment_1.PatternType> credentialStores;
+    private ArrayList<org.apache.geronimo.j2ee.deployment.PatternType> credentialStores;
     private ArrayList<DependencyType> commonLibs;
 
     // singleton class
@@ -100,7 +100,7 @@ public class GeronimoServerInfo {
         return javaMailResources;
     }
 
-    public ArrayList<org.apache.geronimo.xml.ns.deployment_1.PatternType> getDeployedCredentialStores() {
+    public ArrayList<org.apache.geronimo.j2ee.deployment.PatternType> getDeployedCredentialStores() {
         return credentialStores;
     }
 
@@ -211,7 +211,7 @@ public class GeronimoServerInfo {
     }
 
     private void updateDeployedCredentialStores() {
-        credentialStores = new ArrayList<org.apache.geronimo.xml.ns.deployment_1.PatternType>();
+        credentialStores = new ArrayList<org.apache.geronimo.j2ee.deployment.PatternType>();
         Map map = Collections.singletonMap("j2eeType", "GBean");
         AbstractNameQuery query = new AbstractNameQuery(null, map,
                 Collections.EMPTY_SET);
@@ -226,7 +226,7 @@ public class GeronimoServerInfo {
                     if (attribInfo != null) {
                         Artifact artifact = abstractName.getArtifact();
                         Object name = abstractName.getName().get("name");
-                        org.apache.geronimo.xml.ns.deployment_1.PatternType pattern = new org.apache.geronimo.xml.ns.deployment_1.PatternType();
+                        org.apache.geronimo.j2ee.deployment.PatternType pattern = new org.apache.geronimo.j2ee.deployment.PatternType();
                         pattern.setArtifactId(artifact.getArtifactId());
                         pattern.setGroupId(artifact.getGroupId());
                         pattern.setType(artifact.getType());
@@ -395,9 +395,9 @@ public class GeronimoServerInfo {
     }
 
     protected void printDeploymentPatternList(
-            List<org.apache.geronimo.xml.ns.deployment_1.PatternType> patternList) {
+            List<org.apache.geronimo.j2ee.deployment.PatternType> patternList) {
         for (int i = 0; i < patternList.size(); i++) {
-        	org.apache.geronimo.xml.ns.deployment_1.PatternType pattern = patternList
+        	org.apache.geronimo.j2ee.deployment.PatternType pattern = patternList
                     .get(i);
             System.out.println("ArtifactID:" + pattern.getArtifactId()
                     + " GroupID:" + pattern.getGroupId() + " Module:"
@@ -436,7 +436,7 @@ public class GeronimoServerInfo {
         List<PatternType> javaMailResources = getJavaMailSessions();
         printNamingPatternList(javaMailResources);
         System.out.println("\n\nCredential Stores: \n");
-        List<org.apache.geronimo.xml.ns.deployment_1.PatternType> credentialStores = getDeployedCredentialStores();
+        List<org.apache.geronimo.j2ee.deployment.PatternType> credentialStores = getDeployedCredentialStores();
         printDeploymentPatternList(credentialStores);
         System.out.println("\n\nCommon Libs: \n");
         List<DependencyType> dependencies = getCommonLibs();

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/GeronimoUtils.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/GeronimoUtils.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/GeronimoUtils.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/GeronimoUtils.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,224 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v11.core;
+
+import javax.enterprise.deploy.shared.ModuleType;
+
+import org.apache.geronimo.st.core.internal.Trace;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jst.j2ee.internal.deployables.J2EEFlexProjDeployable;
+import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
+import org.eclipse.jst.server.core.IWebModule;
+import org.eclipse.wst.common.componentcore.ArtifactEdit;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.server.core.IModule;
+
+/**
+ * @version $Rev: 817996 $ $Date: 2009-09-23 16:04:12 +0800 (Wed, 23 Sep 2009) $
+ */
+public class GeronimoUtils {
+
+	public static final String WEB_PLAN_NAME = "geronimo-web.xml";
+
+	public static final String OPENEJB_PLAN_NAME = "openejb-jar.xml";
+
+	public static final String APP_PLAN_NAME = "geronimo-application.xml";
+
+	public static final String APP_CLIENT_PLAN_NAME = "geronimo-application-client.xml";
+
+	public static final String CONNECTOR_PLAN_NAME = "geronimo-ra.xml";
+	
+	public static final String SERVICE_PLAN_NAME = "geronimo-service.xml";
+
+	public static boolean isWebModule(IModule module) {
+		return "jst.web".equals(module.getModuleType().getId());
+	}
+
+	public static boolean isEjbJarModule(IModule module) {
+		return "jst.ejb".equals(module.getModuleType().getId());
+	}
+
+	public static boolean isEarModule(IModule module) {
+		return "jst.ear".equals(module.getModuleType().getId());
+	}
+
+	public static boolean isAppClientModule(IModule module) {
+		return "jst.appclient".equals(module.getModuleType().getId());
+	}
+
+	public static boolean isRARModule(IModule module) {
+		return "jst.connector".equals(module.getModuleType().getId());
+	}
+	
+	public static ModuleType getJSR88ModuleType(IModule module) {
+		if (isWebModule(module)) {
+			return ModuleType.WAR;
+		} else if (isEjbJarModule(module)) {
+			return ModuleType.EJB;
+		} else if (isEarModule(module)) {
+			return ModuleType.EAR;
+		} else if (isRARModule(module)) {
+			return ModuleType.RAR;
+		} else {
+			Trace.trace(Trace.SEVERE, "getJSR88ModuleType = null");
+			return null;
+		}
+	}
+	
+	public static IFile getDeploymentPlanFile(IModule module) {
+		IProject project = module.getProject();
+		IVirtualComponent comp = ComponentCore.createComponent(project);
+		String type = J2EEProjectUtilities.getJ2EEProjectType(project);
+		if (IModuleConstants.JST_WEB_MODULE.equals(type)) {
+			return getWebDeploymentPlanFile(comp);
+		} else if (IModuleConstants.JST_EJB_MODULE.equals(type)) {
+			return getOpenEjbDeploymentPlanFile(comp);
+		} else if (IModuleConstants.JST_EAR_MODULE.equals(type)) {
+			return getApplicationDeploymentPlanFile(comp);
+		} else if (IModuleConstants.JST_APPCLIENT_MODULE.equals(type)) {
+			return getApplicationClientDeploymentPlanFile(comp);
+		} else if (IModuleConstants.JST_CONNECTOR_MODULE.equals(type)) {
+			return getConnectorDeploymentPlanFile(comp);
+		}
+		return null;
+	}
+	
+	public static String getQualifiedConfigID(String groupId, String artifactId, String version, String type) {
+		return groupId + "/" + artifactId + "/" + version + "/" + type;
+	}
+
+	public static IFile getWebDeploymentPlanFile(IVirtualComponent comp) {
+		IPath deployPlanPath = comp.getRootFolder().getUnderlyingFolder().getProjectRelativePath().append("WEB-INF").append(WEB_PLAN_NAME);
+		return comp.getProject().getFile(deployPlanPath);
+	}
+
+	public static IFile getOpenEjbDeploymentPlanFile(IVirtualComponent comp) {
+		IPath deployPlanPath = comp.getRootFolder().getUnderlyingFolder().getProjectRelativePath().append("META-INF").append(OPENEJB_PLAN_NAME);
+		return comp.getProject().getFile(deployPlanPath);
+	}
+
+	public static IFile getApplicationDeploymentPlanFile(IVirtualComponent comp) {
+		IPath deployPlanPath = comp.getRootFolder().getUnderlyingFolder().getProjectRelativePath().append("META-INF").append(APP_PLAN_NAME);
+		return comp.getProject().getFile(deployPlanPath);
+	}
+
+	public static IFile getApplicationClientDeploymentPlanFile(IVirtualComponent comp) {
+		IPath deployPlanPath = comp.getRootFolder().getUnderlyingFolder().getProjectRelativePath().append("META-INF").append(APP_CLIENT_PLAN_NAME);
+		return comp.getProject().getFile(deployPlanPath);
+	}
+
+	public static IFile getConnectorDeploymentPlanFile(IVirtualComponent comp) {
+		IPath deployPlanPath = comp.getRootFolder().getUnderlyingFolder().getProjectRelativePath().append("META-INF").append(CONNECTOR_PLAN_NAME);
+		return comp.getProject().getFile(deployPlanPath);
+	}
+
+	public static IVirtualComponent getVirtualComponent(IModule module) {
+		return ComponentCore.createComponent(module.getProject());
+	}
+
+	public static String getContextRoot(IModule module) throws Exception{
+		String contextRoot = null;
+
+		J2EEFlexProjDeployable j2eeModule = (J2EEFlexProjDeployable) module.loadAdapter(J2EEFlexProjDeployable.class, null);
+		contextRoot = ((IWebModule) j2eeModule).getContextRoot();
+
+		if (contextRoot == null)
+			contextRoot = getId(module);
+
+		return contextRoot;
+	}
+
+	public static String getId(IModule module) {
+		// use the module ID
+		String moduleId = module.getId();
+
+		J2EEFlexProjDeployable j2eeModule = (J2EEFlexProjDeployable) module.loadAdapter(J2EEFlexProjDeployable.class, null);
+		if (j2eeModule != null) {
+			// j2eeFlex
+			ArtifactEdit edit = null;
+			try {
+				edit = ArtifactEdit.getArtifactEditForRead(j2eeModule.getProject());
+				//TODO JAXB Refactoring - Can below two lines be removed without harm?
+				//XMIResource res = (XMIResource) edit.getContentModelRoot().eResource();
+				//moduleId = res.getID(edit.getContentModelRoot());
+			} finally {
+				if (edit != null)
+					edit.dispose();
+			}
+		}
+
+		if (moduleId != null && moduleId.length() > 0)
+			return moduleId;
+
+		// ...but if there is no defined module ID, pick the best alternative
+
+		IPath moduleLocation = new Path(j2eeModule.getURI(module));
+		if (moduleLocation != null) {
+			moduleId = moduleLocation.removeFileExtension().lastSegment();
+		}
+
+		if (j2eeModule instanceof IWebModule) {
+			// A better choice is to use the context root
+			// For wars most appservers use the module name
+			// as the context root
+			String contextRoot = ((IWebModule) j2eeModule).getContextRoot();
+			if (contextRoot.charAt(0) == '/')
+				moduleId = contextRoot.substring(1);
+		}
+
+		return moduleId;
+	}
+
+	public static IFile getServiceDeploymentPlanFile(IVirtualComponent comp) {
+		IPath deployPlanPath = comp.getRootFolder().getUnderlyingFolder().getProjectRelativePath().append("META-INF").append(SERVICE_PLAN_NAME);
+		return comp.getProject().getFile(deployPlanPath);
+	}
+
+/*
+//TODO JAXB Refactoring - Can this function be removed without harm?
+	public static Resource load(IFile dpFile, ResourceSet resourceSet) {
+		try {
+
+			URI uri = URI.createPlatformResourceURI(dpFile.getFullPath().toString(), false);
+
+			Resource resource = resourceSet.createResource(uri);
+			if (!resource.isLoaded()) {
+				resource.load(null);
+			}
+			return resource;
+		} catch (MalformedURLException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+*/	
+/*
+//TODO JAXB Refactoring - Can this function be removed without harm?
+	public static void register(ResourceSet resourceSet,
+			Resource.Factory factory, EPackage pkg, String nsUri) {
+		resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, factory);
+		resourceSet.getPackageRegistry().put(nsUri, pkg);
+	}
+*/
+}

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/GeronimoV11Utils.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/GeronimoV11Utils.java?rev=952535&r1=952534&r2=952535&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/GeronimoV11Utils.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/GeronimoV11Utils.java Tue Jun  8 04:40:16 2010
@@ -18,18 +18,18 @@ package org.apache.geronimo.st.v11.core;
 
 import javax.xml.bind.JAXBElement;
 
-import org.apache.geronimo.st.core.GeronimoUtils;
+import org.apache.geronimo.st.v11.core.GeronimoUtils;
 import org.apache.geronimo.st.core.internal.Trace;
 import org.apache.geronimo.st.core.jaxb.JAXBUtils;
-import org.apache.geronimo.xml.ns.deployment_1.ArtifactType;
-import org.apache.geronimo.xml.ns.deployment_1.EnvironmentType;
-import org.apache.geronimo.xml.ns.j2ee.application_1.ApplicationType;
-import org.apache.geronimo.xml.ns.j2ee.connector_1.ConnectorType;
-import org.apache.geronimo.xml.ns.j2ee.web_1.WebAppType;
+import org.apache.geronimo.j2ee.deployment.ArtifactType;
+import org.apache.geronimo.j2ee.deployment.EnvironmentType;
+import org.apache.geronimo.j2ee.application.ApplicationType;
+import org.apache.geronimo.j2ee.connector.ConnectorType;
+import org.apache.geronimo.j2ee.web.WebAppType;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
 import org.eclipse.wst.server.core.IModule;
-import org.openejb.xml.ns.openejb_jar_2.OpenejbJarType;
+import org.apache.geronimo.j2ee.openejb_jar.OpenejbJarType;
 
 /**
  * @version $Rev: 471551 $ $Date: 2006-11-05 17:47:11 -0500 (Sun, 05 Nov 2006) $

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/GeronimoV11VersionHandler.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/GeronimoV11VersionHandler.java?rev=952535&r1=952534&r2=952535&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/GeronimoV11VersionHandler.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/GeronimoV11VersionHandler.java Tue Jun  8 04:40:16 2010
@@ -19,8 +19,8 @@ package org.apache.geronimo.st.v11.core;
 import javax.enterprise.deploy.spi.TargetModuleID;
 
 import org.apache.geronimo.deployment.plugin.TargetModuleIDImpl;
-import org.apache.geronimo.st.core.IGeronimoVersionHandler;
-import org.apache.geronimo.st.v21.core.GeronimoV21Utils;
+import org.apache.geronimo.st.v11.core.IGeronimoVersionHandler;
+import org.apache.geronimo.st.v11.core.GeronimoV11Utils;
 import org.eclipse.wst.server.core.IModule;
 
 /**

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/IGeronimoServer.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/IGeronimoServer.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/IGeronimoServer.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/IGeronimoServer.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v11.core;
+
+import java.util.List;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.factories.DeploymentFactory;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.wst.server.core.model.IURLProvider;
+
+/**
+ * @version $Rev: 797732 $ $Date: 2009-07-25 17:42:04 +0800 (Sat, 25 Jul 2009) $
+ */
+public interface IGeronimoServer extends IURLProvider {
+
+	public String getAdminID();
+
+	public String getAdminPassword();
+
+	public String getRMINamingPort();
+
+	public String getDeployerURL();
+
+	public String getJMXServiceURL();
+
+	public IPath getJSR88DeployerJar();
+	
+	public DeploymentFactory getDeploymentFactory();
+
+	public void configureDeploymentManager(DeploymentManager dm);
+
+	public IGeronimoVersionHandler getVersionHandler();
+	
+	public boolean isNotRedeployJSPFiles();	
+	
+	public boolean isInPlaceSharedLib();
+	
+	public boolean isRunFromWorkspace();
+	
+	public boolean isSelectClasspathContainers();
+	
+	public List<String> getClasspathContainers();
+	
+	public int getPingDelay();
+	
+	public int getPingInterval();
+	
+	public int getMaxPings();
+	
+	public long getPublishTimeout();
+
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/IGeronimoServerBehavior.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/IGeronimoServerBehavior.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/IGeronimoServerBehavior.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/IGeronimoServerBehavior.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v11.core;
+
+import javax.enterprise.deploy.spi.Target;
+
+/**
+ * @version $Rev: 471551 $ $Date: 2006-11-06 06:47:11 +0800 (Mon, 06 Nov 2006) $
+ */
+public interface IGeronimoServerBehavior {
+
+	public boolean isFullyStarted();
+
+	public boolean isKernelAlive();
+
+	public void setServerStarted();
+
+	public void setServerStopped();
+	
+	public Target[] getTargets();
+
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/IGeronimoVersionHandler.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/IGeronimoVersionHandler.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/IGeronimoVersionHandler.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/IGeronimoVersionHandler.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v11.core;
+
+import javax.enterprise.deploy.spi.TargetModuleID;
+
+import org.eclipse.wst.server.core.IModule;
+
+/**
+ * @version $Rev: 817996 $ $Date: 2009-09-23 16:04:12 +0800 (Wed, 23 Sep 2009) $
+ */
+public interface IGeronimoVersionHandler {
+
+	public String getConfigID(IModule module) throws Exception;
+	
+	public TargetModuleID createTargetModuleId(String configId);
+
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/ModuleArtifactMapper.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/ModuleArtifactMapper.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/ModuleArtifactMapper.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/ModuleArtifactMapper.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,216 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v11.core;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInput;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.util.SocketUtil;
+
+/**
+ * @version $Rev: 736695 $ $Date: 2009-01-23 00:36:14 +0800 (Fri, 23 Jan 2009) $
+ */
+public class ModuleArtifactMapper {
+
+	private static ModuleArtifactMapper instance = new ModuleArtifactMapper();
+
+	private static final String FILE_NAME = "servermodule.info";
+
+	ServerEntries serverEntries = null;
+
+	private ModuleArtifactMapper() {
+		if (serverEntries == null)
+			serverEntries = new ServerEntries();
+		load();
+	}
+
+	public static ModuleArtifactMapper getInstance() {
+		return instance;
+	}
+
+	public void addEntry(IServer server, IProject project, String configId) {
+
+		if (!SocketUtil.isLocalhost(server.getHost()))
+			return;
+
+		File runtimeLoc = server.getRuntime().getLocation().toFile();
+		Map artifactEntries = (Map) serverEntries.get(runtimeLoc);
+		if (artifactEntries == null) {
+			artifactEntries = new HashMap();
+			serverEntries.put(runtimeLoc, artifactEntries);
+		}
+
+		artifactEntries.put(project.getName(), configId);
+	}
+
+	public void removeEntry(IServer server, IProject project) {
+
+		if (!SocketUtil.isLocalhost(server.getHost()))
+			return;
+
+		File runtimeLoc = server.getRuntime().getLocation().toFile();
+		Map artifactEntries = (Map) serverEntries.get(runtimeLoc);
+		if (artifactEntries != null) {
+			artifactEntries.remove(project.getName());
+		}
+	}
+
+	public String resolve(IServer server, IModule module) {
+		Map artifactEntries = (Map) serverEntries.get(server.getRuntime().getLocation().toFile());
+		if (artifactEntries != null && module != null && module.getProject() != null) {
+			return (String) artifactEntries.get(module.getProject().getName());
+		}
+		return null;
+	}
+
+	public void save() {
+		ObjectOutput output = null;
+		try {
+			IPath dest = Activator.getDefault().getStateLocation().append(FILE_NAME);
+			OutputStream file = new FileOutputStream(dest.toFile());
+			OutputStream buffer = new BufferedOutputStream(file);
+			output = new ObjectOutputStream(buffer);
+			String xml = serverEntries.toXML();
+			output.writeObject(xml);
+		} catch (IOException e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				if (output != null)
+					output.close();
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+
+	private void load() {
+		ObjectInput input = null;
+		try {
+			IPath dest = Activator.getDefault().getStateLocation().append(FILE_NAME);
+			if (dest.toFile().exists()) {
+				InputStream file = new FileInputStream(dest.toFile());
+				InputStream buffer = new BufferedInputStream(file);
+				input = new ObjectInputStream(buffer);
+				String xml = (String) input.readObject();
+				serverEntries.loadXML(xml);
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		} finally {
+			try {
+				if (input != null)
+					input.close();
+			} catch (IOException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+
+	// This Inner class is the result of removing XStream.  ModuleArtifactMapper
+	// was the only class using it so it seemed silly to have two extra jar
+	// files (xpp3.jar and xstream.jar) just for one class.
+	// this class is a HashMap
+	// keys are the files
+	// entries are the Maps of artifact entries
+	// this is all saved/loaded to .plugins/org.apache.geronimo.st.core/servermodule.info
+    protected class ServerEntries extends HashMap {
+        static final long serialVersionUID = 0;
+
+        protected void loadXML (String xml) {
+            if (xml == null || xml.length() == 0)
+                return;
+
+            String projectName, configId;
+            int fileEndPos, nomapStartPos, mapStartPos, mapEndPos, stringStartPos, stringEndPos;
+            int fileStartPos = xml.indexOf("<file>", 0);
+            Map artifactEntries;
+            while (fileStartPos > -1) {
+                fileEndPos = xml.indexOf("</file>", fileStartPos);
+                File runtimeLoc = new File(xml.substring(fileStartPos + 6, fileEndPos));
+
+                nomapStartPos = xml.indexOf("<map/>", fileEndPos);
+                mapStartPos = xml.indexOf("<map>", fileEndPos);
+                artifactEntries = new HashMap();
+                // have projects on the server
+                if ((nomapStartPos == -1) || (nomapStartPos > mapStartPos)) {
+                    mapEndPos = xml.indexOf("</map>", mapStartPos);
+                    stringStartPos = xml.indexOf("<string>", mapStartPos);
+                    while ((stringStartPos > -1) && (stringStartPos < mapEndPos)) {
+                        stringEndPos = xml.indexOf("</string>", stringStartPos);
+                        projectName = xml.substring(stringStartPos + 8, stringEndPos);
+                        stringStartPos = xml.indexOf("<string>", stringEndPos);
+                        stringEndPos = xml.indexOf("</string>", stringStartPos);
+                        configId = xml.substring(stringStartPos + 8, stringEndPos);
+                        artifactEntries.put(projectName, configId);
+                        stringStartPos = xml.indexOf("<string>", stringEndPos);
+                    }
+                }
+                // if no projects on the server, it is ok to put an empty HashMap
+                this.put (runtimeLoc, artifactEntries);
+
+                fileStartPos = xml.indexOf("<file>", fileEndPos);
+            }
+        }
+
+        protected String toXML () {
+            String xmlString = "";
+            if (!isEmpty()) {
+                xmlString = "<map>\n  <entry>\n";
+
+                Object[] serverKeySet = keySet().toArray();
+                for (int i = 0; i < serverKeySet.length; i++) {
+                    xmlString += "    <file>" + serverKeySet[i] + "</file>\n";
+                    Map projectMap = (Map)get(serverKeySet[i]);
+                    if (projectMap == null || projectMap.size() == 0) {
+                        xmlString += "    <map/>\n";
+                    }
+                    else {
+                        xmlString += "    <map>\n";
+                        Object[] projectKeySet = projectMap.keySet().toArray();
+                        for (int j = 0; j < projectKeySet.length; j++)
+                        {
+                             xmlString += "      <entry>\n";
+                             xmlString += "        <string>" + (String)projectKeySet[j] + "</string>\n";
+                             xmlString += "        <string>" + (String)projectMap.get(projectKeySet[j]) + "</string>\n";
+                             xmlString += "      </entry>\n";
+                        }
+                        xmlString += "    </map>\n";
+                    }
+                }
+                xmlString += "  </entry>\n</map>";
+            }
+            return xmlString;
+        }
+    }
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/PingThread.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/PingThread.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/PingThread.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/PingThread.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v11.core;
+
+import org.apache.geronimo.st.core.internal.Trace;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.util.SocketUtil;
+
+/**
+ * @version $Rev: 817996 $ $Date: 2009-09-23 16:04:12 +0800 (Wed, 23 Sep 2009) $
+ */
+public class PingThread extends Thread {
+
+	private int pingDelay;
+
+	private int pingInterval;
+
+	private int maxPings;
+
+	private IGeronimoServerBehavior geronimoServer;
+
+	private IServer server;
+
+	public PingThread(IGeronimoServerBehavior geronimoServer, IServer server) {
+		super();
+		this.geronimoServer = geronimoServer;
+		this.server = server;
+		this.setDaemon(true);
+		loadPingDelay();
+		loadPingInterval();
+		loadMaxPings();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.lang.Runnable#run()
+	 */
+	public void run() {
+
+		if (!SocketUtil.isLocalhost(server.getHost())) {
+			return;
+		}
+
+		try {
+			sleep(pingDelay);
+		} catch (InterruptedException e) {
+			// ignore
+		}
+
+		for (int tries = maxPings; tries > 0; tries--) {
+			
+			if(server.getServerState() == IServer.STATE_STOPPED || server.getServerState() == IServer.STATE_STOPPING) {
+				return;
+			}
+
+			ClassLoader old = Thread.currentThread().getContextClassLoader();
+			try {
+				ClassLoader cl = ((GeronimoServerBehaviourDelegate) geronimoServer).getContextClassLoader();
+				Thread.currentThread().setContextClassLoader(cl);
+				if (geronimoServer.isFullyStarted()) {
+					Trace.trace(Trace.INFO, "Ping: success");
+					geronimoServer.setServerStarted();
+					return;
+				}
+			} finally {
+				Thread.currentThread().setContextClassLoader(old);
+			}
+
+			Trace.trace(Trace.INFO, "Ping: fail");
+
+			try {
+				sleep(pingInterval);
+			} catch (InterruptedException e) {
+				// ignore
+			}
+		}
+
+		//don't need to show this message to user, since wst Server will show the timeout message to user
+		Trace.trace(Trace.SEVERE, "Ping: Can't ping for server startup.");
+		server.stop(false);
+	}
+	
+	public void loadPingDelay() {
+		pingDelay = getGeronimoServer().getPingDelay();
+	}
+	
+	public void loadPingInterval() {
+		pingInterval = getGeronimoServer().getPingInterval();
+	}
+	
+	public void loadMaxPings() {
+		maxPings = getGeronimoServer().getMaxPings();
+	}
+	
+	private IGeronimoServer getGeronimoServer() {
+		IGeronimoServer gServer = (IGeronimoServer) server.getAdapter(IGeronimoServer.class);
+		if(gServer == null) {
+			gServer = (IGeronimoServer) server.loadAdapter(IGeronimoServer.class, null);
+		}
+		return gServer;
+	}
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/UpdateServerStateTask.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/UpdateServerStateTask.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/UpdateServerStateTask.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/UpdateServerStateTask.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v11.core;
+
+import java.util.TimerTask;
+
+import org.apache.geronimo.st.core.internal.Trace;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.internal.Server;
+
+/**
+ * @version $Rev: 817996 $ $Date: 2009-09-23 16:04:12 +0800 (Wed, 23 Sep 2009) $
+ */
+public class UpdateServerStateTask extends TimerTask {
+
+	private IGeronimoServerBehavior delegate;
+
+	private IServer server;
+
+	public UpdateServerStateTask(IGeronimoServerBehavior delegate, IServer server) {
+		super();
+		this.delegate = delegate;
+		this.server = server;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see java.util.TimerTask#run()
+	 */
+	public void run() {
+		if (canUpdateState()) {
+			updateServerState();
+		}
+	}
+
+	/**
+	 * Returns true if either the connection URL is unique for all g-servers or
+	 * if all other servers that share the same connection URL but have
+	 * different runtime locations are stopped.
+	 * 
+	 * @return true if ok to update state
+	 */
+	private boolean canUpdateState() {
+		IGeronimoServer thisServer = (IGeronimoServer) this.server.loadAdapter(IGeronimoServer.class, null);
+		IServer[] allServers = ServerCore.getServers();
+		for (int i = 0; i < allServers.length; i++) {
+			IServer server = allServers[i];
+			IGeronimoServer gs = (IGeronimoServer) server.loadAdapter(IGeronimoServer.class, null);
+			if (gs != null && !this.server.getId().equals(server.getId())) {
+				if (isSameConnectionURL(gs, thisServer)) {
+					if (!isSameRuntimeLocation(server) && server.getServerState() != IServer.STATE_STOPPED) {
+						Trace.trace(Trace.WARNING, server.getId() + " Cannot update server state.  URL conflict between multiple servers.");
+						return false;
+					}
+				}
+			}
+		}
+
+		return true;
+	}
+
+	private boolean isSameRuntimeLocation(IServer server) {
+		return server.getRuntime().getLocation().equals(this.server.getRuntime().getLocation());
+	}
+
+	private boolean isSameConnectionURL(IGeronimoServer server, IGeronimoServer thisServer) {
+		return server.getJMXServiceURL().equals(thisServer.getJMXServiceURL());
+	}
+
+	private void updateServerState() {
+		Trace.trace(Trace.INFO, ">> " + server.getId() + " Updating Server State.");
+		try {
+			switch (server.getServerState()) {
+			case IServer.STATE_STOPPED:
+				if (delegate.isKernelAlive())
+					updateFromStopped();
+				break;
+			case IServer.STATE_STARTING:
+				if (delegate.isKernelAlive())
+					updateFromStarting();
+				else
+					delegate.setServerStopped();
+				break;
+			case IServer.STATE_STARTED:
+				updateFromStarted();
+				break;
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		Trace.trace(Trace.INFO, "<< " + server.getId() + " Updating Server State.");
+	}
+
+	private void updateFromStopped() throws CoreException {
+		if (isFullyStarted()) {
+			delegate.setServerStarted();
+		} else {
+			((Server) server).setServerState(IServer.STATE_STARTING);
+		}
+	}
+
+	private void updateFromStarting() throws CoreException {
+		if (isFullyStarted())
+			delegate.setServerStarted();
+	}
+
+	private void updateFromStarted() throws CoreException {
+		if (!isFullyStarted())
+			delegate.setServerStopped();
+	}
+
+	private boolean isFullyStarted() throws CoreException {
+		ClassLoader old = Thread.currentThread().getContextClassLoader();
+		try {
+			Thread.currentThread().setContextClassLoader(((GeronimoServerBehaviourDelegate) delegate).getContextClassLoader());
+			return delegate.isFullyStarted();
+		} finally {
+			Thread.currentThread().setContextClassLoader(old);
+		}
+	}
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/AbstractDeploymentCommand.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/commands/AbstractDeploymentCommand.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/AbstractDeploymentCommand.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/AbstractDeploymentCommand.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v11.core.commands;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+
+import org.apache.geronimo.st.v11.core.IGeronimoServer;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+
+/**
+ * @version $Rev: 480044 $ $Date: 2006-11-28 22:02:54 +0800 (Tue, 28 Nov 2006) $
+ */
+abstract class AbstractDeploymentCommand implements IDeploymentCommand {
+	
+	private IServer server;
+
+	private IModule module;
+	
+	private long timeout;
+
+	public AbstractDeploymentCommand(IServer server, IModule module) {
+		super();
+		this.server = server;
+		this.module = module;
+		timeout = getGeronimoServer().getPublishTimeout();
+	}
+
+	public DeploymentManager getDeploymentManager() throws CoreException {
+		return DeploymentCommandFactory.getDeploymentManager(server);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.geronimo.st.core.commands.IDeploymentCommand#getModule()
+	 */
+	public IModule getModule() {
+		return module;
+	}
+
+	public IServer getServer() {
+		return server;
+	}
+	
+	public IGeronimoServer getGeronimoServer() {
+		return (IGeronimoServer) getServer().getAdapter(IGeronimoServer.class);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.geronimo.st.core.commands.IDeploymentCommand#getTimeout()
+	 */
+	public long getTimeout() {
+		return timeout;
+	}
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/DeployCommand.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/commands/DeployCommand.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/DeployCommand.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/DeployCommand.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v11.core.commands;
+
+import java.io.File;
+
+import org.apache.geronimo.st.v11.core.DeploymentUtils;
+import org.apache.geronimo.st.v11.core.IGeronimoServer;
+import org.apache.geronimo.st.core.internal.Trace;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+
+/**
+ * @version $Rev: 509683 $ $Date: 2007-02-21 01:47:35 +0800 (Wed, 21 Feb 2007) $
+ */
+abstract public class DeployCommand extends AbstractDeploymentCommand {
+
+	/**
+	 * @param server
+	 * @param module
+	 */
+	public DeployCommand(IServer server, IModule module) {
+		super(server, module);
+	}
+
+	public File getTargetFile() {
+		File file = null;
+		IGeronimoServer gs = getGeronimoServer();
+		if (gs.isRunFromWorkspace()) {
+		    //TODO Re-enable after DeployableModule supported in G
+			//file = generateRunFromWorkspaceConfig(getModule());
+		} else {
+			IPath outputDir = DeploymentUtils.STATE_LOC.append("server_" + getServer().getId());
+			outputDir.toFile().mkdirs();
+			file = DeploymentUtils.createJarFile(getModule(), outputDir);
+		}
+		Trace.trace(Trace.INFO, "File: " + file.getAbsolutePath());
+		return file;
+	}
+
+	/*protected File generateRunFromWorkspaceConfig(IModule module) {
+		IPath configDir = Activator.getDefault().getStateLocation().append("looseconfig").append("server_" + getServer().getId());
+		configDir.toFile().mkdirs();
+
+		ModuleDocument doc = ModuleDocument.Factory.newInstance();
+		Module deployable = doc.addNewModule();
+		processModuleConfig(deployable, module);
+
+		XmlOptions options = new XmlOptions();
+		options.setSavePrettyPrint();
+		File file = configDir.append(module.getName()).addFileExtension("xml").toFile();
+		Trace.trace(Trace.INFO,doc.xmlText(options));
+		try {
+			doc.save(file, options);
+			return file;
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+
+	private void processModuleConfig(Module deployable, IModule serverModule) {
+		deployable.setName(serverModule.getName());
+		J2EEFlexProjDeployable j2eeModule = (J2EEFlexProjDeployable) serverModule.loadAdapter(J2EEFlexProjDeployable.class, null);
+		if (j2eeModule != null) {
+
+			if(j2eeModule.isBinary()) {
+				deployable.setPath(serverModule.getName());
+				return;
+			}
+
+			IContainer[] containers = j2eeModule.getResourceFolders();
+			for (int i = 0; i < containers.length; i++) {
+				deployable.addNewResources().setPath(containers[i].getLocation().toOSString());
+			}
+			containers = j2eeModule.getJavaOutputFolders();
+			for (int i = 0; i < containers.length; i++) {
+				deployable.addNewClasses().setPath(containers[i].getLocation().toOSString());
+			}
+		}
+
+		IModule[] children = j2eeModule.getChildModules();		
+		if (children.length > 0) {
+			Children modChild = deployable.addNewChildren();
+			for (int i = 0; i < children.length; i++) {
+				processModuleConfig(modChild.addNewModule(), children[i]);
+			}
+		}
+
+		IVirtualComponent vc = ComponentCore.createComponent(serverModule.getProject());
+		IVirtualReference[] refs = vc.getReferences();
+		for(int i = 0; i< refs.length; i++) {
+			IVirtualComponent refComp = refs[i].getReferencedComponent();
+			if(refComp.isBinary()) {
+				Children modChild = deployable.getChildren() == null ? deployable.addNewChildren() : deployable.getChildren();
+				Module binaryModule = modChild.addNewModule();
+				VirtualArchiveComponent archiveComp = (VirtualArchiveComponent) refComp;
+				binaryModule.setName(archiveComp.getUnderlyingDiskFile().getName());
+				binaryModule.setPath(archiveComp.getUnderlyingDiskFile().getAbsolutePath());
+			}
+		}
+	}*/
+
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/DeploymentCmdStatus.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/commands/DeploymentCmdStatus.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/DeploymentCmdStatus.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/DeploymentCmdStatus.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v11.core.commands;
+
+import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * @version $Rev: 471551 $ $Date: 2006-11-06 06:47:11 +0800 (Mon, 06 Nov 2006) $
+ */
+public class DeploymentCmdStatus implements IStatus {
+
+	private IStatus status;
+
+	private ProgressObject po;
+
+	public DeploymentCmdStatus(IStatus status, ProgressObject po) {
+		super();
+		this.status = status;
+		this.po = po;
+	}
+
+	public ProgressObject getProgressObject() {
+		return po;
+	}
+
+	public TargetModuleID[] getResultTargetModuleIDs() {
+		if (po != null) {
+			return po.getResultTargetModuleIDs();
+		}
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.core.runtime.IStatus#getChildren()
+	 */
+	public IStatus[] getChildren() {
+		return status.getChildren();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.core.runtime.IStatus#getCode()
+	 */
+	public int getCode() {
+		return status.getCode();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.core.runtime.IStatus#getException()
+	 */
+	public Throwable getException() {
+		return status.getException();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.core.runtime.IStatus#getMessage()
+	 */
+	public String getMessage() {
+		return status.getMessage();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.core.runtime.IStatus#getPlugin()
+	 */
+	public String getPlugin() {
+		return status.getPlugin();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.core.runtime.IStatus#getSeverity()
+	 */
+	public int getSeverity() {
+		return status.getSeverity();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.core.runtime.IStatus#isMultiStatus()
+	 */
+	public boolean isMultiStatus() {
+		return status.isMultiStatus();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.core.runtime.IStatus#isOK()
+	 */
+	public boolean isOK() {
+		return status.isOK();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.core.runtime.IStatus#matches(int)
+	 */
+	public boolean matches(int severityMask) {
+		return status.matches(severityMask);
+	}
+
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/DeploymentCommandFactory.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/commands/DeploymentCommandFactory.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/DeploymentCommandFactory.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/DeploymentCommandFactory.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v11.core.commands;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.Target;
+import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
+
+import org.apache.geronimo.st.v11.core.Activator;
+import org.apache.geronimo.st.v11.core.GeronimoConnectionFactory;
+import org.apache.geronimo.st.v11.core.IGeronimoServerBehavior;
+import org.apache.geronimo.st.core.internal.Messages;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+
+/**
+ * 
+ * This class provides static factory methods that return "synchronized" wrapper
+ * instances of JSR-88 deployment commands.
+ *
+ * @version $Rev: 471551 $ $Date: 2006-11-06 06:47:11 +0800 (Mon, 06 Nov 2006) $
+ */
+public class DeploymentCommandFactory {
+
+	private DeploymentCommandFactory() {
+	}
+
+	/**
+	 * @param module
+	 * @param server
+	 * @return
+	 * @throws CoreException
+	 */
+	public static IDeploymentCommand createDistributeCommand(IModule module, IServer server) throws CoreException {
+		IGeronimoServerBehavior gs = (IGeronimoServerBehavior) server.loadAdapter(IGeronimoServerBehavior.class, null);
+		Target[] targets = gs.getTargets();
+		return new SynchronizedDeploymentOp(new DistributeCommand(server, module, targets));
+	}
+
+	/**
+	 * @param ids
+	 * @param module
+	 * @param server
+	 * @return
+	 * @throws CoreException
+	 */
+	public static IDeploymentCommand createStartCommand(TargetModuleID[] ids, IModule module, IServer server) throws CoreException {
+		return new SynchronizedDeploymentOp(new StartCommand(server, ids, module));
+	}
+
+	/**
+	 * @param module
+	 * @param server
+	 * @return
+	 * @throws CoreException
+	 */
+	public static IDeploymentCommand createStopCommand(IModule module, IServer server) throws CoreException {
+		return new SynchronizedDeploymentOp(new StopCommand(server, module));
+	}
+
+	/**
+	 * @param module
+	 * @param server
+	 * @return
+	 * @throws CoreException
+	 */
+	public static IDeploymentCommand createRedeployCommand(IModule module, IServer server) throws CoreException {
+		return new SynchronizedDeploymentOp(new RedeployCommand(server, module));
+	}
+
+	/**
+	 * @param module
+	 * @param server
+	 * @return
+	 * @throws CoreException
+	 */
+	public static IDeploymentCommand createUndeployCommand(IModule module, IServer server) throws CoreException {
+		return new SynchronizedDeploymentOp(new UndeployCommand(server, module));
+	}
+
+	/**
+	 * @param server
+	 * @return
+	 * @throws CoreException
+	 */
+	public static DeploymentManager getDeploymentManager(IServer server) throws CoreException {
+		try {
+			DeploymentManager dm = GeronimoConnectionFactory.getInstance().getDeploymentManager(server);
+			if (dm == null) {
+				throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, Messages.DM_CONNECTION_FAIL, null));
+			}
+			return dm;
+		} catch (DeploymentManagerCreationException e) {
+			throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, Messages.DM_CONNECTION_FAIL, e));
+		}
+	}
+
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/DistributeCommand.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/commands/DistributeCommand.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/DistributeCommand.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/DistributeCommand.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v11.core.commands;
+
+import java.io.File;
+
+import javax.enterprise.deploy.shared.CommandType;
+import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.Target;
+
+import org.apache.geronimo.st.core.internal.Trace;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+
+/**
+ * @version $Rev: 612208 $ $Date: 2008-01-16 04:34:43 +0800 (Wed, 16 Jan 2008) $
+ */
+class DistributeCommand extends DeployCommand {
+
+	Target[] targets;
+
+	public DistributeCommand(IServer server, IModule module, Target[] targets) {
+		super(server, module);
+		this.targets = targets;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.geronimo.core.commands.IDeploymentCommand#execute(org.eclipse.core.runtime.IProgressMonitor)
+	 */
+	public IStatus execute(IProgressMonitor monitor) throws CoreException {
+
+		DeploymentManager dm = getDeploymentManager();
+
+		if (targets == null)
+			targets = dm.getTargets();
+
+        Trace.trace(Trace.INFO, "Available targets: ");
+        for ( int ii=0; ii<targets.length; ii++ ) {
+            Trace.trace(Trace.INFO, "--> Target[" + ii + "]: " + targets[ii]);
+        }
+
+        //
+        // Geronimo 2.1 now supports clustering which will likely result in multiple targets getting 
+        // returned from the deployment manager. In our case though we have to ensure that only the 
+        // first target is used, which is the default configuration store and which is explicitly 
+        // configured by users. Thus, we will distribute the project to the defaultTarget only.
+        //
+        Target[] defaultTarget = new Target[1];
+        defaultTarget[0] = targets[0];
+
+        Trace.trace(Trace.INFO, "Using default target:");
+        Trace.trace(Trace.INFO, "--> " + defaultTarget[0]);
+
+		File file = getTargetFile();
+		return new DeploymentCmdStatus(Status.OK_STATUS, dm.distribute( defaultTarget, file, null));
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.geronimo.core.commands.IDeploymentCommand#getCommandType()
+	 */
+	public CommandType getCommandType() {
+		return CommandType.DISTRIBUTE;
+	}
+
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/IDeploymentCommand.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/commands/IDeploymentCommand.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/IDeploymentCommand.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/IDeploymentCommand.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.st.v11.core.commands;
+
+import javax.enterprise.deploy.shared.CommandType;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.wst.server.core.IModule;
+
+/**
+ * @version $Rev: 568527 $ $Date: 2007-08-22 17:21:59 +0800 (Wed, 22 Aug 2007) $
+ */
+public interface IDeploymentCommand {
+
+	public IStatus execute(IProgressMonitor monitor) throws Exception;
+
+	public CommandType getCommandType();
+
+	public IModule getModule();
+	
+	public long getTimeout();
+
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/RedeployCommand.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/commands/RedeployCommand.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/RedeployCommand.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/RedeployCommand.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v11.core.commands;
+
+import javax.enterprise.deploy.shared.CommandType;
+import javax.enterprise.deploy.spi.TargetModuleID;
+
+import org.apache.geronimo.st.v11.core.Activator;
+import org.apache.geronimo.st.v11.core.DeploymentUtils;
+import org.apache.geronimo.st.v11.core.GeronimoUtils;
+import org.apache.geronimo.st.v11.core.IGeronimoServer;
+import org.apache.geronimo.st.core.ModuleArtifactMapper;
+import org.apache.geronimo.st.core.commands.TargetModuleIdNotFoundException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+
+/**
+ * @version $Rev: 817996 $ $Date: 2009-09-23 16:04:12 +0800 (Wed, 23 Sep 2009) $
+ */
+class RedeployCommand extends DeployCommand {
+
+	public RedeployCommand(IServer server, IModule module) {
+		super(server, module);
+	}
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.geronimo.core.commands.IDeploymentCommand#execute(org.eclipse.core.runtime.IProgressMonitor)
+     */
+    public IStatus execute(IProgressMonitor monitor) throws TargetModuleIdNotFoundException, CoreException {
+        String configId = ModuleArtifactMapper.getInstance().resolve(getServer(), getModule());
+        
+        if(configId == null) {
+            IGeronimoServer gs = (IGeronimoServer) getServer().getAdapter(IGeronimoServer.class);
+            try {
+				configId = gs.getVersionHandler().getConfigID(getModule());
+			} catch (Exception e) {
+				throw new CoreException(new Status(IStatus.ERROR,Activator.PLUGIN_ID,"Module config Id not found for redeployment",e));
+			}
+        }
+        
+        TargetModuleID[] ids = null;
+        if(configId != null) {
+            TargetModuleID id = DeploymentUtils.getTargetModuleID(getDeploymentManager(), configId);
+            ids = new TargetModuleID[] {id};
+        }
+        else {
+            throw new CoreException(new Status(IStatus.ERROR,Activator.PLUGIN_ID,"Module config Id not found for redeployment"));
+        }
+        
+        return new DeploymentCmdStatus(Status.OK_STATUS, getDeploymentManager().redeploy(ids, getTargetFile(), GeronimoUtils.getDeploymentPlanFile(getModule()).getLocation().toFile()));
+    }
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.geronimo.core.commands.IDeploymentCommand#getCommandType()
+	 */
+	public CommandType getCommandType() {
+		return CommandType.REDEPLOY;
+	}
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/StartCommand.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/commands/StartCommand.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/StartCommand.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/StartCommand.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.st.v11.core.commands;
+
+import javax.enterprise.deploy.shared.CommandType;
+import javax.enterprise.deploy.spi.TargetModuleID;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+
+/**
+ * @version $Rev: 568527 $ $Date: 2007-08-22 17:21:59 +0800 (Wed, 22 Aug 2007) $
+ */
+class StartCommand extends AbstractDeploymentCommand {
+
+	TargetModuleID[] ids;
+
+	public StartCommand(IServer server, TargetModuleID[] ids, IModule module) {
+		super(server, module);
+		this.ids = ids;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.geronimo.core.commands.IDeploymentCommand#execute(org.eclipse.core.runtime.IProgressMonitor)
+	 */
+	public IStatus execute(IProgressMonitor monitor) throws CoreException {
+		return new DeploymentCmdStatus(Status.OK_STATUS, getDeploymentManager().start(ids));
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.geronimo.core.commands.IDeploymentCommand#getCommandType()
+	 */
+	public CommandType getCommandType() {
+		return CommandType.START;
+	}
+
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/StopCommand.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/commands/StopCommand.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/StopCommand.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/StopCommand.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v11.core.commands;
+
+import javax.enterprise.deploy.shared.CommandType;
+import javax.enterprise.deploy.spi.TargetModuleID;
+
+import org.apache.geronimo.st.core.commands.TargetModuleIdNotFoundException;
+import org.apache.geronimo.st.v11.core.DeploymentUtils;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+
+/**
+ * @version $Rev: 471551 $ $Date: 2006-11-06 06:47:11 +0800 (Mon, 06 Nov 2006) $
+ */
+class StopCommand extends AbstractDeploymentCommand {
+
+	public StopCommand(IServer server, IModule module) {
+		super(server, module);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.geronimo.core.commands.IDeploymentCommand#execute(org.eclipse.core.runtime.IProgressMonitor)
+	 */
+	public IStatus execute(IProgressMonitor monitor) throws TargetModuleIdNotFoundException, CoreException {
+		TargetModuleID id = DeploymentUtils.getTargetModuleID(getServer(), getModule());
+		return new DeploymentCmdStatus(Status.OK_STATUS, getDeploymentManager().stop(new TargetModuleID[] { id }));
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.geronimo.core.commands.IDeploymentCommand#getCommandType()
+	 */
+	public CommandType getCommandType() {
+		return CommandType.STOP;
+	}
+
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/SynchronizedDeploymentOp.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/commands/SynchronizedDeploymentOp.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/SynchronizedDeploymentOp.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/SynchronizedDeploymentOp.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.st.v11.core.commands;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+
+import javax.enterprise.deploy.shared.CommandType;
+import javax.enterprise.deploy.spi.status.DeploymentStatus;
+import javax.enterprise.deploy.spi.status.ProgressEvent;
+import javax.enterprise.deploy.spi.status.ProgressListener;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+
+import org.apache.geronimo.st.v11.core.Activator;
+import org.apache.geronimo.st.v11.core.DeploymentStatusMessage;
+import org.apache.geronimo.st.core.internal.Trace;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IModule;
+
+/**
+ * This class is a wrapper IDeploymentCommand that when executed blocks the
+ * callee's thread until completed, either when the waiting thread times out, or
+ * a failed or completed notification is recieved from the DeploymentManager.
+ *
+ * @version $Rev: 568527 $ $Date: 2007-08-22 17:21:59 +0800 (Wed, 22 Aug 2007) $
+ */
+public class SynchronizedDeploymentOp implements ProgressListener,
+		IDeploymentCommand {
+
+	private IDeploymentCommand command;
+
+	private MultiStatus status = null;
+
+	private IProgressMonitor _monitor = null;
+
+	private boolean timedOut = true;
+
+	public SynchronizedDeploymentOp(IDeploymentCommand command) {
+		super();
+		this.command = command;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.geronimo.core.commands.IDeploymentCommand#execute(org.eclipse.core.runtime.IProgressMonitor)
+	 */
+	public IStatus execute(IProgressMonitor monitor) throws Exception {
+
+		_monitor = monitor;
+
+		if (_monitor == null) {
+			_monitor = new NullProgressMonitor();
+		}
+
+		ProgressObject po = run();
+
+		return new DeploymentCmdStatus(status, po);
+	}
+
+	private synchronized ProgressObject run() throws Exception {
+		Trace.trace(Trace.INFO, "--> run()");
+		
+		IStatus ds = command.execute(_monitor);
+
+		ProgressObject po = null;
+
+		if (ds instanceof DeploymentCmdStatus) {
+			po = ((DeploymentCmdStatus) ds).getProgressObject();
+			po.addProgressListener(this);
+
+			try {
+				wait(getTimeout());
+			} catch (InterruptedException e) {
+			}
+
+			po.removeProgressListener(this);
+			if (timedOut) {
+				Trace.trace(Trace.SEVERE, "Command Timed Out!");
+				status = new MultiStatus(Activator.PLUGIN_ID, 0, "", null);
+				status.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, command.getCommandType() + " timed out.", null));
+			}
+		}
+
+		Trace.trace(Trace.INFO, "<-- run()");
+		return po;
+	}
+
+	private synchronized void sendNotification() {
+		timedOut = false;
+		Trace.trace(Trace.INFO, "notifyAll()");
+		notifyAll();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see javax.enterprise.deploy.spi.status.ProgressListener#handleProgressEvent(javax.enterprise.deploy.spi.status.ProgressEvent)
+	 */
+	public void handleProgressEvent(ProgressEvent event) {
+		DeploymentStatus deploymentStatus = event.getDeploymentStatus();
+		if (deploymentStatus != null) {
+			DeploymentStatusMessage dsm = new DeploymentStatusMessage(deploymentStatus);
+			Trace.trace(Trace.INFO, dsm.toString());
+			_monitor.subTask(dsm.toString());
+			if (command.getCommandType() == deploymentStatus.getCommand()) {
+				if (deploymentStatus.isCompleted()) {
+					messageToStatus(IStatus.OK, dsm.getMessage(), false);
+					sendNotification();
+				} else if (deploymentStatus.isFailed()) {
+					messageToStatus(IStatus.ERROR, dsm.getMessage(), true);
+					sendNotification();
+				}
+			}
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.geronimo.core.commands.IDeploymentCommand#getCommandType()
+	 */
+	public CommandType getCommandType() {
+		return command.getCommandType();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.geronimo.core.commands.IDeploymentCommand#getModule()
+	 */
+	public IModule getModule() {
+		return command.getModule();
+	}
+	
+	public long getTimeout() {
+		return command.getTimeout();
+	}
+	
+    public void messageToStatus(int severity, String source, boolean error) {
+    	status = new MultiStatus(Activator.PLUGIN_ID, 0, "", null);
+		try {
+			BufferedReader in = new BufferedReader(new StringReader(source));
+			String line;
+			while ((line = in.readLine()) != null) {
+				status.add(new Status(severity, Activator.PLUGIN_ID, 0,line, null));
+			}
+		} catch (IOException e) {
+
+		}
+    }
+}

Added: geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/UndeployCommand.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/commands/UndeployCommand.java?rev=952535&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/UndeployCommand.java (added)
+++ geronimo/devtools/eclipse-plugin/branches/2.2.1/plugins/org.apache.geronimo.st.v11.core/src/main/java/org/apache/geronimo/st/v11/core/commands/UndeployCommand.java Tue Jun  8 04:40:16 2010
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.st.v11.core.commands;
+
+import javax.enterprise.deploy.shared.CommandType;
+import javax.enterprise.deploy.spi.TargetModuleID;
+
+import org.apache.geronimo.st.v11.core.Activator;
+import org.apache.geronimo.st.v11.core.DeploymentUtils;
+import org.apache.geronimo.st.v11.core.IGeronimoServer;
+import org.apache.geronimo.st.core.ModuleArtifactMapper;
+import org.apache.geronimo.st.core.commands.TargetModuleIdNotFoundException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+
+/**
+ * @version $Rev: 817996 $ $Date: 2009-09-23 16:04:12 +0800 (Wed, 23 Sep 2009) $
+ */
+class UndeployCommand extends AbstractDeploymentCommand {
+
+	public UndeployCommand(IServer server, IModule module) {
+		super(server, module);
+	}
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.geronimo.core.commands.IDeploymentCommand#execute(org.eclipse.core.runtime.IProgressMonitor)
+     */
+    public IStatus execute(IProgressMonitor monitor) throws TargetModuleIdNotFoundException, CoreException {
+        String configId = ModuleArtifactMapper.getInstance().resolve(getServer(), getModule());
+
+        if(configId == null) {
+            IGeronimoServer gs = (IGeronimoServer) getServer().getAdapter(IGeronimoServer.class);
+            try {
+				configId = gs.getVersionHandler().getConfigID(getModule());
+			} catch (Exception e) {
+				throw new CoreException(new Status(IStatus.ERROR,Activator.PLUGIN_ID,"Module config Id not found for undeployment",e));
+			}
+        }
+       
+        if(configId == null) {
+            throw new CoreException(new Status(IStatus.ERROR,Activator.PLUGIN_ID,"Module config Id not found for undeployment"));
+        }
+        
+        TargetModuleID id = DeploymentUtils.getTargetModuleID(getDeploymentManager(), configId);
+        return new DeploymentCmdStatus(Status.OK_STATUS, getDeploymentManager().undeploy(new TargetModuleID[] { id }));
+    }
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.apache.geronimo.core.commands.IDeploymentCommand#getCommandType()
+	 */
+	public CommandType getCommandType() {
+		return CommandType.UNDEPLOY;
+	}
+
+}