You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by bl...@apache.org on 2002/08/22 15:30:35 UTC

cvs commit: jakarta-avalon-apps/infomover/src/java/org/apache/infomover/connection/impl ConnectionManagerHandlerFactory.java ConnectionManagerImpl.java

bloritsch    2002/08/22 06:30:35

  Modified:    infomover/src/java/org/apache/infomover/connection
                        ConnectionListener.java
                        ConnectionListenerFactory.java
               infomover/src/java/org/apache/infomover/connection/impl
                        ConnectionManagerImpl.java
  Added:       infomover/src/java/org/apache/infomover/connection/impl
                        ConnectionManagerHandlerFactory.java
  Log:
  Finish up the ConnectionManager wrapper
  
  Revision  Changes    Path
  1.2       +3 -1      jakarta-avalon-apps/infomover/src/java/org/apache/infomover/connection/ConnectionListener.java
  
  Index: ConnectionListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/infomover/src/java/org/apache/infomover/connection/ConnectionListener.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConnectionListener.java	21 Aug 2002 20:58:58 -0000	1.1
  +++ ConnectionListener.java	22 Aug 2002 13:30:35 -0000	1.2
  @@ -50,7 +50,9 @@
   package org.apache.infomover.connection;
   
   import java.io.InputStream;
  +import java.io.IOException;
   import java.io.OutputStream;
  +import java.net.ProtocolException;
   
   /**
    * The <code>ConnectionManager</code> interface exposes how we control the
  @@ -61,5 +63,5 @@
    */
   public interface ConnectionListener
   {
  -    void connection( InputStream is, OutputStream os );
  +    void connection( InputStream is, OutputStream os ) throws ProtocolException, IOException;
   }
  
  
  
  1.2       +3 -3      jakarta-avalon-apps/infomover/src/java/org/apache/infomover/connection/ConnectionListenerFactory.java
  
  Index: ConnectionListenerFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/infomover/src/java/org/apache/infomover/connection/ConnectionListenerFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConnectionListenerFactory.java	22 Aug 2002 00:25:34 -0000	1.1
  +++ ConnectionListenerFactory.java	22 Aug 2002 13:30:35 -0000	1.2
  @@ -58,8 +58,8 @@
    */
   public interface ConnectionListenerFactory
   {
  -    public ConnectionListener createConnectionHandler()
  -        throws java.lang.Exception;
  +    public ConnectionListener createConnectionListener()
  +        throws Exception;
   
  -    public void releaseConnectionHandler(ConnectionListener connectionHandler);
  +    public void releaseConnectionListener(ConnectionListener connectionListener);
   }
  
  
  
  1.2       +1 -3      jakarta-avalon-apps/infomover/src/java/org/apache/infomover/connection/impl/ConnectionManagerImpl.java
  
  Index: ConnectionManagerImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-apps/infomover/src/java/org/apache/infomover/connection/impl/ConnectionManagerImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConnectionManagerImpl.java	22 Aug 2002 00:34:37 -0000	1.1
  +++ ConnectionManagerImpl.java	22 Aug 2002 13:30:35 -0000	1.2
  @@ -112,8 +112,7 @@
                   descriptor.getBindAddress()
               );
   
  -        m_connections.connect( name, socket, /*ComponentHandler*/null );
  -        //throw new UnsupportedOperationException();
  +        m_connections.connect( name, socket, new ConnectionManagerHandlerFactory( descriptor ) );
       }
   
       /**
  @@ -134,6 +133,5 @@
           m_descriptors.remove( name );
   
           m_connections.disconnect( name, force );
  -        //throw new UnsupportedOperationException();
       }
   }
  
  
  
  1.1                  jakarta-avalon-apps/infomover/src/java/org/apache/infomover/connection/impl/ConnectionManagerHandlerFactory.java
  
  Index: ConnectionManagerHandlerFactory.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) @year@ The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
      must not be used to endorse or promote products derived from this  software
      without  prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation. For more  information on the
   Apache Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.infomover.connection.impl;
  
  import org.apache.avalon.cornerstone.services.connection.*;
  import org.apache.infomover.connection.ConnectionDescriptor;
  import org.apache.infomover.connection.ConnectionListener;
  
  import java.net.Socket;
  import java.net.ProtocolException;
  import java.io.IOException;
  
  /**
   * The <code>ConnectionManager</code> interface exposes how we control the
   * ConnectionManager externally.
   *
   * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
   * @version 1.0
   */
  final class ConnectionManagerHandlerFactory
      implements ConnectionHandlerFactory
  {
      private final ConnectionDescriptor m_descriptor;
  
      public ConnectionManagerHandlerFactory( ConnectionDescriptor descriptor )
      {
          m_descriptor = descriptor;
      }
  
      public ConnectionHandler createConnectionHandler()
          throws java.lang.Exception
      {
          return new Handler( m_descriptor.getListener().createConnectionListener() );
      }
  
      public void releaseConnectionHandler(ConnectionHandler connectionHandler)
      {
          ConnectionListener listener = ((Handler) connectionHandler).getListener();
          m_descriptor.getListener().releaseConnectionListener(listener);
      }
  
      private static final class Handler implements ConnectionHandler
      {
          private final ConnectionListener m_listener;
  
          public Handler( ConnectionListener listener )
          {
              m_listener = listener;
          }
  
          public void handleConnection( Socket socket )
          throws ProtocolException, IOException
          {
              m_listener.connection( socket.getInputStream(), socket.getOutputStream() );
          }
  
          public ConnectionListener getListener()
          {
              return m_listener;
          }
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>