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-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/connection Connection.java
Date Fri, 12 Jul 2002 00:34:52 GMT
donaldp     2002/07/11 17:34:52

  Modified:    src/java/org/apache/avalon/cornerstone/blocks/connection
                        Connection.java
  Log:
  Made it so that the connection handler is not created until they are actually used. This
is more
  optimal in situations where a block thread pool is used.
  
  Submitted By: "Andrei Ivanov" <myfam@surfeu.fi>
  
  Revision  Changes    Path
  1.13      +11 -8     jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/connection/Connection.java
  
  Index: Connection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/connection/Connection.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Connection.java	10 Jul 2002 10:54:28 -0000	1.12
  +++ Connection.java	12 Jul 2002 00:34:52 -0000	1.13
  @@ -90,9 +90,8 @@
               try
               {
                   final Socket socket = m_serverSocket.accept();
  -                final ConnectionHandler handler = m_handlerFactory.createConnectionHandler();
                   final ConnectionRunner runner =
  -                    new ConnectionRunner( socket, m_runners, handler, m_handlerFactory
);
  +                    new ConnectionRunner( socket, m_runners, m_handlerFactory );
                   setupLogger( runner );
                   m_threadPool.execute( runner );
               }
  @@ -125,17 +124,14 @@
       private Socket m_socket;
       private Thread m_thread;
       private List m_runners;
  -    private ConnectionHandler m_handler;
       private ConnectionHandlerFactory m_handlerFactory;
   
       ConnectionRunner( final Socket socket,
                         final List runners,
  -                      final ConnectionHandler handler,
                         final ConnectionHandlerFactory handlerFactory )
       {
           m_socket = socket;
           m_runners = runners;
  -        m_handler = handler;
           m_handlerFactory = handlerFactory;
       }
   
  @@ -159,6 +155,7 @@
   
       public void run()
       {
  +        ConnectionHandler handler = null;
           try
           {
               m_thread = Thread.currentThread();
  @@ -171,7 +168,9 @@
                       m_socket.getInetAddress().getHostAddress();
                   getLogger().debug( message );
               }
  -            m_handler.handleConnection( m_socket );
  +
  +            handler = m_handlerFactory.createConnectionHandler();
  +            handler.handleConnection( m_socket );
   
               if( getLogger().isDebugEnabled() )
               {
  @@ -180,7 +179,7 @@
                       m_socket.getInetAddress().getHostAddress();
                   getLogger().debug( message );
               }
  -            m_handlerFactory.releaseConnectionHandler( m_handler );
  +
           }
           catch( final Exception e )
           {
  @@ -188,7 +187,11 @@
           }
           finally
           {
  -            m_handlerFactory = null;
  +            if( null != handler )
  +            {
  +                m_handlerFactory.releaseConnectionHandler( handler );
  +            }
  +
               try
               {
                   m_socket.close();
  
  
  

--
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