cziegeler 2002/07/05 02:59:10 Modified: component/src/java/org/apache/avalon/excalibur/component ExcaliburComponentManager.java Log: Applied patch for initialization order of components Revision Changes Path 1.9 +34 -7 jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentManager.java Index: ExcaliburComponentManager.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/ExcaliburComponentManager.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- ExcaliburComponentManager.java 18 Jun 2002 14:25:47 -0000 1.8 +++ ExcaliburComponentManager.java 5 Jul 2002 09:59:10 -0000 1.9 @@ -60,6 +60,11 @@ /** Used to map roles to ComponentHandlers. */ private final BucketMap m_componentHandlers = new BucketMap(); + /** added component handlers before initialization to maintain + * the order of initialization + */ + private final List m_newComponentHandlers = new ArrayList(); + /** RoleInfos. */ private RoleManager m_roles; @@ -144,14 +149,10 @@ { m_initialized = true; - List keys = new ArrayList( m_componentHandlers.keySet() ); - - for( int i = 0; i < keys.size(); i++ ) + for (int i = 0; i < m_newComponentHandlers.size(); i++ ) { - final Object key = keys.get( i ); final ComponentHandler handler = - (ComponentHandler)m_componentHandlers.get( key ); - + (ComponentHandler)m_newComponentHandlers.get( i ); try { handler.initialize(); @@ -164,8 +165,33 @@ "the component handler.", e ); } } + } + + List keys = new ArrayList( m_componentHandlers.keySet() ); + + for( int i = 0; i < keys.size(); i++ ) + { + final Object key = keys.get( i ); + final ComponentHandler handler = + (ComponentHandler)m_componentHandlers.get( key ); + if ( !m_newComponentHandlers.contains( handler ) ) + { + try + { + handler.initialize(); + } + catch( Exception e ) + { + if( getLogger().isErrorEnabled() ) + { + getLogger().error( "Caught an exception trying to initialize " + + "the component handler.", e ); + } + } + } } + m_newComponentHandlers.clear(); } } @@ -645,6 +671,7 @@ handler.setLogger( getLogkitLogger() ); handler.enableLogging( getLogger() ); m_componentHandlers.put( role, handler ); + m_newComponentHandlers.add( handler ); } catch( final Exception e ) {
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>