You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2015/02/16 12:02:21 UTC

svn commit: r1660067 - in /felix/trunk: scr-compat/src/main/java/org/apache/felix/scr/ scr/ scr/src/main/java/org/apache/felix/scr/ scr/src/main/java/org/apache/felix/scr/impl/ scr/src/main/java/org/apache/felix/scr/impl/config/ scr/src/main/java/org/a...

Author: cziegeler
Date: Mon Feb 16 11:02:20 2015
New Revision: 1660067

URL: http://svn.apache.org/r1660067
Log:
FELIX-4785 : Incompatible SCR API

Added:
    felix/trunk/scr-compat/src/main/java/org/apache/felix/scr/Component.java
      - copied unchanged from r1660058, felix/trunk/scr/src/main/java/org/apache/felix/scr/Component.java
    felix/trunk/scr-compat/src/main/java/org/apache/felix/scr/Reference.java
      - copied unchanged from r1660058, felix/trunk/scr/src/main/java/org/apache/felix/scr/Reference.java
    felix/trunk/scr-compat/src/main/java/org/apache/felix/scr/ScrInfo.java
      - copied unchanged from r1660058, felix/trunk/scr/src/main/java/org/apache/felix/scr/ScrInfo.java
    felix/trunk/scr-compat/src/main/java/org/apache/felix/scr/ScrService.java
      - copied unchanged from r1660058, felix/trunk/scr/src/main/java/org/apache/felix/scr/ScrService.java
Removed:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/Component.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/Reference.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/ScrInfo.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/ScrService.java
Modified:
    felix/trunk/scr/bnd.bnd
    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/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/ReferenceManager.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/config/ScrManagedServiceMetaTypeProvider.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/runtime/ServiceComponentRuntimeImpl.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java

Modified: felix/trunk/scr/bnd.bnd
URL: http://svn.apache.org/viewvc/felix/trunk/scr/bnd.bnd?rev=1660067&r1=1660066&r2=1660067&view=diff
==============================================================================
--- felix/trunk/scr/bnd.bnd (original)
+++ felix/trunk/scr/bnd.bnd Mon Feb 16 11:02:20 2015
@@ -8,8 +8,7 @@ Provide-Capability: osgi.extender;\
                    version:Version="1.3"
                    
 
-Export-Package: org.apache.felix.scr;version=1.8.1;provide:=true, \
- org.apache.felix.scr.component;version=1.1.0;provide:=true, \
+Export-Package: org.apache.felix.scr.component;version=1.1.0;provide:=true, \
  org.osgi.service.component;version=1.3;-split-package:=first;provide:=true, \
  org.osgi.service.component.runtime;version=1.3;provide:=true, \
  org.osgi.service.component.runtime.dto;version=1.3;provide:=true, \

Modified: felix/trunk/scr/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/scr/pom.xml?rev=1660067&r1=1660066&r2=1660067&view=diff
==============================================================================
--- felix/trunk/scr/pom.xml (original)
+++ felix/trunk/scr/pom.xml Mon Feb 16 11:02:20 2015
@@ -323,6 +323,7 @@
                     <excludePackageNames>*.impl</excludePackageNames>
                 </configuration>
             </plugin>
+<!-- Disable for now             
              <plugin>
                 <groupId>org.apache.aries.versioning</groupId>
                 <artifactId>org.apache.aries.versioning.plugin</artifactId>
@@ -340,6 +341,7 @@
                     </execution>
                 </executions>
             </plugin>
+-->
         </plugins>
     </build>
 

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=1660067&r1=1660066&r2=1660067&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 Mon Feb 16 11:02:20 2015
@@ -26,7 +26,6 @@ import java.util.Map;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.felix.scr.ScrService;
 import org.apache.felix.scr.impl.config.ScrConfiguration;
 import org.apache.felix.scr.impl.runtime.ServiceComponentRuntimeImpl;
 import org.apache.felix.utils.extender.AbstractExtender;
@@ -149,9 +148,8 @@ public class Activator extends AbstractE
         m_componentBundles = new HashMap<Long, BundleComponentActivator>();
         m_componentRegistry = new ComponentRegistry( m_context );
 
-        ServiceComponentRuntime runtime = new ServiceComponentRuntimeImpl(m_context, m_componentRegistry);
-        m_runtime_reg = m_context.registerService(new String[] {ScrService.class.getName(),
-                ServiceComponentRuntime.class.getName()},
+        final ServiceComponentRuntime runtime = new ServiceComponentRuntimeImpl(m_context, m_componentRegistry);
+        m_runtime_reg = m_context.registerService(ServiceComponentRuntime.class,
                 runtime, null);
 
         // log SCR startup
@@ -167,7 +165,6 @@ public class Activator extends AbstractE
         super.doStart();
 
         m_scrCommand = ScrCommand.register(m_context, runtime, m_configuration);
-        m_configuration.setScrCommand( m_scrCommand );
     }
 
     @Override

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=1660067&r1=1660066&r2=1660067&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 Mon Feb 16 11:02:20 2015
@@ -358,18 +358,6 @@ public class ComponentRegistry implement
     }
 
     /**
-     * We only need this for the ScrService implementation
-     * @param componentId
-     * @return
-     */
-    public final AbstractComponentManager<?> getComponentManagerById(final long componentId)
-    {
-        synchronized ( m_componentsById )
-        {
-            return m_componentsById.get( componentId );
-        }
-    }
-    /**
      * Returns an array of all values currently stored in the component holders
      * map. The entries in the array are either String types for component
      * name reservations or {@link ComponentHolder} instances for actual

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=1660067&r1=1660066&r2=1660067&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 Mon Feb 16 11:02:20 2015
@@ -33,7 +33,6 @@ import java.util.Map.Entry;
 import java.util.TreeMap;
 import java.util.regex.Pattern;
 
-import org.apache.felix.scr.ScrInfo;
 import org.apache.felix.scr.impl.config.ScrConfiguration;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -53,14 +52,13 @@ import org.osgi.service.component.runtim
  * {@link #register(BundleContext, ScrService, ScrConfiguration)} method
  * instantiates and registers the Gogo and Shell commands as possible.
  */
-public class ScrCommand implements ScrInfo
+public class ScrCommand
 {
 
     private final BundleContext bundleContext;
     private final ServiceComponentRuntime scrService;
     private final ScrConfiguration scrConfiguration;
-    
-    private ServiceRegistration<ScrInfo> reg;
+
     private ServiceRegistration<?> gogoReg;
     private ServiceRegistration<?> shellReg;
 
@@ -130,8 +128,8 @@ public class ScrCommand implements ScrIn
             // Ignore.
         }
     }
-    
-    void unregister() 
+
+    void unregister()
     {
         if (gogoReg != null)
         {
@@ -147,29 +145,7 @@ public class ScrCommand implements ScrIn
 
     // ---------- Actual implementation
 
-    
-    public void update( boolean infoAsService )
-    {
-        if (infoAsService)
-        {
-            if ( reg == null )
-            {
-                final Hashtable<String, Object> props = new Hashtable<String, Object>();
-                props.put(Constants.SERVICE_DESCRIPTION, "SCR Info service");
-                props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
-                reg = bundleContext.registerService( ScrInfo.class, this, props );
-            }
-        }
-        else
-        {
-            if ( reg != null )
-            {
-                reg.unregister();
-                reg = null;
-            }
-        }
-    }
-    
+
     /* (non-Javadoc)
      * @see org.apache.felix.scr.impl.ScrInfo#list(java.lang.String, java.io.PrintStream, java.io.PrintStream)
      */
@@ -228,16 +204,16 @@ public class ScrCommand implements ScrIn
             }
         }
 
-        Collections.sort( components, new Comparator<ComponentDescriptionDTO>() 
+        Collections.sort( components, new Comparator<ComponentDescriptionDTO>()
                 {
 
                     public int compare(ComponentDescriptionDTO c1, ComponentDescriptionDTO c2)
                     {
                         return c1.name.compareTo(c2.name);
                     }
-            
+
                 });
-        
+
         out.println(" Name  BundleId DefaultEnabled");
         for ( ComponentDescriptionDTO component : components )
         {
@@ -257,7 +233,7 @@ public class ScrCommand implements ScrIn
             return;
         }
 
-        Collections.sort( new ArrayList<ComponentDescriptionDTO>(components), new Comparator<ComponentDescriptionDTO>() 
+        Collections.sort( new ArrayList<ComponentDescriptionDTO>(components), new Comparator<ComponentDescriptionDTO>()
                 {
 
                     public int compare(ComponentDescriptionDTO c1, ComponentDescriptionDTO c2)
@@ -271,14 +247,14 @@ public class ScrCommand implements ScrIn
                         }
                         return result;
                     }
-            
+
                 });
-        
+
         long bundleId = -1;
 
         for ( ComponentDescriptionDTO component : components )
         {
-            if ( component.bundle.id != bundleId ) 
+            if ( component.bundle.id != bundleId )
             {
                 if ( bundleId != -1 )
                 {
@@ -361,7 +337,7 @@ public class ScrCommand implements ScrIn
                     out.println( ref.policyOption );
                     out.print( "    Reference Scope: ");
                     out.println( ref.scope);
-                    
+
                 }
             }
 
@@ -372,7 +348,7 @@ public class ScrCommand implements ScrIn
                 info(cc, out);
             }
         }
-        
+
         out.flush();
     }
 
@@ -404,7 +380,7 @@ public class ScrCommand implements ScrIn
                         }
                     }
                     out.println("]");
-                } 
+                }
                 else
                 {
                     out.println( prop );
@@ -420,7 +396,7 @@ public class ScrCommand implements ScrIn
         out.println( cc.id );
         out.print("    State: ");
         out.println( toStateString(cc.state));
-        for ( SatisfiedReferenceDTO ref: cc.satisfiedReferences) 
+        for ( SatisfiedReferenceDTO ref: cc.satisfiedReferences)
         {
             out.print( "    SatisfiedReference: ");
             out.println( ref.name );
@@ -443,7 +419,7 @@ public class ScrCommand implements ScrIn
           }
 
         }
-        for ( UnsatisfiedReferenceDTO ref: cc.unsatisfiedReferences) 
+        for ( UnsatisfiedReferenceDTO ref: cc.unsatisfiedReferences)
         {
             out.print( "    UnsatisfiedReference: ");
             out.println( ref.name );
@@ -529,10 +505,8 @@ public class ScrCommand implements ScrIn
         out.println(scrConfiguration.stopTimeout());
         out.print("Global extender: ");
         out.println(scrConfiguration.globalExtender());
-        out.print("Info Service registered: ");
-        out.println(scrConfiguration.infoAsService() ? "Supported" : "Unsupported");
     }
-    
+
     private String toStateString(int state)
     {
         switch (state) {

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ReferenceManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ReferenceManager.java?rev=1660067&r1=1660066&r2=1660067&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ReferenceManager.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ReferenceManager.java Mon Feb 16 11:02:20 2015
@@ -20,7 +20,6 @@ package org.apache.felix.scr.impl.config
 
 import java.util.List;
 
-import org.apache.felix.scr.impl.metadata.ReferenceMetadata;
 import org.osgi.framework.ServiceReference;
 
 public interface ReferenceManager<S, T> {
@@ -47,6 +46,4 @@ public interface ReferenceManager<S, T>
 	String getTarget();
 
     boolean isSatisfied();
-
-    ReferenceMetadata getReferenceMetadata();
 }
\ No newline at end of file

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=1660067&r1=1660066&r2=1660067&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 Mon Feb 16 11:02:20 2015
@@ -23,7 +23,6 @@ import java.util.Dictionary;
 import java.util.Hashtable;
 
 import org.apache.felix.scr.impl.Activator;
-import org.apache.felix.scr.impl.ScrCommand;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceRegistration;
@@ -64,8 +63,6 @@ public class ScrConfiguration
 
     public static final String PROP_DELAYED_KEEP_INSTANCES = "ds.delayed.keepInstances";
 
-    public static final String PROP_INFO_SERVICE = "ds.info.service";
-
     public static final String PROP_LOCK_TIMEOUT = "ds.lock.timeout.milliseconds";
 
     public static final String PROP_STOP_TIMEOUT = "ds.stop.timeout.milliseconds";
@@ -73,7 +70,7 @@ public class ScrConfiguration
     public static final long DEFAULT_LOCK_TIMEOUT_MILLISECONDS = 5000;
 
     public static final long DEFAULT_STOP_TIMEOUT_MILLISECONDS = 60000;
-    
+
     public static final String PROP_LOGLEVEL = "ds.loglevel";
 
     private static final String LOG_LEVEL_DEBUG = "debug";
@@ -87,9 +84,9 @@ public class ScrConfiguration
     private static final String PROP_SHOWTRACE = "ds.showtrace";
 
     private static final String PROP_SHOWERRORS = "ds.showerrors";
-    
+
     public static final String PROP_GLOBAL_EXTENDER="ds.global.extender";
-    
+
     private final Activator activator;
 
     private int logLevel;
@@ -97,20 +94,16 @@ public class ScrConfiguration
     private boolean factoryEnabled;
 
     private boolean keepInstances;
-    
-    private boolean infoAsService;
-    
+
     private long lockTimeout = DEFAULT_LOCK_TIMEOUT_MILLISECONDS;
 
     private long stopTimeout = DEFAULT_STOP_TIMEOUT_MILLISECONDS;
-    
+
     private Boolean globalExtender;
 
     private BundleContext bundleContext;
 
     private ServiceRegistration<ManagedService> managedService;
-    
-    private ScrCommand scrCommand;
 
     public ScrConfiguration( Activator activator )
     {
@@ -118,7 +111,7 @@ public class ScrConfiguration
     }
 
     @SuppressWarnings("unchecked")
-    public void start(final BundleContext bundleContext) 
+    public void start(final BundleContext bundleContext)
     {
         this.bundleContext = bundleContext;
 
@@ -133,7 +126,7 @@ public class ScrConfiguration
         // overriden by configuration admin later.
         // Note that if the managed service is registered first then it is random which will win since
         // configuration may be delivered asynchronously
-        configure( null, false );            
+        configure( null, false );
 
         managedService = ( ServiceRegistration<ManagedService> ) bundleContext.registerService("org.osgi.service.cm.ManagedService", new ScrManagedServiceServiceFactory(this),
             props);
@@ -147,12 +140,6 @@ public class ScrConfiguration
 
         this.bundleContext = null;
     }
-    
-    public void setScrCommand(ScrCommand scrCommand)
-    {
-        this.scrCommand = scrCommand;
-        scrCommand.update(infoAsService());
-    }
 
     // Called from the ScrManagedService.updated method to reconfigure
     void configure( Dictionary<String, ?> config, boolean fromConfig )
@@ -170,7 +157,6 @@ public class ScrConfiguration
                         logLevel = LogService.LOG_ERROR;
                         factoryEnabled = false;
                         keepInstances = false;
-                        infoAsService = false;
                         lockTimeout = DEFAULT_LOCK_TIMEOUT_MILLISECONDS;
                         stopTimeout = DEFAULT_STOP_TIMEOUT_MILLISECONDS;
                         newGlobalExtender = false;
@@ -180,7 +166,6 @@ public class ScrConfiguration
                         logLevel = getDefaultLogLevel();
                         factoryEnabled = getDefaultFactoryEnabled();
                         keepInstances = getDefaultKeepInstances();
-                        infoAsService = getDefaultInfoAsService();
                         lockTimeout = getDefaultLockTimeout();
                         stopTimeout = getDefaultStopTimeout();
                         newGlobalExtender = getDefaultGlobalExtender();
@@ -196,17 +181,12 @@ public class ScrConfiguration
                 logLevel = getLogLevel( config.get( PROP_LOGLEVEL ) );
                 factoryEnabled = VALUE_TRUE.equalsIgnoreCase( String.valueOf( config.get( PROP_FACTORY_ENABLED ) ) );
                 keepInstances = VALUE_TRUE.equalsIgnoreCase( String.valueOf( config.get( PROP_DELAYED_KEEP_INSTANCES ) ) );
-                infoAsService = VALUE_TRUE.equalsIgnoreCase( String.valueOf( config.get( PROP_INFO_SERVICE) ) );
                 Long timeout = ( Long ) config.get( PROP_LOCK_TIMEOUT );
                 lockTimeout = timeout == null? DEFAULT_LOCK_TIMEOUT_MILLISECONDS: timeout;
                 timeout = ( Long ) config.get( PROP_STOP_TIMEOUT );
                 stopTimeout = timeout == null? DEFAULT_STOP_TIMEOUT_MILLISECONDS: timeout;
                 newGlobalExtender = VALUE_TRUE.equalsIgnoreCase( String.valueOf( config.get( PROP_GLOBAL_EXTENDER) ) );
             }
-            if ( scrCommand != null )
-            {
-                scrCommand.update( infoAsService() );
-            }
             oldGlobalExtender = this.globalExtender;
             this.globalExtender = newGlobalExtender;
         }
@@ -236,11 +216,6 @@ public class ScrConfiguration
     {
         return keepInstances;
     }
-    
-    public boolean infoAsService()
-    {
-        return infoAsService;
-    }
 
     public long lockTimeout()
     {
@@ -251,7 +226,7 @@ public class ScrConfiguration
     {
         return stopTimeout;
     }
-    
+
     public boolean globalExtender()
     {
         return globalExtender;
@@ -273,11 +248,6 @@ public class ScrConfiguration
     {
         return getLogLevel( bundleContext.getProperty( PROP_LOGLEVEL ) );
     }
-    
-    private boolean getDefaultInfoAsService()
-    {
-        return VALUE_TRUE.equalsIgnoreCase( bundleContext.getProperty( PROP_INFO_SERVICE) );
-    }
 
     private long getDefaultLockTimeout()
     {

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrManagedServiceMetaTypeProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrManagedServiceMetaTypeProvider.java?rev=1660067&r1=1660066&r2=1660067&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrManagedServiceMetaTypeProvider.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrManagedServiceMetaTypeProvider.java Mon Feb 16 11:02:20 2015
@@ -102,12 +102,6 @@ class ScrManagedServiceMetaTypeProvider
                     .getScrConfiguration().keepInstances() ) );
 
         adList.add( new AttributeDefinitionImpl(
-                ScrConfiguration.PROP_INFO_SERVICE,
-                "Bind Info Service",
-                "Whether to bind a service backing the console commands providing info on components.",
-                this.getScrConfiguration().infoAsService() ) );
-
-        adList.add( new AttributeDefinitionImpl(
                 ScrConfiguration.PROP_LOCK_TIMEOUT,
                 "Lock timeout milliseconds",
                 "How long a lock is held before releasing due to suspected deadlock",

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java?rev=1660067&r1=1660066&r2=1660067&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java Mon Feb 16 11:02:20 2015
@@ -109,11 +109,6 @@ public class DependencyManager<S, T> imp
         }
     }
 
-    public ReferenceMetadata getReferenceMetadata()
-    {
-        return this.m_dependencyMetadata;
-    }
-
     private static int defaultMinimumCardinality(ReferenceMetadata dependency)
     {
         return dependency.isOptional()? 0: 1;

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/runtime/ServiceComponentRuntimeImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/runtime/ServiceComponentRuntimeImpl.java?rev=1660067&r1=1660066&r2=1660067&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/runtime/ServiceComponentRuntimeImpl.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/runtime/ServiceComponentRuntimeImpl.java Mon Feb 16 11:02:20 2015
@@ -21,22 +21,14 @@ package org.apache.felix.scr.impl.runtim
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Dictionary;
 import java.util.HashMap;
-import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.felix.scr.Component;
-import org.apache.felix.scr.Reference;
-import org.apache.felix.scr.ScrService;
-import org.apache.felix.scr.impl.BundleComponentActivator;
 import org.apache.felix.scr.impl.ComponentRegistry;
 import org.apache.felix.scr.impl.config.ComponentHolder;
 import org.apache.felix.scr.impl.config.ComponentManager;
 import org.apache.felix.scr.impl.config.ReferenceManager;
-import org.apache.felix.scr.impl.manager.AbstractComponentManager;
-import org.apache.felix.scr.impl.manager.SingleComponentManager;
 import org.apache.felix.scr.impl.metadata.ComponentMetadata;
 import org.apache.felix.scr.impl.metadata.ReferenceMetadata;
 import org.osgi.dto.DTO;
@@ -46,7 +38,6 @@ import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.dto.BundleDTO;
 import org.osgi.framework.dto.ServiceReferenceDTO;
-import org.osgi.service.component.ComponentInstance;
 import org.osgi.service.component.runtime.ServiceComponentRuntime;
 import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
 import org.osgi.service.component.runtime.dto.ComponentDescriptionDTO;
@@ -55,7 +46,7 @@ import org.osgi.service.component.runtim
 import org.osgi.service.component.runtime.dto.UnsatisfiedReferenceDTO;
 import org.osgi.util.promise.Promise;
 
-public class ServiceComponentRuntimeImpl implements ServiceComponentRuntime, ScrService
+public class ServiceComponentRuntimeImpl implements ServiceComponentRuntime
 {
 
 	private static final String[] EMPTY = {};
@@ -352,343 +343,4 @@ public class ServiceComponentRuntimeImpl
 		b.version = bundle.getVersion().toString();
 		return b;
 	}
-
-	// ScrService
-
-    /**
-     * @see org.apache.felix.scr.ScrService#getComponents()
-     */
-    public Component[] getComponents()
-    {
-        final List<ComponentHolder<?>> holders = componentRegistry.getComponentHolders();
-        ArrayList<Component> list = new ArrayList<Component>();
-        for ( ComponentHolder<?> holder: holders )
-        {
-            if ( holder != null )
-            {
-                final List<? extends ComponentManager<?>> components = holder.getComponents();
-                for ( ComponentManager<?> component: components )
-                {
-                    list.add( new ComponentWrapper((AbstractComponentManager<?>)component) );
-                }
-            }
-        }
-
-        // nothing to return
-        if ( list.isEmpty() )
-        {
-            return null;
-        }
-
-        return list.toArray( new Component[list.size()] );
-    }
-
-
-    /**
-     * @see org.apache.felix.scr.ScrService#getComponents(org.osgi.framework.Bundle)
-     */
-    public Component[] getComponents( Bundle bundle )
-    {
-        final List<ComponentHolder<?>> holders = componentRegistry.getComponentHolders();
-        ArrayList<Component> list = new ArrayList<Component>();
-        for ( ComponentHolder<?> holder: holders )
-        {
-            if ( holder != null )
-            {
-                BundleComponentActivator activator = holder.getActivator();
-                if ( activator != null && activator.getBundleContext().getBundle() == bundle )
-                {
-                    final List<? extends ComponentManager<?>> components = holder.getComponents();
-                    for ( ComponentManager<?> component: components )
-                    {
-                        list.add( new ComponentWrapper((AbstractComponentManager<?>)component) );
-                    }
-                }
-            }
-        }
-
-        // nothing to return
-        if ( list.isEmpty() )
-        {
-            return null;
-        }
-
-        return list.toArray( new Component[list.size()] );
-    }
-
-
-    /**
-     * @see org.apache.felix.scr.ScrService#getComponent(long)
-     */
-    public Component getComponent( long componentId )
-    {
-        final AbstractComponentManager<?> c = componentRegistry.getComponentManagerById(componentId);
-        if ( c != null )
-        {
-            return new ComponentWrapper(c);
-        }
-        return null;
-    }
-
-    /**
-     * @see org.apache.felix.scr.ScrService#getComponents(java.lang.String)
-     */
-    public Component[] getComponents( final String componentName )
-    {
-        final List<Component> list = new ArrayList<Component>();
-        final List<ComponentHolder<?>> holders = componentRegistry.getComponentHolders();
-        for ( ComponentHolder<?> holder: holders )
-        {
-            if ( holder.getComponentMetadata().getName().equals(componentName) )
-            {
-                final List<? extends ComponentManager<?>> components = holder.getComponents();
-                for ( ComponentManager<?> component: components )
-                {
-                    list.add( new ComponentWrapper((AbstractComponentManager<?>)component) );
-                }
-            }
-        }
-
-        return ( list.isEmpty() ) ? null : list.toArray( new Component[list.size()] );
-    }
-
-
-    private static final class ComponentWrapper implements Component
-    {
-        private final AbstractComponentManager<?> mgr;
-
-        public ComponentWrapper(final AbstractComponentManager<?> mgr)
-        {
-            this.mgr = mgr;
-        }
-
-        public long getId()
-        {
-            return mgr.getId();
-        }
-
-        public String getName()
-        {
-            return mgr.getComponentMetadata().getName();
-        }
-
-        public int getState()
-        {
-            final int s = mgr.getState();
-            switch ( s )
-            {
-                case ComponentManager.STATE_DISPOSED : return Component.STATE_DISPOSED;
-                case ComponentManager.STATE_DISABLED : return Component.STATE_DISABLED;
-                case ComponentManager.STATE_UNSATISFIED_REFERENCE : return Component.STATE_UNSATISFIED;
-                case ComponentManager.STATE_ACTIVE : return Component.STATE_ACTIVE;
-                default: // satisfied
-                    return Component.STATE_ENABLED;
-            }
-        }
-
-        public Bundle getBundle()
-        {
-            return mgr.getBundle();
-        }
-
-        public String getFactory()
-        {
-            return mgr.getComponentMetadata().getFactoryIdentifier();
-        }
-
-        public boolean isServiceFactory()
-        {
-            return mgr.getComponentMetadata().isFactory();
-        }
-
-        public String getClassName()
-        {
-            return mgr.getComponentMetadata().getImplementationClassName();
-        }
-
-        public boolean isDefaultEnabled()
-        {
-            return mgr.getComponentMetadata().isEnabled();
-        }
-
-        public boolean isImmediate()
-        {
-            return mgr.getComponentMetadata().isImmediate();
-        }
-
-        public String[] getServices()
-        {
-            if ( mgr.getComponentMetadata().getServiceMetadata() != null )
-            {
-                return mgr.getComponentMetadata().getServiceMetadata().getProvides();
-            }
-
-            return null;
-        }
-
-        public Dictionary getProperties()
-        {
-            return new Hashtable<String, Object>(mgr.getComponentMetadata().getProperties());
-        }
-
-        public Reference[] getReferences()
-        {
-            final List<? extends ReferenceManager<?, ?>> refs = mgr.getReferenceManagers();
-            if ( refs != null && refs.size() > 0 )
-            {
-                final List<Reference> list = new ArrayList<Reference>();
-                for(final ReferenceManager<?, ?> rm : refs)
-                {
-                    list.add(new ReferenceWrapper(rm));
-                }
-                return list.toArray(
-                        new Reference[list.size()] );
-            }
-
-            return null;
-        }
-
-        public ComponentInstance getComponentInstance()
-        {
-            if ( mgr instanceof SingleComponentManager<?> )
-            {
-                return ((SingleComponentManager<?>)mgr).getComponentInstance();
-            }
-
-            return null;
-        }
-
-        public String getActivate()
-        {
-            return mgr.getComponentMetadata().getActivate();
-        }
-
-        public boolean isActivateDeclared()
-        {
-            return mgr.getComponentMetadata().isActivateDeclared();
-        }
-
-        public String getDeactivate()
-        {
-            return mgr.getComponentMetadata().getDeactivate();
-        }
-
-        public boolean isDeactivateDeclared()
-        {
-            return mgr.getComponentMetadata().isDeactivateDeclared();
-        }
-
-        public String getModified()
-        {
-            return mgr.getComponentMetadata().getModified();
-        }
-
-        public String getConfigurationPolicy()
-        {
-            return mgr.getComponentMetadata().getConfigurationPolicy();
-        }
-
-        public String getConfigurationPid()
-        {
-            final List<String> pids = mgr.getComponentMetadata().getConfigurationPid();
-            if ( pids != null && pids.size() > 0 )
-            {
-                return pids.get(0);
-            }
-            return null;
-        }
-
-        public boolean isConfigurationPidDeclared()
-        {
-            return mgr.getComponentMetadata().isConfigurationPidDeclared();
-        }
-
-        public void enable()
-        {
-            mgr.enable(false);
-        }
-
-        public void disable()
-        {
-            mgr.disable(false);
-        }
-    }
-
-    private static final class ReferenceWrapper implements Reference
-    {
-        private final ReferenceManager<?, ?> mgr;
-
-        public ReferenceWrapper(final ReferenceManager<?, ?> mgr)
-        {
-            this.mgr = mgr;
-        }
-
-        public String getName()
-        {
-            return mgr.getReferenceMetadata().getName();
-        }
-
-        public String getServiceName()
-        {
-            return mgr.getReferenceMetadata().getInterface();
-        }
-
-        public ServiceReference[] getServiceReferences()
-        {
-            final List<ServiceReference<?>> refs = this.mgr.getServiceReferences();
-            return refs.toArray(new ServiceReference<?>[refs.size()]);
-        }
-
-        public ServiceReference<?>[] getBoundServiceReferences()
-        {
-            final List<ServiceReference<?>> refs = this.mgr.getServiceReferences();
-            return refs.toArray(new ServiceReference<?>[refs.size()]);
-        }
-
-        public boolean isSatisfied()
-        {
-            return mgr.isSatisfied();
-        }
-
-        public boolean isOptional()
-        {
-            return this.mgr.getReferenceMetadata().isOptional();
-        }
-
-        public boolean isMultiple()
-        {
-            return this.mgr.getReferenceMetadata().isMultiple();
-        }
-
-        public boolean isStatic()
-        {
-            return this.mgr.getReferenceMetadata().isStatic();
-        }
-
-        public boolean isReluctant()
-        {
-            return this.mgr.getReferenceMetadata().isReluctant();
-        }
-
-        public String getTarget()
-        {
-            return this.mgr.getTarget();
-        }
-
-        public String getBindMethodName()
-        {
-            return this.mgr.getReferenceMetadata().getBind();
-        }
-
-        public String getUnbindMethodName()
-        {
-            return this.mgr.getReferenceMetadata().getUnbind();
-        }
-
-        public String getUpdatedMethodName()
-        {
-            return this.mgr.getReferenceMetadata().getUpdated();
-        }
-
-    }
 }

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java?rev=1660067&r1=1660066&r2=1660067&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java Mon Feb 16 11:02:20 2015
@@ -43,17 +43,14 @@ import java.lang.reflect.InvocationTarge
 import java.lang.reflect.Method;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
 import java.util.Dictionary;
 import java.util.HashMap;
 import java.util.Hashtable;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.TreeSet;
 import java.util.concurrent.LinkedBlockingQueue;
 
 import javax.inject.Inject;
@@ -62,7 +59,6 @@ import junit.framework.Assert;
 import junit.framework.TestCase;
 
 import org.apache.felix.scr.impl.ScrCommand;
-import org.apache.felix.scr.impl.config.ScrConfiguration;
 import org.apache.felix.scr.integration.components.SimpleComponent;
 import org.junit.After;
 import org.junit.Before;
@@ -133,10 +129,10 @@ public abstract class ComponentTestBase
     protected volatile Log log;
 
 	protected static String[] ignoredWarnings; //null unless you need it.
-    
+
     //set to true to only get last 1000 lines of log.
     protected static boolean restrictedLogging;
-    
+
     protected static String felixCaVersion = System.getProperty( "felix.ca.version" );
 
     protected static final String PROP_NAME_FACTORY = ComponentTestBase.PROP_NAME + ".factory";
@@ -159,7 +155,7 @@ public abstract class ComponentTestBase
                                             "org.apache.felix.scr.integration.components.deadlock," +
                                             "org.apache.felix.scr.integration.components.felix3680," +
                                             "org.apache.felix.scr.integration.components.felix3680_2");
-        builder.setHeader("Import-Package", "org.apache.felix.scr,org.apache.felix.scr.component");
+        builder.setHeader("Import-Package", "org.apache.felix.scr.component");
         builder.setHeader("Bundle-ManifestVersion", "2");
         return builder;
     }
@@ -200,7 +196,7 @@ public abstract class ComponentTestBase
         log.start();
         bundleContext.addFrameworkListener( log );
         bundleContext.registerService( LogService.class.getName(), log, null );
-        
+
         scrTracker = new ServiceTracker<ServiceComponentRuntime, ServiceComponentRuntime>( bundleContext, ServiceComponentRuntime.class, null );
         scrTracker.open();
         configAdminTracker = new ServiceTracker<ConfigurationAdmin, ConfigurationAdmin>( bundleContext, ConfigurationAdmin.class, null );
@@ -269,12 +265,12 @@ public abstract class ComponentTestBase
         {
         	for (ComponentConfigurationDTO cc: ccs)
         	{
-        		Assert.assertEquals( "for ComponentConfiguration name: " + cc.description.name + " properties" + cc.properties + "Expected state " + STATES.get(expected) + " but was " + STATES.get(cc.state), expected, cc.state);        			
+        		Assert.assertEquals( "for ComponentConfiguration name: " + cc.description.name + " properties" + cc.properties + "Expected state " + STATES.get(expected) + " but was " + STATES.get(cc.state), expected, cc.state);
         	}
         }
         return ccs;
     }
-    
+
     protected Collection<ComponentConfigurationDTO> findComponentConfigurationsByName( String name, int expected )
     {
     	return findComponentConfigurationsByName(bundle, name, expected);
@@ -291,15 +287,15 @@ public abstract class ComponentTestBase
     {
     	return findComponentConfigurationByName( bundle, name, expected );
     }
-    
+
     static final Map<Integer, String> STATES = new HashMap<Integer, String>();
-    
+
     static {
     	STATES.put(ComponentConfigurationDTO.UNSATISFIED_REFERENCE, "Unsatisfied (" + ComponentConfigurationDTO.UNSATISFIED_REFERENCE + ")" );
     	STATES.put(ComponentConfigurationDTO.SATISFIED, "Satisified (" + ComponentConfigurationDTO.SATISFIED + ")" );
     	STATES.put(ComponentConfigurationDTO.ACTIVE, "Active (" + ComponentConfigurationDTO.ACTIVE + ")" );
     }
-    
+
     protected ComponentConfigurationDTO getDisabledConfigurationAndEnable( Bundle b, String name, int initialState ) throws InvocationTargetException, InterruptedException
     {
     	int count = 1;
@@ -308,13 +304,13 @@ public abstract class ComponentTestBase
 		ComponentConfigurationDTO cc = ccs.iterator().next();
     	return cc;
     }
-    
+
     protected ComponentConfigurationDTO getDisabledConfigurationAndEnable( String name, int initialState ) throws InvocationTargetException, InterruptedException
     {
     	return getDisabledConfigurationAndEnable( bundle, name, initialState );
     }
 
-    protected Collection<ComponentConfigurationDTO> getConfigurationsDisabledThenEnable( Bundle b, String name, int count, int initialState) throws InvocationTargetException, InterruptedException 
+    protected Collection<ComponentConfigurationDTO> getConfigurationsDisabledThenEnable( Bundle b, String name, int count, int initialState) throws InvocationTargetException, InterruptedException
     {
 		ServiceComponentRuntime scr = scrTracker.getService();
         if ( scr == null )
@@ -325,7 +321,7 @@ public abstract class ComponentTestBase
     	Assert.assertFalse("Expected component disabled", scr.isComponentEnabled(cd));
     	scr.enableComponent(cd).getValue();
     	Assert.assertTrue("Expected component enabled", scr.isComponentEnabled(cd));
-    	
+
     	Collection<ComponentConfigurationDTO> ccs = scr.getComponentConfigurationDTOs(cd);
     	Assert.assertEquals(count, ccs.size());
     	for (ComponentConfigurationDTO cc: ccs) {
@@ -335,14 +331,14 @@ public abstract class ComponentTestBase
 		}
 		return ccs;
 	}
-    
-    protected Collection<ComponentConfigurationDTO> getConfigurationsDisabledThenEnable( String name, int count, int initialState) throws InvocationTargetException, InterruptedException 
+
+    protected Collection<ComponentConfigurationDTO> getConfigurationsDisabledThenEnable( String name, int count, int initialState) throws InvocationTargetException, InterruptedException
     {
     	return getConfigurationsDisabledThenEnable(bundle, name, count, initialState);
     }
-    
+
     protected ComponentDescriptionDTO checkConfigurationCount( Bundle b, String name, int count, int expectedState )
-    {		
+    {
     	ServiceComponentRuntime scr = scrTracker.getService();
     	if ( scr == null )
     	{
@@ -364,12 +360,12 @@ public abstract class ComponentTestBase
     	}
     	return cd;
     }
-    
+
     protected ComponentDescriptionDTO checkConfigurationCount( String name, int count, int expectedState )
-    {	
+    {
     	return checkConfigurationCount(bundle, name, count, expectedState);
     }
-    
+
     protected <S> S getServiceFromConfiguration( ComponentConfigurationDTO dto, Class<S> clazz )
     {
         long id = dto.id;
@@ -387,7 +383,7 @@ public abstract class ComponentTestBase
             return null;//unreachable in fact
         }
     }
-    
+
     protected <S> void ungetServiceFromConfiguration( ComponentConfigurationDTO dto, Class<S> clazz )
     {
         long id = dto.id;
@@ -402,7 +398,7 @@ public abstract class ComponentTestBase
             TestCase.fail(e.getMessage());
         }
     }
-    
+
     protected void enableAndCheck( ComponentDescriptionDTO cd ) throws InvocationTargetException, InterruptedException
     {
         ServiceComponentRuntime scr = scrTracker.getService();
@@ -411,11 +407,11 @@ public abstract class ComponentTestBase
             scr.enableComponent(cd).getValue();
         	Assert.assertTrue("Expected component enabled", scr.isComponentEnabled(cd));
         }
-        else 
+        else
         {
         	throw new NullPointerException("no ServiceComponentRuntime");
         }
-    	
+
     }
 
     protected void disableAndCheck( ComponentConfigurationDTO cc ) throws InvocationTargetException, InterruptedException
@@ -431,7 +427,7 @@ public abstract class ComponentTestBase
         	scr.disableComponent(cd).getValue();
         	Assert.assertFalse("Expected component disabled", scr.isComponentEnabled(cd));
         }
-        else 
+        else
         {
         	throw new NullPointerException("no ServiceComponentRuntime");
         }
@@ -439,7 +435,7 @@ public abstract class ComponentTestBase
 
 	protected void disableAndCheck(String name) throws InvocationTargetException, InterruptedException {
 		ComponentDescriptionDTO cd = findComponentDescriptorByName(name);
-		disableAndCheck(cd);		
+		disableAndCheck(cd);
 	}
 
     protected static void delay()
@@ -461,7 +457,7 @@ public abstract class ComponentTestBase
 
     protected ConfigurationAdmin getConfigurationAdmin()
     {
-        ConfigurationAdmin ca = ( ConfigurationAdmin ) configAdminTracker.getService();
+        ConfigurationAdmin ca = configAdminTracker.getService();
         if ( ca == null )
         {
             TestCase.fail( "Missing ConfigurationAdmin service" );
@@ -472,7 +468,7 @@ public abstract class ComponentTestBase
     protected org.osgi.service.cm.Configuration configure( String pid )
     {
         return configure( pid, null );
-        
+
     }
 
     protected org.osgi.service.cm.Configuration configure( String pid, String bundleLocation )
@@ -558,7 +554,7 @@ public abstract class ComponentTestBase
             TestCase.fail( "Failed deleting configurations " + factoryPid + ": " + ioe.toString() );
         }
     }
-    
+
     //component factory test helper methods
     protected ComponentFactory getComponentFactory(final String componentfactory)
         throws InvalidSyntaxException
@@ -647,7 +643,7 @@ public abstract class ComponentTestBase
             return null; // keep the compiler happy
         }
     }
-    
+
     protected Object getComponentManagerFromComponentInstance( Object instance )
     {
         Object cc = getFieldValue( instance, "m_componentContext");
@@ -672,7 +668,7 @@ public abstract class ComponentTestBase
             }
             clazz = clazz.getSuperclass();
         }
-        throw new NoSuchFieldException(fieldName);        
+        throw new NoSuchFieldException(fieldName);
     }
 
 
@@ -680,7 +676,7 @@ public abstract class ComponentTestBase
     {
         return installBundle(descriptorFile, componentPackage, "simplecomponent", "0.0.11", null);
     }
-    
+
     protected Bundle installBundle( final String descriptorFile, String componentPackage, String symbolicName, String version, String location ) throws BundleException
     {
         final InputStream bundleStream = bundle()
@@ -719,7 +715,7 @@ public abstract class ComponentTestBase
         PrintStream out = System.out;
         info( new PrintWriter(out) );
     }
-    
+
     private static class InfoWriter extends ScrCommand
     {
 
@@ -727,7 +723,7 @@ public abstract class ComponentTestBase
         {
             super(null, scrService, null);
         }
-        
+
     }
 
     void info( PrintWriter out )
@@ -739,8 +735,8 @@ public abstract class ComponentTestBase
         }
         new InfoWriter(scr).list(null, out);
     }
-    
-    protected boolean isAtLeastR5() 
+
+    protected boolean isAtLeastR5()
     {
         try
         {
@@ -793,6 +789,7 @@ public abstract class ComponentTestBase
         }
 
 
+        @Override
         public String toString()
         {
             return m_msg;
@@ -828,7 +825,7 @@ public abstract class ComponentTestBase
             return m_thread;
         }
     }
-    
+
     public static class Log implements LogService, FrameworkListener, Runnable
     {
         private static final int RESTRICTED_LOG_SIZE = 1000;
@@ -864,7 +861,7 @@ public abstract class ComponentTestBase
             m_logThread.start();
         }
 
-        
+
         public void stop()
         {
             System.setOut(m_realOut);
@@ -900,7 +897,7 @@ public abstract class ComponentTestBase
         {
             return m_warnings;
         }
-        
+
         Throwable getFirstFrameworkThrowable()
         {
             return firstFrameworkThrowable;