You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by gn...@apache.org on 2018/02/21 09:05:20 UTC

svn commit: r1824946 - in /aries/trunk/jndi: jndi-bundle/pom.xml jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java

Author: gnodet
Date: Wed Feb 21 09:05:20 2018
New Revision: 1824946

URL: http://svn.apache.org/viewvc?rev=1824946&view=rev
Log:
[jndi] Fix build

Modified:
    aries/trunk/jndi/jndi-bundle/pom.xml
    aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java

Modified: aries/trunk/jndi/jndi-bundle/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-bundle/pom.xml?rev=1824946&r1=1824945&r2=1824946&view=diff
==============================================================================
--- aries/trunk/jndi/jndi-bundle/pom.xml (original)
+++ aries/trunk/jndi/jndi-bundle/pom.xml Wed Feb 21 09:05:20 2018
@@ -32,7 +32,7 @@
     <artifactId>org.apache.aries.jndi</artifactId>
     <packaging>bundle</packaging>
     <name>Apache Aries JNDI Bundle</name>
-    <version>1.0.1-SNAPSHOT</version>
+    <version>1.1.0-SNAPSHOT</version>
     <description>
         This bundle contains the core JNDI along with the OSGi url handler.
         It's composed of the jndi-api, jndi-core and jndi-url modules.

Modified: aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java
URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java?rev=1824946&r1=1824945&r2=1824946&view=diff
==============================================================================
--- aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java (original)
+++ aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/startup/Activator.java Wed Feb 21 09:05:20 2018
@@ -89,21 +89,32 @@ public class Activator implements Bundle
     }
 
     public static <T> T getService(BundleContext context, ServiceReference<T> ref) {
-        ServiceCache cache = instance.bundleServiceCaches.getObject(context.getBundle());
+        ServiceCache cache = getServiceCache(context);
         return cache.getService(ref);
     }
 
     public static <T> Collection<ServiceReference<T>> getReferences(BundleContext context, Class<T> clazz) {
-        ServiceCache cache = instance.bundleServiceCaches.getObject(context.getBundle());
+        ServiceCache cache = getServiceCache(context);
         return cache.getReferences(clazz);
     }
 
     public static <T> Iterable<T> getServices(BundleContext context, Class<T> clazz) {
-        ServiceCache cache = instance.bundleServiceCaches.getObject(context.getBundle());
+        ServiceCache cache = getServiceCache(context);
+        if (cache == null) {
+            cache = new ServiceCache(context);
+        }
         Collection<ServiceReference<T>> refs = cache.getReferences(clazz);
         return () -> Utils.map(refs.iterator(), ref -> Activator.getService(context, ref));
     }
 
+    private static ServiceCache getServiceCache(BundleContext context) {
+        ServiceCache cache = instance.bundleServiceCaches.getObject(context.getBundle());
+        if (cache == null) {
+            cache = new ServiceCache(context);
+        }
+        return cache;
+    }
+
 
     public void start(BundleContext context) {
         instance = this;