extends AbstractCoreComponentInitializationPhase
{
public void initializeCoreComponent( ContainerInitializationContext context )
throws ContainerInitializationException
{
LoggerManager loggerManager = context.getContainer().getLoggerManager();
// ----------------------------------------------------------------------
// The logger manager may have been set programmatically so we need
// to check. If it hasn't
// ----------------------------------------------------------------------
if ( loggerManager == null )
{
try
{
/* as we do not know what logger role hint has been configured pull the first logger we find. Andy
* TODO - figure how to make this more determanistic? */
Map loggers = context.getContainer().lookupMap( LoggerManager.ROLE );
loggerManager = (LoggerManager) loggers.get( loggers.keySet().iterator().next() );
context.getContainer().setLoggerManager( loggerManager );
}
catch ( ComponentLookupException e )
{
throw new ContainerInitializationException( "Unable to locate logger manager", e );
}
}
//TODO: the container should allow this logger manager change, don't use the DefaultPlexusContainer
context.getContainer().enableLogging( loggerManager.getLoggerForComponent( PlexusContainer.class.getName() ) );
}