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:36 UTC

svn commit: r1824948 - in /aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi: services/ url/

Author: gnodet
Date: Wed Feb 21 09:05:35 2018
New Revision: 1824948

URL: http://svn.apache.org/viewvc?rev=1824948&view=rev
Log:
[jndi] Java 8 syntax

Modified:
    aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/services/ServiceHelper.java
    aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/AbstractName.java
    aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/AbstractServiceRegistryContext.java
    aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/Activator.java
    aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/BlueprintURLContext.java
    aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/BlueprintURLContextFactory.java
    aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/BlueprintURLContextServiceFactory.java
    aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/OsgiNameParser.java
    aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/OsgiURLContextServiceFactory.java
    aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/ServiceRegistryListContext.java

Modified: aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/services/ServiceHelper.java
URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/services/ServiceHelper.java?rev=1824948&r1=1824947&r2=1824948&view=diff
==============================================================================
--- aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/services/ServiceHelper.java (original)
+++ aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/services/ServiceHelper.java Wed Feb 21 09:05:35 2018
@@ -52,7 +52,7 @@ public final class ServiceHelper {
     /**
      * A cache of proxies returned to the client
      */
-    private static final ConcurrentMap<ServiceKey, WeakReference<Object>> proxyCache = new ConcurrentHashMap<ServiceKey, WeakReference<Object>>();
+    private static final ConcurrentMap<ServiceKey, WeakReference<Object>> proxyCache = new ConcurrentHashMap<>();
     private static final CacheClearoutListener cacheClearoutListener = new CacheClearoutListener(proxyCache);
     private static final MessageUtil MESSAGES = MessageUtil.createMessageUtil(ServiceHelper.class, "org.apache.aries.jndi.nls.jndiUrlMessages");
 
@@ -72,7 +72,7 @@ public final class ServiceHelper {
 
         ServicePair pair = null;
 
-        if (!!!lookupName.isServiceNameBased()) {
+        if (!lookupName.isServiceNameBased()) {
             pair = findService(ctx, interfaceName, filter);
         }
 
@@ -124,13 +124,9 @@ public final class ServiceHelper {
         }
 
         if (result == null) {
-            result = AccessController.doPrivileged(new PrivilegedAction<Object>() {
-                public Object run() {
-                    return proxyPrivileged(interface1, filter, rebind, ctx, pair, timeout);
-                }
-            });
+            result = AccessController.doPrivileged((PrivilegedAction<Object>) () -> proxyPrivileged(interface1, filter, rebind, ctx, pair, timeout));
 
-            proxyRef = new WeakReference<Object>(result);
+            proxyRef = new WeakReference<>(result);
             // if we have two threads doing a put and then clashing we ignore it. The code to ensure only
             // one wins is quite complex to save a few bytes of memory and millis of execution time.
             proxyCache.putIfAbsent(k, proxyRef);
@@ -141,14 +137,14 @@ public final class ServiceHelper {
     }
 
     private static Object proxyPrivileged(String interface1, String filter, boolean dynamicRebind, BundleContext ctx, ServicePair pair, int timeout) {
-        String[] interfaces = null;
+        String[] interfaces;
         if (interface1 != null) {
             interfaces = new String[]{interface1};
         } else {
             interfaces = (String[]) pair.ref.getProperty(Constants.OBJECTCLASS);
         }
 
-        List<Class<?>> clazz = new ArrayList<Class<?>>(interfaces.length);
+        List<Class<?>> clazz = new ArrayList<>(interfaces.length);
 
         // We load the interface classes the service is registered under using the defining bundle.
         // This is ok because the service must be able to see the classes to be registered using them.
@@ -172,7 +168,7 @@ public final class ServiceHelper {
         Bundle owningBundle = ctx.getBundle();
         ProxyManager proxyManager = Activator.getProxyManager();
 
-        Collection<String> classesNotFound = new ArrayList<String>();
+        Collection<String> classesNotFound = new ArrayList<>();
         for (String interfaceName : interfaces) {
             try {
                 Class<?> potentialClass = serviceProviderBundle.loadClass(interfaceName);
@@ -227,17 +223,13 @@ public final class ServiceHelper {
         ServicePair p = null;
 
         try {
-            ServiceReference[] refs = ctx.getServiceReferences(interface1, filter);
+            ServiceReference<?>[] refs = ctx.getServiceReferences(interface1, filter);
 
             if (refs != null) {
                 // natural order is the exact opposite of the order we desire.
-                Arrays.sort(refs, new Comparator<ServiceReference>() {
-                    public int compare(ServiceReference o1, ServiceReference o2) {
-                        return o2.compareTo(o1);
-                    }
-                });
+                Arrays.sort(refs, Comparator.reverseOrder());
 
-                for (ServiceReference ref : refs) {
+                for (ServiceReference<?> ref : refs) {
                     Object service = ctx.getService(ref);
 
                     if (service != null) {
@@ -259,9 +251,9 @@ public final class ServiceHelper {
         return p;
     }
 
-    public static ServiceReference[] getServiceReferences(BundleContext ctx, String interface1,
+    public static ServiceReference<?>[] getServiceReferences(BundleContext ctx, String interface1,
                                                           String filter, String serviceName, Map<String, Object> env) throws NamingException {
-        ServiceReference[] refs = null;
+        ServiceReference<?>[] refs;
 
         try {
             refs = ctx.getServiceReferences(interface1, filter);
@@ -276,17 +268,13 @@ public final class ServiceHelper {
 
         if (refs != null) {
             // natural order is the exact opposite of the order we desire.
-            Arrays.sort(refs, new Comparator<ServiceReference>() {
-                public int compare(ServiceReference o1, ServiceReference o2) {
-                    return o2.compareTo(o1);
-                }
-            });
+            Arrays.sort(refs, Comparator.reverseOrder());
         }
 
         return refs;
     }
 
-    public static Object getService(BundleContext ctx, ServiceReference ref) {
+    public static Object getService(BundleContext ctx, ServiceReference<?> ref) {
         Object service = ctx.getService(ref);
         if (service == null) {
             return null;
@@ -299,7 +287,7 @@ public final class ServiceHelper {
     }
 
     static Collection<Class<?>> getAllInterfaces(Class<?>[] baseInterfaces) {
-        Set<Class<?>> result = new HashSet<Class<?>>();
+        Set<Class<?>> result = new HashSet<>();
         for (Class<?> c : baseInterfaces) {
             if (!c.equals(Object.class)) {
                 result.add(c);
@@ -326,11 +314,7 @@ public final class ServiceHelper {
         public void bundleChanged(BundleEvent event) {
             if (event.getType() == BundleEvent.STOPPED) {
                 Bundle b = event.getBundle();
-                Iterator<ServiceKey> keys = cache.keySet().iterator();
-                while (keys.hasNext()) {
-                    ServiceKey key = keys.next();
-                    if (key.requesting == b) keys.remove();
-                }
+                cache.keySet().removeIf(key -> key.requesting == b);
             }
         }
 
@@ -352,11 +336,9 @@ public final class ServiceHelper {
 
         public void add(final BundleContext ctx, ServiceKey k) {
             // try to use the system bundle for our listener, if that fails we fall back to the calling context
-            BundleContext systemBundle = AccessController.doPrivileged(new PrivilegedAction<BundleContext>() {
-                public BundleContext run() {
-                    Bundle system = ctx.getBundle(0);
-                    return system == null ? null : system.getBundleContext();
-                }
+            BundleContext systemBundle = AccessController.doPrivileged((PrivilegedAction<BundleContext>) () -> {
+                Bundle system = ctx.getBundle(0);
+                return system == null ? null : system.getBundleContext();
             });
             if (systemBundle == null) systemBundle = ctx;
             systemBundle.addBundleListener(cacheClearoutListener);
@@ -439,7 +421,7 @@ public final class ServiceHelper {
     }
 
     private static class ServicePair {
-        private ServiceReference ref;
+        private ServiceReference<?> ref;
         private Object service;
     }
 }

Modified: aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/AbstractName.java
URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/AbstractName.java?rev=1824948&r1=1824947&r2=1824948&view=diff
==============================================================================
--- aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/AbstractName.java (original)
+++ aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/AbstractName.java Wed Feb 21 09:05:35 2018
@@ -32,7 +32,7 @@ public abstract class AbstractName exten
     }
 
     protected static Enumeration<String> split(String name) {
-        List<String> elements = new ArrayList<String>();
+        List<String> elements = new ArrayList<>();
 
         StringBuilder builder = new StringBuilder();
 

Modified: aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/AbstractServiceRegistryContext.java
URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/AbstractServiceRegistryContext.java?rev=1824948&r1=1824947&r2=1824948&view=diff
==============================================================================
--- aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/AbstractServiceRegistryContext.java (original)
+++ aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/AbstractServiceRegistryContext.java Wed Feb 21 09:05:35 2018
@@ -64,9 +64,9 @@ public abstract class AbstractServiceReg
 
     @SuppressWarnings("unchecked")
     public AbstractServiceRegistryContext(BundleContext callerContext, Map<?, ?> environment) {
-        env = new HashMap<String, Object>();
-        env.putAll((Map<? extends String, ? extends Object>) environment);
-        Hashtable<String, Object> environmentHT = new Hashtable<String, Object>();
+        env = new HashMap<>();
+        env.putAll((Map<? extends String, Object>) environment);
+        Hashtable<String, Object> environmentHT = new Hashtable<>();
         environmentHT.putAll(env);
         // ARIES-397: If the caller has provided a BundleContext
         // in the hashtable, use this in preference to callerContext

Modified: aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/Activator.java
URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/Activator.java?rev=1824948&r1=1824947&r2=1824948&view=diff
==============================================================================
--- aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/Activator.java (original)
+++ aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/Activator.java Wed Feb 21 09:05:35 2018
@@ -28,7 +28,6 @@ import org.osgi.framework.ServiceRegistr
 import org.osgi.service.jndi.JNDIConstants;
 
 import javax.naming.spi.ObjectFactory;
-import java.util.Dictionary;
 import java.util.Hashtable;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -46,7 +45,7 @@ public class Activator implements Bundle
     @Override
     public void start(BundleContext context) {
         ctx = context;
-        proxyManager = new SingleServiceTracker<ProxyManager>(context, ProxyManager.class, this);
+        proxyManager = new SingleServiceTracker<>(context, ProxyManager.class, this);
         proxyManager.open();
         // Blueprint URL scheme requires access to the BlueprintContainer service.
         // We have an optional import
@@ -54,10 +53,10 @@ public class Activator implements Bundle
         // scheme if it's present
         try {
             ctx.getBundle().loadClass("org.osgi.service.blueprint.container.BlueprintContainer");
-            Hashtable<Object, Object> blueprintURlSchemeProps = new Hashtable<Object, Object>();
+            Hashtable<String, Object> blueprintURlSchemeProps = new Hashtable<>();
             blueprintURlSchemeProps.put(JNDIConstants.JNDI_URLSCHEME, new String[]{"blueprint"});
             blueprintUrlReg = ctx.registerService(ObjectFactory.class.getName(),
-                    new BlueprintURLContextServiceFactory(), (Dictionary) blueprintURlSchemeProps);
+                    new BlueprintURLContextServiceFactory(), blueprintURlSchemeProps);
         } catch (ClassNotFoundException cnfe) {
             // The blueprint packages aren't available, so do nothing. That's fine.
             Logger logger = Logger.getLogger("org.apache.aries.jndi");
@@ -75,10 +74,10 @@ public class Activator implements Bundle
 
     @Override
     public void serviceFound() {
-        Hashtable<Object, Object> osgiUrlprops = new Hashtable<Object, Object>();
+        Hashtable<String, Object> osgiUrlprops = new Hashtable<>();
         osgiUrlprops.put(JNDIConstants.JNDI_URLSCHEME, new String[]{"osgi", "aries"});
         osgiUrlReg = ctx.registerService(ObjectFactory.class.getName(),
-                new OsgiURLContextServiceFactory(), (Dictionary) osgiUrlprops);
+                new OsgiURLContextServiceFactory(), osgiUrlprops);
     }
 
     @Override

Modified: aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/BlueprintURLContext.java
URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/BlueprintURLContext.java?rev=1824948&r1=1824947&r2=1824948&view=diff
==============================================================================
--- aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/BlueprintURLContext.java (original)
+++ aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/BlueprintURLContext.java Wed Feb 21 09:05:35 2018
@@ -49,8 +49,8 @@ public class BlueprintURLContext impleme
     @SuppressWarnings("unchecked")
     public BlueprintURLContext(Bundle callersBundle, Hashtable<?, ?> env) {
         _callersBundle = callersBundle;
-        _env = new HashMap<String, Object>();
-        _env.putAll((Map<? extends String, ? extends Object>) env);
+        _env = new HashMap<>();
+        _env.putAll((Map<? extends String, Object>) env);
         _parentName = null;
     }
 
@@ -66,12 +66,12 @@ public class BlueprintURLContext impleme
      * @param b Bundle to look in
      * @return BlueprintContainer service, or null if none available
      */
-    private static ServiceReference findBPCRef(Bundle b) {
-        ServiceReference[] refs = b.getRegisteredServices();
-        ServiceReference result = null;
+    private static ServiceReference<BlueprintContainer> findBPCRef(Bundle b) {
+        ServiceReference<?>[] refs = b.getRegisteredServices();
+        ServiceReference<?> result = null;
         if (refs != null) {
             outer:
-            for (ServiceReference r : refs) {
+            for (ServiceReference<?> r : refs) {
                 String[] objectClasses = (String[]) r.getProperty(Constants.OBJECTCLASS);
                 for (String objectClass : objectClasses) {
                     if (objectClass.equals(BlueprintContainer.class.getName())) {
@@ -84,7 +84,7 @@ public class BlueprintURLContext impleme
                 }
             }
         }
-        return result;
+        return (ServiceReference<BlueprintContainer>) result;
     }
 
     /**
@@ -95,12 +95,12 @@ public class BlueprintURLContext impleme
      * @return BlueprintContainerService instance for that bundle
      * @throws ServiceUnavailableException If no BlueprinContainerService found
      */
-    private static ServiceReference getBlueprintContainerRef(Bundle b) throws ServiceUnavailableException {
-        ServiceReference result = findBPCRef(b);
+    private static ServiceReference<BlueprintContainer> getBlueprintContainerRef(Bundle b) throws ServiceUnavailableException {
+        ServiceReference<BlueprintContainer> result = findBPCRef(b);
         if (result == null) {
             Semaphore s = new Semaphore(0);
-            AtomicReference<ServiceReference> bpcRef = new AtomicReference<ServiceReference>();
-            ServiceTracker st = new ServiceTracker(b.getBundleContext(), BlueprintContainer.class.getName(),
+            AtomicReference<ServiceReference<BlueprintContainer>> bpcRef = new AtomicReference<>();
+            ServiceTracker<BlueprintContainer, BlueprintContainer> st = new ServiceTracker<>(b.getBundleContext(), BlueprintContainer.class,
                     new BlueprintContainerServiceTrackerCustomizer(b, s, bpcRef));
             st.open();
 
@@ -140,7 +140,7 @@ public class BlueprintURLContext impleme
     public static int getGracePeriod(Bundle b) {
         int result = 300000;            // Blueprint default
         boolean gracePeriodSet = true;  // Blueprint default
-        String bundleSymbolicName = (String) b.getHeaders().get(Constants.BUNDLE_SYMBOLICNAME);
+        String bundleSymbolicName = b.getHeaders().get(Constants.BUNDLE_SYMBOLICNAME);
 
         // I'd like to use ManifestHeaderProcessor here but as of December 15th 2010 it lives
         // application-utils, and I don't want to make that a dependency of jndi-url
@@ -235,7 +235,7 @@ public class BlueprintURLContext impleme
 
     @Override
     public Hashtable<?, ?> getEnvironment() throws NamingException {
-        Hashtable<Object, Object> environment = new Hashtable<Object, Object>();
+        Hashtable<Object, Object> environment = new Hashtable<>();
         environment.putAll(_env);
         return environment;
     }
@@ -262,14 +262,8 @@ public class BlueprintURLContext impleme
 
     @Override
     public NamingEnumeration<NameClassPair> list(String s) throws NamingException {
-        NamingEnumeration<NameClassPair> result = new BlueprintComponentNamingEnumeration<NameClassPair>(_callersBundle, new ComponentProcessor<NameClassPair>() {
-            @Override
-            public NameClassPair get(Binding b) {
-                NameClassPair result = new NameClassPair(b.getName(), b.getClassName());
-                return result;
-            }
-        });
-        return result;
+        return new BlueprintComponentNamingEnumeration<>(_callersBundle,
+                b -> new NameClassPair(b.getName(), b.getClassName()));
     }
 
     @Override
@@ -280,22 +274,15 @@ public class BlueprintURLContext impleme
     @Override
     public NamingEnumeration<Binding> listBindings(String name)
             throws NamingException {
-        NamingEnumeration<Binding> result = new BlueprintComponentNamingEnumeration<Binding>(_callersBundle, new ComponentProcessor<Binding>() {
-            @Override
-            public Binding get(Binding b) {
-                return b;
-            }
-        });
-        return result;
+        return new BlueprintComponentNamingEnumeration<>(_callersBundle, b -> b);
     }
 
     @Override
     public Object lookup(Name name) throws NamingException, ServiceUnavailableException {
-        ServiceReference blueprintContainerRef = getBlueprintContainerRef(_callersBundle);
+        ServiceReference<BlueprintContainer> blueprintContainerRef = getBlueprintContainerRef(_callersBundle);
         Object result;
         try {
-            BlueprintContainer blueprintContainer = (BlueprintContainer)
-                    _callersBundle.getBundleContext().getService(blueprintContainerRef);
+            BlueprintContainer blueprintContainer = _callersBundle.getBundleContext().getService(blueprintContainerRef);
             BlueprintName bpName;
             if (name instanceof BlueprintName) {
                 bpName = (BlueprintName) name;
@@ -437,20 +424,20 @@ public class BlueprintURLContext impleme
 
     }
 
-    private static class BlueprintContainerServiceTrackerCustomizer implements ServiceTrackerCustomizer {
-        Bundle bundleToFindBPCServiceIn = null;
+    private static class BlueprintContainerServiceTrackerCustomizer implements ServiceTrackerCustomizer<BlueprintContainer, BlueprintContainer> {
+        Bundle bundleToFindBPCServiceIn;
         Semaphore semaphore;
-        AtomicReference<ServiceReference> atomicRef = null;
+        AtomicReference<ServiceReference<BlueprintContainer>> atomicRef;
 
-        public BlueprintContainerServiceTrackerCustomizer(Bundle b, Semaphore s, AtomicReference<ServiceReference> aref) {
+        public BlueprintContainerServiceTrackerCustomizer(Bundle b, Semaphore s, AtomicReference<ServiceReference<BlueprintContainer>> aref) {
             bundleToFindBPCServiceIn = b;
             semaphore = s;
             atomicRef = aref;
         }
 
         @Override
-        public Object addingService(ServiceReference reference) {
-            Object result = null;
+        public BlueprintContainer addingService(ServiceReference<BlueprintContainer> reference) {
+            BlueprintContainer result = null;
             if (bundleToFindBPCServiceIn.equals(reference.getBundle())) {
                 atomicRef.set(reference);
                 semaphore.release();
@@ -460,11 +447,11 @@ public class BlueprintURLContext impleme
         }
 
         @Override
-        public void modifiedService(ServiceReference reference, Object service) {
+        public void modifiedService(ServiceReference<BlueprintContainer> reference, BlueprintContainer service) {
         }
 
         @Override
-        public void removedService(ServiceReference reference, Object service) {
+        public void removedService(ServiceReference<BlueprintContainer> reference, BlueprintContainer service) {
         }
     }
 

Modified: aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/BlueprintURLContextFactory.java
URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/BlueprintURLContextFactory.java?rev=1824948&r1=1824947&r2=1824948&view=diff
==============================================================================
--- aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/BlueprintURLContextFactory.java (original)
+++ aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/BlueprintURLContextFactory.java Wed Feb 21 09:05:35 2018
@@ -44,7 +44,7 @@ public class BlueprintURLContextFactory
 
         if (augmenterInvoker == null && _callersBundle != null) {
             BundleContext callerBundleContext = _callersBundle.getBundleContext();
-            ServiceReference augmenterSR = callerBundleContext.getServiceReference(AugmenterInvoker.class.getName());
+            ServiceReference<?> augmenterSR = callerBundleContext.getServiceReference(AugmenterInvoker.class.getName());
             if (augmenterSR != null) augmenterInvoker = (AugmenterInvoker) callerBundleContext.getService(augmenterSR);
         }
         if (augmenterInvoker != null) augmenterInvoker.augmentEnvironment(envmt);
@@ -55,18 +55,13 @@ public class BlueprintURLContextFactory
         Bundle b = (bc != null) ? bc.getBundle() : null;
         Object result = null;
         if (obj == null) {
-            result = new BlueprintURLContext((b == null) ? _callersBundle : b,
-                    envmt);
+            result = new BlueprintURLContext((b == null) ? _callersBundle : b, envmt);
         } else if (obj instanceof String) {
-            Context ctx = null;
+            Context ctx = new BlueprintURLContext((b == null) ? _callersBundle : b, envmt);
             try {
-                ctx = new BlueprintURLContext((b == null) ? _callersBundle : b,
-                        envmt);
                 result = ctx.lookup((String) obj);
             } finally {
-                if (ctx != null) {
-                    ctx.close();
-                }
+                ctx.close();
             }
         }
         return result;

Modified: aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/BlueprintURLContextServiceFactory.java
URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/BlueprintURLContextServiceFactory.java?rev=1824948&r1=1824947&r2=1824948&view=diff
==============================================================================
--- aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/BlueprintURLContextServiceFactory.java (original)
+++ aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/BlueprintURLContextServiceFactory.java Wed Feb 21 09:05:35 2018
@@ -23,18 +23,20 @@ import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceFactory;
 import org.osgi.framework.ServiceRegistration;
 
+import javax.naming.spi.ObjectFactory;
+
 
 /**
  * A factory for the aries blueprint context
  */
-public class BlueprintURLContextServiceFactory implements ServiceFactory {
+public class BlueprintURLContextServiceFactory implements ServiceFactory<ObjectFactory> {
 
     @Override
-    public Object getService(Bundle bundle, ServiceRegistration registration) {
+    public ObjectFactory getService(Bundle bundle, ServiceRegistration<ObjectFactory> registration) {
         return new BlueprintURLContextFactory(bundle);
     }
 
     @Override
-    public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
+    public void ungetService(Bundle bundle, ServiceRegistration registration, ObjectFactory service) {
     }
 }

Modified: aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/OsgiNameParser.java
URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/OsgiNameParser.java?rev=1824948&r1=1824947&r2=1824948&view=diff
==============================================================================
--- aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/OsgiNameParser.java (original)
+++ aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/OsgiNameParser.java Wed Feb 21 09:05:35 2018
@@ -40,17 +40,17 @@ public final class OsgiNameParser implem
         String urlScheme = result.getScheme();
         String schemePath = result.getSchemePath();
 
-        if (!!!(OSGI_SCHEME.equals(urlScheme) || ARIES_SCHEME.equals(urlScheme))) {
+        if (!(OSGI_SCHEME.equals(urlScheme) || ARIES_SCHEME.equals(urlScheme))) {
             throw new InvalidNameException(name);
         }
 
-        if (ARIES_SCHEME.equals(urlScheme) && !!!SERVICES_PATH.equals(schemePath)) {
+        if (ARIES_SCHEME.equals(urlScheme) && !SERVICES_PATH.equals(schemePath)) {
             throw new InvalidNameException(name);
         }
 
-        if (OSGI_SCHEME.equals(urlScheme) && !!!(SERVICE_PATH.equals(schemePath) ||
-                SERVICE_LIST_PATH.equals(schemePath) ||
-                FRAMEWORK_PATH.equals(schemePath))) {
+        if (OSGI_SCHEME.equals(urlScheme) && !(SERVICE_PATH.equals(schemePath)
+                || SERVICE_LIST_PATH.equals(schemePath)
+                || FRAMEWORK_PATH.equals(schemePath))) {
             throw new InvalidNameException(name);
         }
 

Modified: aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/OsgiURLContextServiceFactory.java
URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/OsgiURLContextServiceFactory.java?rev=1824948&r1=1824947&r2=1824948&view=diff
==============================================================================
--- aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/OsgiURLContextServiceFactory.java (original)
+++ aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/OsgiURLContextServiceFactory.java Wed Feb 21 09:05:35 2018
@@ -22,16 +22,18 @@ import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceFactory;
 import org.osgi.framework.ServiceRegistration;
 
+import javax.naming.spi.ObjectFactory;
+
 /**
  * A factory for the aries JNDI context
  */
-public class OsgiURLContextServiceFactory implements ServiceFactory {
+public class OsgiURLContextServiceFactory implements ServiceFactory<ObjectFactory> {
 
-    public Object getService(Bundle bundle, ServiceRegistration registration) {
+    public ObjectFactory getService(Bundle bundle, ServiceRegistration<ObjectFactory> registration) {
         return new OsgiURLContextFactory(bundle.getBundleContext());
     }
 
-    public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
+    public void ungetService(Bundle bundle, ServiceRegistration<ObjectFactory> registration, ObjectFactory service) {
     }
 
 }

Modified: aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/ServiceRegistryListContext.java
URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/ServiceRegistryListContext.java?rev=1824948&r1=1824947&r2=1824948&view=diff
==============================================================================
--- aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/ServiceRegistryListContext.java (original)
+++ aries/trunk/jndi/jndi-url/src/main/java/org/apache/aries/jndi/url/ServiceRegistryListContext.java Wed Feb 21 09:05:35 2018
@@ -43,17 +43,17 @@ public class ServiceRegistryListContext
     }
 
     public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
-        if (!!!"".equals(name)) throw new NameNotFoundException(name);
+        if (!"".equals(name)) throw new NameNotFoundException(name);
         final ServiceReference[] refs = getServiceRefs();
-        return new ServiceNamingEnumeration<NameClassPair>(callerContext, refs, new ThingManager<NameClassPair>() {
-            public NameClassPair get(BundleContext ctx, ServiceReference ref) {
+        return new ServiceNamingEnumeration<>(callerContext, refs, new ThingManager<NameClassPair>() {
+            public NameClassPair get(BundleContext ctx, ServiceReference<?> ref) {
                 Object service = ctx.getService(ref);
                 String className = (service != null) ? service.getClass().getName() : null;
                 ctx.ungetService(ref);
                 return new NameClassPair(serviceId(ref), className, true);
             }
 
-            public void release(BundleContext ctx, ServiceReference ref) {
+            public void release(BundleContext ctx, ServiceReference<?> ref) {
             }
         });
     }
@@ -63,15 +63,15 @@ public class ServiceRegistryListContext
     }
 
     public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
-        if (!!!"".equals(name)) throw new NameNotFoundException(name);
-        final ServiceReference[] refs = getServiceRefs();
-        return new ServiceNamingEnumeration<Binding>(callerContext, refs, new ThingManager<Binding>() {
-            public Binding get(BundleContext ctx, ServiceReference ref) {
+        if (!"".equals(name)) throw new NameNotFoundException(name);
+        final ServiceReference<?>[] refs = getServiceRefs();
+        return new ServiceNamingEnumeration<>(callerContext, refs, new ThingManager<Binding>() {
+            public Binding get(BundleContext ctx, ServiceReference<?> ref) {
                 Object service = ServiceHelper.getService(ctx, ref);
                 return new Binding(serviceId(ref), service, true);
             }
 
-            public void release(BundleContext ctx, ServiceReference ref) {
+            public void release(BundleContext ctx, ServiceReference<?> ref) {
                 ctx.ungetService(ref);
             }
         });
@@ -84,7 +84,7 @@ public class ServiceRegistryListContext
     public Object lookup(String name) throws NamingException {
         Object result = ServiceHelper.getService(callerContext, parentName, name, false, env, true);
         if (result == null) {
-            throw new NameNotFoundException(name.toString());
+            throw new NameNotFoundException(name);
         }
         return result;
     }
@@ -93,24 +93,24 @@ public class ServiceRegistryListContext
         return String.valueOf(ref.getProperty(Constants.SERVICE_ID));
     }
 
-    private ServiceReference[] getServiceRefs() throws NamingException {
+    private ServiceReference<?>[] getServiceRefs() throws NamingException {
         return ServiceHelper.getServiceReferences(callerContext, parentName.getInterface(), parentName.getFilter(), parentName.getServiceName(), env);
     }
 
     private interface ThingManager<T> {
-        public T get(BundleContext ctx, ServiceReference ref);
+        T get(BundleContext ctx, ServiceReference<?> ref);
 
-        public void release(BundleContext ctx, ServiceReference ref);
+        void release(BundleContext ctx, ServiceReference<?> ref);
     }
 
     private static class ServiceNamingEnumeration<T> implements NamingEnumeration<T> {
         private BundleContext ctx;
-        private ServiceReference[] refs;
+        private ServiceReference<?>[] refs;
         private int position = 0;
         private ThingManager<T> mgr;
         private T last;
 
-        private ServiceNamingEnumeration(BundleContext context, ServiceReference[] theRefs, ThingManager<T> manager) {
+        private ServiceNamingEnumeration(BundleContext context, ServiceReference<?>[] theRefs, ThingManager<T> manager) {
             ctx = context;
             refs = (theRefs != null) ? theRefs : new ServiceReference[0];
             mgr = manager;
@@ -134,7 +134,7 @@ public class ServiceRegistryListContext
         }
 
         public T nextElement() {
-            if (!!!hasMoreElements()) throw new NoSuchElementException();
+            if (!hasMoreElements()) throw new NoSuchElementException();
 
             if (position > 0) mgr.release(ctx, refs[position - 1]);