felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1747329 [2/3] - in /felix/trunk/scr/src: main/java/org/apache/felix/scr/impl/manager/ test/java/org/apache/felix/scr/integration/ test/java/org/apache/felix/scr/integration/components/felix5276/ test/resources/
Date Wed, 08 Jun 2016 00:14:12 GMT
Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java?rev=1747329&r1=1747328&r2=1747329&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java Wed Jun  8 00:14:12 2016
@@ -18,7 +18,6 @@
  */
 package org.apache.felix.scr.impl.manager;
 
-
 import java.security.Permission;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -48,7 +47,6 @@ import org.osgi.service.component.Compon
 import org.osgi.service.component.ComponentException;
 import org.osgi.service.log.LogService;
 
-
 /**
  * The <code>DependencyManager</code> manages the references to services
  * declared by a single <code>&lt;reference&gt;</code element in component
@@ -83,29 +81,26 @@ public class DependencyManager<S, T> imp
      * @param dependency An object that contains data about the dependency
      * @param index index of the dependency manager in the metadata
      */
-    DependencyManager( AbstractComponentManager<S> componentManager, ReferenceMetadata dependency, int index )
+    DependencyManager(AbstractComponentManager<S> componentManager, ReferenceMetadata dependency, int index)
     {
         m_componentManager = componentManager;
         m_dependencyMetadata = dependency;
         m_index = index;
         m_customizer = newCustomizer();
 
-        m_minCardinality = defaultMinimumCardinality( dependency );
+        m_minCardinality = defaultMinimumCardinality(dependency);
 
         // dump the reference information if DEBUG is enabled
-        if ( m_componentManager.isLogEnabled( LogService.LOG_DEBUG ) )
+        if (m_componentManager.isLogEnabled(LogService.LOG_DEBUG))
         {
-            m_componentManager
-                .log(
-                    LogService.LOG_DEBUG,
-                    "Dependency Manager created " + dependency.getDebugInfo(),
-                    null );
+            m_componentManager.log(LogService.LOG_DEBUG, "Dependency Manager created " + dependency.getDebugInfo(),
+                null);
         }
     }
 
     private static int defaultMinimumCardinality(ReferenceMetadata dependency)
     {
-        return dependency.isOptional()? 0: 1;
+        return dependency.isOptional() ? 0 : 1;
     }
 
     int getIndex()
@@ -118,7 +113,7 @@ public class DependencyManager<S, T> imp
      */
     void initBindingMethods(ReferenceMethods bindMethods)
     {
-       m_bindMethods = bindMethods;
+        m_bindMethods = bindMethods;
     }
 
     private interface Customizer<S, T> extends ServiceTrackerCustomizer<T, RefPair<S, T>, ExtendedServiceEvent>
@@ -133,15 +128,15 @@ public class DependencyManager<S, T> imp
 
         void close();
 
-        Collection<RefPair<S, T>> getRefs( AtomicInteger trackingCount );
+        Collection<RefPair<S, T>> getRefs(AtomicInteger trackingCount);
 
         boolean isSatisfied();
 
-        void setTracker( ServiceTracker<T, RefPair<S, T>, ExtendedServiceEvent> tracker );
+        void setTracker(ServiceTracker<T, RefPair<S, T>, ExtendedServiceEvent> tracker);
 
         void setTrackerOpened();
 
-        void setPreviousRefMap( Map<ServiceReference<T>, RefPair<S, T>> previousRefMap );
+        void setPreviousRefMap(Map<ServiceReference<T>, RefPair<S, T>> previousRefMap);
     }
 
     private abstract class AbstractCustomizer implements Customizer<S, T>
@@ -152,21 +147,22 @@ public class DependencyManager<S, T> imp
 
         private volatile Map<ServiceReference<T>, RefPair<S, T>> previousRefMap = EMPTY_REF_MAP;
 
-        public void setTracker( ServiceTracker<T, RefPair<S, T>, ExtendedServiceEvent> tracker )
+        public void setTracker(ServiceTracker<T, RefPair<S, T>, ExtendedServiceEvent> tracker)
         {
             m_tracker = tracker;
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracker reset (closed)", new Object[] {getName()}, null );
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracker reset (closed)", new Object[] { getName() },
+                null);
             trackerOpened = false;
         }
 
         public boolean isSatisfied()
         {
             ServiceTracker<T, RefPair<S, T>, ExtendedServiceEvent> tracker = getTracker();
-            if ( tracker == null)
+            if (tracker == null)
             {
                 return false;
             }
-            return cardinalitySatisfied( tracker.getServiceCount() );
+            return cardinalitySatisfied(tracker.getServiceCount());
         }
 
         protected ServiceTracker<T, RefPair<S, T>, ExtendedServiceEvent> getTracker()
@@ -191,13 +187,13 @@ public class DependencyManager<S, T> imp
         public void setTrackerOpened()
         {
             trackerOpened = true;
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracker opened", new Object[] {getName()}, null );
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracker opened", new Object[] { getName() }, null);
         }
 
         protected void deactivateTracker()
         {
             ServiceTracker<T, RefPair<S, T>, ExtendedServiceEvent> tracker = getTracker();
-            if ( tracker != null )
+            if (tracker != null)
             {
                 tracker.deactivate();
             }
@@ -208,9 +204,9 @@ public class DependencyManager<S, T> imp
             return previousRefMap;
         }
 
-        public void setPreviousRefMap( Map<ServiceReference<T>, RefPair<S, T>> previousRefMap )
+        public void setPreviousRefMap(Map<ServiceReference<T>, RefPair<S, T>> previousRefMap)
         {
-            if ( previousRefMap != null )
+            if (previousRefMap != null)
             {
                 this.previousRefMap = previousRefMap;
             }
@@ -221,51 +217,54 @@ public class DependencyManager<S, T> imp
 
         }
 
-        protected void ungetService( RefPair<S, T> ref )
+        protected void ungetService(RefPair<S, T> ref)
         {
             Object service = ref.unsetServiceObject(null);
-            if ( service != null )
+            if (service != null)
             {
                 BundleContext bundleContext = m_componentManager.getBundleContext();
-                if ( bundleContext != null )
+                if (bundleContext != null)
                 {
-                    bundleContext.ungetService( ref.getRef() );
+                    bundleContext.ungetService(ref.getRef());
                 }
             }
         }
 
-        protected void tracked( int trackingCount )
+        protected void tracked(int trackingCount)
         {
-            m_componentManager.tracked( trackingCount );
+            m_componentManager.tracked(trackingCount);
         }
 
     }
 
+    private class FactoryCustomizer extends AbstractCustomizer
+    {
 
-    private class FactoryCustomizer extends AbstractCustomizer {
-
-        public RefPair<S, T> addingService( ServiceReference<T> serviceReference )
+        public RefPair<S, T> addingService(ServiceReference<T> serviceReference)
         {
             RefPair<S, T> refPair = newRefPair(serviceReference);
             return refPair;
         }
 
-        public void addedService( ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount, int serviceCount, ExtendedServiceEvent event )
+        public void addedService(ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount,
+            int serviceCount, ExtendedServiceEvent event)
         {
-            if ( cardinalityJustSatisfied( serviceCount ) )
+            if (cardinalityJustSatisfied(serviceCount))
             {
-                m_componentManager.activateInternal( );
+                m_componentManager.activateInternal();
             }
         }
 
-        public void modifiedService( ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount, ExtendedServiceEvent event )
+        public void modifiedService(ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount,
+            ExtendedServiceEvent event)
         {
         }
 
-        public void removedService( ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount, ExtendedServiceEvent event )
+        public void removedService(ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount,
+            ExtendedServiceEvent event)
         {
             refPair.markDeleted();
-            if ( !cardinalitySatisfied( getTracker().getServiceCount() ) )
+            if (!cardinalitySatisfied(getTracker().getServiceCount()))
             {
                 deactivateComponentManager();
             }
@@ -273,9 +272,9 @@ public class DependencyManager<S, T> imp
 
         public boolean prebind(ComponentContextImpl<S> key)
         {
-            AtomicInteger trackingCount = new AtomicInteger( );
-            int serviceCount = getTracker().getTracked( true, trackingCount ).size();
-            return cardinalitySatisfied( serviceCount );
+            AtomicInteger trackingCount = new AtomicInteger();
+            int serviceCount = getTracker().getTracked(true, trackingCount).size();
+            return cardinalitySatisfied(serviceCount);
         }
 
         public void close()
@@ -283,120 +282,139 @@ public class DependencyManager<S, T> imp
             deactivateTracker();
         }
 
-        public Collection<RefPair<S, T>> getRefs( AtomicInteger trackingCount )
+        public Collection<RefPair<S, T>> getRefs(AtomicInteger trackingCount)
         {
             return Collections.emptyList();
         }
     }
 
-    private class MultipleDynamicCustomizer extends AbstractCustomizer {
+    private class MultipleDynamicCustomizer extends AbstractCustomizer
+    {
 
         private RefPair<S, T> lastRefPair;
         private int lastRefPairTrackingCount;
 
-        public RefPair<S, T> addingService( ServiceReference<T> serviceReference )
+        public RefPair<S, T> addingService(ServiceReference<T> serviceReference)
         {
-            RefPair<S, T> refPair = getPreviousRefMap().get( serviceReference );
-            if ( refPair == null )
+            RefPair<S, T> refPair = getPreviousRefMap().get(serviceReference);
+            if (refPair == null)
             {
                 refPair = newRefPair(serviceReference);
             }
             return refPair;
         }
 
-        public void addedService( ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount, int serviceCount, ExtendedServiceEvent event )
+        public void addedService(ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount,
+            int serviceCount, ExtendedServiceEvent event)
         {
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleDynamic added {2} (enter)", new Object[] {getName(), trackingCount, serviceReference}, null );
-        	boolean tracked = false;
-            if ( getPreviousRefMap().remove( serviceReference ) == null )
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleDynamic added {2} (enter)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
+            boolean tracked = false;
+            if (getPreviousRefMap().remove(serviceReference) == null)
             {
                 if (isActive())
                 {
-                    m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleDynamic already active, binding {2}", new Object[] {getName(), trackingCount, serviceReference}, null );
-                    m_componentManager.invokeBindMethod( DependencyManager.this, refPair, trackingCount );
-                    if ( refPair.isFailed() )
+                    m_componentManager.log(LogService.LOG_DEBUG,
+                        "dm {0} tracking {1} MultipleDynamic already active, binding {2}",
+                        new Object[] { getName(), trackingCount, serviceReference }, null);
+                    m_componentManager.invokeBindMethod(DependencyManager.this, refPair, trackingCount);
+                    if (refPair.isFailed())
                     {
-                        m_componentManager.registerMissingDependency( DependencyManager.this, serviceReference, trackingCount );
+                        m_componentManager.registerMissingDependency(DependencyManager.this, serviceReference,
+                            trackingCount);
                     }
                 }
-                else if ( isTrackerOpened() && cardinalityJustSatisfied( serviceCount ) )
+                else if (isTrackerOpened() && cardinalityJustSatisfied(serviceCount))
                 {
-                    m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleDynamic, activating", new Object[] {getName(), trackingCount}, null );
-                    tracked( trackingCount );
+                    m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleDynamic, activating",
+                        new Object[] { getName(), trackingCount }, null);
+                    tracked(trackingCount);
                     tracked = true;
-                    m_componentManager.activateInternal( );
+                    m_componentManager.activateInternal();
                 }
                 else
                 {
-                    m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleDynamic, inactive, doing nothing: tracker opened: {2}, optional: {3}", new Object[] {getName(), trackingCount, isTrackerOpened(), isOptional()}, null );
+                    m_componentManager.log(LogService.LOG_DEBUG,
+                        "dm {0} tracking {1} MultipleDynamic, inactive, doing nothing: tracker opened: {2}, optional: {3}",
+                        new Object[] { getName(), trackingCount, isTrackerOpened(), isOptional() }, null);
                 }
             }
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleDynamic added {2} (exit)", new Object[] {getName(), trackingCount, serviceReference}, null );
-            if ( !tracked )
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleDynamic added {2} (exit)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
+            if (!tracked)
             {
-				tracked(trackingCount);
-			}
+                tracked(trackingCount);
+            }
         }
 
-        public void modifiedService( ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount, ExtendedServiceEvent event )
+        public void modifiedService(ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount,
+            ExtendedServiceEvent event)
         {
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleDynamic modified {2} (enter)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleDynamic modified {2} (enter)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
             if (isActive())
             {
-                m_componentManager.invokeUpdatedMethod( DependencyManager.this, refPair, trackingCount );
+                m_componentManager.invokeUpdatedMethod(DependencyManager.this, refPair, trackingCount);
             }
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleDynamic modified {2} (exit)", new Object[] {getName(), trackingCount, serviceReference}, null );
-            tracked( trackingCount );
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleDynamic modified {2} (exit)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
+            tracked(trackingCount);
         }
 
-        public void removedService( ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount, ExtendedServiceEvent event )
+        public void removedService(ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount,
+            ExtendedServiceEvent event)
         {
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleDynamic removed {2} (enter)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleDynamic removed {2} (enter)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
             refPair.markDeleted();
-            boolean unbind = cardinalitySatisfied( getTracker().getServiceCount() );
-            if ( unbind )
+            boolean unbind = cardinalitySatisfied(getTracker().getServiceCount());
+            if (unbind)
             {
-                if ( isActive() )
+                if (isActive())
                 {
-                    m_componentManager.invokeUnbindMethod( DependencyManager.this, refPair, trackingCount );
+                    m_componentManager.invokeUnbindMethod(DependencyManager.this, refPair, trackingCount);
                 }
-                m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleDynamic removed (unbind) {2}", new Object[] {getName(), trackingCount, serviceReference}, null );
-                tracked( trackingCount );
+                m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleDynamic removed (unbind) {2}",
+                    new Object[] { getName(), trackingCount, serviceReference }, null);
+                tracked(trackingCount);
             }
             else
             {
                 lastRefPair = refPair;
                 lastRefPairTrackingCount = trackingCount;
-                tracked( trackingCount );
+                tracked(trackingCount);
                 deactivateComponentManager();
                 lastRefPair = null;
-                m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleDynamic removed (deactivate) {2}", new Object[] {getName(), trackingCount, serviceReference}, null );
+                m_componentManager.log(LogService.LOG_DEBUG,
+                    "dm {0} tracking {1} MultipleDynamic removed (deactivate) {2}",
+                    new Object[] { getName(), trackingCount, serviceReference }, null);
             }
-            ungetService( refPair );
+            ungetService(refPair);
         }
 
         public boolean prebind(ComponentContextImpl<S> key)
         {
             int serviceCount = 0;
-            AtomicInteger trackingCount = new AtomicInteger( );
-            SortedMap<ServiceReference<T>, RefPair<S, T>> tracked = getTracker().getTracked( true, trackingCount );
-            List<RefPair<S,T>> failed = new ArrayList<RefPair<S, T>>();
-            for (RefPair<S, T> refPair: tracked.values())
+            AtomicInteger trackingCount = new AtomicInteger();
+            SortedMap<ServiceReference<T>, RefPair<S, T>> tracked = getTracker().getTracked(true, trackingCount);
+            List<RefPair<S, T>> failed = new ArrayList<RefPair<S, T>>();
+            for (RefPair<S, T> refPair : tracked.values())
             {
-                if (getServiceObject( key, m_bindMethods.getBind(), refPair ))
+                if (getServiceObject(key, m_bindMethods.getBind(), refPair))
                 {
-                     serviceCount++;
+                    serviceCount++;
                 }
                 else
                 {
                     failed.add(refPair);
                 }
             }
-            if ( cardinalitySatisfied( serviceCount ) ) 
+            if (cardinalitySatisfied(serviceCount))
             {
-                for ( RefPair<S, T> refPair: failed) 
+                for (RefPair<S, T> refPair : failed)
                 {
-                    m_componentManager.registerMissingDependency( DependencyManager.this, refPair.getRef(), trackingCount.get() );                    
+                    m_componentManager.registerMissingDependency(DependencyManager.this, refPair.getRef(),
+                        trackingCount.get());
                 }
                 return true;
             }
@@ -405,52 +423,54 @@ public class DependencyManager<S, T> imp
 
         public void close()
         {
-            AtomicInteger trackingCount = new AtomicInteger( );
-            for ( RefPair<S, T> ref : getRefs( trackingCount ) )
+            AtomicInteger trackingCount = new AtomicInteger();
+            for (RefPair<S, T> ref : getRefs(trackingCount))
             {
-                ungetService( ref );
+                ungetService(ref);
             }
             deactivateTracker();
         }
 
-
-        public Collection<RefPair<S, T>> getRefs( AtomicInteger trackingCount )
+        public Collection<RefPair<S, T>> getRefs(AtomicInteger trackingCount)
         {
-            if ( lastRefPair == null )
+            if (lastRefPair == null)
             {
                 ServiceTracker<T, RefPair<S, T>, ExtendedServiceEvent> tracker = getTracker();
-                if (tracker == null) {
-                    trackingCount.set( lastRefPairTrackingCount );
+                if (tracker == null)
+                {
+                    trackingCount.set(lastRefPairTrackingCount);
                     return Collections.emptyList();
                 }
-                return getTracker().getTracked( null, trackingCount ).values();
+                return getTracker().getTracked(null, trackingCount).values();
             }
             else
             {
-                trackingCount.set( lastRefPairTrackingCount );
-                return Collections.singletonList( lastRefPair );
+                trackingCount.set(lastRefPairTrackingCount);
+                return Collections.singletonList(lastRefPair);
             }
         }
     }
 
-    private class MultipleStaticGreedyCustomizer extends AbstractCustomizer {
-
+    private class MultipleStaticGreedyCustomizer extends AbstractCustomizer
+    {
 
-        public RefPair<S, T> addingService( ServiceReference<T> serviceReference )
+        public RefPair<S, T> addingService(ServiceReference<T> serviceReference)
         {
             RefPair<S, T> refPair = newRefPair(serviceReference);
             return refPair;
         }
 
-        public void addedService( ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount, int serviceCount, ExtendedServiceEvent event )
+        public void addedService(ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount,
+            int serviceCount, ExtendedServiceEvent event)
         {
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticGreedy added {2} (enter)", new Object[] {getName(), trackingCount, serviceReference}, null );
-            tracked( trackingCount );
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticGreedy added {2} (enter)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
+            tracked(trackingCount);
             if (isActive())
             {
-                m_componentManager.log( LogService.LOG_DEBUG,
-                        "Dependency Manager: Static dependency on {0}/{1} is broken", new Object[]
-                        {getName(), m_dependencyMetadata.getInterface()}, null );
+                m_componentManager.log(LogService.LOG_DEBUG,
+                    "Dependency Manager: Static dependency on {0}/{1} is broken",
+                    new Object[] { getName(), m_dependencyMetadata.getInterface() }, null);
                 deactivateComponentManager();
                 //event may be null during initial operations.
                 if (event != null)
@@ -459,23 +479,27 @@ public class DependencyManager<S, T> imp
                 }
 
             }
-            else if ( isTrackerOpened() && cardinalityJustSatisfied( serviceCount ) )
+            else if (isTrackerOpened() && cardinalityJustSatisfied(serviceCount))
             {
-                m_componentManager.activateInternal( );
+                m_componentManager.activateInternal();
             }
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticGreedy added {2} (exit)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticGreedy added {2} (exit)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
         }
 
-        public void modifiedService( ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount, ExtendedServiceEvent event )
+        public void modifiedService(ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount,
+            ExtendedServiceEvent event)
         {
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticGreedy modified {2} (enter)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            m_componentManager.log(LogService.LOG_DEBUG,
+                "dm {0} tracking {1} MultipleStaticGreedy modified {2} (enter)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
             boolean reactivate = false;
             if (isActive())
             {
-            	reactivate = m_componentManager.invokeUpdatedMethod( DependencyManager.this, refPair, trackingCount );
+                reactivate = m_componentManager.invokeUpdatedMethod(DependencyManager.this, refPair, trackingCount);
             }
-            tracked( trackingCount );
-            if ( reactivate )
+            tracked(trackingCount);
+            if (reactivate)
             {
                 deactivateComponentManager();
                 if (event != null)
@@ -483,20 +507,23 @@ public class DependencyManager<S, T> imp
                     event.addComponentManager(m_componentManager);
                 }
             }
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticGreedy modified {2} (exit)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticGreedy modified {2} (exit)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
         }
 
-        public void removedService( ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount, ExtendedServiceEvent event )
+        public void removedService(ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount,
+            ExtendedServiceEvent event)
         {
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticGreedy removed {2} (enter)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticGreedy removed {2} (enter)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
             refPair.markDeleted();
-            tracked( trackingCount );
-            if ( isActive() )
+            tracked(trackingCount);
+            if (isActive())
             {
                 //deactivate while ref is still tracked
-                m_componentManager.log( LogService.LOG_DEBUG,
-                        "Dependency Manager: Static dependency on {0}/{1} is broken", new Object[]
-                        {getName(), m_dependencyMetadata.getInterface()}, null );
+                m_componentManager.log(LogService.LOG_DEBUG,
+                    "Dependency Manager: Static dependency on {0}/{1} is broken",
+                    new Object[] { getName(), m_dependencyMetadata.getInterface() }, null);
                 deactivateComponentManager();
                 //try to reactivate after ref is no longer tracked.
                 if (event != null)
@@ -504,87 +531,98 @@ public class DependencyManager<S, T> imp
                     event.addComponentManager(m_componentManager);
                 }
             }
-            else if ( !cardinalitySatisfied( getTracker().getServiceCount() ) ) //may be called from an old tracker, so getTracker() may give a different answer
+            else if (!cardinalitySatisfied(getTracker().getServiceCount())) //may be called from an old tracker, so getTracker() may give a different answer
             {
-                m_componentManager.log( LogService.LOG_DEBUG,
-                        "Dependency Manager: Static dependency on {0}/{1} is broken", new Object[]
-                        {getName(), m_dependencyMetadata.getInterface()}, null );
+                m_componentManager.log(LogService.LOG_DEBUG,
+                    "Dependency Manager: Static dependency on {0}/{1} is broken",
+                    new Object[] { getName(), m_dependencyMetadata.getInterface() }, null);
                 deactivateComponentManager();
             }
             //This is unlikely
-            ungetService( refPair );
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticGreedy removed {2} (exit)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            ungetService(refPair);
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticGreedy removed {2} (exit)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
         }
 
         public boolean prebind(ComponentContextImpl<S> key)
         {
             int serviceCount = 0;
-            AtomicInteger trackingCount = new AtomicInteger( );
+            AtomicInteger trackingCount = new AtomicInteger();
             final ServiceTracker<T, RefPair<S, T>, ExtendedServiceEvent> tracker = getTracker();
-            SortedMap<ServiceReference<T>, RefPair<S, T>> tracked = tracker.getTracked( cardinalitySatisfied( tracker.getServiceCount() ), trackingCount );
-            for (RefPair<S, T> refPair: tracked.values())
+            SortedMap<ServiceReference<T>, RefPair<S, T>> tracked = tracker.getTracked(
+                cardinalitySatisfied(tracker.getServiceCount()), trackingCount);
+            for (RefPair<S, T> refPair : tracked.values())
             {
-                if ( getServiceObject( key, m_bindMethods.getBind(), refPair ) )
+                if (getServiceObject(key, m_bindMethods.getBind(), refPair))
                 {
                     serviceCount++;
                 }
             }
-            return cardinalitySatisfied( serviceCount );
+            return cardinalitySatisfied(serviceCount);
         }
 
         public void close()
         {
-            AtomicInteger trackingCount = new AtomicInteger( );
-            for ( RefPair<S, T> ref: getRefs( trackingCount ))
+            AtomicInteger trackingCount = new AtomicInteger();
+            for (RefPair<S, T> ref : getRefs(trackingCount))
             {
-                ungetService( ref );
+                ungetService(ref);
             }
             deactivateTracker();
         }
 
-        public Collection<RefPair<S, T>> getRefs( AtomicInteger trackingCount )
+        public Collection<RefPair<S, T>> getRefs(AtomicInteger trackingCount)
         {
             ServiceTracker<T, RefPair<S, T>, ExtendedServiceEvent> tracker = getTracker();
-            if (tracker == null) {
+            if (tracker == null)
+            {
                 return Collections.emptyList();
             }
-            return tracker.getTracked( null, trackingCount ).values();
+            return tracker.getTracked(null, trackingCount).values();
         }
     }
 
-    private class MultipleStaticReluctantCustomizer extends AbstractCustomizer {
+    private class MultipleStaticReluctantCustomizer extends AbstractCustomizer
+    {
 
         private final AtomicReference<Collection<RefPair<S, T>>> refs = new AtomicReference<Collection<RefPair<S, T>>>();
         private int trackingCount;
 
-        public RefPair<S, T> addingService( ServiceReference<T> serviceReference )
+        public RefPair<S, T> addingService(ServiceReference<T> serviceReference)
         {
             RefPair<S, T> refPair = newRefPair(serviceReference);
             return refPair;
         }
 
-        public void addedService( ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount, int serviceCount, ExtendedServiceEvent event )
+        public void addedService(ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount,
+            int serviceCount, ExtendedServiceEvent event)
         {
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticReluctant added {2} (enter)", new Object[] {getName(), trackingCount, serviceReference}, null );
-            tracked( trackingCount );
-            if ( isTrackerOpened() && cardinalityJustSatisfied( serviceCount ) && !isActive())
+            m_componentManager.log(LogService.LOG_DEBUG,
+                "dm {0} tracking {1} MultipleStaticReluctant added {2} (enter)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
+            tracked(trackingCount);
+            if (isTrackerOpened() && cardinalityJustSatisfied(serviceCount) && !isActive())
             {
-                m_componentManager.activateInternal( );
+                m_componentManager.activateInternal();
             }
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticReluctant added {2} (exit)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticReluctant added {2} (exit)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
         }
 
-        public void modifiedService( ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount, ExtendedServiceEvent event )
+        public void modifiedService(ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount,
+            ExtendedServiceEvent event)
         {
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticReluctant modified {2} (enter)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            m_componentManager.log(LogService.LOG_DEBUG,
+                "dm {0} tracking {1} MultipleStaticReluctant modified {2} (enter)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
             boolean reactivate = false;
             Collection<RefPair<S, T>> refs = this.refs.get();
-            if (isActive() && refs.contains( refPair ))
+            if (isActive() && refs.contains(refPair))
             {
-                reactivate = m_componentManager.invokeUpdatedMethod( DependencyManager.this, refPair, trackingCount );
+                reactivate = m_componentManager.invokeUpdatedMethod(DependencyManager.this, refPair, trackingCount);
             }
-            tracked( trackingCount );
-            if ( reactivate )
+            tracked(trackingCount);
+            if (reactivate)
             {
                 deactivateComponentManager();
                 if (event != null)
@@ -592,23 +630,28 @@ public class DependencyManager<S, T> imp
                     event.addComponentManager(m_componentManager);
                 }
             }
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticReluctant modified {2} (exit)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            m_componentManager.log(LogService.LOG_DEBUG,
+                "dm {0} tracking {1} MultipleStaticReluctant modified {2} (exit)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
         }
 
-        public void removedService( ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount, ExtendedServiceEvent event )
+        public void removedService(ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount,
+            ExtendedServiceEvent event)
         {
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticReluctant removed {2} (enter)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            m_componentManager.log(LogService.LOG_DEBUG,
+                "dm {0} tracking {1} MultipleStaticReluctant removed {2} (enter)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
             refPair.markDeleted();
-            tracked( trackingCount );
+            tracked(trackingCount);
             Collection<RefPair<S, T>> refs = this.refs.get();
-            if ( isActive() && refs != null )
+            if (isActive() && refs != null)
             {
-                if (refs.contains( refPair ))
+                if (refs.contains(refPair))
                 {
                     //we are tracking the used refs, so we can deactivate here.
-                    m_componentManager.log( LogService.LOG_DEBUG,
-                        "Dependency Manager: Static dependency on {0}/{1} is broken", new Object[]
-                            { getName(), m_dependencyMetadata.getInterface() }, null );
+                    m_componentManager.log(LogService.LOG_DEBUG,
+                        "Dependency Manager: Static dependency on {0}/{1} is broken",
+                        new Object[] { getName(), m_dependencyMetadata.getInterface() }, null);
                     deactivateComponentManager();
 
                     // FELIX-2368: immediately try to reactivate
@@ -619,44 +662,47 @@ public class DependencyManager<S, T> imp
 
                 }
             }
-            else if ( !cardinalitySatisfied( getTracker().getServiceCount() ) )
+            else if (!cardinalitySatisfied(getTracker().getServiceCount()))
             {
-                m_componentManager.log( LogService.LOG_DEBUG,
-                        "Dependency Manager: Static dependency on {0}/{1} is broken", new Object[]
-                        {getName(), m_dependencyMetadata.getInterface()}, null );
+                m_componentManager.log(LogService.LOG_DEBUG,
+                    "Dependency Manager: Static dependency on {0}/{1} is broken",
+                    new Object[] { getName(), m_dependencyMetadata.getInterface() }, null);
                 deactivateComponentManager();
             }
-            ungetService( refPair );
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} MultipleStaticReluctant removed {2} (exit)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            ungetService(refPair);
+            m_componentManager.log(LogService.LOG_DEBUG,
+                "dm {0} tracking {1} MultipleStaticReluctant removed {2} (exit)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
         }
 
         public boolean prebind(ComponentContextImpl<S> key)
         {
             int serviceCount = 0;
             Collection<RefPair<S, T>> refs = this.refs.get();
-            if (refs != null) {
+            if (refs != null)
+            {
                 //another thread is concurrently opening, and it got done already
-                for (RefPair<S, T> refPair: refs)
+                for (RefPair<S, T> refPair : refs)
                 {
-                    if (getServiceObject( key, m_bindMethods.getBind(), refPair ))
+                    if (getServiceObject(key, m_bindMethods.getBind(), refPair))
                     {
                         serviceCount++;
                     }
                 }
-                return cardinalitySatisfied( serviceCount );
+                return cardinalitySatisfied(serviceCount);
             }
             refs = new ArrayList<RefPair<S, T>>();
-            AtomicInteger trackingCount = new AtomicInteger( );
-            SortedMap<ServiceReference<T>, RefPair<S, T>> tracked = getTracker().getTracked( true, trackingCount );
-            for (RefPair<S, T> refPair: tracked.values())
+            AtomicInteger trackingCount = new AtomicInteger();
+            SortedMap<ServiceReference<T>, RefPair<S, T>> tracked = getTracker().getTracked(true, trackingCount);
+            for (RefPair<S, T> refPair : tracked.values())
             {
-                if (getServiceObject( key, m_bindMethods.getBind(), refPair ))
+                if (getServiceObject(key, m_bindMethods.getBind(), refPair))
                 {
                     serviceCount++;
                 }
-                refs.add(refPair) ;
+                refs.add(refPair);
             }
-            if ( this.refs.compareAndSet( null, refs ) )
+            if (this.refs.compareAndSet(null, refs))
             {
                 this.trackingCount = trackingCount.get();
             }
@@ -664,200 +710,210 @@ public class DependencyManager<S, T> imp
             {
                 //some other thread got done first.  If we have more refPairs, we might need to unget some services.
                 Collection<RefPair<S, T>> actualRefs = this.refs.get();
-                refs.removeAll( actualRefs );
-                for (RefPair<S, T> ref: refs)
+                refs.removeAll(actualRefs);
+                for (RefPair<S, T> ref : refs)
                 {
-                    ungetService( ref );
+                    ungetService(ref);
                 }
             }
-            return cardinalitySatisfied( serviceCount );
+            return cardinalitySatisfied(serviceCount);
         }
 
         public void close()
         {
-            Collection<RefPair<S, T>> refs = this.refs.getAndSet( null );
-            if ( refs != null )
+            Collection<RefPair<S, T>> refs = this.refs.getAndSet(null);
+            if (refs != null)
             {
-                for ( RefPair<S, T> ref: refs )
+                for (RefPair<S, T> ref : refs)
                 {
-                    ungetService( ref );
+                    ungetService(ref);
                 }
             }
             deactivateTracker();
         }
 
-        public Collection<RefPair<S, T>> getRefs( AtomicInteger trackingCount )
+        public Collection<RefPair<S, T>> getRefs(AtomicInteger trackingCount)
         {
-            trackingCount.set( this.trackingCount );
+            trackingCount.set(this.trackingCount);
             Collection<RefPair<S, T>> refs = this.refs.get();
-            return refs == null? Collections.<RefPair<S, T>>emptyList(): refs;
+            return refs == null ? Collections.<RefPair<S, T>> emptyList() : refs;
         }
     }
 
-    private class SingleDynamicCustomizer extends AbstractCustomizer {
+    private class SingleDynamicCustomizer extends AbstractCustomizer
+    {
 
         private RefPair<S, T> refPair;
         private int trackingCount;
 
-        public RefPair<S, T> addingService( ServiceReference<T> serviceReference )
+        public RefPair<S, T> addingService(ServiceReference<T> serviceReference)
         {
-            RefPair<S, T> refPair = getPreviousRefMap().get( serviceReference );
-            if ( refPair == null )
+            RefPair<S, T> refPair = getPreviousRefMap().get(serviceReference);
+            if (refPair == null)
             {
                 refPair = newRefPair(serviceReference);
             }
             return refPair;
         }
 
-        public void addedService( ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount, int serviceCount, ExtendedServiceEvent event )
+        public void addedService(ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount,
+            int serviceCount, ExtendedServiceEvent event)
         {
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} SingleDynamic added {2} (enter)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} SingleDynamic added {2} (enter)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
             boolean tracked = false;
-            if ( getPreviousRefMap().remove( serviceReference ) == null )
+            if (getPreviousRefMap().remove(serviceReference) == null)
             {
-                if (isActive() )
+                if (isActive())
                 {
                     boolean invokeBind;
-                    synchronized ( getTracker().tracked() )
+                    synchronized (getTracker().tracked())
                     {
                         invokeBind = this.refPair == null
-                                || ( !isReluctant() && refPair.getRef().compareTo( this.refPair.getRef() ) > 0 );
+                            || (!isReluctant() && refPair.getRef().compareTo(this.refPair.getRef()) > 0);
                     }
-                    if ( invokeBind )
+                    if (invokeBind)
                     {
-                        m_componentManager.invokeBindMethod( DependencyManager.this, refPair, trackingCount );
-                        if ( !refPair.isFailed() )
+                        m_componentManager.invokeBindMethod(DependencyManager.this, refPair, trackingCount);
+                        if (!refPair.isFailed())
                         {
-                            if ( this.refPair != null )
+                            if (this.refPair != null)
                             {
-                                m_componentManager.invokeUnbindMethod( DependencyManager.this, this.refPair,
-                                        trackingCount );
+                                m_componentManager.invokeUnbindMethod(DependencyManager.this, this.refPair,
+                                    trackingCount);
                                 closeRefPair();
                             }
                         }
-                        else if ( cardinalitySatisfied( 0 ) )
+                        else if (cardinalitySatisfied(0))
                         {
-                            m_componentManager.registerMissingDependency( DependencyManager.this, serviceReference,
-                                    trackingCount );
+                            m_componentManager.registerMissingDependency(DependencyManager.this, serviceReference,
+                                trackingCount);
                         }
                         this.refPair = refPair;
                     }
                 }
-                else if ( isTrackerOpened() && cardinalityJustSatisfied( serviceCount ) )
+                else if (isTrackerOpened() && cardinalityJustSatisfied(serviceCount))
                 {
-                    tracked( trackingCount );
+                    tracked(trackingCount);
                     tracked = true;
-                    m_componentManager.activateInternal( );
+                    m_componentManager.activateInternal();
                 }
             }
             this.trackingCount = trackingCount;
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} SingleDynamic added {2} (exit)", new Object[] {getName(), trackingCount, serviceReference}, null );
-            if ( !tracked )
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} SingleDynamic added {2} (exit)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
+            if (!tracked)
             {
                 tracked(trackingCount);
             }
         }
 
-        public void modifiedService( ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount, ExtendedServiceEvent event )
+        public void modifiedService(ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount,
+            ExtendedServiceEvent event)
         {
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} SingleDynamic modified {2} (enter)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} SingleDynamic modified {2} (enter)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
             boolean invokeUpdated;
             synchronized (getTracker().tracked())
             {
                 invokeUpdated = isActive() && refPair == this.refPair;
             }
-            if ( invokeUpdated )
+            if (invokeUpdated)
             {
-                m_componentManager.invokeUpdatedMethod( DependencyManager.this, refPair, trackingCount );
+                m_componentManager.invokeUpdatedMethod(DependencyManager.this, refPair, trackingCount);
             }
             this.trackingCount = trackingCount;
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} SingleDynamic modified {2} (exit)", new Object[] {getName(), trackingCount, serviceReference}, null );
-            tracked( trackingCount );
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} SingleDynamic modified {2} (exit)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
+            tracked(trackingCount);
         }
 
-        public void removedService( ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount, ExtendedServiceEvent event )
+        public void removedService(ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount,
+            ExtendedServiceEvent event)
         {
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} SingleDynamic removed {2} (enter)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} SingleDynamic removed {2} (enter)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
             refPair.markDeleted();
             boolean deactivate = false;
             boolean untracked = true;
             RefPair<S, T> oldRefPair = null;
             RefPair<S, T> nextRefPair = null;
-            synchronized ( getTracker().tracked() )
+            synchronized (getTracker().tracked())
             {
-                if ( refPair == this.refPair && isActive() )
+                if (refPair == this.refPair && isActive())
                 {
-                    if ( !getTracker().isEmpty() )
+                    if (!getTracker().isEmpty())
                     {
                         AtomicInteger trackingCount2 = new AtomicInteger();
-                        SortedMap<ServiceReference<T>, RefPair<S, T>> tracked = getTracker().getTracked( true, //TODO true here looks odd.
-                                trackingCount2 );
+                        SortedMap<ServiceReference<T>, RefPair<S, T>> tracked = getTracker().getTracked(true, //TODO true here looks odd.
+                            trackingCount2);
                         nextRefPair = tracked.values().iterator().next();
                     }
 
                     //n.b. we cannot use cardinalitySatisfied( serviceCount ) here as the call may come from an old tracker during target change.
-                    if ( isEffectivelyOptional() || nextRefPair != null )
+                    if (isEffectivelyOptional() || nextRefPair != null)
                     {
                         oldRefPair = this.refPair;
                         this.refPair = null;
                     }
                     else
                     {
-                        deactivate = true;            //required and no replacement service, deactivate
+                        deactivate = true; //required and no replacement service, deactivate
                     }
                 }
-                else if ( !cardinalitySatisfied( getTracker().getServiceCount() ) && this.refPair == null)
+                else if (!cardinalitySatisfied(getTracker().getServiceCount()) && this.refPair == null)
                 {
                     deactivate = true;
                 }
             }
-            if ( nextRefPair != null )
+            if (nextRefPair != null)
             {
-                m_componentManager.invokeBindMethod( DependencyManager.this, nextRefPair,
-                            trackingCount );
+                m_componentManager.invokeBindMethod(DependencyManager.this, nextRefPair, trackingCount);
             }
 
-            if ( oldRefPair != null )
+            if (oldRefPair != null)
             {
                 this.trackingCount = trackingCount;
-                m_componentManager.invokeUnbindMethod( DependencyManager.this, oldRefPair, trackingCount );
-                synchronized ( getTracker().tracked() )
+                m_componentManager.invokeUnbindMethod(DependencyManager.this, oldRefPair, trackingCount);
+                synchronized (getTracker().tracked())
                 {
                     this.refPair = nextRefPair;
                 }
-                tracked( trackingCount );
+                tracked(trackingCount);
                 untracked = false;
             }
-            else if ( deactivate )
+            else if (deactivate)
             {
                 this.trackingCount = trackingCount;
-                tracked( trackingCount );
+                tracked(trackingCount);
                 untracked = false;
                 deactivateComponentManager();
             }
-            if ( oldRefPair != null )
+            if (oldRefPair != null)
             {
-                ungetService( oldRefPair );
+                ungetService(oldRefPair);
             }
             if (untracked) // not ours
             {
                 this.trackingCount = trackingCount;
-                tracked( trackingCount );
+                tracked(trackingCount);
             }
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} SingleDynamic removed {2} (exit)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} SingleDynamic removed {2} (exit)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
         }
 
         public boolean prebind(ComponentContextImpl<S> key)
         {
             RefPair<S, T> refPair = null;
-            boolean success = cardinalitySatisfied( 0 );
+            boolean success = cardinalitySatisfied(0);
             AtomicInteger trackingCount = new AtomicInteger();
-            synchronized ( getTracker().tracked() )
+            synchronized (getTracker().tracked())
             {
-                if ( success || !getTracker().isEmpty() )
+                if (success || !getTracker().isEmpty())
                 {
-                    SortedMap<ServiceReference<T>, RefPair<S, T>> tracked = getTracker().getTracked( true, trackingCount );
-                    if ( !tracked.isEmpty() )
+                    SortedMap<ServiceReference<T>, RefPair<S, T>> tracked = getTracker().getTracked(true,
+                        trackingCount);
+                    if (!tracked.isEmpty())
                     {
                         refPair = tracked.values().iterator().next();
                         this.refPair = refPair;
@@ -866,11 +922,11 @@ public class DependencyManager<S, T> imp
             }
             if (refPair != null)
             {
-                success |= getServiceObject( key, m_bindMethods.getBind(), refPair );
-                if ( refPair.isFailed() &&  cardinalitySatisfied( 0 ))
+                success |= getServiceObject(key, m_bindMethods.getBind(), refPair);
+                if (refPair.isFailed() && cardinalitySatisfied(0))
                 {
-                    m_componentManager.registerMissingDependency( DependencyManager.this, refPair.getRef(),
-                            trackingCount.get() );
+                    m_componentManager.registerMissingDependency(DependencyManager.this, refPair.getRef(),
+                        trackingCount.get());
                 }
             }
             return success;
@@ -884,22 +940,22 @@ public class DependencyManager<S, T> imp
 
         private void closeRefPair()
         {
-            if ( refPair != null )
+            if (refPair != null)
             {
-                ungetService( refPair );
+                ungetService(refPair);
             }
             refPair = null;
         }
 
-        public Collection<RefPair<S, T>> getRefs( AtomicInteger trackingCount )
+        public Collection<RefPair<S, T>> getRefs(AtomicInteger trackingCount)
         {
-            Object monitor = getTracker() == null? null: getTracker().tracked();
-            if ( monitor != null )
+            Object monitor = getTracker() == null ? null : getTracker().tracked();
+            if (monitor != null)
             {
-                synchronized ( monitor )
+                synchronized (monitor)
                 {
-                    trackingCount.set( this.trackingCount );
-                    return refPair == null? Collections.<RefPair<S, T>> emptyList(): Collections.singleton( refPair );
+                    trackingCount.set(this.trackingCount);
+                    return refPair == null ? Collections.<RefPair<S, T>> emptyList() : Collections.singleton(refPair);
                 }
             }
             else
@@ -915,25 +971,28 @@ public class DependencyManager<S, T> imp
         private RefPair<S, T> refPair;
         private int trackingCount;
 
-        public RefPair<S, T> addingService( ServiceReference<T> serviceReference )
+        public RefPair<S, T> addingService(ServiceReference<T> serviceReference)
         {
             RefPair<S, T> refPair = newRefPair(serviceReference);
             return refPair;
         }
 
-        public void addedService( ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount, int serviceCount, ExtendedServiceEvent event )
+        public void addedService(ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount,
+            int serviceCount, ExtendedServiceEvent event)
         {
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} SingleStatic added {2} (enter)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} SingleStatic added {2} (enter)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
             this.trackingCount = trackingCount;
-            tracked( trackingCount );
-            if ( isActive() )
+            tracked(trackingCount);
+            if (isActive())
             {
                 boolean reactivate;
                 synchronized (getTracker().tracked())
                 {
-                    reactivate = !isReluctant() && ( this.refPair == null || refPair.getRef().compareTo( this.refPair.getRef() ) > 0 );
+                    reactivate = !isReluctant()
+                        && (this.refPair == null || refPair.getRef().compareTo(this.refPair.getRef()) > 0);
                 }
-                if ( reactivate )
+                if (reactivate)
                 {
                     deactivateComponentManager();
                     if (event != null)
@@ -943,23 +1002,30 @@ public class DependencyManager<S, T> imp
                 }
                 else
                 {
-                    m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} SingleStatic active but new {2} is worse match than old {3}", new Object[] {getName(), trackingCount, refPair, this.refPair, }, null );
+                    m_componentManager.log(LogService.LOG_DEBUG,
+                        "dm {0} tracking {1} SingleStatic active but new {2} is worse match than old {3}",
+                        new Object[] { getName(), trackingCount, refPair, this.refPair, }, null);
                 }
             }
-            else if (isTrackerOpened() && cardinalityJustSatisfied( serviceCount ) )
+            else if (isTrackerOpened() && cardinalityJustSatisfied(serviceCount))
             {
-                m_componentManager.activateInternal( );
+                m_componentManager.activateInternal();
             }
             else
             {
-                m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} SingleStatic active: {2} trackerOpened: {3} optional: {4}", new Object[] {getName(), trackingCount, isActive(), isTrackerOpened(), isOptional()}, null );
+                m_componentManager.log(LogService.LOG_DEBUG,
+                    "dm {0} tracking {1} SingleStatic active: {2} trackerOpened: {3} optional: {4}",
+                    new Object[] { getName(), trackingCount, isActive(), isTrackerOpened(), isOptional() }, null);
             }
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} SingleStatic added {2} (exit)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} SingleStatic added {2} (exit)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
         }
 
-        public void modifiedService( ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount, ExtendedServiceEvent event )
+        public void modifiedService(ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount,
+            ExtendedServiceEvent event)
         {
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} SingleStatic modified {2} (enter)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} SingleStatic modified {2} (enter)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
             boolean invokeUpdated;
             final Object sync = getTracker().tracked();
             synchronized (sync)
@@ -967,16 +1033,16 @@ public class DependencyManager<S, T> imp
                 invokeUpdated = isActive() && refPair == this.refPair;
             }
             boolean reactivate = false;
-            if ( invokeUpdated )
+            if (invokeUpdated)
             {
-                reactivate = m_componentManager.invokeUpdatedMethod( DependencyManager.this, refPair, trackingCount );
+                reactivate = m_componentManager.invokeUpdatedMethod(DependencyManager.this, refPair, trackingCount);
             }
             this.trackingCount = trackingCount;
-            tracked( trackingCount );
-            if ( reactivate )
+            tracked(trackingCount);
+            if (reactivate)
             {
                 deactivateComponentManager();
-                synchronized ( sync )
+                synchronized (sync)
                 {
                     if (refPair == this.refPair)
                     {
@@ -988,28 +1054,33 @@ public class DependencyManager<S, T> imp
                     event.addComponentManager(m_componentManager);
                 }
             }
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} SingleStatic modified {2} (exit)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} SingleStatic modified {2} (exit)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
         }
 
-        public void removedService( ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount, ExtendedServiceEvent event )
+        public void removedService(ServiceReference<T> serviceReference, RefPair<S, T> refPair, int trackingCount,
+            ExtendedServiceEvent event)
         {
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} SingleStatic removed {2} (enter)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} SingleStatic removed {2} (enter)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
             refPair.markDeleted();
             this.trackingCount = trackingCount;
-            tracked( trackingCount );
+            tracked(trackingCount);
             boolean reactivate;
             final Object sync = getTracker().tracked();
             synchronized (sync)
             {
-                reactivate = ( isActive() && refPair == this.refPair) || ( !cardinalitySatisfied( getTracker().getServiceCount() ));
-                if (!reactivate && refPair == this.refPair) {
+                reactivate = (isActive() && refPair == this.refPair)
+                    || (!cardinalitySatisfied(getTracker().getServiceCount()));
+                if (!reactivate && refPair == this.refPair)
+                {
                     this.refPair = null;
                 }
             }
-            if ( reactivate )
+            if (reactivate)
             {
                 deactivateComponentManager();
-                synchronized ( sync )
+                synchronized (sync)
                 {
                     if (refPair == this.refPair)
                     {
@@ -1021,32 +1092,34 @@ public class DependencyManager<S, T> imp
                     event.addComponentManager(m_componentManager);
                 }
             }
-            m_componentManager.log( LogService.LOG_DEBUG, "dm {0} tracking {1} SingleStatic removed {2} (exit)", new Object[] {getName(), trackingCount, serviceReference}, null );
+            m_componentManager.log(LogService.LOG_DEBUG, "dm {0} tracking {1} SingleStatic removed {2} (exit)",
+                new Object[] { getName(), trackingCount, serviceReference }, null);
         }
 
         public boolean prebind(ComponentContextImpl<S> key)
         {
-            boolean success = cardinalitySatisfied( 0 );
-            if ( success || !getTracker().isEmpty() )
+            boolean success = cardinalitySatisfied(0);
+            if (success || !getTracker().isEmpty())
             {
                 RefPair<S, T> refPair = null;
                 AtomicInteger trackingCount = new AtomicInteger();
-                synchronized ( getTracker().tracked() )
+                synchronized (getTracker().tracked())
                 {
-                    SortedMap<ServiceReference<T>, RefPair<S, T>> tracked = getTracker().getTracked( true, trackingCount );
-                    if ( !tracked.isEmpty() )
+                    SortedMap<ServiceReference<T>, RefPair<S, T>> tracked = getTracker().getTracked(true,
+                        trackingCount);
+                    if (!tracked.isEmpty())
                     {
                         refPair = tracked.values().iterator().next();
                         this.refPair = refPair;
                     }
                 }
-                if ( refPair != null )
+                if (refPair != null)
                 {
-                    success |= getServiceObject( key, m_bindMethods.getBind(), refPair );
-                    if ( refPair.isFailed() )
+                    success |= getServiceObject(key, m_bindMethods.getBind(), refPair);
+                    if (refPair.isFailed())
                     {
-                        m_componentManager.registerMissingDependency( DependencyManager.this, refPair.getRef(),
-                                trackingCount.get() );
+                        m_componentManager.registerMissingDependency(DependencyManager.this, refPair.getRef(),
+                            trackingCount.get());
                     }
                 }
             }
@@ -1056,31 +1129,31 @@ public class DependencyManager<S, T> imp
         public void close()
         {
             ServiceTracker<T, RefPair<S, T>, ExtendedServiceEvent> tracker = getTracker();
-            if ( tracker != null )
+            if (tracker != null)
             {
                 RefPair<S, T> ref;
-                synchronized ( tracker.tracked() )
+                synchronized (tracker.tracked())
                 {
                     ref = refPair;
                     refPair = null;
                 }
-                if ( ref != null )
+                if (ref != null)
                 {
-                    ungetService( ref );
+                    ungetService(ref);
                 }
                 tracker.deactivate();
             }
         }
 
-        public Collection<RefPair<S, T>> getRefs( AtomicInteger trackingCount )
+        public Collection<RefPair<S, T>> getRefs(AtomicInteger trackingCount)
         {
-            Object monitor = getTracker() == null? null: getTracker().tracked();
-            if ( monitor != null )
+            Object monitor = getTracker() == null ? null : getTracker().tracked();
+            if (monitor != null)
             {
-                synchronized ( monitor )
+                synchronized (monitor)
                 {
-                    trackingCount.set( this.trackingCount );
-                    return refPair == null? Collections.<RefPair<S, T>> emptyList(): Collections.singleton( refPair );
+                    trackingCount.set(this.trackingCount);
+                    return refPair == null ? Collections.<RefPair<S, T>> emptyList() : Collections.singleton(refPair);
                 }
             }
             else
@@ -1102,7 +1175,7 @@ public class DependencyManager<S, T> imp
         {
         }
 
-        public Collection<RefPair<S, T>> getRefs( AtomicInteger trackingCount )
+        public Collection<RefPair<S, T>> getRefs(AtomicInteger trackingCount)
         {
             return Collections.emptyList();
         }
@@ -1112,7 +1185,7 @@ public class DependencyManager<S, T> imp
             return isOptional();
         }
 
-        public void setTracker( ServiceTracker<T, RefPair<S, T>, ExtendedServiceEvent> tRefPairServiceTracker )
+        public void setTracker(ServiceTracker<T, RefPair<S, T>, ExtendedServiceEvent> tRefPairServiceTracker)
         {
         }
 
@@ -1120,24 +1193,27 @@ public class DependencyManager<S, T> imp
         {
         }
 
-        public void setPreviousRefMap( Map<ServiceReference<T>, RefPair<S, T>> previousRefMap )
+        public void setPreviousRefMap(Map<ServiceReference<T>, RefPair<S, T>> previousRefMap)
         {
         }
 
-        public RefPair<S, T> addingService( ServiceReference<T> tServiceReference )
+        public RefPair<S, T> addingService(ServiceReference<T> tServiceReference)
         {
             return null;
         }
 
-        public void addedService( ServiceReference<T> tServiceReference, RefPair<S, T> service, int trackingCount, int serviceCount, ExtendedServiceEvent event )
+        public void addedService(ServiceReference<T> tServiceReference, RefPair<S, T> service, int trackingCount,
+            int serviceCount, ExtendedServiceEvent event)
         {
         }
 
-        public void modifiedService( ServiceReference<T> tServiceReference, RefPair<S, T> service, int trackingCount, ExtendedServiceEvent event )
+        public void modifiedService(ServiceReference<T> tServiceReference, RefPair<S, T> service, int trackingCount,
+            ExtendedServiceEvent event)
         {
         }
 
-        public void removedService( ServiceReference<T> tServiceReference, RefPair<S, T> service, int trackingCount, ExtendedServiceEvent event )
+        public void removedService(ServiceReference<T> tServiceReference, RefPair<S, T> service, int trackingCount,
+            ExtendedServiceEvent event)
         {
         }
     }
@@ -1172,7 +1248,6 @@ public class DependencyManager<S, T> imp
         return m_dependencyMetadata.isMultiple();
     }
 
-
     private boolean isStatic()
     {
         return m_dependencyMetadata.isStatic();
@@ -1185,13 +1260,11 @@ public class DependencyManager<S, T> imp
 
     //---------- Service tracking support -------------------------------------
 
-
     void deactivate()
     {
         m_customizer.close();
     }
 
-
     /**
      * Returns the number of services currently registered in the system,
      * which match the service criteria (interface and optional target filter)
@@ -1204,51 +1277,49 @@ public class DependencyManager<S, T> imp
      */
     int size()
     {
-        AtomicInteger trackingCount = new AtomicInteger( );
-        return m_tracker.getTracked( null, trackingCount ).size();
+        AtomicInteger trackingCount = new AtomicInteger();
+        return m_tracker.getTracked(null, trackingCount).size();
     }
 
-
-    private ServiceReference<T>[] getFrameworkServiceReferences( String targetFilter )
+    private ServiceReference<T>[] getFrameworkServiceReferences(String targetFilter)
     {
-        if ( hasGetPermission() )
+        if (hasGetPermission())
         {
             // component activator may be null if disposed concurrently
             ComponentActivator bca = m_componentManager.getActivator();
-            if ( bca == null )
+            if (bca == null)
             {
                 return null;
             }
 
             // get bundle context, may be null if component deactivated since getting bca
             BundleContext bc = bca.getBundleContext();
-            if ( bc == null )
+            if (bc == null)
             {
                 return null;
             }
 
             try
             {
-                return ( ServiceReference<T>[] ) bc.getServiceReferences(
-                    m_dependencyMetadata.getInterface(), targetFilter );
+                return (ServiceReference<T>[]) bc.getServiceReferences(m_dependencyMetadata.getInterface(),
+                    targetFilter);
             }
-            catch ( IllegalStateException ise )
+            catch (IllegalStateException ise)
             {
                 // bundle context is not valid any longer, cannot log
             }
-            catch ( InvalidSyntaxException ise )
+            catch (InvalidSyntaxException ise)
             {
-                m_componentManager.log( LogService.LOG_ERROR, "Unexpected problem with filter ''{0}''", new Object[]
-                    { targetFilter }, ise );
+                m_componentManager.log(LogService.LOG_ERROR, "Unexpected problem with filter ''{0}''",
+                    new Object[] { targetFilter }, ise);
                 return null;
             }
         }
 
-        m_componentManager.log( LogService.LOG_DEBUG, "No permission to access the services", null );
+        m_componentManager.log(LogService.LOG_DEBUG, "No permission to access the services", null);
         return null;
     }
 
-
     /**
      * Returns a <code>ServiceReference</code> instances for a service
      * implementing the interface and complying to the (optional) target filter
@@ -1263,7 +1334,7 @@ public class DependencyManager<S, T> imp
      */
     private RefPair<S, T> getBestRefPair()
     {
-        Collection<RefPair<S, T>> refs = m_customizer.getRefs( new AtomicInteger( ) );
+        Collection<RefPair<S, T>> refs = m_customizer.getRefs(new AtomicInteger());
         if (refs.isEmpty())
         {
             return null;
@@ -1271,7 +1342,6 @@ public class DependencyManager<S, T> imp
         return refs.iterator().next();
     }
 
-
     /**
      * Returns the service instance for the service reference returned by the
      * {@link #getBestRefPair()} method. If this returns a
@@ -1282,10 +1352,9 @@ public class DependencyManager<S, T> imp
     T getService(ComponentContextImpl<S> key)
     {
         RefPair<S, T> sr = getBestRefPair();
-        return getService( key, sr );
+        return getService(key, sr);
     }
 
-
     /**
      * Returns an array of service instances for the service references returned
      * by the customizer. If no services
@@ -1296,30 +1365,29 @@ public class DependencyManager<S, T> imp
      */
     T[] getServices(ComponentContextImpl<S> key)
     {
-        Collection<RefPair<S, T>> refs = m_customizer.getRefs(  new AtomicInteger( ) );
-        List<T> services = new ArrayList<T>( refs.size() );
-        for ( RefPair<S, T> ref: refs)
+        Collection<RefPair<S, T>> refs = m_customizer.getRefs(new AtomicInteger());
+        List<T> services = new ArrayList<T>(refs.size());
+        for (RefPair<S, T> ref : refs)
         {
             T service = getService(key, ref);
             if (service != null)
             {
-                services.add( service );
+                services.add(service);
             }
         }
-        return services.isEmpty()? null: (T[])services.toArray( new Object[ services.size()] );
+        return services.isEmpty() ? null : (T[]) services.toArray(new Object[services.size()]);
     }
 
-
     //---------- bound services maintenance -----------------------------------
 
     /* (non-Javadoc)
-	 * @see org.apache.felix.scr.impl.manager.ReferenceManager#getServiceReferences()
-	 */
+     * @see org.apache.felix.scr.impl.manager.ReferenceManager#getServiceReferences()
+     */
     public List<ServiceReference<?>> getServiceReferences()
     {
-        Collection<RefPair<S, T>> bound = m_customizer.getRefs(  new AtomicInteger( ) );
+        Collection<RefPair<S, T>> bound = m_customizer.getRefs(new AtomicInteger());
         List<ServiceReference<?>> result = new ArrayList<ServiceReference<?>>(bound.size());
-        for (RefPair<S, T> ref: bound)
+        for (RefPair<S, T> ref : bound)
         {
             result.add(ref.getRef());
         }
@@ -1337,18 +1405,17 @@ public class DependencyManager<S, T> imp
      *      if the service is bound or <code>null</code> if the service is not
      *      bound.
      */
-    private RefPair<S, T> getRefPair( ServiceReference<T> serviceReference )
+    private RefPair<S, T> getRefPair(ServiceReference<T> serviceReference)
     {
         final ServiceTracker<T, RefPair<S, T>, ExtendedServiceEvent> tracker = m_tracker;
-        if ( tracker != null )
+        if (tracker != null)
         {
-            AtomicInteger trackingCount = new AtomicInteger( );
-            return tracker.getTracked( null, trackingCount ).get( serviceReference );
+            AtomicInteger trackingCount = new AtomicInteger();
+            return tracker.getTracked(null, trackingCount).get(serviceReference);
         }
         return null;
     }
 
-
     /**
      * Returns the service described by the ServiceReference. If this instance
      * is already bound the given service, that bound service instance is
@@ -1360,14 +1427,14 @@ public class DependencyManager<S, T> imp
      * @return The requested service or <code>null</code> if no service is
      *      registered for the service reference (any more).
      */
-    T getService( ComponentContextImpl<S> key, ServiceReference<T> serviceReference )
+    T getService(ComponentContextImpl<S> key, ServiceReference<T> serviceReference)
     {
         // check whether we already have the service and return that one
-        RefPair<S, T> refPair = getRefPair( serviceReference );
-        return getService( key, refPair );
+        RefPair<S, T> refPair = getRefPair(serviceReference);
+        return getService(key, refPair);
     }
 
-    private T getService( ComponentContextImpl<S> key, RefPair<S, T> refPair )
+    private T getService(ComponentContextImpl<S> key, RefPair<S, T> refPair)
     {
         if (refPair == null)
         {
@@ -1375,7 +1442,7 @@ public class DependencyManager<S, T> imp
             return null;
         }
         T serviceObject;
-        if ( (serviceObject = refPair.getServiceObject(key)) != null )
+        if ((serviceObject = refPair.getServiceObject(key)) != null)
         {
             return serviceObject;
         }
@@ -1383,28 +1450,29 @@ public class DependencyManager<S, T> imp
         final BundleContext bundleContext = m_componentManager.getBundleContext();
         if (bundleContext == null)
         {
-            m_componentManager.log( LogService.LOG_ERROR, "Bundle shut down while getting service {0} ({1}/{2,number,#})", new Object[]
-                    { getName(), m_dependencyMetadata.getInterface(),
-                        refPair.getRef().getProperty( Constants.SERVICE_ID ) }, null );
-                return null;
+            m_componentManager.log(LogService.LOG_ERROR,
+                "Bundle shut down while getting service {0} ({1}/{2,number,#})", new Object[] { getName(),
+                        m_dependencyMetadata.getInterface(), refPair.getRef().getProperty(Constants.SERVICE_ID) },
+                null);
+            return null;
         }
         try
         {
             refPair.getServiceObject(key, bundleContext, m_componentManager);
-            serviceObject = refPair.getServiceObject( key );
+            serviceObject = refPair.getServiceObject(key);
         }
-        catch ( Exception e )
+        catch (Exception e)
         {
             // caused by getService() called on invalid bundle context
             // or if there is a service reference cycle involving service
             // factories !
-            m_componentManager.log( LogService.LOG_ERROR, "Failed getting service {0} ({1}/{2,number,#})", new Object[]
-                { getName(), m_dependencyMetadata.getInterface(),
-                    refPair.getRef().getProperty( Constants.SERVICE_ID ) }, e );
+            m_componentManager.log(LogService.LOG_ERROR, "Failed getting service {0} ({1}/{2,number,#})",
+                new Object[] { getName(), m_dependencyMetadata.getInterface(),
+                        refPair.getRef().getProperty(Constants.SERVICE_ID) },
+                e);
             return null;
         }
 
-
         // return the acquired service (may be null of course)
         //even if we did not set the service object, all the getService are for the same bundle so will have the same object.
         return serviceObject;
@@ -1413,14 +1481,13 @@ public class DependencyManager<S, T> imp
     //---------- DependencyManager core ---------------------------------------
 
     /* (non-Javadoc)
-	 * @see org.apache.felix.scr.impl.manager.ReferenceManager#getName()
-	 */
+     * @see org.apache.felix.scr.impl.manager.ReferenceManager#getName()
+     */
     public String getName()
     {
         return m_dependencyMetadata.getName();
     }
 
-
     /**
      * Returns <code>true</code> if this dependency manager is satisfied, that
      * is if either the dependency is optional or the number of services
@@ -1432,17 +1499,16 @@ public class DependencyManager<S, T> imp
         return m_customizer.isSatisfied();
     }
 
-
     /**
      * Returns <code>true</code> if the component providing bundle has permission
      * to get the service described by this reference.
      */
     public boolean hasGetPermission()
     {
-        if ( System.getSecurityManager() != null )
+        if (System.getSecurityManager() != null)
         {
-            Permission perm = new ServicePermission( getServiceName(), ServicePermission.GET );
-            return m_componentManager.getBundle().hasPermission( perm );
+            Permission perm = new ServicePermission(getServiceName(), ServicePermission.GET);
+            return m_componentManager.getBundle().hasPermission(perm);
         }
 
         // no security manager, hence permission given
@@ -1462,38 +1528,36 @@ public class DependencyManager<S, T> imp
      * @return true if the dependency is satisfied and at least the minimum
      *      number of services could be bound. Otherwise false is returned.
      */
-    boolean open( ComponentContextImpl<S> componentContext, EdgeInfo edgeInfo )
+    boolean open(ComponentContextImpl<S> componentContext, EdgeInfo edgeInfo)
     {
-        if ( !invokeInitMethod(componentContext) )
+        if (!invokeInitMethod(componentContext))
         {
-            m_componentManager.log( LogService.LOG_DEBUG,
-                    "For dependency {0}, failed to initialize object",
-                    new Object[] {getName()}, null );
+            m_componentManager.log(LogService.LOG_DEBUG, "For dependency {0}, failed to initialize object",
+                new Object[] { getName() }, null);
             return false;
         }
 
         int serviceCount = 0;
-        AtomicInteger trackingCount =  new AtomicInteger( );
+        AtomicInteger trackingCount = new AtomicInteger();
         Collection<RefPair<S, T>> refs;
         CountDownLatch openLatch;
-        synchronized ( m_tracker.tracked() )
+        synchronized (m_tracker.tracked())
         {
-            refs = m_customizer.getRefs( trackingCount );
-            edgeInfo.setOpen( trackingCount.get() );
-            openLatch = edgeInfo.getOpenLatch( );
+            refs = m_customizer.getRefs(trackingCount);
+            edgeInfo.setOpen(trackingCount.get());
+            openLatch = edgeInfo.getOpenLatch();
         }
-        m_componentManager.log( LogService.LOG_DEBUG,
-            "For dependency {0}, optional: {1}; to bind: {2}",
-            new Object[]{ getName(), isOptional(), refs }, null );
-        for ( RefPair<S, T> refPair : refs )
+        m_componentManager.log(LogService.LOG_DEBUG, "For dependency {0}, optional: {1}; to bind: {2}",
+            new Object[] { getName(), isOptional(), refs }, null);
+        for (RefPair<S, T> refPair : refs)
         {
-            if ( !refPair.isDeleted() && !refPair.isFailed() )
+            if (!refPair.isDeleted() && !refPair.isFailed())
             {
-                if ( !doInvokeBindMethod( componentContext, refPair ) )
+                if (!doInvokeBindMethod(componentContext, refPair, trackingCount.get()))
                 {
-                    m_componentManager.log( LogService.LOG_DEBUG,
-                            "For dependency {0}, failed to invoke bind method on object {1}",
-                            new Object[] {getName(), refPair}, null );
+                    m_componentManager.log(LogService.LOG_DEBUG,
+                        "For dependency {0}, failed to invoke bind method on object {1}",
+                        new Object[] { getName(), refPair }, null);
 
                 }
                 serviceCount++;
@@ -1509,7 +1573,7 @@ public class DependencyManager<S, T> imp
      * @param componentContext instance we are unbinding from.
      * @param edgeInfo EdgeInfo for the combination of this component instance and this dependency manager.
      */
-    void close( ComponentContextImpl<S> componentContext, EdgeInfo edgeInfo )
+    void close(ComponentContextImpl<S> componentContext, EdgeInfo edgeInfo)
     {
         // only invoke the unbind method if there is an instance (might be null
         // in the delayed component situation) and the unbind method is declared.
@@ -1518,76 +1582,77 @@ public class DependencyManager<S, T> imp
         AtomicInteger trackingCount = new AtomicInteger();
         Collection<RefPair<S, T>> refPairs;
         CountDownLatch latch;
-        synchronized ( m_tracker.tracked() )
+        synchronized (m_tracker.tracked())
         {
-            refPairs = m_customizer.getRefs( trackingCount );
-            edgeInfo.setClose( trackingCount.get() );
-            latch = edgeInfo.getCloseLatch( );
+            refPairs = m_customizer.getRefs(trackingCount);
+            edgeInfo.setClose(trackingCount.get());
+            latch = edgeInfo.getCloseLatch();
         }
 
-        m_componentManager.log( LogService.LOG_DEBUG,
-                "DependencyManager: {0} close component unbinding from {1} at tracking count {2} refpairs: {3}",
-                new Object[] {getName(), componentContext, trackingCount.get(), refPairs}, null );
-        m_componentManager.waitForTracked( trackingCount.get() );
-        for ( RefPair<S, T> boundRef : refPairs )
+        m_componentManager.log(LogService.LOG_DEBUG,
+            "DependencyManager: {0} close component unbinding from {1} at tracking count {2} refpairs: {3}",
+            new Object[] { getName(), componentContext, trackingCount.get(), refPairs }, null);
+        m_componentManager.waitForTracked(trackingCount.get());
+        for (RefPair<S, T> boundRef : refPairs)
         {
-            if ( doUnbind && !boundRef.isFailed() )
+            if (doUnbind && !boundRef.isFailed())
             {
-                invokeUnbindMethod( componentContext, boundRef, trackingCount.get(), edgeInfo );
+                invokeUnbindMethod(componentContext, boundRef, trackingCount.get(), edgeInfo);
             }
 
         }
         latch.countDown();
     }
 
-    public void invokeBindMethodLate( final ServiceReference<T> ref, int trackingCount )
+    public void invokeBindMethodLate(final ServiceReference<T> ref, int trackingCount)
     {
-        if ( !isSatisfied() )
+        if (!isSatisfied())
         {
             return;
         }
-        if ( !isMultiple() )

[... 668 lines stripped ...]



Mime
View raw message