geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hanhongf...@apache.org
Subject svn commit: r1081666 - in /geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core: GeronimoUtils.java commands/RedeployCommand.java
Date Tue, 15 Mar 2011 04:51:52 GMT
Author: hanhongfang
Date: Tue Mar 15 04:51:52 2011
New Revision: 1081666

URL: http://svn.apache.org/viewvc?rev=1081666&view=rev
Log:
GERONIMODEVTOOLS-725 EBA is always undeployed and then deployed due to can not correctly get
the configruration id

Modified:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoUtils.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/RedeployCommand.java

Modified: 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=1081666&r1=1081665&r2=1081666&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoUtils.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoUtils.java
Tue Mar 15 04:51:52 2011
@@ -18,6 +18,7 @@ package org.apache.geronimo.st.v30.core;
 
 import java.io.FileInputStream;
 import java.io.InputStream;
+import java.lang.reflect.Method;
 import java.util.jar.Manifest;
 
 import javax.enterprise.deploy.shared.ModuleType;
@@ -31,6 +32,7 @@ import org.apache.geronimo.jee.openejb.O
 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.apache.geronimo.st.v30.core.osgi.AriesHelper;
 import org.apache.geronimo.st.v30.core.osgi.OsgiConstants;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
@@ -44,6 +46,7 @@ import org.eclipse.wst.common.componentc
 import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants;
 import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
 import org.eclipse.wst.server.core.IModule;
+import org.osgi.framework.Version;
 
 /**
  * @version $Rev$ $Date$
@@ -61,6 +64,14 @@ public class GeronimoUtils {
     public static final String CONNECTOR_PLAN_NAME = "geronimo-ra.xml";
     
     public static final String SERVICE_PLAN_NAME = "geronimo-service.xml";
+    
+    public static final String ARIES_APPLICATION_MODULE = "osgi.app";
+    
+    public static final String ARIES_BUNDLE_MODULE = "osgi.bundle";
+    
+    public static final String ARIES_ARTIFACT_GROUP = "application";
+    
+    public static final String ARIES_ARTIFACT_TYPE = "eba";
 
     public static boolean isWebModule(IModule module) {
         return IModuleConstants.JST_WEB_MODULE.equals(module.getModuleType().getId());
@@ -187,10 +198,52 @@ public class GeronimoUtils {
             Trace.tracePoint("EXIT", "GeronimoUtils.getConfigId", getQualifiedConfigID(environment.getModuleId()));
             return getQualifiedConfigID(environment.getModuleId());
         }
+        
+        if (AriesHelper.isAriesInstalled()) {
+            try {
+                if (isAriesOSGiApplicationModule(module)) {
+                    Class ariesUtilsClass = Class.forName("com.ibm.etools.aries.internal.core.utils.AriesUtils");
+                    Method method = ariesUtilsClass.getMethod("getApplicationManifest", IProject.class);
+                    Object object = method.invoke(null, module.getProject());
+                    
+                    Class appManifestClass = Class.forName("com.ibm.etools.aries.core.models.ApplicationManifest");
+                    method = appManifestClass.getMethod("getApplicationSymbolicName");
+                    String artifactID = (String) method.invoke(object); 
+                    
+                    method = appManifestClass.getMethod("getApplicationVersion"); 
+                    String versionStr = (String) method.invoke(object);
+                    Version version = Version.parseVersion(versionStr);
+                    String newVersionStr = getVersion(version);                    
+                    
+                    if (artifactID != null && version != null) {
+                        return getQualifiedConfigID(ARIES_ARTIFACT_GROUP, artifactID, newVersionStr,
ARIES_ARTIFACT_TYPE);
+                    }                 
+                }
+            } catch (Exception e) {
+            } 
+        }
 
         Trace.tracePoint("EXIT", "GeronimoUtils.getConfigId", getId(module));
         return getId(module);
     }
+    
+    // copied from org.apache.geronimo.aries.builder.ApplicationInstaller.getVersion(Version)
+    private static String getVersion(Version version) {
+        String str = version.getMajor() + "." + version.getMinor() + "." + version.getMicro();
+        String qualifier = version.getQualifier();
+        if (qualifier != null && qualifier.trim().length() > 0) {
+            str += "-" + version.getQualifier().trim();
+        }
+        return str;
+    }
+    
+    public static boolean isAriesOSGiApplicationModule(IModule module) {
+        return ARIES_APPLICATION_MODULE.equals(module.getModuleType().getId());
+    }
+    
+    public static boolean isAiresOSGiBundleModule(IModule module) {
+        return ARIES_BUNDLE_MODULE.equals(module.getModuleType().getId());
+    }
 
     public static String getQualifiedConfigID(String groupId, String artifactId, String version,
String type) {
         return groupId + "/" + artifactId + "/" + version + "/" + type;

Modified: 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=1081666&r1=1081665&r2=1081666&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/RedeployCommand.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/RedeployCommand.java
Tue Mar 15 04:51:52 2011
@@ -16,6 +16,8 @@
  */
 package org.apache.geronimo.st.v30.core.commands;
 
+import java.io.File;
+
 import javax.enterprise.deploy.shared.CommandType;
 import javax.enterprise.deploy.spi.TargetModuleID;
 
@@ -24,6 +26,7 @@ import org.apache.geronimo.st.v30.core.D
 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.resources.IFile;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
@@ -66,7 +69,12 @@ class RedeployCommand extends DeployComm
             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()));
+        IFile dp = GeronimoUtils.getDeploymentPlanFile(getModule());
+        File deploymentPlanFile = null;
+        if (dp != null) {
+            deploymentPlanFile = dp.getLocation().toFile();
+        }
+        return new DeploymentCmdStatus(Status.OK_STATUS, getDeploymentManager().redeploy(ids,
getTargetFile(), deploymentPlanFile));
     }
 
     /*



Mime
View raw message