Use component.id instead of service.pid as the key in the INSTANCES map
because the service.pid property may not always be present.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@805803 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/test/java/org/apache/felix/scr/integration/components/SimpleComponent.java b/scr/src/test/java/org/apache/felix/scr/integration/components/SimpleComponent.java
index b900190..5c58423 100644
--- a/scr/src/test/java/org/apache/felix/scr/integration/components/SimpleComponent.java
+++ b/scr/src/test/java/org/apache/felix/scr/integration/components/SimpleComponent.java
@@ -26,7 +26,7 @@
import java.util.Map;
import java.util.Set;
-import org.osgi.framework.Constants;
+import org.osgi.service.component.ComponentConstants;
import org.osgi.service.component.ComponentContext;
@@ -35,7 +35,7 @@
public static SimpleComponent INSTANCE;
- public static final Map<String, SimpleComponent> INSTANCES = new HashMap<String, SimpleComponent>();
+ public static final Map<Long, SimpleComponent> INSTANCES = new HashMap<Long, SimpleComponent>();
public static final Set<SimpleComponent> PREVIOUS_INSTANCES = new HashSet<SimpleComponent>();
@@ -46,7 +46,7 @@
private void activate( Map<?, ?> config )
{
INSTANCE = this;
- INSTANCES.put( config.get( Constants.SERVICE_PID ).toString(), this );
+ INSTANCES.put( ( Long ) config.get( ComponentConstants.COMPONENT_ID ), this );
setConfig( config );
if ( PREVIOUS_INSTANCES.contains( this ) )
@@ -74,7 +74,7 @@
@SuppressWarnings("unused")
private void deactivate()
{
- INSTANCES.remove( getProperty( Constants.SERVICE_PID ).toString() );
+ INSTANCES.remove( getProperty( ComponentConstants.COMPONENT_ID ) );
INSTANCE = null;
setConfig( new HashMap<Object, Object>() );
}