incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mnutt...@apache.org
Subject svn commit: r983970 - in /incubator/aries/trunk/application/application-management: ./ src/main/java/org/apache/aries/application/management/impl/ src/main/java/org/apache/aries/application/management/repository/ src/main/resources/OSGI-INF/blueprint/ ...
Date Tue, 10 Aug 2010 12:45:39 GMT
Author: mnuttall
Date: Tue Aug 10 12:45:38 2010
New Revision: 983970

URL: http://svn.apache.org/viewvc?rev=983970&view=rev
Log:
ARIES-359: Isolated application support. From a patch by Chris Wilkinson. 

Added:
    incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/repository/
    incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/repository/ApplicationRepository.java
Modified:
    incubator/aries/trunk/application/application-management/pom.xml
    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-management/src/test/java/org/apache/aries/application/management/impl/AriesApplicationManagerImplTest.java

Modified: incubator/aries/trunk/application/application-management/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-management/pom.xml?rev=983970&r1=983969&r2=983970&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-management/pom.xml (original)
+++ incubator/aries/trunk/application/application-management/pom.xml Tue Aug 10 12:45:38 2010
@@ -36,7 +36,8 @@
         </aries.osgi.export.pkg>
         <aries.osgi.private.pkg>
             org.apache.aries.application.management.impl;
-			org.apache.aries.application.management.internal
+			org.apache.aries.application.management.internal;
+			org.apache.aries.application.management.repository
         </aries.osgi.private.pkg>
     </properties>
 

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=983970&r1=983969&r2=983970&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
Tue Aug 10 12:45:38 2010
@@ -26,8 +26,10 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.URL;
 import java.util.Collections;
+import java.util.Dictionary;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -49,12 +51,14 @@ import org.apache.aries.application.mana
 import org.apache.aries.application.management.BundleConversion;
 import org.apache.aries.application.management.BundleConverter;
 import org.apache.aries.application.management.BundleInfo;
+import org.apache.aries.application.management.BundleRepository;
 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;
 import org.apache.aries.application.management.ResolverException;
 import org.apache.aries.application.management.internal.MessageUtil;
+import org.apache.aries.application.management.repository.ApplicationRepository;
 import org.apache.aries.application.utils.AppConstants;
 import org.apache.aries.application.utils.filesystem.FileSystem;
 import org.apache.aries.application.utils.filesystem.IOUtils;
@@ -62,7 +66,9 @@ import org.apache.aries.application.util
 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.BundleContext;
 import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -75,6 +81,7 @@ public class AriesApplicationManagerImpl
   private AriesApplicationResolver _resolver;
   private LocalPlatform _localPlatform;
   private AriesApplicationContextManager _applicationContextManager;
+  private BundleContext _bundleContext;
 
   private static final Logger _logger = LoggerFactory.getLogger("org.apache.aries.application.management.impl");
 
@@ -102,6 +109,11 @@ public class AriesApplicationManagerImpl
     _applicationContextManager = acm;
   }
   
+  public void setBundleContext(BundleContext b)
+  {
+    _bundleContext = b;
+  }
+  
   
   /**
    * Create an AriesApplication from a .eba file: a zip file with a '.eba' extension
@@ -142,7 +154,7 @@ public class AriesApplicationManagerImpl
         BundleManifest bm = getBundleManifest (f);
         if (bm != null) {
           if (bm.isValid()) {
-            extraBundlesInfo.add(new SimpleBundleInfo(_applicationMetadataFactory, bm, f.toURL().toExternalForm()));
+            extraBundlesInfo.add(new SimpleBundleInfo(bm, f.toURL().toExternalForm()));
           } else if (deploymentManifest == null) { 
             // We have a jar that needs converting to a bundle, or a war to migrate to a
WAB 
             // We only do this if a DEPLOYMENT.MF does not exist.
@@ -166,7 +178,7 @@ public class AriesApplicationManagerImpl
             }
             if (convertedBinary != null) { 
               modifiedBundles.put (f.getName(), convertedBinary);             
-              extraBundlesInfo.add(convertedBinary.getBundleInfo(_applicationMetadataFactory));
+              extraBundlesInfo.add(convertedBinary.getBundleInfo());
             } 
           }
         } 
@@ -182,7 +194,7 @@ public class AriesApplicationManagerImpl
       applicationMetadata = _applicationMetadataFactory.createApplicationMetadata(applicationManifest);
       
       if (deploymentManifest != null) { 
-        deploymentMetadata = _deploymentMetadataFactory.createDeploymentMetadata(deploymentManifest);
+        deploymentMetadata = _deploymentMetadataFactory.parseDeploymentMetadata(deploymentManifest);
         
         // Validate: symbolic names must match
         String appSymbolicName = applicationMetadata.getApplicationSymbolicName();
@@ -268,6 +280,14 @@ public class AriesApplicationManagerImpl
     if (!app.isResolved()) {
         app = resolve(app);
     }
+    
+    // Register an Application Repository for this application
+    Dictionary dict = new Hashtable();
+    dict.put(ApplicationRepository.REPOSITORY_SCOPE, app.getApplicationMetadata().getApplicationScope());
+    _bundleContext.registerService(BundleRepository.class.getName(), 
+        new ApplicationRepository(_resolver), 
+        dict);
+    
     AriesApplicationContext result = _applicationContextManager.getApplicationContext(app);
     return result;
   }

Added: incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/repository/ApplicationRepository.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/repository/ApplicationRepository.java?rev=983970&view=auto
==============================================================================
--- incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/repository/ApplicationRepository.java
(added)
+++ incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/repository/ApplicationRepository.java
Tue Aug 10 12:45:38 2010
@@ -0,0 +1,93 @@
+/*
+ * 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.repository;
+
+import java.util.Set;
+
+import org.apache.aries.application.ApplicationMetadata;
+import org.apache.aries.application.Content;
+import org.apache.aries.application.DeploymentContent;
+import org.apache.aries.application.management.AriesApplication;
+import org.apache.aries.application.management.AriesApplicationResolver;
+import org.apache.aries.application.management.BundleInfo;
+import org.apache.aries.application.management.BundleRepository;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Version;
+
+public class ApplicationRepository implements BundleRepository
+{
+  private static final int REPOSITORY_COST = 0;
+  public static final String REPOSITORY_SCOPE = "repositoryScope";
+  
+  AriesApplicationResolver resolver;
+
+  public ApplicationRepository(AriesApplicationResolver resolver)
+  {
+    this.resolver = resolver;
+  }
+  
+  public int getCost()
+  {
+    return REPOSITORY_COST;
+  }
+
+  public BundleSuggestion suggestBundleToUse(DeploymentContent content)
+  {
+    return new BundleSuggestionImpl(content);
+  }
+
+  private class BundleSuggestionImpl implements BundleSuggestion
+  {
+    private BundleInfo bundleInfo;
+    
+    BundleSuggestionImpl(DeploymentContent content)
+    {
+      this.bundleInfo = resolver.getBundleInfo(content.getContentName(), content.getExactVersion());
+    }
+    
+    public int getCost()
+    {
+      return REPOSITORY_COST;
+    }
+
+    public Set<Content> getExportPackage()
+    {
+      return bundleInfo.getExportPackage();
+    }
+
+    public Set<Content> getImportPackage()
+    {
+      return bundleInfo.getImportPackage();
+    }
+
+    public Version getVersion()
+    {
+      return bundleInfo.getVersion();
+    }
+
+    public Bundle install(BundleContext ctx, AriesApplication app) throws BundleException
+    {
+      return ctx.installBundle(bundleInfo.getLocation());
+    }
+    
+  }
+  
+}

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=983970&r1=983969&r2=983970&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
Tue Aug 10 12:45:38 2010
@@ -26,6 +26,7 @@
     <property name="resolver" ref="resolver"/>
     <property name="localPlatform" ref="localPlatform"/>
     <property name="applicationContextManager" ref="application-context-manager"/>
+    <property name="bundleContext" ref="blueprintBundleContext"/>
   </bean>
   
   <reference id="app-metadata-factory" interface="org.apache.aries.application.ApplicationMetadataFactory"/>

Modified: incubator/aries/trunk/application/application-management/src/test/java/org/apache/aries/application/management/impl/AriesApplicationManagerImplTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/application/application-management/src/test/java/org/apache/aries/application/management/impl/AriesApplicationManagerImplTest.java?rev=983970&r1=983969&r2=983970&view=diff
==============================================================================
--- incubator/aries/trunk/application/application-management/src/test/java/org/apache/aries/application/management/impl/AriesApplicationManagerImplTest.java
(original)
+++ incubator/aries/trunk/application/application-management/src/test/java/org/apache/aries/application/management/impl/AriesApplicationManagerImplTest.java
Tue Aug 10 12:45:38 2010
@@ -118,8 +118,8 @@ public class AriesApplicationManagerImpl
                 final String location = toBeConverted.toString();                
             	return new BundleConversion() {
 
-					public BundleInfo getBundleInfo(ApplicationMetadataFactory amf) throws IOException {
-						return new SimpleBundleInfo(amf, BundleManifest.fromBundle(convertedFile), location);
+					public BundleInfo getBundleInfo() throws IOException {
+						return new SimpleBundleInfo(BundleManifest.fromBundle(convertedFile), location);
 					}
 
 					public InputStream getInputStream() throws IOException {
@@ -304,7 +304,7 @@ public class AriesApplicationManagerImpl
     String persistenceLibraryLocation = "../src/test/resources/bundles/repository/a.handy.persistence.library.jar";
     File persistenceLibrary = new File (persistenceLibraryLocation);
     BundleManifest mf = BundleManifest.fromBundle(persistenceLibrary);
-    BundleInfo resolvedPersistenceLibrary = new SimpleBundleInfo(_appMetaFactory, mf, persistenceLibraryLocation);

+    BundleInfo resolvedPersistenceLibrary = new SimpleBundleInfo(mf, persistenceLibraryLocation);

     Field v = SimpleBundleInfo.class.getDeclaredField("_version");
     v.setAccessible(true);
     v.set(resolvedPersistenceLibrary, new Version("1.1.0"));



Mime
View raw message