You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by dj...@apache.org on 2013/05/09 07:50:39 UTC

svn commit: r1480532 - in /felix/trunk/scr: ./ src/main/java/org/apache/felix/scr/impl/ src/main/java/org/apache/felix/scr/impl/config/ src/main/java/org/apache/felix/scr/impl/helper/ src/main/java/org/apache/felix/scr/impl/manager/ src/main/java/org/a...

Author: djencks
Date: Thu May  9 05:50:38 2013
New Revision: 1480532

URL: http://svn.apache.org/r1480532
Log:
FELIX-4057 use findbugs plugin and fix many of the bugs

Modified:
    felix/trunk/scr/pom.xml
    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/ScrShellCommand.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationSupport.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrConfiguration.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ActivateMethod.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/BaseMethod.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ReadOnlyDictionary.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/ConfigurationComponentFactoryImpl.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceTracker.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/XmlHandler.java

Modified: felix/trunk/scr/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/scr/pom.xml?rev=1480532&r1=1480531&r2=1480532&view=diff
==============================================================================
--- felix/trunk/scr/pom.xml (original)
+++ felix/trunk/scr/pom.xml Thu May  9 05:50:38 2013
@@ -412,6 +412,20 @@
         </plugins>
     </build>
 
+	<reporting>
+		<plugins>
+			<plugin>
+				<groupId>org.codehaus.mojo</groupId>
+				<artifactId>findbugs-maven-plugin</artifactId>
+				<version>2.5.2</version>
+				<configuration>
+					<effort>Max</effort>
+					<threshold>Low</threshold>
+				</configuration>
+			</plugin>
+		</plugins>
+	</reporting>
+
     <profiles>
         <!--
             copy the package such that IDEs may easily use it without

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=1480532&r1=1480531&r2=1480532&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 May  9 05:50:38 2013
@@ -55,10 +55,10 @@ public class Activator implements Bundle
     private static BundleContext m_context;
 
     // the log service to log messages to
-    private static ServiceTracker m_logService;
+    private static volatile ServiceTracker m_logService;
 
     // the package admin service (see BindMethod.getParameterClass)
-    private static ServiceTracker m_packageAdmin;
+    private static volatile ServiceTracker m_packageAdmin;
 
     // map of BundleComponentActivator instances per Bundle indexed by Bundle id
     private Map<Long, BundleComponentActivator> m_componentBundles;

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=1480532&r1=1480531&r2=1480532&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 May  9 05:50:38 2013
@@ -325,7 +325,7 @@ public class BundleComponentActivator im
         m_active = false;
 
         log( LogService.LOG_DEBUG, "BundleComponentActivator : Bundle [{0}] will destroy {1} instances", new Object[]
-            { new Long( m_context.getBundle().getBundleId() ), new Integer( m_managers.size() ) }, null, null, null );
+            { m_context.getBundle().getBundleId(), m_managers.size() }, null, null, null );
 
         while ( m_managers.size() != 0 )
         {

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=1480532&r1=1480531&r2=1480532&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 May  9 05:50:38 2013
@@ -119,7 +119,7 @@ public class ComponentRegistry implement
      * {@link #registerComponentId(AbstractComponentManager)} method. This
      * counter is only incremented.
      */
-    private volatile long m_componentCounter;
+    private long m_componentCounter = -1;
 
     /**
      * The OSGi service registration for the ScrService provided by this
@@ -139,7 +139,6 @@ public class ComponentRegistry implement
         m_componentHoldersByName = new HashMap<ComponentRegistryKey, ComponentHolder>();
         m_componentHoldersByPid = new HashMap<String, Set<ComponentHolder>>();
         m_componentsById = new HashMap<Long, AbstractComponentManager<?>>();
-        m_componentCounter = -1;
 
         // keep me informed on ConfigurationAdmin state changes
         try
@@ -193,7 +192,7 @@ public class ComponentRegistry implement
         ArrayList<Component> list = new ArrayList<Component>();
         for ( ComponentHolder holder: holders )
         {
-            if ( holders != null )
+            if ( holder != null )
             {
                 Component[] components = holder.getComponents();
                 for ( Component component: components )
@@ -247,7 +246,7 @@ public class ComponentRegistry implement
     {
         synchronized ( m_componentsById )
         {
-            return m_componentsById.get( new Long( componentId ) );
+            return m_componentsById.get( componentId );
         }
     }
 
@@ -286,10 +285,9 @@ public class ComponentRegistry implement
         long componentId;
         synchronized ( m_componentsById )
         {
-            m_componentCounter++;
-            componentId = m_componentCounter;
+            componentId = ++m_componentCounter;
 
-            m_componentsById.put( new Long( componentId ), componentManager );
+            m_componentsById.put( componentId, componentManager );
         }
 
         return componentId;
@@ -431,19 +429,10 @@ public class ComponentRegistry implement
      */
     public final ComponentHolder getComponentHolder( final Bundle bundle, final String name )
     {
-        ComponentHolder entry;
         synchronized ( m_componentHoldersByName )
         {
-            entry = m_componentHoldersByName.get( new ComponentRegistryKey( bundle, name ) );
+            return m_componentHoldersByName.get( new ComponentRegistryKey( bundle, name ) );
         }
-
-        // only return the entry if non-null and not a reservation
-        if ( entry instanceof ComponentHolder )
-        {
-            return ( ComponentHolder ) entry;
-        }
-
-        return null;
     }
 
     /**

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrShellCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrShellCommand.java?rev=1480532&r1=1480531&r2=1480532&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrShellCommand.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrShellCommand.java Thu May  9 05:50:38 2013
@@ -63,28 +63,19 @@ class ScrShellCommand implements Command
     public void execute(String commandLine, PrintStream out, PrintStream err)
     {
         // Parse the commandLine to get the OBR command.
-        StringTokenizer st = new StringTokenizer(commandLine);
+        String[] st = commandLine.split("//s");
         // Ignore the invoking command.
-        st.nextToken();
         // Try to get the OBR command, default is HELP command.
-        String command = HELP_CMD;
-        try
-        {
-            command = st.nextToken();
-        }
-        catch (Exception ex)
-        {
-            // Ignore.
-        }
-
+        String command = st.length > 1? st[1]: HELP_CMD;
+        String arg = (st.length > 2) ? st[2] : null;
+        
         // Perform the specified command.
-        if ((command == null) || (command.equals(HELP_CMD)))
+        if (command.equals(HELP_CMD))
         {
-            help(out, st);
+            help(out, arg);
         }
         else
         {
-            String arg = (st.hasMoreTokens()) ? st.nextToken() : null;
             PrintWriter pw = new PrintWriter(out);
             try
             {
@@ -120,13 +111,8 @@ class ScrShellCommand implements Command
         }
     }
 
-    private void help(PrintStream out, StringTokenizer st)
+    private void help(PrintStream out, String command)
     {
-        String command = HELP_CMD;
-        if (st.hasMoreTokens())
-        {
-            command = st.nextToken();
-        }
         if (command.equals(LIST_CMD))
         {
             out.println("");

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationSupport.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationSupport.java?rev=1480532&r1=1480531&r2=1480532&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationSupport.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationSupport.java Thu May  9 05:50:38 2013
@@ -108,7 +108,6 @@ public class ConfigurationSupport implem
         if (!holder.getComponentMetadata().isConfigurationIgnored())
         {
             final BundleContext bundleContext = holder.getActivator().getBundleContext();
-            final String bundleLocation = bundleContext.getBundle().getLocation();
             final String confPid = holder.getComponentMetadata().getConfigurationPid();
 
             final ServiceReference caRef = bundleContext.getServiceReference(ComponentRegistry.CONFIGURATION_ADMIN);
@@ -159,7 +158,6 @@ public class ConfigurationSupport implem
                                     + "ours. This happens if multiple Configuration Admin API versions "
                                     + "are deployed and different bundles wire to different versions", null );
 
-                            Class<?> caoc = cao.getClass();
                         }
                     }
                     finally
@@ -462,50 +460,7 @@ public class ConfigurationSupport implem
             }
         }
         return confInfo;
-    }
-    
-    private ConfigurationAdmin getConfigurationAdmin(BundleContext bundleContext)
-    {
-        final ServiceReference caRef = bundleContext
-                .getServiceReference(ComponentRegistry.CONFIGURATION_ADMIN);
-            if (caRef != null)
-            {
-                try
-                {
-                    final Object cao = bundleContext.getService(caRef);
-                    if (cao != null)
-                    {
-                        try
-                        {
-                            if ( cao instanceof ConfigurationAdmin )
-                            {
-                                return ( ConfigurationAdmin ) cao;
-                            }
-                            else
-                            {
-                                Activator.log( LogService.LOG_WARNING, null,
-                                    "Component Bundle's Configuration Admin is not compatible with " +
-                                    "ours. This happens if multiple Configuration Admin API versions " +
-                                    "are deployed and different bundles wire to different versions",
-                                    null );
-                            }
-                        }
-                        finally
-                        {
-                            bundleContext.ungetService( caRef );
-                        }
-                    }
-                }
-                catch (IllegalStateException ise)
-                {
-                    // If the bundle has been stopped concurrently
-                    Activator.log(LogService.LOG_WARNING, null, "Bundle in unexpected state",
-                        ise);
-                }
-            }
-            return null;
-       
-    }
+    }    
 
     private Configuration getConfiguration(final ConfigurationAdmin ca, final String pid)
     {

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrConfiguration.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrConfiguration.java?rev=1480532&r1=1480531&r2=1480532&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrConfiguration.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrConfiguration.java Thu May  9 05:50:38 2013
@@ -115,7 +115,7 @@ public class ScrConfiguration
         props.put(Constants.SERVICE_PID, PID);
         props.put(Constants.SERVICE_DESCRIPTION, "SCR Configurator");
         props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
-        bundleContext.registerService("org.osgi.service.cm.ManagedService", new ScrManagedServiceServiceFactory(this),
+        managedService = bundleContext.registerService("org.osgi.service.cm.ManagedService", new ScrManagedServiceServiceFactory(this),
             props);
     }
 

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ActivateMethod.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ActivateMethod.java?rev=1480532&r1=1480531&r2=1480532&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ActivateMethod.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ActivateMethod.java Thu May  9 05:50:38 2013
@@ -129,7 +129,7 @@ public class ActivateMethod extends Base
             }
             else if ( parameterTypes[i] == INTEGER_CLASS || parameterTypes[i] == Integer.TYPE )
             {
-                param[i] = new Integer( ap.getReason() );
+                param[i] = ap.getReason();
             }
         }
 

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/BaseMethod.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/BaseMethod.java?rev=1480532&r1=1480531&r2=1480532&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/BaseMethod.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/BaseMethod.java Thu May  9 05:50:38 2013
@@ -22,6 +22,8 @@ package org.apache.felix.scr.impl.helper
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.Arrays;
 import java.util.Map;
 
@@ -109,7 +111,7 @@ abstract class BaseMethod
     }
 
 
-    synchronized void setMethod( Method method, SimpleLogger logger )
+    void setMethod( Method method, SimpleLogger logger )
     {
         this.m_method = method;
 
@@ -162,8 +164,9 @@ abstract class BaseMethod
         final Class targetClass = getComponentClass();
         final ClassLoader targetClasslLoader = targetClass.getClassLoader();
         final String targetPackage = getPackageName( targetClass );
+        Class theClass = targetClass;
 
-        for ( Class theClass = targetClass; theClass != null; )
+        while (true) 
         {
 
             if ( logger.isLogEnabled( LogService.LOG_DEBUG ) )
@@ -402,7 +405,7 @@ abstract class BaseMethod
      * @param allowReturnValue whether the method can return a value (to update service registration properties)
      * @return whether the method is acceptable
      */
-    static boolean accept( Method method, boolean acceptPrivate, boolean acceptPackage, boolean allowReturnValue )
+    static boolean accept( final Method method, boolean acceptPrivate, boolean acceptPackage, boolean allowReturnValue )
     {
         if (!(Void.TYPE == method.getReturnType() || (MAP_CLASS == method.getReturnType() && allowReturnValue)))
         {
@@ -421,7 +424,7 @@ abstract class BaseMethod
         // accept public and protected methods
         if ( Modifier.isPublic( mod ) || Modifier.isProtected( mod ) )
         {
-            method.setAccessible( true );
+            setAccessible( method );
             return true;
         }
 
@@ -430,7 +433,7 @@ abstract class BaseMethod
         {
             if ( acceptPrivate )
             {
-                method.setAccessible( acceptPrivate );
+                setAccessible( method );
                 return true;
             }
 
@@ -440,7 +443,7 @@ abstract class BaseMethod
         // accept default (package)
         if ( acceptPackage )
         {
-            method.setAccessible( true );
+            setAccessible( method );
             return true;
         }
 
@@ -449,6 +452,19 @@ abstract class BaseMethod
     }
 
 
+    private static void setAccessible(final Method method)
+    {
+        AccessController.doPrivileged( new PrivilegedAction<Object>()
+        {
+            public Object run()
+            {
+                method.setAccessible( true );
+                return null;
+            }
+        } );
+    }
+
+
     /**
      * Returns the name of the package to which the class belongs or an
      * empty string if the class is in the default package.
@@ -539,20 +555,19 @@ abstract class BaseMethod
         private static final State INSTANCE = new NotResolved();
 
 
-        private void resolve( final BaseMethod baseMethod, SimpleLogger logger )
+        private synchronized void resolve( final BaseMethod baseMethod, SimpleLogger logger )
         {
             logger.log( LogService.LOG_DEBUG, "getting {0}: {1}", new Object[]
                     {baseMethod.getMethodNamePrefix(), baseMethod.getMethodName()}, null );
 
             // resolve the method
-            Method method;
+            Method method = null;
             try
             {
                 method = baseMethod.findMethod( logger );
             }
             catch ( InvocationTargetException ex )
             {
-                method = null;
                 logger.log( LogService.LOG_WARNING, "{0} cannot be found", new Object[]
                         {baseMethod.getMethodName()}, ex.getTargetException() );
             }

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ReadOnlyDictionary.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ReadOnlyDictionary.java?rev=1480532&r1=1480531&r2=1480532&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ReadOnlyDictionary.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ReadOnlyDictionary.java Thu May  9 05:50:38 2013
@@ -38,26 +38,26 @@ import org.osgi.framework.ServiceReferen
 public class ReadOnlyDictionary<S, T> extends Dictionary<S, T> implements Map<S, T>
 {
 
-    private final Hashtable<S, T> m_delegatee;
+    private final Hashtable<S, T> m_delegate;
 
 
     /**
-     * Creates a wrapper for the given delegatee dictionary providing read
+     * Creates a wrapper for the given delegate dictionary providing read
      * only access to the data.
      */
-    public ReadOnlyDictionary( final Dictionary<S, T> delegatee )
+    public ReadOnlyDictionary( final Dictionary<S, T> delegate )
     {
-        if ( delegatee instanceof Hashtable )
+        if ( delegate instanceof Hashtable )
         {
-            this.m_delegatee = ( Hashtable<S, T> ) delegatee;
+            this.m_delegate = ( Hashtable<S, T> ) delegate;
         }
         else
         {
-            this.m_delegatee = new Hashtable<S, T>();
-            for ( Enumeration<S> ke = delegatee.keys(); ke.hasMoreElements(); )
+            this.m_delegate = new Hashtable<S, T>();
+            for ( Enumeration<S> ke = delegate.keys(); ke.hasMoreElements(); )
             {
                 S key = ke.nextElement();
-                this.m_delegatee.put( key, delegatee.get( key ) );
+                this.m_delegate.put( key, delegate.get( key ) );
             }
         }
     }
@@ -79,7 +79,7 @@ public class ReadOnlyDictionary<S, T> ex
                 properties.put( key, serviceReference.getProperty( key ) );
             }
         }
-        m_delegatee = properties;
+        m_delegate = properties;
     }
 
 
@@ -87,24 +87,24 @@ public class ReadOnlyDictionary<S, T> ex
 
     public Enumeration<T> elements()
     {
-        return m_delegatee.elements();
+        return m_delegate.elements();
     }
 
     public T get( final Object key )
     {
-        return m_delegatee.get( key );
+        return m_delegate.get( key );
     }
 
 
     public boolean isEmpty()
     {
-        return m_delegatee.isEmpty();
+        return m_delegate.isEmpty();
     }
 
 
     public Enumeration<S> keys()
     {
-        return m_delegatee.keys();
+        return m_delegate.keys();
     }
 
 
@@ -130,13 +130,13 @@ public class ReadOnlyDictionary<S, T> ex
 
     public int size()
     {
-        return m_delegatee.size();
+        return m_delegate.size();
     }
 
 
     public String toString()
     {
-        return m_delegatee.toString();
+        return m_delegate.toString();
     }
 
 
@@ -150,25 +150,25 @@ public class ReadOnlyDictionary<S, T> ex
 
     public boolean containsKey( Object key )
     {
-        return m_delegatee.containsKey( key );
+        return m_delegate.containsKey( key );
     }
 
 
     public boolean containsValue( Object value )
     {
-        return m_delegatee.containsValue( value );
+        return m_delegate.containsValue( value );
     }
 
 
     public Set entrySet()
     {
-        return Collections.unmodifiableSet( m_delegatee.entrySet() );
+        return Collections.unmodifiableSet( m_delegate.entrySet() );
     }
 
 
     public Set keySet()
     {
-        return Collections.unmodifiableSet( m_delegatee.keySet() );
+        return Collections.unmodifiableSet( m_delegate.keySet() );
     }
 
 
@@ -180,6 +180,6 @@ public class ReadOnlyDictionary<S, T> ex
 
     public Collection values()
     {
-        return Collections.unmodifiableCollection( m_delegatee.values() );
+        return Collections.unmodifiableCollection( m_delegate.values() );
     }
 }

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=1480532&r1=1480531&r2=1480532&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 May  9 05:50:38 2013
@@ -108,16 +108,9 @@ public abstract class AbstractComponentM
     private final Object enabledLatchLock = new Object();
 
     protected volatile boolean m_internalEnabled;
-    /**
-     * synchronizing while creating the service registration is safe as long as the bundle is not stopped
-     * during some service registrations.  So, avoid synchronizing during unregister service if the component is being
-     * disposed.
-     */
-    private volatile boolean disposed;
-
 
     //service event tracking
-    private volatile int floor;
+    private int floor;
 
     private volatile int ceiling;
 
@@ -153,9 +146,9 @@ public abstract class AbstractComponentM
                 LogService.LOG_DEBUG,
                 "Component {0} created: DS={1}, implementation={2}, immediate={3}, default-enabled={4}, factory={5}, configuration-policy={6}, activate={7}, deactivate={8}, modified={9} configuration-pid={10}",
                 new Object[]
-                    { metadata.getName(), new Integer( metadata.getNamespaceCode() ),
-                        metadata.getImplementationClassName(), Boolean.valueOf( metadata.isImmediate() ),
-                        Boolean.valueOf( metadata.isEnabled() ), metadata.getFactoryIdentifier(),
+                    { metadata.getName(), metadata.getNamespaceCode(),
+                        metadata.getImplementationClassName(), metadata.isImmediate(),
+                        metadata.isEnabled(), metadata.getFactoryIdentifier(),
                         metadata.getConfigurationPolicy(), metadata.getActivate(), metadata.getDeactivate(),
                         metadata.getModified(), metadata.getConfigurationPid() }, null );
 
@@ -527,7 +520,6 @@ public abstract class AbstractComponentM
      */
     public void dispose( int reason )
     {
-        disposed = true;
         disposeInternal( reason );
     }
     
@@ -1054,19 +1046,11 @@ public abstract class AbstractComponentM
         return depMgrList;
     }
 
-    private void enableDependencyManagers() throws InvalidSyntaxException
-    {
-        if ( !m_componentMetadata.isConfigurationRequired() || hasConfiguration() )
-        {
-            updateTargets( getProperties() );
-        }
-    }
-
-    protected void updateTargets(Dictionary properties)
+    protected void updateTargets(Dictionary<String, Object> properties)
     {
         if ( m_internalEnabled )
         {
-            for ( DependencyManager dm: getDependencyManagers() )
+            for ( DependencyManager<S, ?> dm: getDependencyManagers() )
             {
                 dm.setTargetFilter( properties );
             }
@@ -1078,7 +1062,7 @@ public abstract class AbstractComponentM
         // indicates whether all dependencies are satisfied
         boolean satisfied = true;
 
-        for ( DependencyManager dm: getDependencyManagers() )
+        for ( DependencyManager<S, ?> dm: getDependencyManagers() )
         {
 
             if ( !dm.hasGetPermission() )

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=1480532&r1=1480531&r2=1480532&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 May  9 05:50:38 2013
@@ -49,7 +49,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<S> extends ComponentFactoryImpl<S> implements ComponentHolder
+public class ConfigurationComponentFactoryImpl<S> extends ComponentFactoryImpl<S>
 {
 
     /**
@@ -57,7 +57,7 @@ public class ConfigurationComponentFacto
      * {@link org.apache.felix.scr.impl.manager.ImmediateComponentManager} for configuration updating this map is
      * lazily created.
      */
-    private Map<String, ImmediateComponentManager<S>> m_configuredServices;
+    private final Map<String, ImmediateComponentManager<S>> m_configuredServices = new HashMap<String, ImmediateComponentManager<S>>();
 
     public ConfigurationComponentFactoryImpl( BundleComponentActivator activator, ComponentMetadata metadata )
     {
@@ -92,13 +92,14 @@ public class ConfigurationComponentFacto
      * configuration instances are to disabled as a consequence of deactivating
      * the component factory.
      */
+    @Override
     protected void deleteComponent( int reason )
     {
-        List cms = new ArrayList( );
+        List<AbstractComponentManager<S>> cms = new ArrayList<AbstractComponentManager<S>>( );
         getComponentManagers( m_configuredServices, cms );
-        for ( Iterator i = cms.iterator(); i.hasNext(); )
+        for ( AbstractComponentManager<S> cm: cms )
         {
-            ((AbstractComponentManager)i.next()).disable();
+            cm.disable();
         }
     }
 
@@ -113,21 +114,17 @@ public class ConfigurationComponentFacto
         }
         else
         {
-            Map configuredServices = m_configuredServices;
-            if ( configuredServices != null )
+            ImmediateComponentManager<S> cm;
+            synchronized ( m_configuredServices )
             {
-                ImmediateComponentManager cm;
-                synchronized ( configuredServices )
-                {
-                    cm = ( ImmediateComponentManager ) configuredServices.remove( pid );
-                }
+                cm = m_configuredServices.remove( pid );
+            }
 
-                if ( cm != null )
-                {
-                    log( LogService.LOG_DEBUG, "Disposing component after configuration deletion", null );
+            if ( cm != null )
+            {
+                log( LogService.LOG_DEBUG, "Disposing component after configuration deletion", null );
 
-                    cm.dispose();
-                }
+                cm.dispose();
             }
         }
     }
@@ -142,16 +139,9 @@ public class ConfigurationComponentFacto
         else   //non-spec backwards compatible
         {
             ImmediateComponentManager<S> cm;
-            Map<String, ImmediateComponentManager<S>> configuredServices = m_configuredServices;
-            if ( configuredServices != null )
+            synchronized ( m_configuredServices )
             {
-                cm = configuredServices.get( pid );
-            }
-            else
-            {
-                m_configuredServices = new HashMap<String, ImmediateComponentManager<S>>();
-                configuredServices = m_configuredServices;
-                cm = null;
+                cm = m_configuredServices.get( pid );
             }
 
             if ( cm == null )
@@ -169,8 +159,11 @@ public class ConfigurationComponentFacto
                     cm.enable( false );
                 }
 
-                // keep a reference for future updates
-                configuredServices.put( pid, cm );
+                synchronized ( m_configuredServices )
+                {
+                    // keep a reference for future updates
+                    m_configuredServices.put( pid, cm );
+                }
 
             }
             else
@@ -207,7 +200,7 @@ public class ConfigurationComponentFacto
             acm.dispose( reason );
         }
 
-        m_configuredServices = null;
+        m_configuredServices.clear();
 
         // finally dispose the component factory itself
         dispose( reason );
@@ -220,12 +213,11 @@ public class ConfigurationComponentFacto
         {
             return m_changeCount;
         }
-        if (m_configuredServices == null)
+        synchronized ( m_configuredServices )
         {
-            return -1;
+            ImmediateComponentManager icm = m_configuredServices.get( pid );
+            return icm == null? -1: icm.getChangeCount();
         }
-        ImmediateComponentManager icm =  m_configuredServices.get( pid );
-        return icm == null? -1: icm.getChangeCount();
     }
 
 

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceTracker.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceTracker.java?rev=1480532&r1=1480531&r2=1480532&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceTracker.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceTracker.java Thu May  9 05:50:38 2013
@@ -203,7 +203,7 @@ public class ServiceTracker<S, T> {
 		this.trackClass = clazz;
 		this.customizer = customizer;
 		// we call clazz.toString to verify clazz is non-null!
-		this.listenerFilter = "(" + Constants.OBJECTCLASS + "=" + clazz.toString() + ")";
+		this.listenerFilter = "(" + Constants.OBJECTCLASS + "=" + clazz + ")";
 		try {
 			this.filter = context.createFilter(listenerFilter);
 		} catch (InvalidSyntaxException e) {
@@ -243,11 +243,11 @@ public class ServiceTracker<S, T> {
 		this.filter = filter;
 		this.customizer = customizer;
 		this.active = initialActive;
-		if ((context == null) || (filter == null)) {
+		if ((context == null)) {
 			/*
 			 * we throw a NPE here to be consistent with the other constructors
 			 */
-			throw new NullPointerException();
+			throw new NullPointerException( "BundleContext");
 		}
 	}
 
@@ -1440,6 +1440,9 @@ public class ServiceTracker<S, T> {
 					 * safe to let it propagate
 					 */
 					break;
+				default :
+	                System.out.println("Unrecognized event type: ServiceTracker.Tracked.serviceChanged[" + event.getType() + "]: " + reference);
+				    
 			}
 		}
 

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=1480532&r1=1480531&r2=1480532&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 May  9 05:50:38 2013
@@ -225,7 +225,7 @@ public class PropertyMetadata {
             // For Character types, the conversion is handled by Integer.valueOf method.
             // (since valueOf is defined in terms of parseInt we directly call
             // parseInt to prevent unneeded Object creation)
-            return new Character( ( char ) Integer.parseInt( value ) );
+            return Character.valueOf( ( char ) Integer.parseInt( value ) );
         }
         else if ( m_type.equals( "Boolean" ) )
         {

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=1480532&r1=1480531&r2=1480532&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 May  9 05:50:38 2013
@@ -111,12 +111,12 @@ public class XmlHandler implements KXml2
     static
     {
         NAMESPACE_CODE_MAP = new HashMap();
-        NAMESPACE_CODE_MAP.put( NAMESPACE_URI_EMPTY, new Integer( DS_VERSION_1_0 ) );
-        NAMESPACE_CODE_MAP.put( NAMESPACE_URI, new Integer( DS_VERSION_1_0 ) );
-        NAMESPACE_CODE_MAP.put( NAMESPACE_URI_1_1, new Integer( DS_VERSION_1_1 ) );
-        NAMESPACE_CODE_MAP.put( NAMESPACE_URI_1_1_FELIX, new Integer( DS_VERSION_1_1_FELIX ) );
-        NAMESPACE_CODE_MAP.put( NAMESPACE_URI_1_2, new Integer( DS_VERSION_1_2 ) );
-        NAMESPACE_CODE_MAP.put( NAMESPACE_URI_1_2_FELIX, new Integer( DS_VERSION_1_2_FELIX ) );
+        NAMESPACE_CODE_MAP.put( NAMESPACE_URI_EMPTY, DS_VERSION_1_0 );
+        NAMESPACE_CODE_MAP.put( NAMESPACE_URI, DS_VERSION_1_0 );
+        NAMESPACE_CODE_MAP.put( NAMESPACE_URI_1_1, DS_VERSION_1_1 );
+        NAMESPACE_CODE_MAP.put( NAMESPACE_URI_1_1_FELIX, DS_VERSION_1_1_FELIX );
+        NAMESPACE_CODE_MAP.put( NAMESPACE_URI_1_2, DS_VERSION_1_2 );
+        NAMESPACE_CODE_MAP.put( NAMESPACE_URI_1_2_FELIX, DS_VERSION_1_2_FELIX );
     }