if ( roleHint == null )
{
roleHint = PlexusConstants.PLEXUS_DEFAULT_HINT;
}
ComponentManager componentManager = container.getComponentManagerManager()
.findComponentManagerByComponentKey( componentRole, roleHint, realm );
// The first time we lookup a component a component manager will not exist so we ask the
// component manager manager to create a component manager for us. Also if we are reloading
// components then we'll also get a new component manager.
if ( container.isReloadingEnabled() || componentManager == null )
{
ComponentDescriptor descriptor = container.getComponentRepository().getComponentDescriptor( componentRole,
roleHint,
realm );
if ( descriptor == null )
{
if ( container.getParentContainer() != null )
{
return container.getParentContainer().lookup( componentRole, roleHint, realm );
}
String message = "Component descriptor cannot be found in the component repository: " + componentRole
+ " [" + roleHint + "]" + " (lookup realm: " + realm + ").";
throw new ComponentLookupException( message );
}
componentManager = createComponentManager( descriptor, componentRole, roleHint );
}
try
{
component = componentManager.getComponent( realm );
}
catch ( ComponentInstantiationException e )
{
throw new ComponentLookupException( "Unable to lookup component '" + componentRole
+ "', it could not be created", e );