FELIX-3700: fixed a bug where target filters specified in component metadata may be ignored when configuration
is loaded from config admin. Refactored the code because since FELIX-3726, the target filters are always updated
from Unsatisfied.activate method: now, getProperties is returning the target filters specified
in both config admin or in metadata.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1400265 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java b/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java
index f5d2dd4..f9130d2 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java
@@ -81,7 +81,7 @@
private volatile Dictionary m_configuration;
/**
- * Flag telling if our component factory is configured.
+ * Flag telling if our component factory is configured from config admin.
* We are configured when configuration policy is required and we have received the
* config admin properties, or when configuration policy is optional or ignored.
*/
@@ -230,9 +230,18 @@
}
}
+ // add target properties from configuration (if we have one)
+ for ( Object key : Collections.list( m_configuration.keys() ) )
+ {
+ if ( key.toString().endsWith( ".target" ) )
+ {
+ props.put( key, m_configuration.get( key ) );
+ }
+ }
+
return props;
}
-
+
public void setServiceProperties( Dictionary serviceProperties )
{
throw new IllegalStateException( "ComponentFactory service properties are immutable" );
@@ -376,23 +385,22 @@
log( LogService.LOG_INFO, "Current ComponentFactory state={0}", new Object[]
{ getState() }, null );
-
- // Update our target filters.
- log( LogService.LOG_DEBUG, "Updating target filters", null );
- super.updateTargets( m_configuration );
// If we are active, but if some config target filters don't match anymore
// any required references, then deactivate.
if ( getState() == STATE_FACTORY )
{
+ log( LogService.LOG_INFO, "Verifying if Active Component Factory is still satisfied", null );
+
+ // First update target filters.
+ super.updateTargets( getProperties() );
+
+ // Next, verify dependencies
if ( !verifyDependencyManagers( m_configuration ) )
{
- if ( ( getState() & STATE_DISPOSED ) == 0 )
- {
- log( LogService.LOG_DEBUG,
- "Component Factory target filters not satisfied anymore: deactivating", null );
- deactivateInternal( ComponentConstants.DEACTIVATION_REASON_REFERENCE );
- }
+ log( LogService.LOG_DEBUG,
+ "Component Factory target filters not satisfied anymore: deactivating", null );
+ deactivateInternal( ComponentConstants.DEACTIVATION_REASON_REFERENCE );
return;
}
}