private synchronized <T> ComponentManager<T> getComponentManager( Class<T> type, String role, String roleHint, ComponentDescriptor<T> descriptor )
throws ComponentLookupException
{
if ( disposingComponents )
{
throw new ComponentLookupException("ComponentRegistry is not active",
role,
roleHint );
}
if ( descriptor == null )
{
descriptor = getComponentDescriptor( type, role, roleHint );
}
ComponentManager<T> componentManager = null;
if ( descriptor != null )
{
componentManager = getComponentManager( type, role, descriptor.getRoleHint(), descriptor.getRealm() );
}
else
{
componentManager = getComponentManager( type, role, roleHint );
}
if ( componentManager == null )
{
// we need to create a component manager, but first we must have a descriptor
if ( descriptor == null )
{
descriptor = getComponentDescriptor( type, role, roleHint );
if ( descriptor == null )
{
throw new ComponentLookupException(
"Component descriptor cannot be found in the component repository",
role,
roleHint );
}
// search also into descriptor realm as the key of a created component is per descriptor realm