felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1415461 [2/2] - in /felix/trunk/scr/src: main/java/org/apache/felix/scr/impl/ main/java/org/apache/felix/scr/impl/config/ main/java/org/apache/felix/scr/impl/helper/ main/java/org/apache/felix/scr/impl/manager/ main/java/org/apache/felix/s...
Date Thu, 29 Nov 2012 23:53:24 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=1415461&r1=1415460&r2=1415461&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 Thu Nov 29 23:53:21 2012
@@ -53,14 +53,14 @@ import org.osgi.service.log.LogService;
  * declared by a single <code>&lt;reference&gt;</code element in component
  * descriptor.
  */
-public class DependencyManager implements ServiceListener, Reference
+public class DependencyManager<S, T> implements ServiceListener, Reference
 {
     // mask of states ok to send events
     private static final int STATE_MASK = //Component.STATE_UNSATISFIED |
          Component.STATE_ACTIVE | Component.STATE_REGISTERED | Component.STATE_FACTORY;
 
     // the component to which this dependency belongs
-    private final AbstractComponentManager m_componentManager;
+    private final AbstractComponentManager<S> m_componentManager;
 
     // Reference to the metadata
     private final ReferenceMetadata m_dependencyMetadata;
@@ -77,8 +77,8 @@ public class DependencyManager implement
     private volatile Filter m_targetFilter;
 
     private final Object enableLock = new Object();
-    private final Collection<ServiceReference> added = new ArrayList<ServiceReference>();
-    private final Collection<ServiceReference> removed = new ArrayList<ServiceReference>();
+    private final Collection<ServiceReference<T>> added = new ArrayList<ServiceReference<T>>();
+    private final Collection<ServiceReference<T>> removed = new ArrayList<ServiceReference<T>>();
 
     private boolean registered;
 
@@ -88,7 +88,7 @@ public class DependencyManager implement
      *
      * @param dependency An object that contains data about the dependency
      */
-    DependencyManager( AbstractComponentManager componentManager, ReferenceMetadata dependency )
+    DependencyManager( AbstractComponentManager<S> componentManager, ReferenceMetadata dependency )
     {
         m_componentManager = componentManager;
         m_dependencyMetadata = dependency;
@@ -124,10 +124,10 @@ public class DependencyManager implement
      */
     public void serviceChanged( ServiceEvent event )
     {
-        final ServiceReference ref = event.getServiceReference();
+        final ServiceReference<T> ref = ( ServiceReference<T> ) event.getServiceReference();
         final String serviceString = "Service " + m_dependencyMetadata.getInterface() + "/"
             + ref.getProperty( Constants.SERVICE_ID );
-        Collection<ServiceReference> changes = null;
+        Collection<ServiceReference<T>> changes = null;
         try
         {
             switch ( event.getType() )
@@ -318,7 +318,7 @@ public class DependencyManager implement
      * @param reference The reference to the service newly registered or
      *      modified.
      */
-    private void serviceAdded( ServiceReference reference )
+    private void serviceAdded( ServiceReference<T> reference )
     {
         // if the component is currently unsatisfied, it may become satisfied
         // by adding this service, try to activate (also schedule activation
@@ -337,10 +337,10 @@ public class DependencyManager implement
                     "Dependency Manager: Service {0} activation did not occur on this thread", new Object[]
                         { m_dependencyMetadata.getName() }, null );
 
-                Map dependenciesMap = m_componentManager.getDependencyMap();
+                Map<DependencyManager<S, ?>, Map<ServiceReference<?>, RefPair<?>>> dependenciesMap = m_componentManager.getDependencyMap();
                 if (dependenciesMap  != null) {
                     //someone else has managed to activate
-                    Map references = ( Map ) dependenciesMap.get( this );
+                    Map<ServiceReference<T>, RefPair<T>> references = (Map)dependenciesMap.get( this );
                     if (references == null )
                     {
                         throw new IllegalStateException( "Allegedly active but dependency manager not represented: " + this );
@@ -380,10 +380,10 @@ public class DependencyManager implement
                 }
                 else
                 {
-                    Map dependenciesMap = m_componentManager.getDependencyMap();
+                    Map<DependencyManager<S, ?>, Map<ServiceReference<?>, RefPair<?>>> dependenciesMap = m_componentManager.getDependencyMap();
                     if ( dependenciesMap != null )
                     {
-                        Map bound = ( Map ) dependenciesMap.get( this );
+                        Map<ServiceReference<T>, RefPair<T>> bound = (Map)dependenciesMap.get( this );
                         if ( m_dependencyMetadata.isMultiple() ||
                                                 bound.isEmpty() ||
                                                 reference.compareTo( bound.keySet().iterator().next() ) > 0 )
@@ -408,11 +408,11 @@ public class DependencyManager implement
                 else if ( !isReluctant() )
                 {
                     //dynamic greedy single: bind then unbind
-                    Map dependenciesMap = m_componentManager.getDependencyMap();
+                    Map<DependencyManager<S, ?>, Map<ServiceReference<?>, RefPair<?>>> dependenciesMap = m_componentManager.getDependencyMap();
                     if ( dependenciesMap != null )
                     {
-                        Map bound = ( Map ) dependenciesMap.get( this );
-                        ServiceReference oldRef = ( ServiceReference ) bound.keySet().iterator().next();
+                        Map<ServiceReference<T>, RefPair<T>> bound = (Map)dependenciesMap.get( this );
+                        ServiceReference oldRef = bound.keySet().iterator().next();
                         if ( reference.compareTo( oldRef ) > 0 )
                         {
                             m_componentManager.invokeBindMethod( this, reference );
@@ -444,7 +444,7 @@ public class DependencyManager implement
      * @param reference The reference to the service unregistering or being
      *      modified.
      */
-    private void serviceRemoved( ServiceReference reference )
+    private void serviceRemoved( ServiceReference<T> reference )
     {
         // if the dependency is not satisfied anymore, we have to
         // deactivate the component
@@ -470,11 +470,11 @@ public class DependencyManager implement
         // otherwise check whether the component is in a state to handle the event
         else if ( handleServiceEvent() || (m_componentManager.getState() & (Component.STATE_DISABLED | Component.STATE_DISPOSED)) != 0 )
         {
-            Map dependencyMap = m_componentManager.getDependencyMap();
-            Map referenceMap = null;
+            Map<DependencyManager<S, ?>, Map<ServiceReference<?>, RefPair<?>>> dependencyMap = m_componentManager.getDependencyMap();
+            Map<ServiceReference<T>, RefPair<T>> referenceMap = null;
             if (dependencyMap != null)
             {
-                referenceMap = ( Map ) dependencyMap.get( this );
+                referenceMap = (Map)dependencyMap.get( this );
             }
             // if the dependency is static, we have to deactivate the component
             // to "remove" the dependency
@@ -511,7 +511,7 @@ public class DependencyManager implement
                     // if the dependency is mandatory and no replacement is
                     // available, bind returns false and we deactivate
                     // bind best matching service
-                    ServiceReference ref = getFrameworkServiceReference();
+                    ServiceReference<T> ref = getFrameworkServiceReference();
 
                     if ( ref == null )
                     {
@@ -652,12 +652,12 @@ public class DependencyManager implement
         // unget all services we once got
         if ( m_componentManager.getDependencyMap() != null )
         {
-            ServiceReference[] boundRefs = getBoundServiceReferences();
+            ServiceReference<T>[] boundRefs = getBoundServiceReferences();
             if ( boundRefs != null )
             {
-                for ( int i = 0; i < boundRefs.length; i++ )
+                for ( ServiceReference<T> ref: boundRefs )
                 {
-                    ungetService( boundRefs[i] );
+                    ungetService( ref );
                 }
             }
         }
@@ -691,13 +691,13 @@ public class DependencyManager implement
      * This method always directly accesses the framework's service registry
      * and ignores the services bound by this dependency manager.
      */
-    ServiceReference[] getFrameworkServiceReferences()
+    ServiceReference<T>[] getFrameworkServiceReferences()
     {
         return getFrameworkServiceReferences( getTarget() );
     }
 
 
-    private ServiceReference[] getFrameworkServiceReferences( String targetFilter )
+    private ServiceReference<T>[] getFrameworkServiceReferences( String targetFilter )
     {
         if ( hasGetPermission() )
         {
@@ -717,7 +717,7 @@ public class DependencyManager implement
 
             try
             {
-                return bc.getServiceReferences(
+                return ( ServiceReference<T>[] ) bc.getServiceReferences(
                     m_dependencyMetadata.getInterface(), targetFilter );
             }
             catch ( IllegalStateException ise )
@@ -738,7 +738,7 @@ public class DependencyManager implement
 
     private int getServiceReferenceCount()
     {
-        ServiceReference[] refs = getFrameworkServiceReferences();
+        ServiceReference<T>[] refs = getFrameworkServiceReferences();
         return refs == null? 0: refs.length;
     }
 
@@ -757,10 +757,10 @@ public class DependencyManager implement
      * This method always directly accesses the framework's service registry
      * and ignores the services bound by this dependency manager.
      */
-    ServiceReference getFrameworkServiceReference()
+    ServiceReference<T> getFrameworkServiceReference()
     {
         // get the framework registered services and short cut
-        ServiceReference[] refs = getFrameworkServiceReferences();
+        ServiceReference<T>[] refs = getFrameworkServiceReferences();
         if ( refs == null )
         {
             return null;
@@ -772,10 +772,10 @@ public class DependencyManager implement
 
 
         // find the service with the highest ranking
-        ServiceReference selectedRef = refs[0];
+        ServiceReference<T> selectedRef = refs[0];
         for ( int i = 1; i < refs.length; i++ )
         {
-            ServiceReference ref = refs[i];
+            ServiceReference<T> ref = refs[i];
             if ( ref.compareTo( selectedRef ) > 0 )
             {
                 selectedRef = ref;
@@ -792,9 +792,9 @@ public class DependencyManager implement
      * non-<code>null</code> service instance the service is then considered
      * bound to this instance.
      */
-    Object getService()
+    T getService()
     {
-        ServiceReference sr = getFrameworkServiceReference();
+        ServiceReference<T> sr = getFrameworkServiceReference();
         return ( sr != null ) ? getService( sr ) : null;
     }
 
@@ -806,25 +806,25 @@ public class DependencyManager implement
      * returned. All services returned by this method will be considered bound
      * after this method returns.
      */
-    Object[] getServices()
+    T[] getServices()
     {
-        ServiceReference[] sr = getFrameworkServiceReferences();
+        ServiceReference<T>[] sr = getFrameworkServiceReferences();
         if ( sr == null || sr.length == 0 )
         {
             return null;
         }
 
-        List services = new ArrayList();
-        for ( int i = 0; i < sr.length; i++ )
+        List<Object> services = new ArrayList<Object>();
+        for ( ServiceReference<T> ref: sr )
         {
-            Object service = getService( sr[i] );
+            Object service = getService( ref );
             if ( service != null )
             {
                 services.add( service );
             }
         }
 
-        return ( services.size() > 0 ) ? services.toArray() : null;
+        return ( services.size() > 0 ) ? services.toArray((T[])new Object[services.size()]) : null;
     }
 
 
@@ -835,20 +835,20 @@ public class DependencyManager implement
      * services this instance is bound to or <code>null</code> if no services
      * are actually bound.
      */
-    public ServiceReference[] getBoundServiceReferences()
+    public ServiceReference<T>[] getBoundServiceReferences()
     {
-        Map dependencyMap = m_componentManager.getDependencyMap();
+        Map<DependencyManager<S, ?>, Map<ServiceReference<?>, RefPair<?>>> dependencyMap = m_componentManager.getDependencyMap();
         if ( dependencyMap == null )
         {
             return null;
         }
-        Map bound = ( Map ) dependencyMap.get( this );
+        Map<ServiceReference<T>, RefPair<T>> bound = (Map)dependencyMap.get( this );
         if ( bound.isEmpty() )
         {
             return null;
         }
 
-        return ( ServiceReference[] ) bound.keySet().toArray( new ServiceReference[bound.size()] );
+        return bound.keySet().toArray( new ServiceReference[bound.size()] );
     }
 
 
@@ -857,12 +857,12 @@ public class DependencyManager implement
      */
     private boolean isBound()
     {
-        Map dependencyMap = m_componentManager.getDependencyMap();
+        Map<DependencyManager<S, ?>, Map<ServiceReference<?>, RefPair<?>>> dependencyMap = m_componentManager.getDependencyMap();
         if (dependencyMap  == null )
         {
             return false;
         }
-        Map bound = ( Map ) dependencyMap.get( this );
+        Map<ServiceReference<T>, RefPair<T>> bound = (Map)dependencyMap.get( this );
         return !bound.isEmpty();
     }
 
@@ -878,14 +878,14 @@ public class DependencyManager implement
      *      if the service is bound or <code>null</code> if the service is not
      *      bound.
      */
-    private RefPair getBoundService( ServiceReference serviceReference )
+    private RefPair getBoundService( ServiceReference<T> serviceReference )
     {
-        Map dependencyMap = m_componentManager.getDependencyMap();
+        Map<DependencyManager<S, ?>, Map<ServiceReference<?>, RefPair<?>>> dependencyMap = m_componentManager.getDependencyMap();
         if (dependencyMap == null)
         {
             return null;
         }
-        return ( RefPair ) (( Map ) dependencyMap.get( this )).get(serviceReference);
+        return dependencyMap.get( this ).get( serviceReference );
     }
 
 
@@ -900,15 +900,15 @@ public class DependencyManager implement
      * @return The requested service or <code>null</code> if no service is
      *      registered for the service reference (any more).
      */
-    Object getService( ServiceReference serviceReference )
+    T getService( ServiceReference<T> serviceReference )
     {
         // check whether we already have the service and return that one
         RefPair refPair = getBoundService( serviceReference );
         if ( refPair != null && refPair.getServiceObject() != null )
         {
-            return refPair.getServiceObject();
+            return (T)refPair.getServiceObject();
         }
-        Object serviceObject = null;
+        T serviceObject = null;
         // otherwise acquire the service
         try
         {
@@ -936,7 +936,7 @@ public class DependencyManager implement
             {
                 refPair = new RefPair( serviceReference );
                 refPair.setServiceObject( serviceObject );
-                ((Map)m_componentManager.getDependencyMap().get( this )).put( serviceReference, refPair );
+                m_componentManager.getDependencyMap().get( this ).put( serviceReference, refPair );
             }
         }
 
@@ -949,13 +949,13 @@ public class DependencyManager implement
      * Ungets the service described by the ServiceReference and removes it from
      * the list of bound services.
      */
-    void ungetService( ServiceReference serviceReference )
+    void ungetService( ServiceReference<T> serviceReference )
     {
         // check we really have this service, do nothing if not
-        Map dependencyMap = m_componentManager.getDependencyMap();
+        Map<DependencyManager<S, ?>, Map<ServiceReference<?>, RefPair<?>>> dependencyMap = m_componentManager.getDependencyMap();
         if ( dependencyMap != null )
         {
-            RefPair refPair  = ( RefPair ) ((Map ) dependencyMap.get( this )).get( serviceReference );
+            RefPair refPair  = dependencyMap.get( this ).get( serviceReference );
             if ( refPair != null && refPair.getServiceObject() != null )
             {
                 BundleComponentActivator activator = m_componentManager.getActivator();
@@ -1023,9 +1023,9 @@ public class DependencyManager implement
     }
 
 
-    boolean open( Object componentInstance, Map parameters )
+    boolean open( S componentInstance, Map<ServiceReference<?>, RefPair<?>> parameters )
     {
-        return bind( componentInstance, parameters);
+        return bind( componentInstance, (Map)parameters);
     }
 
 
@@ -1034,13 +1034,12 @@ public class DependencyManager implement
      * try to complete all that it can
      * @param componentInstance
      */
-    void close( Object componentInstance )
+    void close( S componentInstance )
     {
         unbind( componentInstance, getBoundServiceReferences() );
     }
 
-    //returns Map<ServiceReference, RefPair>
-    boolean prebind( Map dependencyMap)
+    boolean prebind( Map<DependencyManager<S, T>, Map<ServiceReference<T>, RefPair<T>>> dependencyMap)
     {
         // If no references were received, we have to check if the dependency
         // is optional, if it is not then the dependency is invalid
@@ -1053,11 +1052,11 @@ public class DependencyManager implement
         // we have nothing to do and just signal success
         if ( m_dependencyMetadata.getBind() == null )
         {
-            dependencyMap.put( this, new HashMap( ) );
+            dependencyMap.put( this, new HashMap<ServiceReference<T>, RefPair<T>>( ) );
             return true;
         }
 
-        Map result = new HashMap(); //<ServiceReference, RefPair>
+        Map<ServiceReference<T>, RefPair<T>> result = new HashMap<ServiceReference<T>, RefPair<T>>();
         // assume success to begin with: if the dependency is optional,
         // we don't care, whether we can bind a service. Otherwise, we
         // require at least one service to be bound, thus we require
@@ -1068,22 +1067,22 @@ public class DependencyManager implement
         if ( m_dependencyMetadata.isMultiple() )
         {
             // bind all registered services
-            ServiceReference[] refs = getFrameworkServiceReferences();
+            ServiceReference<T>[] refs = getFrameworkServiceReferences();
             if ( refs != null )
             {
-                for ( int index = 0; index < refs.length; index++ )
+                for ( ServiceReference<T> ref : refs )
                 {
-                    RefPair refPair = new RefPair( refs[index] );
+                    RefPair refPair = new RefPair( ref );
                     // success is if we have the minimal required number of services bound
                     if ( m_bindMethods.getBind().getServiceObject( refPair, m_componentManager.getActivator().getBundleContext() ) )
                     {
-                        result.put( refs[index], refPair );
+                        result.put( ref, refPair );
                         // of course, we have success if the service is bound
                         success = true;
                     }
                     else
                     {
-                        m_componentManager.getActivator().registerMissingDependency(this, refs[index]);
+                        m_componentManager.getActivator().registerMissingDependency( this, ref );
                     }
                 }
             }
@@ -1123,7 +1122,7 @@ public class DependencyManager implement
      * @return true if the dependency is satisfied and at least the minimum
      *      number of services could be bound. Otherwise false is returned.
      */
-    private boolean bind( Object componentInstance, Map parameters )
+    private boolean bind( S componentInstance, Map<ServiceReference<T>, RefPair<T>> parameters )
     {
         // If no references were received, we have to check if the dependency
         // is optional, if it is not then the dependency is invalid
@@ -1150,11 +1149,10 @@ public class DependencyManager implement
 
         m_componentManager.log( LogService.LOG_DEBUG,
             "For dependency {0}, optional: {1}; to bind: {2}",
-            new Object[]{ m_dependencyMetadata.getName(), new Boolean( success ), parameters }, null );
-        for ( Iterator i = parameters.entrySet().iterator(); i.hasNext(); )
+            new Object[]{ m_dependencyMetadata.getName(), success, parameters }, null );
+        for ( Map.Entry<ServiceReference<T>, RefPair<T>> entry : parameters.entrySet() )
         {
-            Map.Entry entry = ( Map.Entry ) i.next();
-            if ( !invokeBindMethod( componentInstance, ( RefPair ) entry.getValue() ) )
+            if ( !invokeBindMethod( componentInstance, entry.getValue() ) )
             {
                 m_componentManager.log( LogService.LOG_DEBUG,
                         "For dependency {0}, failed to invoke bind method on object {1}",
@@ -1177,7 +1175,7 @@ public class DependencyManager implement
      * @param componentInstance
      * @param ref The <code>ServiceReference</code> representing the updated
      */
-    void update( Object componentInstance, final ServiceReference ref )
+    void update( S componentInstance, final ServiceReference<T> ref )
     {
         if ( m_dependencyMetadata.getUpdated() != null )
         {
@@ -1190,7 +1188,7 @@ public class DependencyManager implement
      * Revoke the given bindings. This method cannot throw an exception since
      * it must try to complete all that it can
      */
-    private void unbind( Object componentInstance, ServiceReference[] boundRefs )
+    private void unbind( S componentInstance, ServiceReference<T>[] boundRefs )
     {
         if ( boundRefs != null )
         {
@@ -1198,28 +1196,28 @@ public class DependencyManager implement
             // in the delayed component situation) and the unbind method is declared.
             boolean doUnbind = componentInstance != null && m_dependencyMetadata.getUnbind() != null;
 
-            for ( int i = 0; i < boundRefs.length; i++ )
+            for ( ServiceReference<T> boundRef : boundRefs )
             {
                 if ( doUnbind )
                 {
-                    invokeUnbindMethod( componentInstance, boundRefs[i] );
+                    invokeUnbindMethod( componentInstance, boundRef );
                 }
 
                 // unget the service, we call it here since there might be a
                 // bind method (or the locateService method might have been
                 // called) but there is no unbind method to actually unbind
                 // the service (see FELIX-832)
-                ungetService( boundRefs[i] );
+                ungetService( boundRef );
             }
         }
     }
 
-    boolean invokeBindMethod( Object componentInstance, ServiceReference ref )
+    boolean invokeBindMethod( S componentInstance, ServiceReference<T> ref )
     {
         //event driven, and we already checked this ref is not yet handled.
         if ( componentInstance != null )
         {
-            Map dependencyMap = m_componentManager.getDependencyMap();
+            Map<DependencyManager<S, ?>, Map<ServiceReference<?>, RefPair<?>>> dependencyMap = m_componentManager.getDependencyMap();
             if ( dependencyMap != null )
             {
                 if (m_bindMethods == null)
@@ -1230,8 +1228,8 @@ public class DependencyManager implement
                             { m_dependencyMetadata.getName(), new Integer(m_componentManager.getState())  }, null );
 
                 }
-                Map deps = ( Map ) dependencyMap.get( this );
-                RefPair refPair = new RefPair( ref );
+                Map<ServiceReference<T>, RefPair<T>> deps = (Map)dependencyMap.get( this );
+                RefPair<T> refPair = new RefPair<T>( ref );
                 if ( !m_bindMethods.getBind().getServiceObject( refPair, m_componentManager.getActivator().getBundleContext() ) )
                 {
                     //reference deactivated while we are processing.
@@ -1251,7 +1249,7 @@ public class DependencyManager implement
         }
     }
 
-    public void invokeBindMethodLate( final ServiceReference ref )
+    public void invokeBindMethodLate( final ServiceReference<T> ref )
     {
         if ( !isSatisfied() )
         {
@@ -1259,7 +1257,7 @@ public class DependencyManager implement
         }
         if ( !isMultiple() )
         {
-            ServiceReference[] refs = getFrameworkServiceReferences();
+            ServiceReference<T>[] refs = getFrameworkServiceReferences();
             if ( refs == null )
             {
                 return; // should not happen, we have one!
@@ -1267,7 +1265,7 @@ public class DependencyManager implement
             // find the service with the highest ranking
             for ( int i = 1; i < refs.length; i++ )
             {
-                ServiceReference test = refs[i];
+                ServiceReference<T> test = refs[i];
                 if ( test.compareTo( ref ) > 0 )
                 {
                     return; //another ref is better
@@ -1296,7 +1294,7 @@ public class DependencyManager implement
      *      be handed over to the bind method but the service cannot be
      *      retrieved using the service reference.
      */
-    private boolean invokeBindMethod( Object componentInstance, RefPair refPair )
+    private boolean invokeBindMethod( S componentInstance, RefPair refPair )
     {
         // The bind method is only invoked if the implementation object is not
         // null. This is valid for both immediate and delayed components
@@ -1337,13 +1335,13 @@ public class DependencyManager implement
      * @param componentInstance
      * @param ref A service reference corresponding to the service whose service
      */
-    private void invokeUpdatedMethod( Object componentInstance, final ServiceReference ref )
+    private void invokeUpdatedMethod( S componentInstance, final ServiceReference<T> ref )
     {
         // The updated method is only invoked if the implementation object is not
         // null. This is valid for both immediate and delayed components
         if ( componentInstance != null )
         {
-            RefPair refPair = ( RefPair ) ((Map )m_componentManager.getDependencyMap().get( this )).get( ref );
+            RefPair refPair = m_componentManager.getDependencyMap().get( this ).get( ref );
             if (refPair == null)
             {
 
@@ -1387,13 +1385,13 @@ public class DependencyManager implement
      * @param componentInstance
      * @param ref A service reference corresponding to the service that will be
      */
-    void invokeUnbindMethod( Object componentInstance, final ServiceReference ref )
+    void invokeUnbindMethod( S componentInstance, final ServiceReference<T> ref )
     {
         // The unbind method is only invoked if the implementation object is not
         // null. This is valid for both immediate and delayed components
         if ( componentInstance != null )
         {
-            RefPair refPair = ( RefPair ) ((Map )m_componentManager.getDependencyMap().get( this )).get( ref );
+            RefPair refPair = m_componentManager.getDependencyMap().get( this ).get( ref );
             if (refPair == null)
             {
                 //TODO should this be possible? If so, reduce or eliminate logging
@@ -1448,7 +1446,7 @@ public class DependencyManager implement
      * apply.</li>
      * </ol>
      */
-    boolean canUpdateDynamically( Dictionary properties )
+    boolean canUpdateDynamically( Dictionary<String, Object> properties )
     {
         // 1. no target filter change
         final String newTarget = ( String ) properties.get( m_dependencyMetadata.getTargetPropertyName() );
@@ -1474,7 +1472,7 @@ public class DependencyManager implement
         // invariant: target filter change + dynamic policy
 
         // 3. check target services matching the new filter
-        ServiceReference[] refs = getFrameworkServiceReferences( newTarget );
+        ServiceReference<T>[] refs = getFrameworkServiceReferences( newTarget );
         if ( refs != null && refs.length > 0 )
         {
             // can update since there is at least on service matching the
@@ -1508,7 +1506,7 @@ public class DependencyManager implement
      * @param properties The properties containing the optional target service
      *      filter property
      */
-    void setTargetFilter( Dictionary properties )
+    void setTargetFilter( Dictionary<String, Object> properties )
     {
         try
         {

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java?rev=1415461&r1=1415460&r2=1415461&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java Thu Nov 29 23:53:21 2012
@@ -46,16 +46,16 @@ import org.osgi.service.log.LogService;
  * The default ComponentManager. Objects of this class are responsible for managing
  * implementation object's lifecycle.
  */
-public class ImmediateComponentManager extends AbstractComponentManager implements ServiceFactory
+public class ImmediateComponentManager<S> extends AbstractComponentManager<S> implements ServiceFactory<S>
 {
 
     // The object that implements the service and that is bound to other services
-    private volatile Object m_implementationObject;
+    private volatile S m_implementationObject;
 
     // The component implementation object temporarily set to allow
     // for service updates during activation. This field is only set
     // to a non-null value while calling the activate method
-    private volatile Object m_tmpImplementationObject;
+    private volatile S m_tmpImplementationObject;
 
     // keep the using bundles as reference "counters" for instance deactivation
     private volatile int m_useCount;
@@ -67,18 +67,18 @@ public class ImmediateComponentManager e
     private ComponentHolder m_componentHolder;
 
     // optional properties provided in the ComponentFactory.newInstance method
-    private Dictionary m_factoryProperties;
+    private Dictionary<String, Object> m_factoryProperties;
 
     // the component properties, also used as service properties
-    private Dictionary m_properties;
+    private Dictionary<String, Object> m_properties;
 
     // properties supplied ot ExtComponentContext.updateProperties
     // null if properties are not to be overwritten
-    private Dictionary m_serviceProperties;
+    private Dictionary<String, Object> m_serviceProperties;
 
     // the component properties from the Configuration Admin Service
     // this is null, if none exist or none are provided
-    private Dictionary m_configurationProperties;
+    private Dictionary<String, Object> m_configurationProperties;
 
     /**
      * The constructor receives both the activator and the metadata
@@ -121,9 +121,9 @@ public class ImmediateComponentManager e
         if ( m_implementationObject == null )
         {
             final ComponentContextImpl tmpContext = new ComponentContextImpl( this );
-            Object tmpComponent = createImplementationObject( tmpContext, new SetImplementationObject()
+            S tmpComponent = createImplementationObject( tmpContext, new SetImplementationObject<S>()
             {
-                public void setImplementationObject( Object implementationObject )
+                public void setImplementationObject( S implementationObject )
                 {
                     m_componentContext = tmpContext;
                     m_implementationObject = implementationObject;
@@ -131,13 +131,13 @@ public class ImmediateComponentManager e
                 }
 
 
-                public void presetImplementationObject( Object implementationObject )
+                public void presetImplementationObject( S implementationObject )
                 {
                     m_tmpImplementationObject = implementationObject;
                 }
 
 
-                public void resetImplementationObject( Object implementationObject )
+                public void resetImplementationObject( S implementationObject )
                 {
                     m_tmpImplementationObject = null;
                 }
@@ -202,7 +202,7 @@ public class ImmediateComponentManager e
      * potentially other parts as part of the {@link #createImplementationObject} method
      * processing.
      */
-    protected interface SetImplementationObject
+    protected interface SetImplementationObject<S>
     {
 
         /**
@@ -211,7 +211,7 @@ public class ImmediateComponentManager e
          * temporarily set the implementation object during the activator
          * call.
          */
-        void presetImplementationObject( Object implementationObject );
+        void presetImplementationObject( S implementationObject );
 
 
         /**
@@ -220,7 +220,7 @@ public class ImmediateComponentManager e
          * revert any temporary settings done in the {@link #presetImplementationObject(Object)}
          * method.
          */
-        void resetImplementationObject( Object implementationObject );
+        void resetImplementationObject( S implementationObject );
 
 
         /**
@@ -230,14 +230,14 @@ public class ImmediateComponentManager e
          * by the {@link #presetImplementationObject(Object)} should be
          * removed and the implementation object is now accessible.
          */
-        void setImplementationObject( Object implementationObject );
+        void setImplementationObject( S implementationObject );
     }
 
 
-    protected Object createImplementationObject( ComponentContext componentContext, SetImplementationObject setter )
+    protected S createImplementationObject( ComponentContext componentContext, SetImplementationObject setter )
     {
-        final Class implementationObjectClass;
-        final Object implementationObject;
+        final Class<S> implementationObjectClass;
+        final S implementationObject;
 
         // 1. Load the component implementation class
         // 2. Create the component instance and component context
@@ -245,8 +245,8 @@ public class ImmediateComponentManager e
         try
         {
             // 112.4.4 The class is retrieved with the loadClass method of the component's bundle
-            implementationObjectClass = getActivator().getBundleContext().getBundle().loadClass(
-                    getComponentMetadata().getImplementationClassName() );
+            implementationObjectClass = (Class<S>) getActivator().getBundleContext().getBundle().loadClass(
+                    getComponentMetadata().getImplementationClassName() )  ;
 
             // 112.4.4 The class must be public and have a public constructor without arguments so component instances
             // may be created by the SCR with the newInstance method on Class
@@ -260,15 +260,14 @@ public class ImmediateComponentManager e
         }
 
         // 3. Bind the target services
-        Map parameters = getParameterMap();
-        Iterator it = getDependencyManagers();
-        while ( it.hasNext() )
+        Map<DependencyManager<S, ?>, Map<ServiceReference<?>, RefPair<?>>> parameters = getDependencyMap();
+
+        for ( DependencyManager<S, ?> dm: getDependencyManagers())
         {
             // if a dependency turned unresolved since the validation check,
             // creating the instance fails here, so we deactivate and return
             // null.
-            DependencyManager dm = ( DependencyManager ) it.next();
-            Map params = ( Map ) parameters.get( dm );  //<ServiceReference, RefPair>
+            Map<ServiceReference<?>, RefPair<?>> params = parameters.get( dm );
             if ( !dm.open( implementationObject, params ) )
             {
                 log( LogService.LOG_ERROR, "Cannot create component instance due to failure to bind reference {0}",
@@ -276,11 +275,9 @@ public class ImmediateComponentManager e
                                 {dm.getName()}, null );
 
                 // make sure, we keep no bindings
-                it = getReversedDependencyManagers();
-                while ( it.hasNext() )
+                for ( DependencyManager md: getReversedDependencyManagers() )
                 {
-                    dm = ( DependencyManager ) it.next();
-                    dm.close( implementationObject );
+                    md.close( implementationObject );
                 }
 
                 return null;
@@ -300,11 +297,9 @@ public class ImmediateComponentManager e
 
             // 112.5.8 If the activate method throws an exception, SCR must log an error message
             // containing the exception with the Log Service and activation fails
-            it = getDependencyManagers();
-            while ( it.hasNext() )
+            for ( DependencyManager md: getReversedDependencyManagers() )
             {
-                DependencyManager dm = ( DependencyManager ) it.next();
-                dm.close( implementationObject );
+                md.close( implementationObject );
             }
 
             return null;
@@ -335,11 +330,9 @@ public class ImmediateComponentManager e
         }
 
         // 2. Unbind any bound services
-        Iterator it = getReversedDependencyManagers();
-        while ( it.hasNext() )
+        for ( DependencyManager md: getReversedDependencyManagers() )
         {
-            DependencyManager dm = ( DependencyManager ) it.next();
-            dm.close( implementationObject );
+            md.close( implementationObject );
         }
 
         // 3. Release all references
@@ -356,25 +349,25 @@ public class ImmediateComponentManager e
         return Active.getInstance();
     }
 
-    void update( DependencyManager dependencyManager, ServiceReference ref )
+    <T> void update( DependencyManager<S, T> dependencyManager, ServiceReference<T> ref )
     {
-        final Object impl = ( m_tmpImplementationObject != null ) ? m_tmpImplementationObject : m_implementationObject;
+        final S impl = ( m_tmpImplementationObject != null ) ? m_tmpImplementationObject : m_implementationObject;
         dependencyManager.update( impl, ref );
     }
 
-    void invokeBindMethod( DependencyManager dependencyManager, ServiceReference reference )
+    <T> void invokeBindMethod( DependencyManager<S, T> dependencyManager, ServiceReference<T> reference )
     {
-        final Object impl = ( m_tmpImplementationObject != null ) ? m_tmpImplementationObject : m_implementationObject;
+        final S impl = ( m_tmpImplementationObject != null ) ? m_tmpImplementationObject : m_implementationObject;
         dependencyManager.invokeBindMethod( impl, reference);
     }
 
-    void invokeUnbindMethod( DependencyManager dependencyManager, ServiceReference oldRef )
+    <T> void invokeUnbindMethod( DependencyManager<S, T> dependencyManager, ServiceReference<T> oldRef )
     {
-        final Object impl = ( m_tmpImplementationObject != null ) ? m_tmpImplementationObject : m_implementationObject;
+        final S impl = ( m_tmpImplementationObject != null ) ? m_tmpImplementationObject : m_implementationObject;
         dependencyManager.invokeUnbindMethod( impl, oldRef);
     }
 
-    protected void setFactoryProperties( Dictionary dictionary )
+    protected void setFactoryProperties( Dictionary<String, Object> dictionary )
     {
         m_factoryProperties = copyTo( null, dictionary );
     }
@@ -409,21 +402,19 @@ public class ImmediateComponentManager e
      *
      * @return a private Hashtable of component properties
      */
-    public Dictionary getProperties()
+    public Dictionary<String, Object> getProperties()
     {
 
         if ( m_properties == null )
         {
 
             // 1. the properties from the component descriptor
-            Dictionary props = copyTo( null, getComponentMetadata().getProperties() );
+            Dictionary<String, Object> props = copyTo( null, getComponentMetadata().getProperties() );
 
             // 2. add target properties of references
             // 112.6 Component Properties, target properties (p. 302)
-            List depMetaData = getComponentMetadata().getDependencies();
-            for ( Iterator di = depMetaData.iterator(); di.hasNext(); )
+            for ( ReferenceMetadata rm : getComponentMetadata().getDependencies() )
             {
-                ReferenceMetadata rm = ( ReferenceMetadata ) di.next();
                 if ( rm.getTarget() != null )
                 {
                     props.put( rm.getTargetPropertyName(), rm.getTarget() );
@@ -438,7 +429,7 @@ public class ImmediateComponentManager e
 
             // 5. set component.name and component.id
             props.put( ComponentConstants.COMPONENT_NAME, getComponentMetadata().getName() );
-            props.put( ComponentConstants.COMPONENT_ID, new Long( getId() ) );
+            props.put( ComponentConstants.COMPONENT_ID, getId() );
 
             m_properties = props;
         }
@@ -446,7 +437,7 @@ public class ImmediateComponentManager e
         return m_properties;
     }
 
-    public void setServiceProperties( Dictionary serviceProperties )
+    public void setServiceProperties( Dictionary<String, Object> serviceProperties )
     {
         if ( serviceProperties == null || serviceProperties.isEmpty() )
         {
@@ -457,13 +448,13 @@ public class ImmediateComponentManager e
             m_serviceProperties = copyTo( null, serviceProperties, false );
             // set component.name and component.id
             m_serviceProperties.put( ComponentConstants.COMPONENT_NAME, getComponentMetadata().getName() );
-            m_serviceProperties.put( ComponentConstants.COMPONENT_ID, new Long( getId() ) );
+            m_serviceProperties.put( ComponentConstants.COMPONENT_ID, getId() );
         }
 
         updateServiceRegistration();
     }
 
-    public Dictionary getServiceProperties()
+    public Dictionary<String, Object> getServiceProperties()
     {
         if ( m_serviceProperties != null )
         {
@@ -474,13 +465,13 @@ public class ImmediateComponentManager e
 
     private void updateServiceRegistration()
     {
-        ServiceRegistration sr = getServiceRegistration();
+        ServiceRegistration<?> sr = getServiceRegistration();
         if ( sr != null )
         {
             try
             {
                 // Don't propagate if service properties did not change.
-                final Dictionary regProps = getServiceProperties();
+                final Dictionary<String, Object> regProps = getServiceProperties();
                 if ( !servicePropertiesMatches( sr, regProps ) )
                 {
                     sr.setProperties( regProps );
@@ -518,7 +509,7 @@ public class ImmediateComponentManager e
      *                      the Configuration Admin Service or <code>null</code> if there is
      *                      no configuration or if the configuration has just been deleted.
      */
-    public void reconfigure( Dictionary configuration )
+    public void reconfigure( Dictionary<String, Object> configuration )
     {
         // nothing to do if there is no configuration (see FELIX-714)
         if ( configuration == null && m_configurationProperties == null )
@@ -594,11 +585,9 @@ public class ImmediateComponentManager e
 
         // 3. check whether we can dynamically apply the configuration if
         // any target filters influence the bound services
-        final Dictionary props = getProperties();
-        Iterator it = getDependencyManagers();
-        while ( it.hasNext() )
+        final Dictionary<String, Object> props = getProperties();
+        for ( DependencyManager dm: getDependencyManagers() )
         {
-            DependencyManager dm = ( DependencyManager ) it.next();
             if ( !dm.canUpdateDynamically( props ) )
             {
                 log( LogService.LOG_DEBUG,
@@ -672,9 +661,9 @@ public class ImmediateComponentManager e
      * @return <code>true</code> if the registration service properties equals
      *         the prop properties, false if not.
      */
-    private boolean servicePropertiesMatches( ServiceRegistration reg, Dictionary props )
+    private boolean servicePropertiesMatches( ServiceRegistration reg, Dictionary<String, Object> props )
     {
-        Dictionary regProps = new Hashtable();
+        Dictionary<String, Object> regProps = new Hashtable<String, Object>();
         String[] keys = reg.getReference().getPropertyKeys();
         for ( int i = 0; keys != null && i < keys.length; i++ )
         {
@@ -687,7 +676,7 @@ public class ImmediateComponentManager e
         return regProps.equals( props );
     }
 
-    public Object getService( Bundle bundle, ServiceRegistration serviceRegistration )
+    public S getService( Bundle bundle, ServiceRegistration<S> serviceRegistration )
     {
             Object implementationObject = m_implementationObject;
             if ( implementationObject == null )
@@ -725,7 +714,7 @@ public class ImmediateComponentManager e
                     if ( m_implementationObject == null )
                     {
                         //state should be "Registered"
-                        Object result = state().getService( this );
+                        S result = (S) state().getService( this );
                         if ( result != null )
                         {
                             m_useCount++;
@@ -740,10 +729,10 @@ public class ImmediateComponentManager e
                 }
             }
             m_useCount++;
-            return implementationObject;
+            return (S) implementationObject;
     }
 
-    public void ungetService( Bundle bundle, ServiceRegistration serviceRegistration, Object o )
+    public void ungetService( Bundle bundle, ServiceRegistration<S> serviceRegistration, S o )
     {
         // the framework should not call ungetService more than it calls
         // calls getService. Still, we want to be sure to not go below zero

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/RefPair.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/RefPair.java?rev=1415461&r1=1415460&r2=1415461&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/RefPair.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/RefPair.java Thu Nov 29 23:53:21 2012
@@ -25,27 +25,27 @@ import org.osgi.framework.ServiceReferen
 /**
  * @version $Rev:$ $Date:$
  */
-public class RefPair
+public class RefPair<T>
 {
-    private final ServiceReference ref;
-    private Object serviceObject;
+    private final ServiceReference<T> ref;
+    private T serviceObject;
 
-    public RefPair( ServiceReference ref )
+    public RefPair( ServiceReference<T> ref )
     {
         this.ref = ref;
     }
 
-    public ServiceReference getRef()
+    public ServiceReference<T> getRef()
     {
         return ref;
     }
 
-    public Object getServiceObject()
+    public T getServiceObject()
     {
         return serviceObject;
     }
 
-    public void setServiceObject( Object serviceObject )
+    public void setServiceObject( T serviceObject )
     {
         this.serviceObject = serviceObject;
     }

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceFactoryComponentManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceFactoryComponentManager.java?rev=1415461&r1=1415460&r2=1415461&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceFactoryComponentManager.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceFactoryComponentManager.java Thu Nov 29 23:53:21 2012
@@ -42,18 +42,18 @@ import org.osgi.service.log.LogService;
  * The <code>ServiceFactoryComponentManager</code> for components specified with &lt;service serviceFactory='true'/&gt;
  * in the xml metadata. The component must be delayed, not immediate or factory.
  */
-public class ServiceFactoryComponentManager extends ImmediateComponentManager
+public class ServiceFactoryComponentManager<S> extends ImmediateComponentManager<S>
 {
 
     // maintain the map of ComponentContext objects created for the
     // service instances
-    private IdentityHashMap serviceContexts = new IdentityHashMap();
+    private IdentityHashMap<S, BundleComponentContext> serviceContexts = new IdentityHashMap<S, BundleComponentContext>();
 
     // pseudo map of implementation objects to be used for service
     // binding while calling the activate method. The map's keys and values
     // are just the implementation objects. The objects will only be
     // contained while the activate method is being called.
-    private IdentityHashMap tmpImplementationObjects = new IdentityHashMap();
+    private IdentityHashMap<S, BundleComponentContext> tmpImplementationObjects = new IdentityHashMap<S, BundleComponentContext>();
 
     /**
      * @param activator BundleComponentActivator for this DS implementation
@@ -111,7 +111,7 @@ public class ServiceFactoryComponentMana
     /* (non-Javadoc)
      * @see org.osgi.framework.ServiceFactory#getService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration)
      */
-    public Object getService( Bundle bundle, ServiceRegistration registration )
+    public S getService( Bundle bundle, ServiceRegistration<S> registration )
     {
         log( LogService.LOG_DEBUG, "ServiceFactory.getService()", null );
 
@@ -143,9 +143,9 @@ public class ServiceFactoryComponentMana
         }
         // private ComponentContext and implementation instances
         final BundleComponentContext serviceContext = new BundleComponentContext( this, bundle );
-        Object service = createImplementationObject( serviceContext, new SetImplementationObject()
+        S service = createImplementationObject( serviceContext, new SetImplementationObject<S>()
         {
-            public void presetImplementationObject( Object implementationObject )
+            public void presetImplementationObject( S implementationObject )
             {
                 serviceContext.setImplementationObject( implementationObject );
                 tmpImplementationObjects.put( implementationObject, serviceContext );
@@ -153,7 +153,7 @@ public class ServiceFactoryComponentMana
             }
 
 
-            public void setImplementationObject( Object implementationObject )
+            public void setImplementationObject( S implementationObject )
             {
                 serviceContexts.put( implementationObject, serviceContext );
                 tmpImplementationObjects.remove( implementationObject );
@@ -166,7 +166,7 @@ public class ServiceFactoryComponentMana
             }
 
 
-            public void resetImplementationObject( Object implementationObject )
+            public void resetImplementationObject( S implementationObject )
             {
                 tmpImplementationObjects.remove( implementationObject );
                 serviceContext.setImplementationObject( null );
@@ -189,7 +189,7 @@ public class ServiceFactoryComponentMana
     /* (non-Javadoc)
      * @see org.osgi.framework.ServiceFactory#ungetService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration, java.lang.Object)
      */
-    public void ungetService( Bundle bundle, ServiceRegistration registration, Object service )
+    public void ungetService( Bundle bundle, ServiceRegistration<S> registration, S service )
     {
         log( LogService.LOG_DEBUG, "ServiceFactory.ungetService()", null );
 
@@ -208,40 +208,35 @@ public class ServiceFactoryComponentMana
         }
     }
 
-    void update( DependencyManager dependencyManager, ServiceReference ref )
+    <T> void update( DependencyManager<S, T> dependencyManager, ServiceReference<T> ref )
     {
-        for ( Iterator it = serviceContexts.keySet().iterator(); it.hasNext(); )
+        for ( S implementationObject : serviceContexts.keySet() )
         {
-            Object implementationObject = it.next();
             dependencyManager.update( implementationObject, ref );
         }
     }
 
-    void invokeBindMethod( DependencyManager dependencyManager, ServiceReference reference )
+    <T> void invokeBindMethod( DependencyManager<S, T> dependencyManager, ServiceReference<T> reference )
     {
-        for ( Iterator it = serviceContexts.keySet().iterator(); it.hasNext(); )
+        for ( S implementationObject : serviceContexts.keySet() )
         {
-            Object implementationObject = it.next();
-            dependencyManager.invokeBindMethod( implementationObject, reference);
+            dependencyManager.invokeBindMethod( implementationObject, reference );
         }
-        for ( Iterator it = tmpImplementationObjects.keySet().iterator(); it.hasNext(); )
+        for ( S implementationObject : tmpImplementationObjects.keySet() )
         {
-            Object implementationObject = it.next();
-            dependencyManager.invokeBindMethod( implementationObject, reference);
+            dependencyManager.invokeBindMethod( implementationObject, reference );
         }
     }
 
-    void invokeUnbindMethod( DependencyManager dependencyManager, ServiceReference oldRef )
+    <T> void invokeUnbindMethod( DependencyManager<S, T> dependencyManager, ServiceReference<T> oldRef )
     {
-        for ( Iterator it = serviceContexts.keySet().iterator(); it.hasNext(); )
+        for ( S implementationObject : serviceContexts.keySet() )
         {
-            Object implementationObject = it.next();
-            dependencyManager.invokeUnbindMethod( implementationObject, oldRef);
+            dependencyManager.invokeUnbindMethod( implementationObject, oldRef );
         }
-        for ( Iterator it = tmpImplementationObjects.keySet().iterator(); it.hasNext(); )
+        for ( S implementationObject : tmpImplementationObjects.keySet() )
         {
-            Object implementationObject = it.next();
-            dependencyManager.invokeUnbindMethod( implementationObject, oldRef);
+            dependencyManager.invokeUnbindMethod( implementationObject, oldRef );
         }
     }
 
@@ -249,20 +244,18 @@ public class ServiceFactoryComponentMana
     {
         ModifiedMethod modifiedMethod = getComponentMethods().getModifiedMethod();
         MethodResult result = null;
-        for (Iterator i = serviceContexts.values().iterator(); i.hasNext(); )
+        for ( BundleComponentContext componentContext : serviceContexts.values() )
         {
-            BundleComponentContext componentContext = ( BundleComponentContext ) i.next();
             Object instance = componentContext.getInstance();
             result = modifiedMethod.invoke( instance,
                     new ActivateMethod.ActivatorParameter( componentContext, -1 ), MethodResult.VOID );
 
         }
-        for (Iterator i = tmpImplementationObjects.values().iterator(); i.hasNext(); )
+        for ( BundleComponentContext componentContext : tmpImplementationObjects.values() )
         {
-            BundleComponentContext componentContext = ( BundleComponentContext ) i.next();
             Object instance = componentContext.getInstance();
             result = modifiedMethod.invoke( instance,
-                new ActivateMethod.ActivatorParameter( componentContext, -1 ), MethodResult.VOID );
+                    new ActivateMethod.ActivatorParameter( componentContext, -1 ), MethodResult.VOID );
 
         }
         return result;

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java?rev=1415461&r1=1415460&r2=1415461&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java Thu Nov 29 23:53:21 2012
@@ -47,7 +47,7 @@ public class ComponentMetadata
     public static final String CONFIGURATION_POLICY_OPTIONAL = "optional";
 
     // set of valid configuration policy settings
-    private static final Set CONFIGURATION_POLICY_VALID;
+    private static final Set<String> CONFIGURATION_POLICY_VALID;
 
     // marker value indicating duplicate implementation class setting
     private static final String IMPLEMENTATION_CLASS_DUPLICATE = "icd";
@@ -98,26 +98,26 @@ public class ComponentMetadata
     private String m_configurationPid;
 
     // Associated properties (0..*)
-    private Dictionary m_properties = new Hashtable();
+    private Dictionary<String, Object> m_properties = new Hashtable<String, Object>();
 
     // List of Property metadata - used while building the meta data
     // while validating the properties contained in the PropertyMetadata
     // instances are copied to the m_properties Dictionary while this
     // list will be cleared
-    private List m_propertyMetaData = new ArrayList();
+    private List<PropertyMetadata> m_propertyMetaData = new ArrayList<PropertyMetadata>();
 
     // Provided services (0..1)
     private ServiceMetadata m_service = null;
 
     // List of service references, (required services 0..*)
-    private List m_references = new ArrayList();
+    private List<ReferenceMetadata> m_references = new ArrayList<ReferenceMetadata>();
 
     // Flag that is set once the component is verified (its properties cannot be changed)
     private boolean m_validated = false;
 
     static
     {
-        CONFIGURATION_POLICY_VALID = new TreeSet();
+        CONFIGURATION_POLICY_VALID = new TreeSet<String>();
         CONFIGURATION_POLICY_VALID.add( CONFIGURATION_POLICY_IGNORE );
         CONFIGURATION_POLICY_VALID.add( CONFIGURATION_POLICY_OPTIONAL );
         CONFIGURATION_POLICY_VALID.add( CONFIGURATION_POLICY_REQUIRE );
@@ -135,7 +135,7 @@ public class ComponentMetadata
      * Setter for the configuration-pid component (since DS 1.2)
      * @param configurationPid
      */
-    public void setConfigirationPid(String configurationPid)
+    public void setConfigurationPid( String configurationPid )
     {
         if ( m_validated )
         {
@@ -487,7 +487,7 @@ public class ComponentMetadata
      * Returns the flag that defines the activation policy for the component.
      * <p>
      * This method may only be trusted after this instance has been validated
-     * by the {@link #validate()} call. Else it will either return the value
+     * by the {@link #validate( Logger logger )} call. Else it will either return the value
      * of an explicitly set "immediate" attribute or return false if a service
      * element or the factory attribute is set or true otherwise. This latter
      * default value deduction may be unsafe while the descriptor has not been
@@ -611,7 +611,7 @@ public class ComponentMetadata
      *
      * @return the properties as a Dictionary
      */
-    public Dictionary getProperties()
+    public Dictionary<String, Object> getProperties()
     {
         return m_properties;
     }
@@ -623,7 +623,7 @@ public class ComponentMetadata
      *
      * @return the list of property meta data.
      */
-    List getPropertyMetaData()
+    List<PropertyMetadata> getPropertyMetaData()
     {
         return m_propertyMetaData;
     }
@@ -634,7 +634,7 @@ public class ComponentMetadata
      *
      * @return a Collection of dependency descriptors
      */
-    public List getDependencies()
+    public List<ReferenceMetadata> getDependencies()
     {
         return m_references;
     }

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/PropertyMetadata.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/PropertyMetadata.java?rev=1415461&r1=1415460&r2=1415461&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/PropertyMetadata.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/PropertyMetadata.java Thu Nov 29 23:53:21 2012
@@ -92,7 +92,7 @@ public class PropertyMetadata {
             return;
         }
         // splite th values
-        List valueList = new ArrayList();
+        List<String> valueList = new ArrayList<String>();
         StringTokenizer tokener = new StringTokenizer(values, "\r\n");
         while (tokener.hasMoreTokens()) {
             String value = tokener.nextToken().trim();
@@ -324,7 +324,7 @@ public class PropertyMetadata {
             boolean[] array = new boolean[valueList.length];
             for ( int i = 0; i < array.length; i++ )
             {
-                array[i] = Boolean.valueOf( valueList[i] ).booleanValue();
+                array[i] = Boolean.valueOf( valueList[i] );
             }
             return array;
         }

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ServiceMetadata.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ServiceMetadata.java?rev=1415461&r1=1415460&r2=1415461&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ServiceMetadata.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ServiceMetadata.java Thu Nov 29 23:53:21 2012
@@ -33,7 +33,7 @@ public class ServiceMetadata {
 	private boolean m_serviceFactory = false;
 
 	// List of provided interfaces
-	private List m_provides = new ArrayList();
+	private List<String> m_provides = new ArrayList<String>();
 
 	// Flag that indicates if this metadata has been validated and has become immutable
 	private boolean m_validated = false;
@@ -79,7 +79,7 @@ public class ServiceMetadata {
      * @return the implemented interfaces as a string array
      */
     public String [] getProvides() {
-        return (String[]) m_provides.toArray( new String[m_provides.size()] );
+        return m_provides.toArray( new String[m_provides.size()] );
     }
 
     /**

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/XmlHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/XmlHandler.java?rev=1415461&r1=1415460&r2=1415461&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/XmlHandler.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/XmlHandler.java Thu Nov 29 23:53:21 2012
@@ -242,7 +242,7 @@ public class XmlHandler implements KXml2
                     // configuration-pid attribute is optional (since DS 1.2)
                     if (attrib.getProperty("configuration-pid") != null)
                     {
-                        m_currentComponent.setConfigirationPid( attrib.getProperty( "configuration-pid" ) );
+                        m_currentComponent.setConfigurationPid( attrib.getProperty( "configuration-pid" ) );
                     }
 
                     // Add this component to the list

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/metadata/ComponentMetadataTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/metadata/ComponentMetadataTest.java?rev=1415461&r1=1415460&r2=1415461&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/metadata/ComponentMetadataTest.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/metadata/ComponentMetadataTest.java Thu Nov 29 23:53:21 2012
@@ -715,7 +715,7 @@ public class ComponentMetadataTest exten
       ComponentMetadata cm = createComponentMetadata11( null, null );
         try
         {
-          cm.setConfigirationPid( "configurationPid" );
+          cm.setConfigurationPid( "configurationPid" );
           cm.validate( logger );
           fail( "Expect validation failure for illegal configuration-pid usage in ds 1.1 namespace" );
         }
@@ -727,7 +727,7 @@ public class ComponentMetadataTest exten
         cm = createComponentMetadata12( null, null );
         try
         {
-          cm.setConfigirationPid( "configurationPid" );
+          cm.setConfigurationPid( "configurationPid" );
           cm.validate( logger );
         }
         catch ( ComponentException ce )



Mime
View raw message