incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mnutt...@apache.org
Subject svn commit: r899230 - 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/ application-management/src/main/java/...
Date Thu, 14 Jan 2010 15:10:26 GMT
Author: mnuttall
Date: Thu Jan 14 15:10:25 2010
New Revision: 899230

URL: http://svn.apache.org/viewvc?rev=899230&view=rev
Log:
ARIES-89: Implement application support: Very basic runtime support, and some improved logging

Added:
    incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/internal/
    incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/internal/MessageUtil.java
    incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/messages/AppManagementMessages.properties
Modified:
    incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/ApplicationContext.java
    incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/AriesApplication.java
    incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/AriesApplicationManager.java
    incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationImpl.java
    incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationManagerImpl.java
    incubator/aries/trunk/application/application-management/src/main/resources/OSGI-INF/blueprint/app-management.xml
    incubator/aries/trunk/application/application-runtime/pom.xml

Modified: incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/ApplicationContext.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/ApplicationContext.java?rev=899230&r1=899229&r2=899230&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/ApplicationContext.java
(original)
+++ incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/ApplicationContext.java
Thu Jan 14 15:10:25 2010
@@ -22,6 +22,7 @@
 import java.util.Set;
 
 import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
 
 /**
  * Represents an Aries application in the runtime
@@ -30,8 +31,8 @@
 {
   public ApplicationState getApplicationState();
   public AriesApplication getApplication();
-  public void start();
-  public void stop();
+  public void start() throws BundleException;
+  public void stop() throws BundleException;
   public Set<Bundle> getApplicationContent(); // 
   
   public enum ApplicationState

Modified: incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/AriesApplication.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/AriesApplication.java?rev=899230&r1=899229&r2=899230&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/AriesApplication.java
(original)
+++ incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/AriesApplication.java
Thu Jan 14 15:10:25 2010
@@ -40,7 +40,7 @@
   public DeploymentMetadata getDeploymentMetadata();
 
   /** the set of bundles included in the application by value */
-  public Set<BundleInfo> getBundles();
+  public Set<BundleInfo> getBundleInfo();
 
   /** Stores any changes to disk using this implementations storage form */
   public void store(File f) throws FileNotFoundException, IOException;

Modified: incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/AriesApplicationManager.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/AriesApplicationManager.java?rev=899230&r1=899229&r2=899230&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/AriesApplicationManager.java
(original)
+++ incubator/aries/trunk/application/application-api/src/main/java/org/apache/aries/application/management/AriesApplicationManager.java
Thu Jan 14 15:10:25 2010
@@ -21,9 +21,9 @@
 package org.apache.aries.application.management;
 
 import java.net.URL;
-import java.util.Set;
 
 import org.apache.aries.application.filesystem.IDirectory;
+import org.osgi.framework.BundleException;
 
 /**
  * Create, install and uninstall applications via this service. 
@@ -32,8 +32,8 @@
 {
   public AriesApplication createApplication(IDirectory source) throws ManagementException;
   public AriesApplication createApplication(URL url) throws ManagementException;
-  public ApplicationContext install(AriesApplication app);
-  public void uninstall(ApplicationContext app);
+  public ApplicationContext install(AriesApplication app) throws BundleException;
+  public void uninstall(ApplicationContext app) throws BundleException;
   public void addApplicationListener(ApplicationListener l);
   public void removeApplicationListener(ApplicationListener l);
   AriesApplication resolve (AriesApplication originalApp, ResolveConstraint ... constraints);

Modified: incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationImpl.java?rev=899230&r1=899229&r2=899230&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationImpl.java
(original)
+++ incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationImpl.java
Thu Jan 14 15:10:25 2010
@@ -38,9 +38,13 @@
 import org.apache.aries.application.management.LocalPlatform;
 import org.apache.aries.application.utils.AppConstants;
 import org.apache.aries.application.utils.filesystem.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class AriesApplicationImpl implements AriesApplication {
 
+  private static final Logger _logger = LoggerFactory.getLogger("org.apache.aries.application.management");
+
   private Set<BundleInfo> _bundleInfo;
   private ApplicationMetadata _applicationMetadata;
   private DeploymentMetadata _deploymentMetadata;
@@ -71,7 +75,7 @@
     return _applicationMetadata;
   }
 
-  public Set<BundleInfo> getBundles() {
+  public Set<BundleInfo> getBundleInfo() {
     return _bundleInfo;
   }
 
@@ -159,7 +163,7 @@
     IOUtils.zipUp(tempDir, targetStream);
     if (!IOUtils.deleteRecursive(tempDir))
     {
-      // TODO: Log a warning
+      _logger.warn("APPMANAGEMENT0001E", tempDir);
     }
   }
 }

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=899230&r1=899229&r2=899230&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
Thu Jan 14 15:10:25 2010
@@ -41,6 +41,7 @@
 import org.apache.aries.application.filesystem.IDirectory;
 import org.apache.aries.application.filesystem.IFile;
 import org.apache.aries.application.management.ApplicationContext;
+import org.apache.aries.application.management.ApplicationContextManager;
 import org.apache.aries.application.management.ApplicationListener;
 import org.apache.aries.application.management.AriesApplication;
 import org.apache.aries.application.management.AriesApplicationManager;
@@ -51,12 +52,15 @@
 import org.apache.aries.application.management.LocalPlatform;
 import org.apache.aries.application.management.ManagementException;
 import org.apache.aries.application.management.ResolveConstraint;
+import org.apache.aries.application.management.internal.MessageUtil;
 import org.apache.aries.application.utils.AppConstants;
 import org.apache.aries.application.utils.filesystem.FileSystem;
 import org.apache.aries.application.utils.filesystem.IOUtils;
 import org.apache.aries.application.utils.manifest.BundleManifest;
 import org.apache.aries.application.utils.manifest.ManifestDefaultsInjector;
 import org.apache.aries.application.utils.manifest.ManifestProcessor;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
 import org.osgi.framework.ServiceException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -68,6 +72,7 @@
   private List<BundleConverter> _bundleConverters;
   private AriesApplicationResolver _resolver;
   private LocalPlatform _localPlatform;
+  private ApplicationContextManager _applicationContextManager;
 
   private static final Logger _logger = LoggerFactory.getLogger("org.apache.aries.application.management.impl");
 
@@ -91,6 +96,10 @@
     _localPlatform = lp;
   }
   
+  public void setApplicationContextManager (ApplicationContextManager acm) { 
+    _applicationContextManager = acm;
+  }
+  
   
   /**
    * Create an AriesApplication from a .eba file: a zip file with a '.eba' extension
@@ -110,10 +119,15 @@
       IFile deploymentManifest = ebaFile.getFile(AppConstants.DEPLOYMENT_MF);
       if (deploymentManifest != null) { 
         deploymentMetadata = _deploymentMetadataFactory.createDeploymentMetadata(deploymentManifest);
+        
+        // Validate: symbolic names must match
+        String appSymbolicName = applicationMetadata.getApplicationSymbolicName();
+        String depSymbolicName = applicationMetadata.getApplicationSymbolicName();
+        if (!appSymbolicName.equals(depSymbolicName)) {
+          throw new ManagementException (MessageUtil.getMessage("APPMANAGEMENT0002E", ebaFile.getName(),
appSymbolicName, depSymbolicName));
+        }
       }
       
-      // 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
@@ -130,7 +144,7 @@
           if (bm.isValid()) {
             extraBundlesInfo.add(new BundleInfoImpl(bm, f.toURL().toExternalForm()));
           } else if (deploymentMetadata != null) {
-            throw new ManagementException ("Invalid bundle " + f.getName() + " found when
DEPLOYMENT.MF present");
+            throw new ManagementException (MessageUtil.getMessage("APPMANAGEMENT0003E", f.getName(),
ebaFile.getName()));
           } else { 
             // We have a jar that needs converting to a bundle, or a war to migrate to a
WAB
             InputStream convertedBinary = null;
@@ -147,9 +161,9 @@
             }
             if (conversionExceptions.size() > 0) {
               for (ConversionException cx : conversionExceptions) { 
-                _logger.error("Conversion failure", cx);
+                _logger.error("APPMANAGEMENT0004E", new Object[]{f.getName(), ebaFile.getName(),
cx});
               }
-              throw new ManagementException ("createApplication failed due to conversion
failures: see log for details");
+              throw new ManagementException (MessageUtil.getMessage("APPMANAGEMENT0005E",
ebaFile.getName()));
             }
             if (convertedBinary != null) { 
               modifiedBundles.put (f.getName(), convertedBinary);
@@ -172,7 +186,7 @@
         
       }
     } catch (IOException iox) { 
-      _logger.error ("createApplication failed", iox);
+      _logger.error ("APPMANAGEMENT0006E", new Object []{ebaFile.getName(), iox});
       throw new ManagementException(iox);
     }
     
@@ -208,14 +222,17 @@
     // TODO Auto-generated method stub
     return null;
   } 
-  
+
   public ApplicationContext install(AriesApplication app) {
-    // TODO Auto-generated method stub
-    return null;
+    ApplicationContext result = _applicationContextManager.getApplicationContext(app);
+    return result;
   }
   
-  public void uninstall(ApplicationContext app) {
-    // TODO Auto-generated method stub
+  public void uninstall(ApplicationContext app) throws BundleException {
+    Set<Bundle> bundles = app.getApplicationContent();
+    for (Bundle b : bundles) { 
+      b.uninstall();
+    }
 
   }
 
@@ -245,7 +262,7 @@
         is = f.open();
         result = ManifestProcessor.parseManifest(is);
       } catch (IOException iox) { 
-        // TODO: log error
+        _logger.error ("APPMANAGEMENT0007E", new Object[]{source.getName(), iox});
         throw iox;
       } finally { 
         IOUtils.close(is);

Added: incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/internal/MessageUtil.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/internal/MessageUtil.java?rev=899230&view=auto
==============================================================================
--- incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/internal/MessageUtil.java
(added)
+++ incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/internal/MessageUtil.java
Thu Jan 14 15:10:25 2010
@@ -0,0 +1,46 @@
+/*
+ * 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.internal;
+
+import java.text.MessageFormat;
+import java.util.ResourceBundle;
+
+public class MessageUtil
+{
+  /** The resource bundle for blueprint messages */
+  private final static ResourceBundle messages = ResourceBundle.getBundle("org.apache.aries.application.management.messages.AppManagementMessages");
+  
+  /**
+   * Resolve a message from the bundle, including any necessary formatting.
+   * 
+   * @param key     the message key.
+   * @param inserts any required message inserts.
+   * @return        the message translated into the server local.
+   */
+  public static final String getMessage(String key, Object ... inserts)
+  {
+    String msg = messages.getString(key);
+    
+    if (inserts.length > 0)
+      msg = MessageFormat.format(msg, inserts);
+    
+    return msg;
+  }
+}

Added: incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/messages/AppManagementMessages.properties
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/messages/AppManagementMessages.properties?rev=899230&view=auto
==============================================================================
--- incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/messages/AppManagementMessages.properties
(added)
+++ incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/messages/AppManagementMessages.properties
Thu Jan 14 15:10:25 2010
@@ -0,0 +1,7 @@
+APPMANAGEMENT0001E=APPMANAGEMENT0001E: Unable to fully delete directory {0}. 
+APPMANAGEMENT0002E=APPMANAGEMENT0002E: Unable to create Aries application from {0} since
APPLICATION.MF symbolic name {1} does not equals DEPLOYMENT.MF symbolic name {2}.
+APPMANAGEMENT0003E=APPMANAGEMENT0003E: Invalid bundle {0} found when DEPLOYMENT.MF present
in {1}.
+APPMANAGEMENT0004E=APPMANAGEMENT0004E: Exception caught when converting artifact {0} in {1}:
{2}.
+APPMANAGEMENT0005E=APPMANAGEMENT0005E: Failed to create application from {0} due to conversion
errors: see log for details.
+APPMANAGEMENT0006E=APPMANAGEMENT0006E: IOException encountered while constructing Aries application
from {0}: {1}.
+APPMANAGEMENT0007E=APPMANAGEMENT0007E: IOException encountered while parsing APPICATION.MF
in {0}: {1}. 
\ No newline at end of file

Modified: incubator/aries/trunk/application/application-management/src/main/resources/OSGI-INF/blueprint/app-management.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-management/src/main/resources/OSGI-INF/blueprint/app-management.xml?rev=899230&r1=899229&r2=899230&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-management/src/main/resources/OSGI-INF/blueprint/app-management.xml
(original)
+++ incubator/aries/trunk/application/application-management/src/main/resources/OSGI-INF/blueprint/app-management.xml
Thu Jan 14 15:10:25 2010
@@ -25,6 +25,7 @@
     <property name="bundleConverters" ref="bundle-converters"/>
     <property name="resolver" ref="resolver"/>
     <property name="localPlatform" ref="localPlatform"/>
+    <property name="applicationContextManager" ref="application-context-manager"/>
   </bean>
   
   <reference id="app-metadata-manager" interface="org.apache.aries.application.ApplicationMetadataManager"/>
@@ -34,6 +35,7 @@
                   availability="optional"/>
   <reference id="resolver" interface="org.apache.aries.application.management.AriesApplicationResolver"/>
   <reference id="localPlatform" interface="org.apache.aries.application.management.LocalPlatform"/>
+  <reference id="application-context-manager" interface="org.apache.aries.application.management.ApplicationContextManager"/>
     
   <service interface="org.apache.aries.application.management.AriesApplicationManager"
ref="manager-service" />
   

Modified: incubator/aries/trunk/application/application-runtime/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-runtime/pom.xml?rev=899230&r1=899229&r2=899230&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-runtime/pom.xml (original)
+++ incubator/aries/trunk/application/application-runtime/pom.xml Thu Jan 14 15:10:25 2010
@@ -7,7 +7,10 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.aries.application</groupId>
   <artifactId>application-runtime</artifactId>
-  <name>application-runtime</name>
+    <name>Apache Aries application runtime</name>
+  <description>
+      A very basic runtime implementation
+  </description>
   <version>1.0.0-incubating-SNAPSHOT</version>
   <url>http://maven.apache.org</url>
  <dependencies>
@@ -55,4 +58,23 @@
   		<version>1.0.0-incubating-SNAPSHOT</version>
   	</dependency>
   </dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId> 
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration> 
+           <instructions>
+	         <Bundle-SymbolicName>${pom.groupId}.runtime</Bundle-SymbolicName>
+	         <Bundle-Activator>org.apache.aries.application.runtime.internal.Activator</Bundle-Activator>
+             <Private-Package>org.apache.aries.application.management.impl</Private-Package>

+             <_versionpolicy>[$(version;==;$(@)),$(version;+;$(@)))</_versionpolicy>
+             <_removeheaders>Ignore-Package,Include-Resource,Private-Package,Bundle-DocURL</_removeheaders>
+         </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
 </project>
\ No newline at end of file



Mime
View raw message