atagunov 2003/06/08 04:19:42
Modified: fortress/src/java/org/apache/avalon/fortress/impl
DefaultContainerManager.java
Log:
Let DefaultContainerManager blow up early and with a correct exception if
creation of ContextManager fails. This allow for example when a LoggerManager
could not have been initialized to get only one error message instead of two.
As nearly everybody puts new DefaultContainerManager() in the same try{}catch{}
as DefaultContainerManager.initialize() -- this practice has been promoted by
the examples -- this change shouldn't break anybody. I hope so. :-)
Revision Changes Path
1.27 +6 -22
avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/DefaultContainerManager.java
Index: DefaultContainerManager.java
===================================================================
RCS file:
/home/cvs/avalon-excalibur/fortress/src/java/org/apache/avalon/fortress/impl/DefaultContainerManager.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- DefaultContainerManager.java 4 Jun 2003 15:48:36 -0000 1.26
+++ DefaultContainerManager.java 8 Jun 2003 11:19:42 -0000 1.27
@@ -95,13 +95,13 @@
createLoggerFromContext( m_contextManager.getContainerManagerContext()
) : logger );
}
- public DefaultContainerManager( final Context initParameters )
+ public DefaultContainerManager( final Context initParameters ) throws Exception
{
this( initParameters, null );
}
public DefaultContainerManager( final Context initParameters,
- final Logger logger )
+ final Logger logger ) throws Exception
{
this( getInitializedContextManager( initParameters, logger ), logger );
}
@@ -112,28 +112,12 @@
* super constructor has been executed.
*/
private static ContextManager getInitializedContextManager( final Context
initParameters,
- Logger logger )
+ Logger logger )
throws Exception
{
// The context manager will use an internal coonsole logger if logger is
null.
final ContextManager contextManager = new ContextManager( initParameters,
logger );
- try
- {
- contextManager.initialize();
- return contextManager;
- }
- catch ( Exception e )
- {
- if ( logger == null )
- {
- logger = new ConsoleLogger( ConsoleLogger.LEVEL_INFO );
- }
- logger.fatalError( "Unable to initialize the contextManager.", e );
-
- // What should happen now. There needs to be a failure mode here.
- // As is, this will result in an NPE, but it can't really be allowed
- // to continue without having been initialized.
- return null;
- }
+ contextManager.initialize();
+ return contextManager;
}
protected Logger createLoggerFromContext( final Context initParameters )
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]