aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mnutt...@apache.org
Subject svn commit: r898776 - in /incubator/aries/trunk/application: application-api/src/main/java/org/apache/aries/application/management/ application-management/src/main/java/org/apache/aries/application/management/impl/
Date Wed, 13 Jan 2010 14:40:46 GMT
Author: mnuttall
Date: Wed Jan 13 14:40:45 2010
New Revision: 898776

URL: http://svn.apache.org/viewvc?rev=898776&view=rev
Log:
ARIES-89: Implement application support: make createApplication() throw an exception if one
or more bundle conversions were attempted but failed. 

Added:
    incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/ConversionException.java
Modified:
    incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/BundleConverter.java
    incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationManagerImpl.java

Modified: incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/BundleConverter.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/BundleConverter.java?rev=898776&r1=898775&r2=898776&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/BundleConverter.java
(original)
+++ incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/BundleConverter.java
Wed Jan 13 14:40:45 2010
@@ -31,15 +31,13 @@
  */
 public interface BundleConverter {
   /**
-   * 
-   * @param inputBundle Stream to the input bundle
    * @param parentEba The root of the eba containing the artifact being converted - 
-   *                  currently a .zip file. In time we may come to support this 
-   *                  being an exploded directory.
-   * @param pathToArtifact Path to the artifact to be converted
-   *                   
-   * @return valid input stream or null if the bundle could not be converted. 
+   *                  a zip format file with .eba suffix, or an exploded directory. 
+   * @param fileInEba The object within the eba to convert
+   * @throws ConversionException if conversion was attempted but failed
+   * @return valid input stream or null if this converter does not support conversion of
+   *         this artifact type.  
    */
-  public InputStream convert (IDirectory parentEba, IFile fileInEba);
+  public InputStream convert (IDirectory parentEba, IFile fileInEba) throws ConversionException;
 
 }

Added: incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/ConversionException.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/ConversionException.java?rev=898776&view=auto
==============================================================================
--- incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/ConversionException.java
(added)
+++ incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/ConversionException.java
Wed Jan 13 14:40:45 2010
@@ -0,0 +1,33 @@
+/*
+ * 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 WARRANTIESOR 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.aries.application.management;
+
+public class ConversionException extends Exception {
+
+  private static final long serialVersionUID = -5921912484821992252L;
+
+  public ConversionException (Exception e) { 
+    super(e);
+  }
+  
+  public ConversionException (String s) { 
+    super(s);
+  }
+}

Modified: incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationManagerImpl.java?rev=898776&r1=898775&r2=898776&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationManagerImpl.java
(original)
+++ incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationManagerImpl.java
Wed Jan 13 14:40:45 2010
@@ -25,6 +25,7 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.URL;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -46,6 +47,7 @@
 import org.apache.aries.application.management.AriesApplicationResolver;
 import org.apache.aries.application.management.BundleConverter;
 import org.apache.aries.application.management.BundleInfo;
+import org.apache.aries.application.management.ConversionException;
 import org.apache.aries.application.management.LocalPlatform;
 import org.apache.aries.application.management.ManagementException;
 import org.apache.aries.application.management.ResolveConstraint;
@@ -56,6 +58,8 @@
 import org.apache.aries.application.utils.manifest.ManifestDefaultsInjector;
 import org.apache.aries.application.utils.manifest.ManifestProcessor;
 import org.osgi.framework.ServiceException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class AriesApplicationManagerImpl implements AriesApplicationManager {
 
@@ -65,6 +69,8 @@
   private AriesApplicationResolver _resolver;
   private LocalPlatform _localPlatform;
 
+  private static final Logger _logger = LoggerFactory.getLogger("org.apache.aries.application.management.impl");
+
   public void setApplicationMetadataManager (ApplicationMetadataManager amm) { 
     _applicationMetadataManager = amm;
   }
@@ -105,6 +111,9 @@
       if (deploymentManifest != null) { 
         deploymentMetadata = _deploymentMetadataFactory.createDeploymentMetadata(deploymentManifest);
       }
+      
+      // TODO: validate
+      
       /* We require that all other .jar and .war files included by-value be valid bundles
        * because a DEPLOYMENT.MF has been provided. If no DEPLOYMENT.MF, migrate 
        * wars to wabs, plain jars to bundles
@@ -126,14 +135,21 @@
             // We have a jar that needs converting to a bundle, or a war to migrate to a
WAB
             InputStream convertedBinary = null;
             Iterator<BundleConverter> converters = _bundleConverters.iterator();
+            List<ConversionException> conversionExceptions = Collections.emptyList();
             while (converters.hasNext() && convertedBinary == null) { 
               try { 
-                // WarToWabConverter can extract application.xml via
-                // eba.getFile(AppConstants.APPLICATION_XML);
                 convertedBinary = converters.next().convert(ebaFile, f);
               } catch (ServiceException sx) {
                 // We'll get this if our optional BundleConverter has not been injected.

+              } catch (ConversionException cx) { 
+                conversionExceptions.add(cx);
+              }
+            }
+            if (conversionExceptions.size() > 0) {
+              for (ConversionException cx : conversionExceptions) { 
+                _logger.error("Conversion failure", cx);
               }
+              throw new ManagementException ("createApplication failed due to conversion
failures: see log for details");
             }
             if (convertedBinary != null) { 
               modifiedBundles.put (f.getName(), convertedBinary);
@@ -156,7 +172,7 @@
         
       }
     } catch (IOException iox) { 
-      // Log an error
+      _logger.error ("createApplication failed", iox);
       throw new ManagementException(iox);
     }
     



Mime
View raw message