FELIX-3732 The service.factoryPid property is not relevant for the decision of
whether a ManagedServiceFactory service implementing the MetaTypeProvider
interface is a factory or not. This is the ManagedServiceFactory type
itself. So remove support for the service.factoryPid property
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1402997 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeInformationImpl.java b/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeInformationImpl.java
index 7b97c20..7b5e5b4 100644
--- a/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeInformationImpl.java
+++ b/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeInformationImpl.java
@@ -49,10 +49,6 @@
public class MetaTypeInformationImpl implements MetaTypeInformation
{
- // also defined in org.osgi.service.cm.ConfigurationAdmin, but copied
- // here to not create a synthetic dependency
- public static final String SERVICE_FACTORYPID = "service.factoryPid";
-
private final Bundle bundle;
private final Set pids;
diff --git a/metatype/src/main/java/org/apache/felix/metatype/internal/ServiceMetaTypeInformation.java b/metatype/src/main/java/org/apache/felix/metatype/internal/ServiceMetaTypeInformation.java
index 3a6cdf0..2fdde3d 100644
--- a/metatype/src/main/java/org/apache/felix/metatype/internal/ServiceMetaTypeInformation.java
+++ b/metatype/src/main/java/org/apache/felix/metatype/internal/ServiceMetaTypeInformation.java
@@ -176,32 +176,19 @@
if ( srv instanceof MetaTypeProvider )
{
MetaTypeProvider mtp = ( MetaTypeProvider ) srv;
-
- // 1. check for a service factory PID
- String factoryPid = ( String ) serviceRef.getProperty( SERVICE_FACTORYPID );
- if ( factoryPid != null )
+ String[] pids = getServicePids( serviceRef );
+ if ( pids != null )
{
- addFactoryMetaTypeProvider( new String[]
- { factoryPid }, mtp );
- ungetService = false;
- }
- else
- {
- // 2. check for a service PID
- String[] pids = getServicePids( serviceRef );
- if ( pids != null )
+ if ( isService( serviceRef, MANAGED_SERVICE ) )
{
- if ( isService( serviceRef, MANAGED_SERVICE ) )
- {
- addSingletonMetaTypeProvider( pids, mtp );
- ungetService = false;
- }
+ addSingletonMetaTypeProvider( pids, mtp );
+ ungetService = false;
+ }
- if ( isService( serviceRef, MANAGED_SERVICE_FACTORY ) )
- {
- addFactoryMetaTypeProvider( pids, mtp );
- ungetService = false;
- }
+ if ( isService( serviceRef, MANAGED_SERVICE_FACTORY ) )
+ {
+ addFactoryMetaTypeProvider( pids, mtp );
+ ungetService = false;
}
}
}
@@ -230,33 +217,20 @@
protected void removeService( ServiceReference serviceRef )
{
boolean ungetService = false;
-
- // 1. check for a service factory PID
- String factoryPid = ( String ) serviceRef.getProperty( SERVICE_FACTORYPID );
- if ( factoryPid != null )
+ String[] pids = getServicePids( serviceRef );
+ if ( pids != null )
{
- ungetService = removeFactoryMetaTypeProvider( new String[]
- { factoryPid } );
- }
- else
- {
- // 2. check for a service PID
- String[] pids = getServicePids( serviceRef );
- if ( pids != null )
+ if ( isService( serviceRef, MANAGED_SERVICE ) )
{
- if ( isService( serviceRef, MANAGED_SERVICE ) )
- {
- ungetService |= removeSingletonMetaTypeProvider( pids );
- }
+ ungetService |= removeSingletonMetaTypeProvider( pids );
+ }
- if ( isService( serviceRef, MANAGED_SERVICE_FACTORY ) )
- {
- ungetService |= removeFactoryMetaTypeProvider( pids );
- }
+ if ( isService( serviceRef, MANAGED_SERVICE_FACTORY ) )
+ {
+ ungetService |= removeFactoryMetaTypeProvider( pids );
}
}
- // 3. drop the service reference
if ( ungetService )
{
bundleContext.ungetService( serviceRef );
diff --git a/metatype/src/test/java/org/apache/felix/metatype/internal/MetaTypeServiceImplTest.java b/metatype/src/test/java/org/apache/felix/metatype/internal/MetaTypeServiceImplTest.java
index c65789e..3ef76c3 100644
--- a/metatype/src/test/java/org/apache/felix/metatype/internal/MetaTypeServiceImplTest.java
+++ b/metatype/src/test/java/org/apache/felix/metatype/internal/MetaTypeServiceImplTest.java
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -28,7 +28,6 @@
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.cm.ManagedService;
import org.osgi.service.cm.ManagedServiceFactory;
import org.osgi.service.metatype.MetaTypeInformation;
@@ -123,9 +122,8 @@
String factoryPid = "testAfterCreation_factory";
MockManagedServiceFactory service = new MockManagedServiceFactory();
Dictionary props = new Hashtable();
- props.put( Constants.SERVICE_PID, pid );
- props.put( ConfigurationAdmin.SERVICE_FACTORYPID, factoryPid );
- ServiceRegistration sr = bundleContext.registerService( ManagedService.class.getName(), service, props );
+ props.put( Constants.SERVICE_PID, factoryPid );
+ ServiceRegistration sr = bundleContext.registerService( ManagedServiceFactory.class.getName(), service, props );
// locales should contain MockMetaTypeProvider.LOCALES
assertNotNull( mti.getLocales() );