geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1089967 - in /geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core: ./ src/main/java/org/apache/geronimo/st/v30/core/ src/main/java/org/apache/geronimo/st/v30/core/commands/ src/main/java/org/apache/geronimo/st/v3...
Date Thu, 07 Apr 2011 20:02:14 GMT
Author: gawor
Date: Thu Apr  7 20:01:45 2011
New Revision: 1089967

URL: http://svn.apache.org/viewvc?rev=1089967&view=rev
Log:
GERONIMODEVTOOLS-733, GERONIMODEVTOOLS-734: Better error handling when module fails to export
and support for OSGi fragment bundles

Modified:
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/plugin.xml
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/DeploymentUtils.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoUtils.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DeployCommand.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Messages.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Messages.properties
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/AriesHelper.java
    geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/OsgiConstants.java

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/plugin.xml
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/plugin.xml?rev=1089967&r1=1089966&r2=1089967&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/plugin.xml
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/plugin.xml
Thu Apr  7 20:01:45 2011
@@ -43,6 +43,7 @@
             <moduleType types="jst.appclient" versions="1.2, 1.3, 1.4, 5.0, 6.0"/>
             <moduleType types="osgi.app"      versions="1.0"/>
             <moduleType types="osgi.bundle"   versions="1.0"/>
+            <moduleType types="osgi.fragment" versions="1.0"/>
             <moduleType types="osgi.comp"     versions="1.0"/>
         </runtimeType>
     </extension>
@@ -146,6 +147,7 @@
             <runtime-component id="org.apache.geronimo.runtime.osgi" version="3.0"/>
   
             <facet id="osgi.app"        version="1.0"/>
             <facet id="osgi.bundle"     version="1.0"/>
+            <facet id="osgi.fragment"   version="1.0"/>
             <facet id="osgi.comp"       version="1.0"/>
         </supported>    
     </extension>
@@ -450,6 +452,8 @@
             class="com.ibm.etools.aries.internal.core.datatransfer.exportmodel.ApplicationExportDataModelProvider"/>
         <DataModelProvider id="osgi.bundle.datamodelprovider"
             class="com.ibm.etools.aries.internal.core.datatransfer.exportmodel.BundleExportDataModelProvider"/>
+        <DataModelProvider id="osgi.fragment.datamodelprovider"
+            class="com.ibm.etools.aries.internal.core.datatransfer.exportmodel.BundleExportDataModelProvider"/>
      </extension>
     
 </plugin>

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/DeploymentUtils.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/DeploymentUtils.java?rev=1089967&r1=1089966&r2=1089967&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/DeploymentUtils.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/DeploymentUtils.java
Thu Apr  7 20:01:45 2011
@@ -118,41 +118,55 @@ public class DeploymentUtils {
         return null;
     }
     
+    public static File getTargetFile(IServer server, IModule module) {        
+        File file = null;
+        IGeronimoServer gs = (IGeronimoServer) server.getAdapter(IGeronimoServer.class);
+        if (gs.isRunFromWorkspace()) {
+            //TODO Re-enable after DeployableModule supported in G
+            //file = generateRunFromWorkspaceConfig(getModule());
+        } else {
+            IPath outputDir = DeploymentUtils.STATE_LOC.append("server_" + server.getId());
+            outputDir.toFile().mkdirs();
+            file = DeploymentUtils.createJarFile(module, outputDir);
+        }
+        return file;
+    }
     
     private static String getModuleExtension(IModule module) {
         Trace.tracePoint("Entry", "DeploymentUtils.getModuleExtension", module);
     
+        String extension = null;
+        
         if (GeronimoUtils.isEarModule(module)) {
-            Trace.tracePoint("Exit ", "DeploymentUtils.getModuleExtension", ".ear");
-            return ".ear";
+            extension = ".ear";
         }
         else if (GeronimoUtils.isWebModule(module)) {
-            Trace.tracePoint("Exit ", "DeploymentUtils.getModuleExtension", ".war");
-            return ".war";
+            extension = ".war";
         }
         else if (GeronimoUtils.isRARModule(module)) {
-            Trace.tracePoint("Exit ", "DeploymentUtils.getModuleExtension", ".rar");
-            return ".rar";
+            extension = ".rar";
         }
         else if (GeronimoUtils.isAppClientModule(module)) {
-            Trace.tracePoint("Exit ", "DeploymentUtils.getModuleExtension", ".car");
-            return ".car";
+            extension = ".car";
         }
         else if (GeronimoUtils.isEBAModule(module)) {
-            Trace.tracePoint("Exit ", "DeploymentUtils.getModuleExtension", OsgiConstants.APPLICATION_EXTENSION);
-            return OsgiConstants.APPLICATION_EXTENSION;
+            extension = OsgiConstants.APPLICATION_EXTENSION;
         }
         else if (GeronimoUtils.isCBAModule(module)) {
-            Trace.tracePoint("Exit ", "DeploymentUtils.getModuleExtension", OsgiConstants.COMPOSITE_BUNDLE_EXTENSION);
-            return OsgiConstants.COMPOSITE_BUNDLE_EXTENSION;
+            extension = OsgiConstants.COMPOSITE_BUNDLE_EXTENSION;
         }
         else if (GeronimoUtils.isBundleModule(module)) {
-            Trace.tracePoint("Exit ", "DeploymentUtils.getModuleExtension", OsgiConstants.BUNDLE_EXTENSION);
-            return OsgiConstants.BUNDLE_EXTENSION;
+            extension = OsgiConstants.BUNDLE_EXTENSION;
+        }
+        else if (GeronimoUtils.isFragmentBundleModule(module)) {
+            extension = OsgiConstants.FRAGMENT_BUNDLE_EXTENSION;
+        }
+        else {
+            extension = ".jar";
         }
 
-        Trace.tracePoint("Exit ", "DeploymentUtils.getModuleExtension", ".jar");
-        return ".jar";
+        Trace.tracePoint("Exit ", "DeploymentUtils.getModuleExtension", extension);
+        return extension;
     }
 
 
@@ -160,7 +174,8 @@ public class DeploymentUtils {
         Trace.tracePoint("Entry", "DeploymentUtils.createJarFile", module, outputPath);
 
         IDataModel model = getExportDataModel(module);
-
+        File exportedFile = null;
+        
         if (model != null) {
 
             IVirtualComponent comp = ComponentCore.createComponent(module.getProject());
@@ -177,19 +192,16 @@ public class DeploymentUtils {
             model.setBooleanProperty(J2EEComponentExportDataModelProvider.OVERWRITE_EXISTING,
true);
             model.setBooleanProperty(J2EEComponentExportDataModelProvider.RUN_BUILD, false);
 
-            if (model != null) {
-                try {
-                    model.getDefaultOperation().execute(null, null);
-                    Trace.tracePoint("Exit ", "DeploymentUtils.createJarFile",new File(model.getStringProperty(J2EEComponentExportDataModelProvider.ARCHIVE_DESTINATION)));
-                    return new File(model.getStringProperty(J2EEComponentExportDataModelProvider.ARCHIVE_DESTINATION));
-                } catch (ExecutionException e) {
-                    e.printStackTrace();
-                }
-            }
+            try {
+                model.getDefaultOperation().execute(null, null);
+                exportedFile = new File(model.getStringProperty(J2EEComponentExportDataModelProvider.ARCHIVE_DESTINATION));
+            } catch (ExecutionException e) {
+                Trace.trace(Trace.SEVERE, "Error exporting module", e);
+            }            
         }
 
-        Trace.tracePoint("Exit ", "DeploymentUtils.createJarFile", null);
-        return null;
+        Trace.tracePoint("Exit ", "DeploymentUtils.createJarFile", exportedFile);
+        return exportedFile;
     }
 
 
@@ -219,6 +231,9 @@ public class DeploymentUtils {
             else if (OsgiConstants.BUNDLE.equals(type)) {
                 return DataModelFactory.createDataModel(OsgiConstants.BUNDLE_DATAMODEL_PROVIDER_ID);
             }
+            else if (OsgiConstants.FRAGMENT_BUNDLE.equals(type)) {
+                return DataModelFactory.createDataModel(OsgiConstants.FRAGMENT_BUNDLE_DATAMODEL_PROVIDER_ID);
+            }
         }
 
         Trace.tracePoint("Exit ", "DeploymentUtils.getExportDataModel", (Object) null);
@@ -291,7 +306,7 @@ public class DeploymentUtils {
         } catch (TargetModuleIdNotFoundException e) {
             Trace.trace(Trace.INFO, e.getMessage());
         }
-        
+                
         if(query != currentId) {
             try {
                 getTargetModuleID(dm, currentId);

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java?rev=1089967&r1=1089966&r2=1089967&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServerBehaviourDelegate.java
Thu Apr  7 20:01:45 2011
@@ -418,7 +418,10 @@ abstract public class GeronimoServerBeha
                         Messages.REFRESH_NO_CONFIGURATION_FAIL, ebaModule.getProject().getName()));
             }
             AbstractName abstractName = dm.getApplicationGBeanName(Artifact.create(configId));
-            File file = getTargetFile(bundleModule);
+            File file = DeploymentUtils.getTargetFile(getServer(), bundleModule);
+            if (file == null) {
+                return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.bind(Messages.moduleExportError,
bundleModule.getProject().getName()));
+            }
             String bundleId = ModuleArtifactMapper.getInstance().resolveBundle(getServer(),
ebaModule, bundleModule);
             if (bundleId != null) {
                 dm.updateEBAContent(abstractName, Long.parseLong(bundleId), file);
@@ -432,25 +435,6 @@ abstract public class GeronimoServerBeha
 
         return Status.OK_STATUS;
     }
-    
-     
-    // copied from org.apache.geronimo.st.v30.core.commands.DeployCommand.java
-    private File getTargetFile(IModule module) {
-        
-        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(module, outputDir);
-        }
-        
-        return file;
-    }
 
     private static class ModuleList {
         private final IModule rootModule;
@@ -1403,7 +1387,12 @@ abstract public class GeronimoServerBeha
         Trace.tracePoint("Entry", "GeronimoServerBehaviourDelegate.canControlModule", Arrays.asList(module));
         // Enable start/stop for top-level modules only 
         if (module.length == 1) {
-            return true;
+            if (GeronimoUtils.isFragmentBundleModule(module[0])) {
+                // fragment bundles cannot be started/stopped
+                return false;
+            } else {
+                return true;
+            }
         } else {
             return false;
         }

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=1089967&r1=1089966&r2=1089967&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
Thu Apr  7 20:01:45 2011
@@ -16,7 +16,6 @@
  */
 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;
@@ -101,6 +100,10 @@ public class GeronimoUtils {
         return OsgiConstants.BUNDLE.equals(module.getModuleType().getId());
     }
     
+    public static boolean isFragmentBundleModule(IModule module) {
+        return OsgiConstants.FRAGMENT_BUNDLE.equals(module.getModuleType().getId());
+    }
+    
     public static ModuleType getJSR88ModuleType(IModule module) {
         if (isWebModule(module)) {
             return ModuleType.WAR;

Modified: 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=1089967&r1=1089966&r2=1089967&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/commands/DeployCommand.java
(original)
+++ 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  7 20:01:45 2011
@@ -18,10 +18,13 @@ package org.apache.geronimo.st.v30.core.
 
 import java.io.File;
 
+import org.apache.geronimo.st.v30.core.Activator;
 import org.apache.geronimo.st.v30.core.DeploymentUtils;
-import org.apache.geronimo.st.v30.core.IGeronimoServer;
+import org.apache.geronimo.st.v30.core.internal.Messages;
 import org.apache.geronimo.st.v30.core.internal.Trace;
-import org.eclipse.core.runtime.IPath;
+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;
 
@@ -48,19 +51,15 @@ abstract public class DeployCommand exte
      * 
      * @return A File representation of the zipped/jar file 
      */
-    public File getTargetFile() {
+    public File getTargetFile() throws CoreException {
         Trace.tracePoint("Entry", "DeployCommand.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);
+        IModule module = getModule();
+        File file = DeploymentUtils.getTargetFile(getServer(), module);
+        
+        if (file == null) {
+            throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, 
+                    Messages.bind(Messages.moduleExportError, module.getProject().getName())));
    
         }
 
         Trace.tracePoint("Exit ", "DeployCommand.getTargetFile", file);

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Messages.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/internal/Messages.java?rev=1089967&r1=1089966&r2=1089967&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Messages.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Messages.java
Thu Apr  7 20:01:45 2011
@@ -73,4 +73,6 @@ public class Messages extends NLS {
     
     public static String moduleModified;
     
+    public static String moduleExportError;
+    
 }

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Messages.properties
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/internal/Messages.properties?rev=1089967&r1=1089966&r2=1089967&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Messages.properties
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/internal/Messages.properties
Thu Apr  7 20:01:45 2011
@@ -58,3 +58,4 @@ configSizeMismatch=A plugin configuratio
 noDefaultServer=Invalid setup, no default server instance registered.
 
 moduleModified=Modified
+moduleExportError=Module {0} failed to export.

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/AriesHelper.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/osgi/AriesHelper.java?rev=1089967&r1=1089966&r2=1089967&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/AriesHelper.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/AriesHelper.java
Thu Apr  7 20:01:45 2011
@@ -17,9 +17,7 @@
 package org.apache.geronimo.st.v30.core.osgi;
 
 import org.apache.geronimo.st.v30.core.internal.Trace;
-import org.eclipse.core.runtime.IAdapterManager;
 import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.server.core.IModule;
 import org.osgi.framework.Bundle;
 
 /**

Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/OsgiConstants.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/osgi/OsgiConstants.java?rev=1089967&r1=1089966&r2=1089967&view=diff
==============================================================================
--- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/OsgiConstants.java
(original)
+++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/osgi/OsgiConstants.java
Thu Apr  7 20:01:45 2011
@@ -25,6 +25,10 @@ public final class OsgiConstants {
     public final static String BUNDLE = "osgi.bundle"; 
     public final static String BUNDLE_EXTENSION = ".jar"; 
     public final static String BUNDLE_DATAMODEL_PROVIDER_ID = "osgi.bundle.datamodelprovider";
+    
+    public final static String FRAGMENT_BUNDLE = "osgi.fragment"; 
+    public final static String FRAGMENT_BUNDLE_EXTENSION = ".jar"; 
+    public final static String FRAGMENT_BUNDLE_DATAMODEL_PROVIDER_ID = "osgi.fragment.datamodelprovider";
 
     public final static String COMPOSITE_BUNDLE = "osgi.comp"; 
     public final static String COMPOSITE_BUNDLE_EXTENSION = ".cba";  



Mime
View raw message