*
* @param event The configuration change event
*/
public void configurationEvent(ConfigurationEvent event)
{
final TargetedPID pid = new TargetedPID( event.getPid());
String rawFactoryPid = event.getFactoryPid();
final TargetedPID factoryPid = rawFactoryPid == null? null: new TargetedPID( rawFactoryPid);
// iterate over all components which must be configured with this pid
// (since DS 1.2, components may specify a specific configuration PID (112.4.4 configuration-pid)
Collection<ComponentHolder<?>> holders;
if (factoryPid == null)
{
holders = this.m_registry.getComponentHoldersByPid(pid);
}
else
{
holders = this.m_registry.getComponentHoldersByPid(factoryPid);
}
Activator.log(LogService.LOG_DEBUG, null, "configurationEvent: Handling {0} of Configuration PID={1} for component holders {2}",
new Object[] {getEventType(event), pid, holders},
null);
for ( ComponentHolder<?> componentHolder: holders )
{
if (!componentHolder.getComponentMetadata().isConfigurationIgnored())
{
switch (event.getType()) {
case ConfigurationEvent.CM_DELETED:
if ( factoryPid != null || !configureComponentHolder( componentHolder ) )
{
componentHolder.configurationDeleted( pid, factoryPid );
}
break;
case ConfigurationEvent.CM_UPDATED:
{
final BundleComponentActivator activator = componentHolder.getActivator();
if (activator == null)
{
break;
}
final BundleContext bundleContext = activator.getBundleContext();
if (bundleContext == null)
{
break;
}
TargetedPID targetedPid = factoryPid == null? pid: factoryPid;
TargetedPID oldTargetedPID = componentHolder.getConfigurationTargetedPID(pid, factoryPid);
if ( factoryPid != null || targetedPid.equals(oldTargetedPID) || targetedPid.bindsStronger( oldTargetedPID ))
{
final ConfigurationInfo configInfo = getConfigurationInfo( pid, targetedPid, componentHolder, bundleContext );
if ( checkBundleLocation( configInfo.getBundleLocation(), bundleContext.getBundle() ) )
{
//If this is replacing a weaker targetedPID delete the old one.
if ( factoryPid == null && !targetedPid.equals(oldTargetedPID) && oldTargetedPID != null)
{
componentHolder.configurationDeleted( pid, factoryPid );
}
componentHolder.configurationUpdated( pid, factoryPid, configInfo.getProps(), configInfo.getChangeCount() );
}
}
break;
}
case ConfigurationEvent.CM_LOCATION_CHANGED:
{
//TODO is this logic correct for factory pids????
final BundleComponentActivator activator = componentHolder.getActivator();
if (activator == null)
{
break;
}
final BundleContext bundleContext = activator.getBundleContext();
if (bundleContext == null)
{
break;
}
TargetedPID targetedPid = factoryPid == null? pid: factoryPid;
TargetedPID oldTargetedPID = componentHolder.getConfigurationTargetedPID(pid, factoryPid);
if ( targetedPid.equals(oldTargetedPID))
{
//this sets the location to this component's bundle if not already set. OK here
//since it used to be set to this bundle, ok to reset it
final ConfigurationInfo configInfo = getConfigurationInfo( pid, targetedPid, componentHolder, bundleContext );