incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mnutt...@apache.org
Subject svn commit: r1021368 - /incubator/aries/trunk/application/application-management/src/main/java/org/apache/aries/application/management/impl/AriesApplicationManagerImpl.java
Date Mon, 11 Oct 2010 15:01:45 GMT
Author: mnuttall
Date: Mon Oct 11 15:01:44 2010
New Revision: 1021368

URL: http://svn.apache.org/viewvc?rev=1021368&view=rev
Log:
ARIES-466: AriesApplicationManager registers an application BundleRepository even when one
already exists. Patch by Chris Wilkinson. 

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

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=1021368&r1=1021367&r2=1021368&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
Mon Oct 11 15:01:44 2010
@@ -69,7 +69,9 @@ import org.apache.aries.application.util
 import org.apache.aries.application.utils.manifest.ManifestProcessor;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
+import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceException;
+import org.osgi.framework.ServiceReference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -282,17 +284,31 @@ public class AriesApplicationManagerImpl
   } 
 
   public AriesApplicationContext install(AriesApplication app) throws BundleException, ManagementException,
ResolverException {
+    
     if (!app.isResolved()) {
-        app = resolve(app);
+      app = resolve(app);
+    }
+  
+    // Register an Application Repository for this application if none exists
+    String appScope = app.getApplicationMetadata().getApplicationScope();    
+    ServiceReference[] ref = null;
+    try {
+        String filter = "(" + BundleRepository.REPOSITORY_SCOPE + "=" + appScope + ")";
+        ref = _bundleContext.getServiceReferences(BundleRepository.class.getName(),filter);
+    } 
+    catch (InvalidSyntaxException e) {
+        // Something went wrong attempting to find a service so we will act as if 
+        // there is no existing service.
     }
     
-    // Register an Application Repository for this application
-    Dictionary dict = new Hashtable();
-    dict.put(BundleRepository.REPOSITORY_SCOPE, app.getApplicationMetadata().getApplicationScope());
-    _bundleContext.registerService(BundleRepository.class.getName(), 
-        new ApplicationRepository(app), 
-        dict);
-    
+    if (ref == null || ref.length == 0) {
+        Dictionary dict = new Hashtable();
+        dict.put(BundleRepository.REPOSITORY_SCOPE, appScope);
+        _bundleContext.registerService(BundleRepository.class.getName(), 
+            new ApplicationRepository(app), 
+            dict);
+    }
+  
     AriesApplicationContext result = _applicationContextManager.getApplicationContext(app);
     return result;
   }



Mime
View raw message