avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application DefaultApplication.java
Date Tue, 30 Apr 2002 09:45:16 GMT
donaldp     02/04/30 02:45:16

  Modified:    src/java/org/apache/avalon/phoenix/components/application
                        DefaultApplication.java
  Log:
  Made sure that we nulled ThreadContext after processing application specific code so as
to make sure we don't reuse same context multiple times.
  
  PR: 8637
  Submitted by: colus@apache.org (Eung-ju Park)
  
  Revision  Changes    Path
  1.12      +60 -19    jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/DefaultApplication.java
  
  Index: DefaultApplication.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/application/DefaultApplication.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DefaultApplication.java	9 Apr 2002 10:55:50 -0000	1.11
  +++ DefaultApplication.java	30 Apr 2002 09:45:16 -0000	1.12
  @@ -246,22 +246,40 @@
           //Setup thread context for calling visitors
           ThreadContext.setThreadContext( m_context.getThreadContext() );
   
  -        final BlockListenerMetaData[] listeners = m_context.getMetaData().getListeners();
  -        for( int i = 0; i < listeners.length; i++ )
  +	try
  +	{
  +	    doLoadBlockListeners();
  +	}
  +	finally
  +	{
  +	    ThreadContext.setThreadContext( null );
  +	}
  +    }
  +
  +    /**
  +     * Actually perform loading of each individual Listener.
  +     * Note that by this stage it is assumed that the ThreadContext 
  +     * has already been setup correctly.
  +     */
  +    private void doLoadBlockListeners()
  +	throws Exception
  +    {
  +	final BlockListenerMetaData[] listeners = m_context.getMetaData().getListeners();
  +	for( int i = 0; i < listeners.length; i++ )
           {
  -            try
  -            {
  -                m_lifecycle.startupListener( listeners[ i ] );
  -            }
  -            catch( final Exception e )
  -            {
  -                final String name = listeners[ i ].getName();
  -                final String message =
  -                    REZ.getString( "bad-listener", "startup", name, e.getMessage() );
  -                getLogger().error( message, e );
  -                throw e;
  -            }
  -        }
  +	    try
  +	    {
  +		m_lifecycle.startupListener( listeners[ i ] );
  +	    }
  +	    catch( final Exception e )
  +	    {
  +		final String name = listeners[ i ].getName();
  +		final String message =
  +		    REZ.getString( "bad-listener", "startup", name, e.getMessage() );
  +		getLogger().error( message, e );
  +		throw e;
  +	    }
  +	}
       }
   
       /**
  @@ -276,6 +294,30 @@
       private final void runPhase( final String name )
           throws Exception
       {
  +        //Setup thread context for calling visitors
  +        ThreadContext.setThreadContext( m_context.getThreadContext() );
  +
  +	try
  +	{
  +	    doRunPhase( name );
  +	}
  +	finally
  +	{
  +	    ThreadContext.setThreadContext( null );
  +	}
  +    }
  +
  +    /**
  +     * Actually run applications phas.
  +     * By this methods calling it is assumed that ThreadContext
  +     * has already been setup.
  +     *
  +     * @param name the name of phase (for logging purposes)
  +     * @exception Exception if an error occurs
  +     */
  +    private final void doRunPhase( final String name )
  +        throws Exception
  +    {
           final BlockMetaData[] blocks = m_context.getMetaData().getBlocks();
           final String[] order = DependencyGraph.walkGraph( PHASE_STARTUP == name, blocks
);
   
  @@ -291,14 +333,13 @@
               getLogger().info( message );
           }
   
  -        //Setup thread context for calling visitors
  -        ThreadContext.setThreadContext( m_context.getThreadContext() );
  -
           //All blocks about to be processed ...
           if( PHASE_STARTUP == name )
           {
               //... for startup, so indicate to applicable listeners
  -            m_lifecycle.applicationStarting( new ApplicationEvent( m_sarMetaData.getName(),
m_sarMetaData ) );
  +	    final ApplicationEvent event = 
  +		new ApplicationEvent( m_sarMetaData.getName(), m_sarMetaData );
  +            m_lifecycle.applicationStarting( event );
           }
           else
           {
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message