felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1415461 [1/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
Author: djencks
Date: Thu Nov 29 23:53:21 2012
New Revision: 1415461

URL: http://svn.apache.org/viewvc?rev=1415461&view=rev
Log:
FELIX-3708 use java 5-isms in DS

Modified:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ComponentHolder.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/MethodResult.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ConfigurationComponentFactoryImpl.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DelayedComponentManager.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/RefPair.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceFactoryComponentManager.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/PropertyMetadata.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ServiceMetadata.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/XmlHandler.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/metadata/ComponentMetadataTest.java

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java?rev=1415461&r1=1415460&r2=1415461&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java Thu Nov 29 23:53:21 2012
@@ -61,7 +61,7 @@ public class Activator implements Bundle
     private static ServiceTracker m_packageAdmin;
 
     // map of BundleComponentActivator instances per Bundle indexed by Bundle id
-    private Map m_componentBundles;
+    private Map<Long, BundleComponentActivator> m_componentBundles;
 
     // registry of managed component
     private ComponentRegistry m_componentRegistry;
@@ -85,7 +85,7 @@ public class Activator implements Bundle
         m_logService.open();
 
         // prepare component registry
-        m_componentBundles = new HashMap();
+        m_componentBundles = new HashMap<Long, BundleComponentActivator>();
         m_componentRegistry = new ComponentRegistry( context );
 
         // get the configuration
@@ -191,9 +191,8 @@ public class Activator implements Bundle
     private void loadAllComponents( BundleContext context )
     {
         Bundle[] bundles = context.getBundles();
-        for ( int i = 0; i < bundles.length; i++ )
+        for ( Bundle bundle : bundles )
         {
-            Bundle bundle = bundles[i];
             if ( ComponentRegistry.isBundleActive( bundle ) )
             {
                 loadComponents( bundle );
@@ -234,7 +233,7 @@ public class Activator implements Bundle
         // FELIX-2231 Mark bundle loaded early to prevent concurrent loading
         // if LAZY_ACTIVATION and STARTED event are fired at the same time
         final boolean loaded;
-        final Long bundleId = new Long( bundle.getBundleId() );
+        final Long bundleId = bundle.getBundleId();
         synchronized ( m_componentBundles )
         {
             if ( m_componentBundles.containsKey( bundleId ) )
@@ -243,7 +242,7 @@ public class Activator implements Bundle
             }
             else
             {
-                m_componentBundles.put( bundleId, bundleId );
+                m_componentBundles.put( bundleId, null );
                 loaded = false;
             }
         }
@@ -306,7 +305,7 @@ public class Activator implements Bundle
         final Object ga;
         synchronized ( m_componentBundles )
         {
-            ga = m_componentBundles.remove( new Long( bundle.getBundleId() ) );
+            ga = m_componentBundles.remove( bundle.getBundleId() );
         }
 
         if ( ga instanceof BundleComponentActivator )
@@ -334,11 +333,11 @@ public class Activator implements Bundle
             m_componentBundles.clear();
         }
 
-        for ( int i = 0; i < activators.length; i++ )
+        for ( Object activator : activators )
         {
-            if ( activators[i] instanceof BundleComponentActivator )
+            if ( activator instanceof BundleComponentActivator )
             {
-                final BundleComponentActivator ga = ( BundleComponentActivator ) activators[i];
+                final BundleComponentActivator ga = ( BundleComponentActivator ) activator;
                 try
                 {
                     final Bundle bundle = ga.getBundleContext().getBundle();
@@ -349,7 +348,7 @@ public class Activator implements Bundle
                     catch ( Exception e )
                     {
                         log( LogService.LOG_ERROR, m_context.getBundle(), "Error while disposing components of bundle "
-                            + bundle.getSymbolicName() + "/" + bundle.getBundleId(), e );
+                                + bundle.getSymbolicName() + "/" + bundle.getBundleId(), e );
                     }
                 }
                 catch ( IllegalStateException e )

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java?rev=1415461&r1=1415460&r2=1415461&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java Thu Nov 29 23:53:21 2012
@@ -61,7 +61,7 @@ public class BundleComponentActivator im
     private BundleContext m_context = null;
 
     // This is a list of component instance managers that belong to a particular bundle
-    private List m_managers = new ArrayList();
+    private List<ComponentHolder> m_managers = new ArrayList<ComponentHolder>();
 
     // The Configuration Admin tracker providing configuration for components
     private ServiceTracker m_logService;
@@ -144,16 +144,15 @@ public class BundleComponentActivator im
             }
 
             // load from the descriptors
-            for ( int i = 0; i < descriptorURLs.length; i++ )
+            for ( URL descriptorURL : descriptorURLs )
             {
-                loadDescriptor( descriptorURLs[i] );
+                loadDescriptor( descriptorURL );
             }
         }
         //enable all the enabled components
-        for (Iterator it = m_managers.iterator(); it.hasNext();)
+        for ( ComponentHolder componentHolder : m_managers )
         {
-            ComponentHolder componentHolder = ( ComponentHolder ) it.next();
-            if (componentHolder.getComponentMetadata().isEnabled())
+            if ( componentHolder.getComponentMetadata().isEnabled() )
             {
                 componentHolder.enableComponents( false );
             }
@@ -191,19 +190,19 @@ public class BundleComponentActivator im
         }
 
         // find the entries
-        final Enumeration entries = bundle.findEntries( path, filePattern, false );
+        final Enumeration<URL> entries = bundle.findEntries( path, filePattern, false );
         if ( entries == null || !entries.hasMoreElements() )
         {
             return new URL[0];
         }
 
         // create the result list
-        List urls = new ArrayList();
+        List<URL> urls = new ArrayList<URL>();
         while ( entries.hasMoreElements() )
         {
             urls.add( entries.nextElement() );
         }
-        return ( URL[] ) urls.toArray( new URL[urls.size()] );
+        return urls.toArray( new URL[urls.size()] );
     }
 
 
@@ -227,10 +226,9 @@ public class BundleComponentActivator im
 
             // 112.4.2 Component descriptors may contain a single, root component element
             // or one or more component elements embedded in a larger document
-            Iterator i = handler.getComponentMetadataList().iterator();
-            while ( i.hasNext() )
+            for ( Object o : handler.getComponentMetadataList() )
             {
-                ComponentMetadata metadata = ( ComponentMetadata ) i.next();
+                ComponentMetadata metadata = ( ComponentMetadata ) o;
                 ComponentRegistryKey key = null;
                 try
                 {
@@ -313,7 +311,7 @@ public class BundleComponentActivator im
 
         while ( m_managers.size() != 0 )
         {
-            ComponentHolder holder = ( ComponentHolder ) m_managers.get( 0 );
+            ComponentHolder holder = m_managers.get( 0 );
             try
             {
                 m_managers.remove( holder );
@@ -333,7 +331,7 @@ public class BundleComponentActivator im
         }
 
         log( LogService.LOG_DEBUG, "BundleComponentActivator : Bundle [{0}] STOPPED", new Object[]
-            { new Long( m_context.getBundle().getBundleId() ) }, null, null );
+            {m_context.getBundle().getBundleId()}, null, null );
 
         if (m_logService != null) {
             m_logService.close();
@@ -393,16 +391,16 @@ public class BundleComponentActivator im
             return;
         }
 
-        for ( int i = 0; i < holder.length; i++ )
+        for ( ComponentHolder aHolder : holder )
         {
             try
             {
-                log( LogService.LOG_DEBUG, "Enabling Component", holder[i].getComponentMetadata(), null );
-                holder[i].enableComponents( true );
+                log( LogService.LOG_DEBUG, "Enabling Component", aHolder.getComponentMetadata(), null );
+                aHolder.enableComponents( true );
             }
             catch ( Throwable t )
             {
-                log( LogService.LOG_ERROR, "Cannot enable component", holder[i].getComponentMetadata(), t );
+                log( LogService.LOG_ERROR, "Cannot enable component", aHolder.getComponentMetadata(), t );
             }
         }
     }
@@ -425,16 +423,16 @@ public class BundleComponentActivator im
             return;
         }
 
-        for ( int i = 0; i < holder.length; i++ )
+        for ( ComponentHolder aHolder : holder )
         {
             try
             {
-                log( LogService.LOG_DEBUG, "Disabling Component", holder[i].getComponentMetadata(), null );
-                holder[i].disableComponents( true );
+                log( LogService.LOG_DEBUG, "Disabling Component", aHolder.getComponentMetadata(), null );
+                aHolder.disableComponents( true );
             }
             catch ( Throwable t )
             {
-                log( LogService.LOG_ERROR, "Cannot disable component", holder[i].getComponentMetadata(), t );
+                log( LogService.LOG_ERROR, "Cannot disable component", aHolder.getComponentMetadata(), t );
             }
         }
     }
@@ -460,7 +458,7 @@ public class BundleComponentActivator im
         // if all components are selected
         if ( name == null )
         {
-            return ( ComponentHolder[] ) m_managers.toArray( new ComponentHolder[m_managers.size()] );
+            return m_managers.toArray( new ComponentHolder[m_managers.size()] );
         }
 
         ComponentHolder componentHolder = m_componentRegistry.getComponentHolder( m_context.getBundle(), name );

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java?rev=1415461&r1=1415460&r2=1415461&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java Thu Nov 29 23:53:21 2012
@@ -19,6 +19,7 @@
 package org.apache.felix.scr.impl;
 
 
+import java.lang.reflect.Array;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Dictionary;
@@ -82,7 +83,7 @@ public class ComponentRegistry implement
      * @see #registerComponentHolder(String, ComponentHolder)
      * @see #unregisterComponentHolder(String)
      */
-    private final Map /* <ComponentRegistryKey, Object> */ m_componentHoldersByName;
+    private final Map<ComponentRegistryKey, ComponentHolder> m_componentHoldersByName;
 
     /**
      * The map of known components indexed by component configuration pid. The values are
@@ -101,7 +102,7 @@ public class ComponentRegistry implement
      * @see #unregisterComponentHolder(String)
      * @see ConfigurationSupport#configurationEvent(org.osgi.service.cm.ConfigurationEvent)
      */
-    private final Map m_componentHoldersByPid;
+    private final Map<String, Set<ComponentHolder>> m_componentHoldersByPid;
 
     /**
      * Map of components by component ID. This map indexed by the component
@@ -111,7 +112,7 @@ public class ComponentRegistry implement
      * @see #registerComponentId(AbstractComponentManager)
      * @see #unregisterComponentId(long)
      */
-    private final Map m_componentsById;
+    private final Map<Long, AbstractComponentManager> m_componentsById;
 
     /**
      * Counter to setup the component IDs as issued by the
@@ -130,7 +131,7 @@ public class ComponentRegistry implement
     // the ConfigurationAdmin service
     private ConfigurationSupport configurationSupport;
 
-    private final Map m_missingDependencies = new HashMap( );
+    private final Map<ServiceReference<?>, List<DependencyManager>> m_missingDependencies = new HashMap<ServiceReference<?>, List<DependencyManager>>( );
 
     protected ComponentRegistry( BundleContext context )
     {
@@ -333,27 +334,31 @@ public class ComponentRegistry implement
     {
         // register the name if no registration for that name exists already
         final ComponentRegistryKey key = new ComponentRegistryKey( bundle, name );
-        final Object existingRegistration;
+        ComponentHolder existingRegistration = null;
+        boolean present;
         synchronized ( m_componentHoldersByName )
         {
-            existingRegistration = m_componentHoldersByName.get( key );
-            if ( existingRegistration == null )
+            present = m_componentHoldersByName.containsKey( key );
+            if ( !present )
             {
-                m_componentHoldersByName.put( key, key );
+                m_componentHoldersByName.put( key, null );
+            }
+            else
+            {
+                existingRegistration = m_componentHoldersByName.get( key );
             }
         }
 
         // there was a registration already, throw an exception and use the
         // existing registration to provide more information if possible
-        if ( existingRegistration != null )
+        if ( present )
         {
             String message = "The component name '" + name + "' has already been registered";
 
-            if ( existingRegistration instanceof ComponentHolder )
+            if ( existingRegistration != null )
             {
-                ComponentHolder c = ( ComponentHolder ) existingRegistration;
-                Bundle cBundle = c.getActivator().getBundleContext().getBundle();
-                ComponentMetadata cMeta = c.getComponentMetadata();
+                Bundle cBundle = existingRegistration.getActivator().getBundleContext().getBundle();
+                ComponentMetadata cMeta = existingRegistration.getComponentMetadata();
 
                 StringBuffer buf = new StringBuffer( message );
                 buf.append( " by Bundle " ).append( cBundle.getBundleId() );
@@ -388,7 +393,7 @@ public class ComponentRegistry implement
         synchronized ( m_componentHoldersByName )
         {
             // only register the component if there is a m_registration for it !
-            if ( !key.equals( m_componentHoldersByName.get( key ) ) )
+            if ( m_componentHoldersByName.get( key ) != null )
             {
                 // this is not expected if all works ok
                 throw new ComponentException( "The component name '" + component.getComponentMetadata().getName()
@@ -406,10 +411,10 @@ public class ComponentRegistry implement
             // Since several components may refer to the same configuration pid, we have to
             // store the component holder in a Set, in order to be able to lookup every
             // components from a given pid.
-            Set set = (Set) m_componentHoldersByPid.get(configurationPid);
+            Set<ComponentHolder> set = m_componentHoldersByPid.get(configurationPid);
             if (set == null)
             {
-                set = new HashSet();
+                set = new HashSet<ComponentHolder>();
                 m_componentHoldersByPid.put(configurationPid, set);
             }
             set.add(component);
@@ -422,7 +427,7 @@ public class ComponentRegistry implement
      */
     public final ComponentHolder getComponentHolder( final Bundle bundle, final String name )
     {
-        Object entry;
+        ComponentHolder entry;
         synchronized ( m_componentHoldersByName )
         {
             entry = m_componentHoldersByName.get( new ComponentRegistryKey( bundle, name ) );
@@ -444,12 +449,12 @@ public class ComponentRegistry implement
      * @return a iterator of ComponentHolder, or an empty iterator if no ComponentHolders
      * are found
      */
-    public final Iterator getComponentHoldersByPid(String pid)
+    public final Iterator<ComponentHolder> getComponentHoldersByPid(String pid)
     {
-        Set componentHoldersUsingPid = new HashSet();
+        Set<ComponentHolder> componentHoldersUsingPid = new HashSet<ComponentHolder>();
         synchronized (m_componentHoldersByPid)
         {
-            Set set = (Set) m_componentHoldersByPid.get(pid);
+            Set<ComponentHolder> set = m_componentHoldersByPid.get(pid);
             // only return the entry if non-null and not a reservation
             if (set != null)
             {
@@ -465,11 +470,11 @@ public class ComponentRegistry implement
      * name reservations or {@link ComponentHolder} instances for actual
      * holders of components.
      */
-    private Object[] getComponentHolders()
+    private ComponentHolder[] getComponentHolders()
     {
         synchronized ( m_componentHoldersByName )
         {
-            return m_componentHoldersByName.values().toArray();
+            return m_componentHoldersByName.values().toArray( new ComponentHolder[ m_componentHoldersByName.size() ]);
         }
     }
 
@@ -494,17 +499,17 @@ public class ComponentRegistry implement
      */
     final void unregisterComponentHolder( final ComponentRegistryKey key )
     {
-        Object component;
+        ComponentHolder component;
         synchronized ( m_componentHoldersByName )
         {
             component = m_componentHoldersByName.remove( key );
         }
 
-        if (component instanceof ComponentHolder) {
+        if (component != null) {
             synchronized (m_componentHoldersByPid)
             {
-                String configurationPid = ((ComponentHolder) component).getComponentMetadata().getConfigurationPid();
-                Set componentsForPid = (Set) m_componentHoldersByPid.get(configurationPid);
+                String configurationPid = component.getComponentMetadata().getConfigurationPid();
+                Set<ComponentHolder> componentsForPid = m_componentHoldersByPid.get(configurationPid);
                 if (componentsForPid != null)
                 {
                     componentsForPid.remove(component);
@@ -655,7 +660,7 @@ public class ComponentRegistry implement
 
     public void missingServicePresent( final ServiceReference serviceReference, ComponentActorThread actor )
     {
-        final List dependencyManagers = ( List ) m_missingDependencies.remove( serviceReference );
+        final List<DependencyManager> dependencyManagers = m_missingDependencies.remove( serviceReference );
         if ( dependencyManagers != null )
         {
             actor.schedule( new Runnable()
@@ -663,9 +668,8 @@ public class ComponentRegistry implement
 
                 public void run()
                 {
-                    for ( Iterator i = dependencyManagers.iterator(); i.hasNext(); )
+                    for ( DependencyManager dm : dependencyManagers )
                     {
-                        DependencyManager dm = ( DependencyManager ) i.next();
                         dm.invokeBindMethodLate( serviceReference );
                     }
                 }
@@ -680,10 +684,10 @@ public class ComponentRegistry implement
         {
             return;
         }
-        List dependencyManagers = ( List ) m_missingDependencies.get( serviceReference );
+        List<DependencyManager> dependencyManagers = m_missingDependencies.get( serviceReference );
         if ( dependencyManagers == null )
         {
-            dependencyManagers = new ArrayList();
+            dependencyManagers = new ArrayList<DependencyManager>();
             m_missingDependencies.put( serviceReference, dependencyManagers );
         }
         dependencyManagers.add( dependencyManager );

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java?rev=1415461&r1=1415460&r2=1415461&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java Thu Nov 29 23:53:21 2012
@@ -167,14 +167,14 @@ class ScrCommand
         }
 
         out.println("   Id   State          Name");
-        for (int i = 0; i < components.length; i++)
+        for ( Component component : components )
         {
-            out.print('[');
-            out.print(pad(String.valueOf(components[i].getId()), -4));
-            out.print("] [");
-            out.print(pad(toStateString(components[i].getState()), 13));
-            out.print("] ");
-            out.print(components[i].getName());
+            out.print( '[' );
+            out.print( pad( String.valueOf( component.getId() ), -4 ) );
+            out.print( "] [" );
+            out.print( pad( toStateString( component.getState() ), 13 ) );
+            out.print( "] " );
+            out.print( component.getName() );
             out.println();
         }
     }
@@ -187,131 +187,131 @@ class ScrCommand
             return;
         }
 
-        for (int j = 0; j < components.length; j++)
+        for ( Component component : components )
         {
-            Component component = components[j];
-            out.print("ID: ");
-            out.println(component.getId());
-            out.print("Name: ");
-            out.println(component.getName());
-            out.print("Bundle: ");
-            out.println(component.getBundle().getSymbolicName() + " (" + component.getBundle().getBundleId() + ")");
-            out.print("State: ");
-            out.println(toStateString(component.getState()));
-            out.print("Default State: ");
-            out.println(component.isDefaultEnabled() ? "enabled" : "disabled");
-            out.print("Activation: ");
-            out.println(component.isImmediate() ? "immediate" : "delayed");
+            out.print( "ID: " );
+            out.println( component.getId() );
+            out.print( "Name: " );
+            out.println( component.getName() );
+            out.print( "Bundle: " );
+            out.println( component.getBundle().getSymbolicName() + " (" + component.getBundle().getBundleId() + ")" );
+            out.print( "State: " );
+            out.println( toStateString( component.getState() ) );
+            out.print( "Default State: " );
+            out.println( component.isDefaultEnabled() ? "enabled" : "disabled" );
+            out.print( "Activation: " );
+            out.println( component.isImmediate() ? "immediate" : "delayed" );
 
             // DS 1.1 new features
-            out.print("Configuration Policy: ");
-            out.println(component.getConfigurationPolicy());
-            out.print("Activate Method: ");
-            out.print(component.getActivate());
-            if (component.isActivateDeclared())
+            out.print( "Configuration Policy: " );
+            out.println( component.getConfigurationPolicy() );
+            out.print( "Activate Method: " );
+            out.print( component.getActivate() );
+            if ( component.isActivateDeclared() )
             {
-                out.print(" (declared in the descriptor)");
+                out.print( " (declared in the descriptor)" );
             }
             out.println();
-            out.print("Deactivate Method: ");
-            out.print(component.getDeactivate());
-            if (component.isDeactivateDeclared())
+            out.print( "Deactivate Method: " );
+            out.print( component.getDeactivate() );
+            if ( component.isDeactivateDeclared() )
             {
-                out.print(" (declared in the descriptor)");
+                out.print( " (declared in the descriptor)" );
             }
             out.println();
-            out.print("Modified Method: ");
-            if (component.getModified() != null)
+            out.print( "Modified Method: " );
+            if ( component.getModified() != null )
             {
-                out.print(component.getModified());
+                out.print( component.getModified() );
             }
             else
             {
-                out.print("-");
+                out.print( "-" );
             }
             out.println();
 
-            out.print("Configuration Pid: ");
-            out.print(component.getConfigurationPid());
-            if (component.isConfigurationPidDeclared())
+            out.print( "Configuration Pid: " );
+            out.print( component.getConfigurationPid() );
+            if ( component.isConfigurationPidDeclared() )
             {
-                out.print(" (declared in the descriptor)");
+                out.print( " (declared in the descriptor)" );
             }
             out.println();
 
-            if (component.getFactory() != null)
+            if ( component.getFactory() != null )
             {
-                out.print("Factory: ");
-                out.println(component.getFactory());
+                out.print( "Factory: " );
+                out.println( component.getFactory() );
             }
 
             String[] services = component.getServices();
-            if (services != null)
+            if ( services != null )
             {
-                out.print("Services: ");
-                out.println(services[0]);
-                for (int i = 1; i < services.length; i++)
+                out.print( "Services: " );
+                out.println( services[0] );
+                for ( int i = 1; i < services.length; i++ )
                 {
-                    out.print("          ");
-                    out.println(services[i]);
+                    out.print( "          " );
+                    out.println( services[i] );
                 }
-                out.print("Service Type: ");
-                out.println(component.isServiceFactory() ? "service factory" : "service");
+                out.print( "Service Type: " );
+                out.println( component.isServiceFactory() ? "service factory" : "service" );
             }
 
             Reference[] refs = component.getReferences();
-            if (refs != null)
+            if ( refs != null )
             {
-                for (int i = 0; i < refs.length; i++)
+                for ( Reference ref : refs )
                 {
-                    out.print("Reference: ");
-                    out.println(refs[i].getName());
-                    out.print("    Satisfied: ");
-                    out.println(refs[i].isSatisfied() ? "satisfied" : "unsatisfied");
-                    out.print("    Service Name: ");
-                    out.println(refs[i].getServiceName());
-                    if (refs[i].getTarget() != null)
+                    out.print( "Reference: " );
+                    out.println( ref.getName() );
+                    out.print( "    Satisfied: " );
+                    out.println( ref.isSatisfied() ? "satisfied" : "unsatisfied" );
+                    out.print( "    Service Name: " );
+                    out.println( ref.getServiceName() );
+                    if ( ref.getTarget() != null )
                     {
-                        out.print("    Target Filter: ");
-                        out.println(refs[i].getTarget());
+                        out.print( "    Target Filter: " );
+                        out.println( ref.getTarget() );
                     }
-                    out.print("    Multiple: ");
-                    out.println(refs[i].isMultiple() ? "multiple" : "single");
-                    out.print("    Optional: ");
-                    out.println(refs[i].isOptional() ? "optional" : "mandatory");
-                    out.print("    Policy: ");
-                    out.println(refs[i].isStatic() ? "static" : "dynamic");
-                    out.print("    Policy option: ");
-                    out.println(refs[i].isReluctant() ? "reluctant" : "greedy");
-                    ServiceReference[] serviceRefs = refs[i].getBoundServiceReferences();
-                    if (serviceRefs != null) {
-                        out.print("    Bound to:");
-                        for (int k = 0; k< serviceRefs.length; k++) {
-                            out.print("        " );
-                            out.println(serviceRefs[k]);
+                    out.print( "    Multiple: " );
+                    out.println( ref.isMultiple() ? "multiple" : "single" );
+                    out.print( "    Optional: " );
+                    out.println( ref.isOptional() ? "optional" : "mandatory" );
+                    out.print( "    Policy: " );
+                    out.println( ref.isStatic() ? "static" : "dynamic" );
+                    out.print( "    Policy option: " );
+                    out.println( ref.isReluctant() ? "reluctant" : "greedy" );
+                    ServiceReference[] serviceRefs = ref.getBoundServiceReferences();
+                    if ( serviceRefs != null )
+                    {
+                        out.print( "    Bound to:" );
+                        for ( int k = 0; k < serviceRefs.length; k++ )
+                        {
+                            out.print( "        " );
+                            out.println( serviceRefs[k] );
                         }
                     }
                 }
             }
 
             Dictionary props = component.getProperties();
-            if (props != null)
+            if ( props != null )
             {
-                out.println("Properties:");
-                TreeSet keys = new TreeSet(Collections.list(props.keys()));
-                for (Iterator ki = keys.iterator(); ki.hasNext();)
+                out.println( "Properties:" );
+                TreeSet keys = new TreeSet( Collections.list( props.keys() ) );
+                for ( Object key : keys )
                 {
-                    Object key = ki.next();
-                    out.print("    ");
-                    out.print(key);
-                    out.print(" = ");
+                    out.print( "    " );
+                    out.print( key );
+                    out.print( " = " );
 
-                    Object prop = props.get(key);
-                    if (prop.getClass().isArray())
+                    Object prop = props.get( key );
+                    if ( prop.getClass().isArray() )
                     {
-                        prop = Arrays.asList((Object[]) prop);
+                        prop = Arrays.asList( ( Object[] ) prop );
                     }
-                    out.print(prop);
+                    out.print( prop );
 
                     out.println();
                 }
@@ -327,35 +327,34 @@ class ScrCommand
             return;
         }
 
-        for (int i = 0; i < components.length; i++)
+        for ( Component component : components )
         {
-            Component component = components[i];
-            if (component.getState() == Component.STATE_DISPOSED)
+            if ( component.getState() == Component.STATE_DISPOSED )
             {
-                err.println("Component " + component.getName() + " already disposed, cannot change state");
+                err.println( "Component " + component.getName() + " already disposed, cannot change state" );
             }
-            else if (enable)
+            else if ( enable )
             {
-                if (component.getState() == Component.STATE_DISABLED)
+                if ( component.getState() == Component.STATE_DISABLED )
                 {
                     component.enable();
-                    out.println("Component " + component.getName() + " enabled");
+                    out.println( "Component " + component.getName() + " enabled" );
                 }
                 else
                 {
-                    out.println("Component " + component.getName() + " already enabled");
+                    out.println( "Component " + component.getName() + " already enabled" );
                 }
             }
             else
             {
-                if (component.getState() != Component.STATE_DISABLED)
+                if ( component.getState() != Component.STATE_DISABLED )
                 {
                     component.disable();
-                    out.println("Component " + component.getName() + " disabled");
+                    out.println( "Component " + component.getName() + " disabled" );
                 }
                 else
                 {
-                    out.println("Component " + component.getName() + " already disabled");
+                    out.println( "Component " + component.getName() + " already disabled" );
                 }
             }
         }

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ComponentHolder.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ComponentHolder.java?rev=1415461&r1=1415460&r2=1415461&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ComponentHolder.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ComponentHolder.java Thu Nov 29 23:53:21 2012
@@ -68,7 +68,7 @@ public interface ComponentHolder
      *
      * @param pid The PID of the configuration used to configure the component
      */
-    void configurationUpdated( String pid, Dictionary props );
+    void configurationUpdated( String pid, Dictionary<String, Object> props );
 
     /**
      * Returns all <code>Component</code> instances held by this holder.

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/MethodResult.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/MethodResult.java?rev=1415461&r1=1415460&r2=1415461&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/MethodResult.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/MethodResult.java Thu Nov 29 23:53:21 2012
@@ -41,11 +41,11 @@ public class MethodResult
     /**
      * The actual result from the method, which may be <code>null</code>.
      */
-    private final Map result;
+    private final Map<String, Object> result;
 
     private final boolean hasResult;
 
-    MethodResult(final boolean hasResult, final Map result)
+    MethodResult(final boolean hasResult, final Map<String, Object> result)
     {
         this.hasResult = hasResult;
         this.result = result;
@@ -56,7 +56,7 @@ public class MethodResult
         return hasResult;
     }
 
-    public Map getResult()
+    public Map<String, Object> getResult()
     {
         return result;
     }

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java?rev=1415461&r1=1415460&r2=1415461&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java Thu Nov 29 23:53:21 2012
@@ -35,6 +35,7 @@ import java.util.concurrent.atomic.Atomi
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.concurrent.locks.ReentrantLock;
 
+import com.sun.xml.internal.rngom.binary.DataExceptPattern;
 import org.apache.felix.scr.Component;
 import org.apache.felix.scr.Reference;
 import org.apache.felix.scr.impl.BundleComponentActivator;
@@ -59,7 +60,7 @@ import org.osgi.service.log.LogService;
  * implementation object's lifecycle.
  *
  */
-public abstract class AbstractComponentManager implements Component, SimpleLogger
+public abstract class AbstractComponentManager<S> implements Component, SimpleLogger
 {
 
     // the ID of this component
@@ -76,27 +77,22 @@ public abstract class AbstractComponentM
     private final ComponentMethods m_componentMethods;
 
     // The dependency managers that manage every dependency
-    private final List m_dependencyManagers;
+    private final List<DependencyManager> m_dependencyManagers;
 
     private boolean m_dependencyManagersInitialized;
 
-    //<Map<DependencyManager, Map<ServiceReference, RefPair>>>
-    private final AtomicReference m_dependencies_map;
+    private final AtomicReference<Map<DependencyManager<S, ?>, Map<ServiceReference<?>, RefPair<?>>>> m_dependencies_map;
 
     // A reference to the BundleComponentActivator
     private BundleComponentActivator m_activator;
 
     // The ServiceRegistration
-    private final AtomicReference m_serviceRegistration;
+    private final AtomicReference<ServiceRegistration<S>> m_serviceRegistration;
 
     private final ReentrantLock m_stateLock;
 
     private long m_timeout = 5000;
 
-//    private Thread lockingThread;
-//    private Throwable lockingStackTrace;
-//    private ArrayList lockingActivity = new ArrayList( );
-
     protected volatile boolean enabled;
     protected volatile CountDownLatch enabledLatch;
     private final Object enabledLatchLock = new Object();
@@ -125,8 +121,8 @@ public abstract class AbstractComponentM
         m_dependencyManagers = loadDependencyManagers( metadata );
 
         m_stateLock = new ReentrantLock( true );
-        m_dependencies_map = new AtomicReference();
-        m_serviceRegistration = new AtomicReference();
+        m_dependencies_map = new AtomicReference<Map<DependencyManager<S, ?>, Map<ServiceReference<?>, RefPair<?>>>>();
+        m_serviceRegistration = new AtomicReference<ServiceRegistration<S>>();
 
         // dump component details
         if ( isLogEnabled( LogService.LOG_DEBUG ) )
@@ -158,19 +154,12 @@ public abstract class AbstractComponentM
 
     final void obtainWriteLock( String source )
     {
-//        if ( isLogEnabled( LogService.LOG_DEBUG ) )
-//        {
-//            lockingActivity.add( "obtainWriteLock from: " +  source + " readLocks: " + m_stateLock.getReadHoldCount() + " writeLocks: " + m_stateLock.getWriteHoldCount() + " thread: " + Thread.currentThread() + " time: " + System.currentTimeMillis());
-//        }
         try
         {
             if (!m_stateLock.tryLock( m_timeout, TimeUnit.MILLISECONDS ) )
             {
-//                lockingActivity.add( "obtainWriteLock failure from: " +  source + " readLocks: " + m_stateLock.getReadHoldCount() + " writeLocks: " + m_stateLock.getWriteHoldCount() + " thread: " + Thread.currentThread() + " time: " + System.currentTimeMillis() + " Could not obtain write lock.");
                 throw new IllegalStateException( "Could not obtain lock" );
             }
-//            lockingThread = Thread.currentThread();
-//            lockingStackTrace = new Exception("Write lock stack trace for thread: " + lockingThread);
         }
         catch ( InterruptedException e )
         {
@@ -181,13 +170,7 @@ public abstract class AbstractComponentM
 
     final void releaseWriteLock( String source )
     {
-//        if ( isLogEnabled( LogService.LOG_DEBUG ) )
-//        {
-//            lockingActivity.add( "deescalateLock from: " +  source + " readLocks: " + m_stateLock.getReadHoldCount() + " writeLocks: " + m_stateLock.getWriteHoldCount() + " thread: " + Thread.currentThread() + " time: " + System.currentTimeMillis());
-//        }
         m_stateLock.unlock();
-//        lockingThread = null;
-//        lockingStackTrace = null;
     }
 
     final boolean isWriteLocked()
@@ -649,13 +632,13 @@ public abstract class AbstractComponentM
     {
         synchronized ( m_serviceRegistration )
         {
-            ServiceRegistration existing = ( ServiceRegistration ) m_serviceRegistration.get();
+            ServiceRegistration existing = m_serviceRegistration.get();
             if ( existing == null )
             {
                 log( LogService.LOG_DEBUG, "registering services", null );
 
                 // get a copy of the component properties as service properties
-                final Dictionary serviceProperties = getServiceProperties();
+                final Dictionary<String, Object> serviceProperties = getServiceProperties();
 
                 ServiceRegistration newRegistration = getActivator().getBundleContext().registerService(
                         provides,
@@ -694,7 +677,7 @@ public abstract class AbstractComponentM
         {
             synchronized ( m_serviceRegistration )
             {
-                ServiceRegistration sr = ( ServiceRegistration ) m_serviceRegistration.get();
+                ServiceRegistration sr = m_serviceRegistration.get();
 
                 if ( sr != null && m_serviceRegistration.compareAndSet( sr, null ) )
                 {
@@ -719,7 +702,7 @@ public abstract class AbstractComponentM
         {
             return true;
         }
-        Class implementationObjectClass;
+        Class<?> implementationObjectClass;
         try
         {
             implementationObjectClass = getActivator().getBundleContext().getBundle().loadClass(
@@ -732,10 +715,8 @@ public abstract class AbstractComponentM
         }
         m_componentMethods.initComponentMethods( this, m_componentMetadata, implementationObjectClass );
 
-        for (Iterator it = m_dependencyManagers.iterator(); it.hasNext(); )
+        for ( DependencyManager dependencyManager : m_dependencyManagers )
         {
-            DependencyManager dependencyManager = ( DependencyManager ) it.next();
-
             dependencyManager.initBindingMethods( m_componentMethods.getBindMethods( dependencyManager.getName() ) );
         }
         m_dependencyManagersInitialized = true;
@@ -753,19 +734,17 @@ public abstract class AbstractComponentM
      */
     protected boolean collectDependencies() throws IllegalStateException
     {
-        Map old = ( Map ) m_dependencies_map.get();
+        Map<DependencyManager<S, ?>, Map<ServiceReference<?>, RefPair<?>>> old = m_dependencies_map.get();
         if ( old != null)
         {
             log( LogService.LOG_DEBUG, "dependency map already present, do not collect dependencies", null );
             return false;
         }
         initDependencyManagers();
-        Map newDeps = new HashMap( );//<DependencyManager, Map<ServiceReference, RefPair>
-        for (Iterator it = m_dependencyManagers.iterator(); it.hasNext(); )
+        Map<DependencyManager<S, ?>, Map<ServiceReference<?>, RefPair<?>>> newDeps = new HashMap<DependencyManager<S, ?>, Map<ServiceReference<?>, RefPair<?>>>( );
+        for ( DependencyManager dependencyManager : m_dependencyManagers )
         {
-            DependencyManager dependencyManager = ( DependencyManager ) it.next();
-
-            if (!dependencyManager.prebind( newDeps) )
+            if ( !dependencyManager.prebind( newDeps ) )
             {
                 //not actually satisfied any longer
                 returnServices( newDeps );
@@ -784,7 +763,7 @@ public abstract class AbstractComponentM
         return true;
     }
 
-    protected boolean setDependencyMap( Map old, Map newDeps )
+    protected boolean setDependencyMap( Map<DependencyManager<S, ?>, Map<ServiceReference<?>, RefPair<?>>> old, Map<DependencyManager<S, ?>, Map<ServiceReference<?>, RefPair<?>>> newDeps )
     {
         return m_dependencies_map.compareAndSet( old, newDeps );
     }
@@ -794,35 +773,33 @@ public abstract class AbstractComponentM
         m_dependencies_map.set( null );
     }
 
-    private void returnServices( Map deps )
+    private void returnServices( Map<DependencyManager<S, ?>, Map<ServiceReference<?>, RefPair<?>>> deps )
     {
-         for (Iterator it = deps.values().iterator(); it.hasNext(); )
-         {
-             Map refs = ( Map ) it.next();
-             if ( refs != null )
-             {
-                 for (Iterator ri = refs.entrySet().iterator(); ri.hasNext(); )
-                 {
-                     Map.Entry entry = ( Map.Entry ) ri.next();
-                     RefPair args = ( RefPair ) entry.getValue();
-                     if ( args.getServiceObject() != null )
-                     {
-                         getActivator().getBundleContext().ungetService( (ServiceReference) entry.getKey() );
-                     }
-                 }
-             }
-         }
-    }
-
-    abstract void update( DependencyManager dependencyManager, ServiceReference ref );
+        for ( Map<ServiceReference<?>, RefPair<?>> refs : deps.values() )
+        {
+            if ( refs != null )
+            {
+                for ( Map.Entry<ServiceReference<?>, RefPair<?>> serviceReferenceRefPairEntry : refs.entrySet() )
+                {
+                    RefPair<?> args = serviceReferenceRefPairEntry.getValue();
+                    if ( args.getServiceObject() != null )
+                    {
+                        getActivator().getBundleContext().ungetService( serviceReferenceRefPairEntry.getKey() );
+                    }
+                }
+            }
+        }
+    }
+
+    abstract <T> void update( DependencyManager<S, T> dependencyManager, ServiceReference<T> ref );
 
-    abstract void invokeBindMethod( DependencyManager dependencyManager, ServiceReference reference );
+    abstract <T> void invokeBindMethod( DependencyManager<S, T> dependencyManager, ServiceReference<T> reference );
 
-    abstract void invokeUnbindMethod( DependencyManager dependencyManager, ServiceReference oldRef );
+    abstract <T> void invokeUnbindMethod( DependencyManager<S, T> dependencyManager, ServiceReference<T> oldRef );
 
-    Map getDependencyMap()
+    Map<DependencyManager<S, ?>, Map<ServiceReference<?>, RefPair<?>>> getDependencyMap()
     {
-        return ( Map ) m_dependencies_map.get();
+        return m_dependencies_map.get();
     }
 
     //**********************************************************************************************************
@@ -839,9 +816,9 @@ public abstract class AbstractComponentM
     }
 
 
-    final ServiceRegistration getServiceRegistration()
+    final ServiceRegistration<?> getServiceRegistration()
     {
-        return ( ServiceRegistration ) m_serviceRegistration.get();
+        return m_serviceRegistration.get();
     }
 
 
@@ -857,13 +834,6 @@ public abstract class AbstractComponentM
         m_dependencyManagers.clear();
     }
 
-    //<DependencyManager, Map<ServiceReference, RefPair>>
-    protected Map getParameterMap()
-    {
-        return ( Map ) m_dependencies_map.get();
-    }
-
-
     /**
      * Returns <code>true</code> if logging for the given level is enabled.
      */
@@ -917,13 +887,13 @@ public abstract class AbstractComponentM
                 if ( services != null && services.length > 0 )
                 {
                     final Bundle bundle = getBundle();
-                    for ( int i = 0; i < services.length; i++ )
+                    for ( String service : services )
                     {
-                        final Permission perm = new ServicePermission( services[i], ServicePermission.REGISTER );
+                        final Permission perm = new ServicePermission( service, ServicePermission.REGISTER );
                         if ( !bundle.hasPermission( perm ) )
                         {
                             log( LogService.LOG_DEBUG, "Permission to register service {0} is denied", new Object[]
-                                { services[i] }, null );
+                                    {service}, null );
                             allowed = false;
                         }
                     }
@@ -936,19 +906,15 @@ public abstract class AbstractComponentM
     }
 
 
-    private List loadDependencyManagers( ComponentMetadata metadata )
+    private List<DependencyManager> loadDependencyManagers( ComponentMetadata metadata )
     {
-        List depMgrList = new ArrayList(metadata.getDependencies().size());
+        List<DependencyManager> depMgrList = new ArrayList<DependencyManager>(metadata.getDependencies().size());
 
         // If this component has got dependencies, create dependency managers for each one of them.
         if ( metadata.getDependencies().size() != 0 )
         {
-            Iterator dependencyit = metadata.getDependencies().iterator();
-
-            while ( dependencyit.hasNext() )
+            for ( ReferenceMetadata currentdependency: metadata.getDependencies() )
             {
-                ReferenceMetadata currentdependency = (ReferenceMetadata) dependencyit.next();
-
                 DependencyManager depmanager = new DependencyManager( this, currentdependency );
 
                 depMgrList.add( depmanager );
@@ -962,10 +928,8 @@ public abstract class AbstractComponentM
     {
         if ( !m_componentMetadata.isConfigurationRequired() )
         {
-            Iterator it = getDependencyManagers();
-            while ( it.hasNext() )
+            for ( DependencyManager dm: getDependencyManagers() )
             {
-                DependencyManager dm = (DependencyManager) it.next();
                 dm.enable();
             }
         }
@@ -973,10 +937,9 @@ public abstract class AbstractComponentM
 
     protected void updateTargets(Dictionary properties)
     {
-        for (Object o: m_dependencyManagers)
+        for ( DependencyManager dm: getDependencyManagers() )
         {
-            DependencyManager dependencyManager = ( DependencyManager ) o;
-            dependencyManager.setTargetFilter( properties );
+            dm.setTargetFilter( properties );
         }
     }
 
@@ -985,10 +948,8 @@ public abstract class AbstractComponentM
         // indicates whether all dependencies are satisfied
         boolean satisfied = true;
 
-        Iterator it = getDependencyManagers();
-        while ( it.hasNext() )
+        for ( DependencyManager dm: getDependencyManagers() )
         {
-            DependencyManager dm = ( DependencyManager ) it.next();
 
             if ( !dm.hasGetPermission() )
             {
@@ -1023,29 +984,27 @@ public abstract class AbstractComponentM
      * Returns an iterator over the {@link DependencyManager} objects
      * representing the declared references in declaration order
      */
-    Iterator getDependencyManagers()
+    List<DependencyManager> getDependencyManagers()
     {
-        return m_dependencyManagers.iterator();
+        return m_dependencyManagers;
     }
 
     /**
      * Returns an iterator over the {@link DependencyManager} objects
      * representing the declared references in reversed declaration order
      */
-    Iterator getReversedDependencyManagers()
+    List<DependencyManager> getReversedDependencyManagers()
     {
         List list = new ArrayList( m_dependencyManagers );
         Collections.reverse( list );
-        return list.iterator();
+        return list;
     }
 
 
     DependencyManager getDependencyManager(String name)
     {
-        Iterator it = getDependencyManagers();
-        while ( it.hasNext() )
+        for ( DependencyManager dm: getDependencyManagers() )
         {
-            DependencyManager dm = (DependencyManager) it.next();
             if ( name.equals(dm.getName()) )
             {
                 return dm;
@@ -1058,29 +1017,25 @@ public abstract class AbstractComponentM
 
     private void deactivateDependencyManagers()
     {
-        Iterator it = getDependencyManagers();
-        while ( it.hasNext() )
+        for ( DependencyManager dm: getDependencyManagers() )
         {
-            DependencyManager dm = (DependencyManager) it.next();
             dm.deactivate();
         }
     }
 
     private void disableDependencyManagers()
     {
-        Iterator it = getDependencyManagers();
-        while ( it.hasNext() )
+        for ( DependencyManager dm: getDependencyManagers() )
         {
-            DependencyManager dm = (DependencyManager) it.next();
             dm.unregisterServiceListener();
         }
     }
 
     public abstract boolean hasConfiguration();
 
-    public abstract Dictionary getProperties();
+    public abstract Dictionary<String, Object> getProperties();
 
-    public abstract void setServiceProperties( Dictionary serviceProperties );
+    public abstract void setServiceProperties( Dictionary<String, Object> serviceProperties );
 
     /**
      * Returns the subset of component properties to be used as service
@@ -1088,7 +1043,7 @@ public abstract class AbstractComponentM
      * name does not start with dot (.), properties which are considered
      * private.
      */
-    public Dictionary getServiceProperties()
+    public Dictionary<String, Object> getServiceProperties()
     {
         return copyTo( null, getProperties(), false );
     }
@@ -1107,7 +1062,7 @@ public abstract class AbstractComponentM
      *      <code>source</code> is <code>null</code> or empty and
      *      <code>target</code> was <code>null</code>.
      */
-    protected static Dictionary copyTo( Dictionary target, Dictionary source )
+    protected static Dictionary<String, Object> copyTo( Dictionary<String, Object> target, Dictionary<String, Object> source )
     {
         return copyTo( target, source, true );
     }
@@ -1131,11 +1086,11 @@ public abstract class AbstractComponentM
      *         <code>target</code> was <code>null</code> or all properties are
      *         private and had not to be copied
      */
-    protected static Dictionary copyTo( Dictionary target, final Dictionary source, final boolean allProps )
+    protected static Dictionary<String, Object> copyTo( Dictionary<String, Object> target, final Dictionary<String, Object> source, final boolean allProps )
     {
         if ( target == null )
         {
-            target = new Hashtable();
+            target = new Hashtable<String, Object>();
         }
 
         if ( source != null && !source.isEmpty() )
@@ -1187,7 +1142,7 @@ public abstract class AbstractComponentM
     {
         if ( methodResult.hasResult() )
         {
-            Dictionary serviceProps = ( methodResult.getResult() == null) ? null : new Hashtable( methodResult.getResult() );
+            Dictionary<String, Object> serviceProps = ( methodResult.getResult() == null) ? null : new Hashtable<String, Object>( methodResult.getResult() );
             setServiceProperties(serviceProps );
         }
     }
@@ -1239,7 +1194,7 @@ public abstract class AbstractComponentM
         }
 
 
-        ServiceReference getServiceReference( AbstractComponentManager acm )
+        ServiceReference<?> getServiceReference( AbstractComponentManager acm )
         {
             throw new IllegalStateException("getServiceReference" + this);
         }

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java?rev=1415461&r1=1415460&r2=1415461&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java Thu Nov 29 23:53:21 2012
@@ -58,7 +58,7 @@ import org.osgi.service.log.LogService;
  * with earlier releases of the Apache Felix Declarative Services implementation.
  * But keep in mind, that this is non-standard behaviour.
  */
-public class ComponentFactoryImpl extends AbstractComponentManager implements ComponentFactory, ComponentHolder
+public class ComponentFactoryImpl<S> extends AbstractComponentManager<S> implements ComponentFactory, ComponentHolder
 {
 
     /**
@@ -71,14 +71,14 @@ public class ComponentFactoryImpl extend
      * entry is the same as the entry's key.
      * This is an IdentityHashMap for speed, thus not a Set.
      */
-    private final Map m_componentInstances;
+    private final Map<ImmediateComponentManager, ImmediateComponentManager> m_componentInstances;
 
     /**
      * The configuration for the component factory. This configuration is
      * supplied as the base configuration for each component instance created
      * by the {@link #newInstance(Dictionary)} method.
      */
-    private volatile Dictionary m_configuration;
+    private volatile Dictionary<String, Object> m_configuration;
     
     /**
      * Flag telling if our component factory is configured from config admin.
@@ -90,8 +90,8 @@ public class ComponentFactoryImpl extend
     public ComponentFactoryImpl( BundleComponentActivator activator, ComponentMetadata metadata )
     {
         super( activator, metadata, new ComponentMethods() );
-        m_componentInstances = new IdentityHashMap();
-        m_configuration = new Hashtable();
+        m_componentInstances = new IdentityHashMap<ImmediateComponentManager, ImmediateComponentManager>();
+        m_configuration = new Hashtable<String, Object>();
     }
 
 
@@ -204,15 +204,14 @@ public class ComponentFactoryImpl extend
     }
 
 
-    public Dictionary getProperties()
+    public Dictionary<String, Object> getProperties()
     {
-        Dictionary props = getServiceProperties();
+        Dictionary<String, Object> props = getServiceProperties();
 
         // add target properties of references
-        List depMetaData = getComponentMetadata().getDependencies();
-        for ( Iterator di = depMetaData.iterator(); di.hasNext(); )
+        List<ReferenceMetadata> depMetaData = getComponentMetadata().getDependencies();
+        for ( ReferenceMetadata rm : depMetaData )
         {
-            ReferenceMetadata rm = ( ReferenceMetadata ) di.next();
             if ( rm.getTarget() != null )
             {
                 props.put( rm.getTargetPropertyName(), rm.getTarget() );
@@ -220,9 +219,9 @@ public class ComponentFactoryImpl extend
         }
 
         // add target properties from configuration (if we have one)        
-        for ( Object key : Collections.list( m_configuration.keys() ) )
+        for ( String key : Collections.list( m_configuration.keys() ) )
         {
-            if ( key.toString().endsWith( ".target" ) )
+            if ( key.endsWith( ".target" ) )
             {
                 props.put( key, m_configuration.get( key ) );
             }
@@ -237,9 +236,9 @@ public class ComponentFactoryImpl extend
     }
 
 
-    public Dictionary getServiceProperties()
+    public Dictionary<String, Object> getServiceProperties()
     {
-        Dictionary props = new Hashtable();
+        Dictionary<String, Object> props = new Hashtable<String, Object>();
 
         // 112.5.5 The Component Factory service must register with the following properties
         props.put( ComponentConstants.COMPONENT_NAME, getComponentMetadata().getName() );
@@ -268,28 +267,28 @@ public class ComponentFactoryImpl extend
 
     protected boolean collectDependencies()
     {
-        Map old = getDependencyMap();
+        Map<DependencyManager<S, ?>, Map<ServiceReference<?>, RefPair<?>>> old = getDependencyMap();
         if ( old == null )
         {
-            Map dependenciesMap = new HashMap();
-            for (Iterator i = getDependencyManagers(); i.hasNext(); )
+            Map<DependencyManager<S, ?>, Map<ServiceReference<?>, RefPair<?>>> dependenciesMap = new HashMap<DependencyManager<S, ?>, Map<ServiceReference<?>, RefPair<?>>>();
+            for (DependencyManager dm: getDependencyManagers() )
             {
-                dependenciesMap.put( i.next(), Collections.EMPTY_MAP );
+                dependenciesMap.put( dm, Collections.EMPTY_MAP );
             }
             setDependencyMap( old, dependenciesMap );
         }
         return true;
     }
 
-    void update( DependencyManager dependencyManager, ServiceReference ref )
+    <T> void update( DependencyManager<S, T> dependencyManager, ServiceReference<T> ref )
     {
     }
 
-    void invokeBindMethod( DependencyManager dependencyManager, ServiceReference reference )
+    <T> void invokeBindMethod( DependencyManager<S, T> dependencyManager, ServiceReference<T> reference )
     {
     }
 
-    void invokeUnbindMethod( DependencyManager dependencyManager, ServiceReference oldRef )
+    <T> void invokeUnbindMethod( DependencyManager<S, T> dependencyManager, ServiceReference<T> oldRef )
     {
     }
 
@@ -340,7 +339,7 @@ public class ComponentFactoryImpl extend
     }
 
 
-    public void configurationUpdated( String pid, Dictionary configuration )
+    public void configurationUpdated( String pid, Dictionary<String, Object> configuration )
     {
         if ( pid.equals( getComponentMetadata().getConfigurationPid() ) )
         {
@@ -399,13 +398,13 @@ public class ComponentFactoryImpl extend
 
     public Component[] getComponents()
     {
-        List cms = getComponentList();
-        return (Component[]) cms.toArray( new Component[ cms.size() ] );
+        List<AbstractComponentManager> cms = getComponentList();
+        return cms.toArray( new Component[ cms.size() ] );
     }
 
-    protected List getComponentList()
+    protected List<AbstractComponentManager> getComponentList()
     {
-        List cms = new ArrayList( );
+        List<AbstractComponentManager> cms = new ArrayList<AbstractComponentManager>( );
         cms.add( this );
         getComponentManagers( m_componentInstances, cms );
         return cms;
@@ -440,11 +439,11 @@ public class ComponentFactoryImpl extend
      */
     public void disposeComponents( int reason )
     {
-        List cms = new ArrayList( );
+        List<AbstractComponentManager> cms = new ArrayList<AbstractComponentManager>( );
         getComponentManagers( m_componentInstances, cms );
-        for ( Iterator i = cms.iterator(); i.hasNext(); )
+        for ( AbstractComponentManager acm: cms )
         {
-            ((AbstractComponentManager)i.next()).dispose( reason );
+            acm.dispose( reason );
         }
 
         synchronized ( m_componentInstances )

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ConfigurationComponentFactoryImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ConfigurationComponentFactoryImpl.java?rev=1415461&r1=1415460&r2=1415461&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ConfigurationComponentFactoryImpl.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ConfigurationComponentFactoryImpl.java Thu Nov 29 23:53:21 2012
@@ -48,7 +48,7 @@ import org.osgi.service.log.LogService;
  * with earlier releases of the Apache Felix Declarative Services implementation.
  * But keep in mind, that this is non-standard behaviour.
  */
-public class ConfigurationComponentFactoryImpl extends ComponentFactoryImpl implements ComponentHolder
+public class ConfigurationComponentFactoryImpl<S> extends ComponentFactoryImpl<S> implements ComponentHolder
 {
 
     /**
@@ -132,7 +132,7 @@ public class ConfigurationComponentFacto
     }
 
 
-    public void configurationUpdated( String pid, Dictionary configuration )
+    public void configurationUpdated( String pid, Dictionary<String, Object> configuration )
     {
         if ( pid.equals( getComponentMetadata().getConfigurationPid() ) )
         {
@@ -199,11 +199,11 @@ public class ConfigurationComponentFacto
     {
         super.disposeComponents( reason );
 
-        List cms = new ArrayList( );
+        List<AbstractComponentManager> cms = new ArrayList<AbstractComponentManager>( );
         getComponentManagers( m_configuredServices, cms );
-        for ( Iterator i = cms.iterator(); i.hasNext(); )
+        for ( AbstractComponentManager acm: cms )
         {
-            ((AbstractComponentManager)i.next()).dispose( reason );
+            acm.dispose( reason );
         }
 
         m_configuredServices = null;

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DelayedComponentManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DelayedComponentManager.java?rev=1415461&r1=1415460&r2=1415461&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DelayedComponentManager.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DelayedComponentManager.java Thu Nov 29 23:53:21 2012
@@ -26,7 +26,7 @@ import org.apache.felix.scr.impl.metadat
 
 
 /**
- * The <code>DelayedComponentManager</code> TODO
+ * The <code>DelayedComponentManager</code> marker class.  Needed?
  */
 public class DelayedComponentManager extends ImmediateComponentManager
 {
@@ -42,10 +42,4 @@ public class DelayedComponentManager ext
         super( activator, componentHolder, metadata, componentMethods );
     }
 
-
-//    State getSatisfiedState()
-//    {
-//        return Registered.getInstance();
-//    }
-
 }



Mime
View raw message