avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject cvs commit: jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/publishing AbstractStreamPublisher.java
Date Wed, 20 Mar 2002 22:12:00 GMT
hammant     02/03/20 14:12:00

  Modified:    src/java/org/apache/avalon/cornerstone/blocks/transport/publishing
                        AbstractStreamPublisher.java
  Log:
  Binding to any address also allowed. Patch from Mike Miller
  
  Revision  Changes    Path
  1.4       +39 -15    jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/publishing/AbstractStreamPublisher.java
  
  Index: AbstractStreamPublisher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/publishing/AbstractStreamPublisher.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractStreamPublisher.java	16 Mar 2002 00:18:34 -0000	1.3
  +++ AbstractStreamPublisher.java	20 Mar 2002 22:12:00 -0000	1.4
  @@ -1,3 +1,4 @@
  +
   /*
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -7,10 +8,14 @@
    */
   package org.apache.avalon.cornerstone.blocks.transport.publishing;
   
  +
  +
   import java.io.IOException;
  +
   import java.net.InetAddress;
   import java.net.ServerSocket;
   import java.net.UnknownHostException;
  +
   import org.apache.avalon.cornerstone.services.connection.ConnectionHandlerFactory;
   import org.apache.avalon.cornerstone.services.connection.ConnectionManager;
   import org.apache.avalon.cornerstone.services.sockets.ServerSocketFactory;
  @@ -20,21 +25,24 @@
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   
  +
   /**
    * Class AbstractStreamPublisher
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.3 $
  + * @author Mike Miller.
  + * @version $Revision: 1.4 $
    */
   public abstract class AbstractStreamPublisher extends AbstractPublisher
  -    implements ConnectionHandlerFactory
  +        implements ConnectionHandlerFactory
   {
   
       protected SocketManager m_socketManager;
       protected ConnectionManager m_connectionManager;
       private int m_port;
       private InetAddress m_bindTo;
  +    boolean m_allAddresses = false;
   
       /**
        * Pass the <code>Configuration</code> to the <code>Configurable</code>
  @@ -43,22 +51,31 @@
        *
        * @param configuration the class configurations.
        */
  -    public final void configure( Configuration configuration ) throws ConfigurationException
  +    public final void configure(Configuration configuration) throws ConfigurationException
       {
   
  -        super.configure( configuration );
  +        super.configure(configuration);
   
  -        m_port = configuration.getChild( "port" ).getValueAsInteger();
  +        m_port = configuration.getChild("port").getValueAsInteger();
   
           try
           {
  -            final String bindAddress = configuration.getChild( "bind" ).getValue();
  +            final String bindAddress = configuration.getChild("bind").getValue();
   
  -            m_bindTo = InetAddress.getByName( bindAddress );
  +            if ("*".equals(bindAddress))
  +            {
  +                m_allAddresses = true;
  +                m_bindTo = null;
  +            }
  +            else
  +            {
  +                m_allAddresses = false;
  +                m_bindTo = InetAddress.getByName(bindAddress);
  +            }
           }
  -        catch( final UnknownHostException unhe )
  +        catch (final UnknownHostException unhe)
           {
  -            throw new ConfigurationException( "Malformed bind parameter", unhe );
  +            throw new ConfigurationException("Malformed bind parameter", unhe);
           }
       }
   
  @@ -71,20 +88,27 @@
        * @throws ComponentException
        *
        */
  -    public final void compose( ComponentManager manager ) throws ComponentException
  +    public final void compose(ComponentManager manager) throws ComponentException
       {
   
  -        super.compose( manager );
  +        super.compose(manager);
   
  -        m_socketManager = (SocketManager)manager.lookup( SocketManager.ROLE );
  -        m_connectionManager = (ConnectionManager)manager.lookup( ConnectionManager.ROLE
);
  +        m_socketManager = (SocketManager) manager.lookup(SocketManager.ROLE);
  +        m_connectionManager = (ConnectionManager) manager.lookup(ConnectionManager.ROLE);
       }
   
       protected ServerSocket makeServerSocket() throws ComponentException, IOException
       {
   
  -        final ServerSocketFactory factory = m_socketManager.getServerSocketFactory( "plain"
);
  +        final ServerSocketFactory factory = m_socketManager.getServerSocketFactory("plain");
   
  -        return factory.createServerSocket( m_port, 5, m_bindTo );
  +        if (m_allAddresses)
  +        {
  +            return factory.createServerSocket(m_port, 5);
  +        }
  +        else
  +        {
  +            return factory.createServerSocket(m_port, 5, m_bindTo);
  +        }
       }
   }
  
  
  

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