aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1824940 - /aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/tracker/ServiceTrackerCustomizers.java
Date Wed, 21 Feb 2018 09:03:57 GMT
Author: gnodet
Date: Wed Feb 21 09:03:57 2018
New Revision: 1824940

URL: http://svn.apache.org/viewvc?rev=1824940&view=rev
Log:
[jndi] Reformat class

Modified:
    aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/tracker/ServiceTrackerCustomizers.java

Modified: aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/tracker/ServiceTrackerCustomizers.java
URL: http://svn.apache.org/viewvc/aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/tracker/ServiceTrackerCustomizers.java?rev=1824940&r1=1824939&r2=1824940&view=diff
==============================================================================
--- aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/tracker/ServiceTrackerCustomizers.java
(original)
+++ aries/trunk/jndi/jndi-core/src/main/java/org/apache/aries/jndi/tracker/ServiceTrackerCustomizers.java
Wed Feb 21 09:03:57 2018
@@ -33,105 +33,106 @@ import org.osgi.service.jndi.JNDIConstan
 import org.osgi.util.tracker.ServiceTrackerCustomizer;
 
 
-public class ServiceTrackerCustomizers 
-{
-  public static interface CachingServiceTracker extends ServiceTrackerCustomizer {
-    public ServiceReference find(String identifier);
-  }
-  
-  private static abstract class BaseCachingServiceTracker implements CachingServiceTracker
{
-    /** The cached references */
-    protected ConcurrentMap<String, ServiceReference> cache = new ConcurrentHashMap<String,
ServiceReference>();
-    /** A list of service references that are being tracked */
-    protected List<ServiceReference> trackedReferences = new ArrayList<ServiceReference>();
-
-    public ServiceReference find(String identifier) 
-    {
-      return cache.get(identifier);
-    }
+public class ServiceTrackerCustomizers {
 
-    public synchronized Object addingService(ServiceReference reference) 
-    {
-      List<String> cacheKeys = getProperty(reference);
-      
-      for (String key : cacheKeys) { 
-        cache.putIfAbsent(key, reference);
-      }
-      
-      trackedReferences.add(reference);
-      
-      return reference;
+    public interface CachingServiceTracker extends ServiceTrackerCustomizer {
+        ServiceReference find(String identifier);
     }
 
-    protected abstract List<String> getProperty(ServiceReference reference);
+    private static abstract class BaseCachingServiceTracker implements CachingServiceTracker
{
+        /** The cached references */
+        protected ConcurrentMap<String, ServiceReference> cache = new ConcurrentHashMap<String,
ServiceReference>();
+        /** A list of service references that are being tracked */
+        protected List<ServiceReference> trackedReferences = new ArrayList<ServiceReference>();
+
+        public ServiceReference find(String identifier) {
+            return cache.get(identifier);
+        }
+
+        public synchronized Object addingService(ServiceReference reference) {
+            List<String> cacheKeys = getProperty(reference);
 
-    public synchronized void removedService(ServiceReference reference, Object service) 
-    {
-      trackedReferences.remove(reference);
-      
-      List<String> keysToProcess = new ArrayList<String>(getProperty(reference));
-      
-      refLoop: for (ServiceReference ref : trackedReferences) {
-        List<String> refInt = getProperty(ref);
-        for (String interfaceName : refInt) {
-          int index = keysToProcess.indexOf(interfaceName);
-          if (index >= 0) {
-            keysToProcess.remove(index);
-            if (cache.replace(interfaceName, reference, ref)) {
-              if (keysToProcess.isEmpty()) break refLoop;
+            for (String key : cacheKeys) {
+                cache.putIfAbsent(key, reference);
             }
-          }
+
+            trackedReferences.add(reference);
+
+            return reference;
         }
-      }
-      
-      for (String interfaceName : keysToProcess) {
-        cache.remove(interfaceName, reference);
-      }
-    }
 
-    public void modifiedService(ServiceReference reference, Object service) { }
-  }
-  
-  public static final ServiceTrackerCustomizer LAZY = new ServiceTrackerCustomizer() {
-    public Object addingService(ServiceReference reference) 
-    {
-      return reference;
-    }
-    public void modifiedService(ServiceReference reference, Object service)  { }
-    public void removedService(ServiceReference reference, Object service)  { }
-  };
-
-  public static final CachingServiceTracker ICF_CACHE = new BaseCachingServiceTracker() {
-    public List<String> getProperty(ServiceReference ref)
-    {
-      String[] interfaces = (String[]) ref.getProperty(Constants.OBJECTCLASS);
-      List<String> resultList = new ArrayList<String>();
-      for (String interfaceName : interfaces) {
-        if (!!!InitialContextFactory.class.getName().equals(interfaceName)) {
-          resultList.add(interfaceName);
-        }
-      }
-      
-      return resultList;
-    }
-  };
-  
-  // TODO we should probably cope with the url.scheme property changing.
-  public static final CachingServiceTracker URL_FACTORY_CACHE = new BaseCachingServiceTracker()
{
-    protected List<String> getProperty(ServiceReference reference) {
-      Object scheme = reference.getProperty(JNDIConstants.JNDI_URLSCHEME);
-      List<String> result;
-      
-      if (scheme instanceof String) {
-        result = new ArrayList<String>();
-        result.add((String) scheme);
-      } else if (scheme instanceof String[]) {
-        result = Arrays.asList((String[])scheme);
-      } else {
-        result = Collections.emptyList();
-      }
-      
-      return result;
+        protected abstract List<String> getProperty(ServiceReference reference);
+
+        public synchronized void removedService(ServiceReference reference, Object service)
{
+            trackedReferences.remove(reference);
+
+            List<String> keysToProcess = new ArrayList<String>(getProperty(reference));
+
+            refLoop:
+            for (ServiceReference ref : trackedReferences) {
+                List<String> refInt = getProperty(ref);
+                for (String interfaceName : refInt) {
+                    int index = keysToProcess.indexOf(interfaceName);
+                    if (index >= 0) {
+                        keysToProcess.remove(index);
+                        if (cache.replace(interfaceName, reference, ref)) {
+                            if (keysToProcess.isEmpty()) break refLoop;
+                        }
+                    }
+                }
+            }
+
+            for (String interfaceName : keysToProcess) {
+                cache.remove(interfaceName, reference);
+            }
+        }
+
+        public void modifiedService(ServiceReference reference, Object service) {
+        }
     }
-  };
+
+    public static final ServiceTrackerCustomizer LAZY = new ServiceTrackerCustomizer() {
+        public Object addingService(ServiceReference reference) {
+            return reference;
+        }
+
+        public void modifiedService(ServiceReference reference, Object service) {
+        }
+
+        public void removedService(ServiceReference reference, Object service) {
+        }
+    };
+
+    public static final CachingServiceTracker ICF_CACHE = new BaseCachingServiceTracker()
{
+        public List<String> getProperty(ServiceReference ref) {
+            String[] interfaces = (String[]) ref.getProperty(Constants.OBJECTCLASS);
+            List<String> resultList = new ArrayList<String>();
+            for (String interfaceName : interfaces) {
+                if (!!!InitialContextFactory.class.getName().equals(interfaceName)) {
+                    resultList.add(interfaceName);
+                }
+            }
+
+            return resultList;
+        }
+    };
+
+    // TODO we should probably cope with the url.scheme property changing.
+    public static final CachingServiceTracker URL_FACTORY_CACHE = new BaseCachingServiceTracker()
{
+        protected List<String> getProperty(ServiceReference reference) {
+            Object scheme = reference.getProperty(JNDIConstants.JNDI_URLSCHEME);
+            List<String> result;
+
+            if (scheme instanceof String) {
+                result = new ArrayList<String>();
+                result.add((String) scheme);
+            } else if (scheme instanceof String[]) {
+                result = Arrays.asList((String[]) scheme);
+            } else {
+                result = Collections.emptyList();
+            }
+
+            return result;
+        }
+    };
 }



Mime
View raw message