You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by mc...@apache.org on 2010/04/29 02:45:15 UTC
svn commit: r939145 [4/7] - in
/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core:
./ META-INF/ src/main/java/org/apache/geronimo/st/v30/core/
src/main/java/org/apache/geronimo/st/v30/core/commands/
src/main/java/org/apache...
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoUtils.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/GeronimoUtils.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoUtils.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoUtils.java Thu Apr 29 00:45:13 2010
@@ -0,0 +1,354 @@
+/*
+ * 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.v30.core;
+
+import javax.enterprise.deploy.shared.ModuleType;
+import javax.xml.bind.JAXBElement;
+
+import org.apache.geronimo.jee.application.Application;
+import org.apache.geronimo.jee.connector.Connector;
+import org.apache.geronimo.jee.deployment.Artifact;
+import org.apache.geronimo.jee.deployment.Environment;
+import org.apache.geronimo.jee.openejb.OpenejbJar;
+import org.apache.geronimo.jee.web.WebApp;
+import org.apache.geronimo.st.v30.core.internal.Trace;
+import org.apache.geronimo.st.v30.core.jaxb.JAXBUtils;
+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$ $Date$
+ */
+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 JAXBElement getDeploymentPlan(IFile file) throws Exception {
+ Trace.tracePoint("ENTRY", "GeronimoUtils.getDeploymentPlan", file);
+
+ if (!file.exists()) {
+ return null;
+ }
+
+ if (file.getName().equals(GeronimoUtils.APP_PLAN_NAME))
+ return getApplicationDeploymentPlan(file);
+ else if (file.getName().equals(GeronimoUtils.OPENEJB_PLAN_NAME))
+ return getOpenEjbDeploymentPlan(file);
+ else if (file.getName().equals(GeronimoUtils.WEB_PLAN_NAME))
+ return getWebDeploymentPlan(file);
+ else if (file.getName().equals(GeronimoUtils.CONNECTOR_PLAN_NAME))
+ return getConnectorDeploymentPlan(file);
+ else if (file.getName().equals(GeronimoUtils.APP_CLIENT_PLAN_NAME))
+ return getApplicationClientDeploymentPlan(file);
+
+ Trace.tracePoint("EXIT", "GeronimoUtils.getDeploymentPlan", 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 getConfigId(IModule module) throws Exception {
+ Trace.tracePoint("ENTRY", "GeronimoUtils.getConfigId", module);
+
+ Environment environment = null;
+ if (isWebModule(module)) {
+ if (getWebDeploymentPlan(module)!=null) {
+ WebApp plan = getWebDeploymentPlan(module).getValue();
+ if (plan != null)
+ environment = plan.getEnvironment();
+ }
+ }
+ else if (isEjbJarModule(module)) {
+ if (getOpenEjbDeploymentPlan(module)!=null) {
+ OpenejbJar plan = getOpenEjbDeploymentPlan(module).getValue();
+ if (plan != null)
+ environment = plan.getEnvironment();
+ }
+ }
+ else if (isEarModule(module)) {
+ if (getApplicationDeploymentPlan(module)!=null) {
+ Application plan = getApplicationDeploymentPlan(module).getValue();
+ if (plan != null)
+ environment = plan.getEnvironment();
+ }
+ }
+ else if (isRARModule(module)) {
+ if (getConnectorDeploymentPlan(module)!=null) {
+ Connector plan = getConnectorDeploymentPlan(module).getValue();
+ if (plan != null)
+ environment = plan.getEnvironment();
+ }
+ }
+
+ if (environment != null
+ && environment.getModuleId() != null) {
+ Trace.tracePoint("EXIT", "GeronimoUtils.getConfigId", getQualifiedConfigID(environment.getModuleId()));
+ return getQualifiedConfigID(environment.getModuleId());
+ }
+
+ Trace.tracePoint("EXIT", "GeronimoUtils.getConfigId", getId(module));
+ return getId(module);
+ }
+
+ 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 JAXBElement getApplicationClientDeploymentPlan(IFile file) throws Exception {
+ Trace.tracePoint("ENTRY", "GeronimoUtils.getApplicationClientDeploymentPlan", file);
+
+ if (file.getName().equals(APP_CLIENT_PLAN_NAME) && file.exists()) {
+ return JAXBUtils.unmarshalFilterDeploymentPlan(file);
+ }
+
+ Trace.tracePoint("EXIT", "GeronimoUtils.getApplicationClientDeploymentPlan", null);
+ return null;
+ }
+ 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);
+ }
+ public static JAXBElement<WebApp> getWebDeploymentPlan(IModule module) throws Exception {
+ return getWebDeploymentPlan(getVirtualComponent(module));
+ }
+ public static JAXBElement getWebDeploymentPlan(IVirtualComponent comp) throws Exception {
+ return getWebDeploymentPlan(getWebDeploymentPlanFile(comp));
+ }
+ public static JAXBElement getWebDeploymentPlan(IFile file) throws Exception {
+ Trace.tracePoint("ENTRY", "GeronimoUtils.getWebDeploymentPlan", file);
+
+ if (file.getName().equals(WEB_PLAN_NAME) && file.exists()) {
+ return JAXBUtils.unmarshalFilterDeploymentPlan(file);
+ }
+
+ Trace.tracePoint("EXIT", "GeronimoUtils.getWebDeploymentPlan", null);
+ return null;
+ }
+
+
+ public static JAXBElement<OpenejbJar> getOpenEjbDeploymentPlan(IModule module) throws Exception {
+ return getOpenEjbDeploymentPlan(getVirtualComponent(module));
+ }
+ public static JAXBElement getOpenEjbDeploymentPlan(IVirtualComponent comp) throws Exception {
+ return getOpenEjbDeploymentPlan(getOpenEjbDeploymentPlanFile(comp));
+ }
+ public static JAXBElement getOpenEjbDeploymentPlan(IFile file) throws Exception {
+ Trace.tracePoint("ENTRY", "GeronimoUtils.getOpenEjbDeploymentPlan", file);
+
+ if (file.getName().equals(OPENEJB_PLAN_NAME) && file.exists()) {
+ return JAXBUtils.unmarshalFilterDeploymentPlan(file);
+ }
+
+ Trace.tracePoint("EXIT", "GeronimoUtils.getOpenEjbDeploymentPlan", null);
+ return null;
+ }
+
+
+
+ public static JAXBElement<Application> getApplicationDeploymentPlan(IModule module) throws Exception {
+ return getApplicationDeploymentPlan(getVirtualComponent(module));
+ }
+ public static JAXBElement getApplicationDeploymentPlan(IVirtualComponent comp) throws Exception {
+ return getApplicationDeploymentPlan(getApplicationDeploymentPlanFile(comp));
+ }
+ public static JAXBElement getApplicationDeploymentPlan(IFile file) throws Exception {
+ Trace.tracePoint("ENTRY", "GeronimoUtils.getApplicationDeploymentPlan", file);
+
+ if (file.getName().equals(APP_PLAN_NAME) && file.exists()) {
+ return JAXBUtils.unmarshalFilterDeploymentPlan(file);
+ }
+
+ Trace.tracePoint("EXIT", "GeronimoUtils.getApplicationDeploymentPlan", null);
+ return null;
+ }
+
+
+
+ public static JAXBElement<Connector> getConnectorDeploymentPlan(IModule module) throws Exception {
+ return getConnectorDeploymentPlan(getVirtualComponent(module));
+ }
+ public static String getQualifiedConfigID(Artifact artifact) {
+ return getQualifiedConfigID(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType());
+ }
+ public static JAXBElement getConnectorDeploymentPlan(IVirtualComponent comp) throws Exception {
+ return getConnectorDeploymentPlan(getConnectorDeploymentPlanFile(comp));
+ }
+ public static JAXBElement getConnectorDeploymentPlan(IFile file) throws Exception {
+ Trace.tracePoint("ENTRY", "GeronimoUtils.getConnectorDeploymentPlan", file);
+
+ if (file.getName().equals(CONNECTOR_PLAN_NAME) && file.exists()) {
+ return JAXBUtils.unmarshalFilterDeploymentPlan(file);
+ }
+
+ Trace.tracePoint("EXIT", "GeronimoUtils.getConnectorDeploymentPlan", null);
+ return null;
+ }
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoUtils.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoUtils.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoVersionHandler.java (from r938779, geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoV30VersionHandler.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/GeronimoVersionHandler.java?p2=geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoVersionHandler.java&p1=geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoV30VersionHandler.java&r1=938779&r2=939145&rev=939145&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoV30VersionHandler.java (original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoVersionHandler.java Thu Apr 29 00:45:13 2010
@@ -19,13 +19,13 @@ package org.apache.geronimo.st.v30.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.v30.core.IGeronimoVersionHandler;
import org.eclipse.wst.server.core.IModule;
/**
* @version $Rev$ $Date$
*/
-public class GeronimoV30VersionHandler implements IGeronimoVersionHandler {
+public class GeronimoVersionHandler implements IGeronimoVersionHandler {
/*
* (non-Javadoc)
@@ -33,7 +33,7 @@ public class GeronimoV30VersionHandler i
* @see org.apache.geronimo.st.core.IGeronimoVersionHandler#getConfigID(org.eclipse.wst.server.core.IModule)
*/
public String getConfigID(IModule module) throws Exception {
- return GeronimoV30Utils.getConfigId(module);
+ return GeronimoUtils.getConfigId(module);
}
/* (non-Javadoc)
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/IGeronimoRuntime.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/IGeronimoRuntime.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/IGeronimoRuntime.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/IGeronimoRuntime.java Thu Apr 29 00:45:13 2010
@@ -0,0 +1,29 @@
+/*
+ * 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.v30.core;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jst.server.core.IJavaRuntime;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface IGeronimoRuntime extends IJavaRuntime {
+
+ public IPath getRuntimeSourceLocation();
+
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/IGeronimoRuntime.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/IGeronimoRuntime.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/IGeronimoRuntime.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/IGeronimoServer.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/IGeronimoServer.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/IGeronimoServer.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/IGeronimoServer.java Thu Apr 29 00:45:13 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.v30.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$ $Date$
+ */
+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();
+
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/IGeronimoServer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/IGeronimoServer.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/IGeronimoServer.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/IGeronimoServerBehavior.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/IGeronimoServerBehavior.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/IGeronimoServerBehavior.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/IGeronimoServerBehavior.java Thu Apr 29 00:45:13 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.v30.core;
+
+import javax.enterprise.deploy.spi.Target;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface IGeronimoServerBehavior {
+
+ public boolean isFullyStarted();
+
+ public boolean isKernelAlive();
+
+ public void setServerStarted();
+
+ public void setServerStopped();
+
+ public Target[] getTargets();
+
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/IGeronimoServerBehavior.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/IGeronimoServerBehavior.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/IGeronimoServerBehavior.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/IGeronimoVersionHandler.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/IGeronimoVersionHandler.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/IGeronimoVersionHandler.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/IGeronimoVersionHandler.java Thu Apr 29 00:45:13 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.v30.core;
+
+import javax.enterprise.deploy.spi.TargetModuleID;
+
+import org.eclipse.wst.server.core.IModule;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface IGeronimoVersionHandler {
+
+ public String getConfigID(IModule module) throws Exception;
+
+ public TargetModuleID createTargetModuleId(String configId);
+
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/IGeronimoVersionHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/IGeronimoVersionHandler.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/IGeronimoVersionHandler.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/ModuleArtifactMapper.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/ModuleArtifactMapper.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/ModuleArtifactMapper.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/ModuleArtifactMapper.java Thu Apr 29 00:45:13 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.v30.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$ $Date$
+ */
+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.v30.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;
+ }
+ }
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/ModuleArtifactMapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/ModuleArtifactMapper.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/ModuleArtifactMapper.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/PingThread.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/PingThread.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/PingThread.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/PingThread.java Thu Apr 29 00:45:13 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.v30.core;
+
+import org.apache.geronimo.st.v30.core.internal.Trace;
+import org.eclipse.wst.server.core.IServer;
+import org.eclipse.wst.server.core.util.SocketUtil;
+
+/**
+ * @version $Rev$ $Date$
+ */
+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;
+ }
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/PingThread.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/PingThread.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/PingThread.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/UpdateServerStateTask.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/UpdateServerStateTask.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/UpdateServerStateTask.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/UpdateServerStateTask.java Thu Apr 29 00:45:13 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.v30.core;
+
+import java.util.TimerTask;
+
+import org.apache.geronimo.st.v30.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$ $Date$
+ */
+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);
+ }
+ }
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/UpdateServerStateTask.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/UpdateServerStateTask.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/UpdateServerStateTask.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/AbstractDeploymentCommand.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/commands/AbstractDeploymentCommand.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/AbstractDeploymentCommand.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/AbstractDeploymentCommand.java Thu Apr 29 00:45:13 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.v30.core.commands;
+
+import javax.enterprise.deploy.spi.DeploymentManager;
+
+import org.apache.geronimo.st.v30.core.IGeronimoServer;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IServer;
+
+/**
+ * @version $Rev$ $Date$
+ */
+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.v30.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.v30.core.commands.IDeploymentCommand#getTimeout()
+ */
+ public long getTimeout() {
+ return timeout;
+ }
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/AbstractDeploymentCommand.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/AbstractDeploymentCommand.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/AbstractDeploymentCommand.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DeployCommand.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/commands/DeployCommand.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DeployCommand.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DeployCommand.java Thu Apr 29 00:45:13 2010
@@ -0,0 +1,57 @@
+/*
+ * 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.v30.core.commands;
+
+import java.io.File;
+
+import org.apache.geronimo.st.v30.core.DeploymentUtils;
+import org.apache.geronimo.st.v30.core.IGeronimoServer;
+import org.apache.geronimo.st.v30.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$ $Date$
+ */
+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;
+ }
+
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DeployCommand.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DeployCommand.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DeployCommand.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DeploymentCmdStatus.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/commands/DeploymentCmdStatus.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DeploymentCmdStatus.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DeploymentCmdStatus.java Thu Apr 29 00:45:13 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.v30.core.commands;
+
+import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.enterprise.deploy.spi.status.ProgressObject;
+
+import org.eclipse.core.runtime.IStatus;
+
+/**
+ * @version $Rev$ $Date$
+ */
+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);
+ }
+
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DeploymentCmdStatus.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DeploymentCmdStatus.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DeploymentCmdStatus.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DeploymentCommandFactory.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/commands/DeploymentCommandFactory.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DeploymentCommandFactory.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DeploymentCommandFactory.java Thu Apr 29 00:45:13 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.v30.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.v30.core.Activator;
+import org.apache.geronimo.st.v30.core.GeronimoConnectionFactory;
+import org.apache.geronimo.st.v30.core.IGeronimoServerBehavior;
+import org.apache.geronimo.st.v30.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$ $Date$
+ */
+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));
+ }
+ }
+
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DeploymentCommandFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DeploymentCommandFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DeploymentCommandFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DistributeCommand.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/commands/DistributeCommand.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DistributeCommand.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DistributeCommand.java Thu Apr 29 00:45:13 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.v30.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.v30.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$ $Date$
+ */
+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;
+ }
+
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DistributeCommand.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DistributeCommand.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DistributeCommand.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/IDeploymentCommand.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/commands/IDeploymentCommand.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/IDeploymentCommand.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/IDeploymentCommand.java Thu Apr 29 00:45:13 2010
@@ -0,0 +1,38 @@
+/*
+ * 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.v30.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$ $Date$
+ */
+public interface IDeploymentCommand {
+
+ public IStatus execute(IProgressMonitor monitor) throws Exception;
+
+ public CommandType getCommandType();
+
+ public IModule getModule();
+
+ public long getTimeout();
+
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/IDeploymentCommand.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/IDeploymentCommand.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/IDeploymentCommand.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/RedeployCommand.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/commands/RedeployCommand.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/RedeployCommand.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/RedeployCommand.java Thu Apr 29 00:45:13 2010
@@ -0,0 +1,80 @@
+/*
+ * 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.v30.core.commands;
+
+import javax.enterprise.deploy.shared.CommandType;
+import javax.enterprise.deploy.spi.TargetModuleID;
+
+import org.apache.geronimo.st.v30.core.Activator;
+import org.apache.geronimo.st.v30.core.DeploymentUtils;
+import org.apache.geronimo.st.v30.core.GeronimoUtils;
+import org.apache.geronimo.st.v30.core.IGeronimoServer;
+import org.apache.geronimo.st.v30.core.ModuleArtifactMapper;
+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$ $Date$
+ */
+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;
+ }
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/RedeployCommand.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/RedeployCommand.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/RedeployCommand.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/StartCommand.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/commands/StartCommand.java?rev=939145&view=auto
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/StartCommand.java (added)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/StartCommand.java Thu Apr 29 00:45:13 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.v30.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$ $Date$
+ */
+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;
+ }
+
+}
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/StartCommand.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/StartCommand.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/StartCommand.java
------------------------------------------------------------------------------
svn:mime-type = text/plain