{
log( LogService.LOG_DEBUG, "ImmediateComponentHolder configuration deleted for pid {0}",
new Object[] {pid}, null);
// component to deconfigure or dispose of
final SingleComponentManager icm;
boolean deconfigure = false;
synchronized ( m_components )
{
// FELIX-2231: nothing to do any more, all components have been disposed off
if (m_singleComponent == null)
{
return;
}
if ( pid.equals( getComponentMetadata().getConfigurationPid() ) )
{
// singleton configuration has pid equal to component name
icm = m_singleComponent;
deconfigure = true;
}
else
{
// remove the component configured with the deleted configuration
icm = m_components.remove( pid );
if ( icm == null )
{
// we already removed the component with the deleted configuration
return;
}
// special casing if the single component is deconfigured
if ( m_singleComponent == icm )
{
// if the single component is the last remaining, deconfig
if ( m_components.isEmpty() )
{
// if the single component is the last remaining
// deconfigure it
deconfigure = true;
}
else
{
// replace the single component field with another
// entry from the map
m_singleComponent = m_components.values().iterator().next();
}
}
}
}
// icm may be null if the last configuration deleted was the
// single component's configuration. Otherwise the component
// is not the "last" and has to be disposed off
if ( deconfigure )
{
icm.reconfigure( null, -1, null );
}
else
{
icm.dispose( ComponentConstants.DEACTIVATION_REASON_CONFIGURATION_DELETED );
}
}