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/transport/publishing AbstractPublisher.java PartialSocketStreamConnectionHandler.java RmiPublisher.java SocketStreamPublisher.java
Date Fri, 12 Jul 2002 00:13:11 GMT
donaldp     2002/07/11 17:13:11

  Modified:    src/java/org/apache/avalon/cornerstone/blocks/transport/publishing
                        AbstractPublisher.java
                        PartialSocketStreamConnectionHandler.java
                        RmiPublisher.java SocketStreamPublisher.java
  Log:
  Made some variables private and only changed via accessor/mutators.
  
  Decoupled from framework.component.*
  
  Revision  Changes    Path
  1.19      +15 -90    jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/publishing/AbstractPublisher.java
  
  Index: AbstractPublisher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/publishing/AbstractPublisher.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- AbstractPublisher.java	30 Jun 2002 17:24:03 -0000	1.18
  +++ AbstractPublisher.java	12 Jul 2002 00:13:11 -0000	1.19
  @@ -14,9 +14,6 @@
   import java.util.Vector;
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.activity.Startable;
  -import org.apache.avalon.framework.component.ComponentException;
  -import org.apache.avalon.framework.component.ComponentManager;
  -import org.apache.avalon.framework.component.Composable;
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  @@ -49,22 +46,14 @@
       implements AltrmiPublisher, Startable, Serviceable, Contextualizable, Configurable,
       Initializable
   {
  -
  -    protected AbstractServer m_abstractServer;
  +    private AbstractServer m_abstractServer;
       private ClassRetriever m_classRetriever;
  -    protected AltrmiAuthenticator m_altrmiAuthenticator;
  +    private AltrmiAuthenticator m_altrmiAuthenticator;
       protected File m_baseDirectory;
   
  -    /**
  -     * Pass the <code>Configuration</code> to the <code>Configurable</code>
  -     * class. This method must always be called after the constructor
  -     * and before any other method.
  -     *
  -     * @param configuration the class configurations.
  -     */
  -    public void configure( Configuration configuration ) throws ConfigurationException
  +    public void configure( Configuration configuration )
  +        throws ConfigurationException
       {
  -
           String classRetrieverType = configuration.getChild( "classRetrieverType" ).getValue();
   
           if( classRetrieverType.equals( "jarFile" ) )
  @@ -131,31 +120,12 @@
               (AltrmiAuthenticator)manager.lookup( AltrmiAuthenticator.class.getName() );
       }
   
  -    /**
  -     * Initialialize the component. Initialization includes
  -     * allocating any resources required throughout the
  -     * components lifecycle.
  -     *
  -     * @exception Exception if an error occurs
  -     */
       public void initialize() throws Exception
       {
           m_abstractServer.setClassRetriever( m_classRetriever );
           m_abstractServer.setAuthenticator( m_altrmiAuthenticator );
       }
   
  -    /**
  -     * Method publish
  -     *
  -     *
  -     * @param implementation
  -     * @param asName
  -     * @param interfaceToExpose
  -     *
  -     *
  -     * @throws PublicationException
  -     *
  -     */
       public void publish( Object implementation, String asName, Class interfaceToExpose
)
           throws PublicationException
       {
  @@ -166,18 +136,6 @@
           m_abstractServer.publish( implementation, asName, interfaceToExpose );
       }
   
  -    /**
  -     * Method publish
  -     *
  -     *
  -     * @param implementation
  -     * @param asName
  -     * @param publicationDescription
  -     *
  -     *
  -     * @throws PublicationException
  -     *
  -     */
       public void publish(
           Object implementation, String asName, PublicationDescription publicationDescription
)
           throws PublicationException
  @@ -188,17 +146,6 @@
           m_abstractServer.publish( implementation, asName, publicationDescription );
       }
   
  -    /**
  -     * Method unPublish
  -     *
  -     *
  -     * @param o
  -     * @param s
  -     *
  -     *
  -     * @throws PublicationException
  -     *
  -     */
       public void unPublish( Object o, String s ) throws PublicationException
       {
           if( getLogger().isDebugEnabled() )
  @@ -207,18 +154,6 @@
           m_abstractServer.unPublish( o, s );
       }
   
  -    /**
  -     * Method replacePublished
  -     *
  -     *
  -     * @param o
  -     * @param s
  -     * @param o1
  -     *
  -     *
  -     * @throws PublicationException
  -     *
  -     */
       public void replacePublished( Object o, String s, Object o1 ) throws PublicationException
       {
           if( getLogger().isDebugEnabled() )
  @@ -227,36 +162,16 @@
           m_abstractServer.replacePublished( o, s, o1 );
       }
   
  -    /**
  -     * Starts the component.
  -     *
  -     * @exception Exception if Component can not be started
  -     */
       public void start() throws Exception
       {
           m_abstractServer.start();
       }
   
  -    /**
  -     * Stops the component.
  -     *
  -     * @exception Exception if the Component can not be Stopped.
  -     */
       public void stop() throws Exception
       {
           m_abstractServer.stop();
       }
   
  -    /**
  -     * Method getMethodInvocationHandler
  -     *
  -     *
  -     * @param request
  -     * @param s
  -     *
  -     * @return
  -     *
  -     */
       public MethodInvocationHandler getMethodInvocationHandler( MethodRequest request, String
publishedName )
       {
           return m_abstractServer.getMethodInvocationHandler( request, publishedName );
  @@ -265,5 +180,15 @@
       public MethodInvocationHandler getMethodInvocationHandler(String publishedName)
       {
           return m_abstractServer.getMethodInvocationHandler( publishedName );
  +    }
  +
  +    protected AbstractServer getAbstractServer()
  +    {
  +        return m_abstractServer;
  +    }
  +
  +    protected void setAbstractServer( AbstractServer abstractServer )
  +    {
  +        m_abstractServer = abstractServer;
       }
   }
  
  
  
  1.3       +4 -15     jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/publishing/PartialSocketStreamConnectionHandler.java
  
  Index: PartialSocketStreamConnectionHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/publishing/PartialSocketStreamConnectionHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PartialSocketStreamConnectionHandler.java	18 May 2002 04:11:16 -0000	1.2
  +++ PartialSocketStreamConnectionHandler.java	12 Jul 2002 00:13:11 -0000	1.3
  @@ -11,32 +11,20 @@
   import java.net.ProtocolException;
   import java.net.Socket;
   import org.apache.avalon.cornerstone.services.connection.ConnectionHandler;
  -import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.excalibur.altrmi.server.impl.socket.AbstractPartialSocketStreamServer;
   
   /**
  - * Class PartialSocketStreamConnectionHandler
  - *
  - *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
    * @author Peter Royal.
    * @version $Revision$
    */
   public class PartialSocketStreamConnectionHandler
       extends AbstractLogEnabled
  -    implements Component, ConnectionHandler
  +    implements ConnectionHandler
   {
  -
       private AbstractPartialSocketStreamServer m_PartialSockeStreamServer;
   
  -    /**
  -     * Constructor PartialSocketStreamConnectionHandler
  -     *
  -     *
  -     * @param partialSocketStreamServer
  -     *
  -     */
       public PartialSocketStreamConnectionHandler(
           AbstractPartialSocketStreamServer partialSocketStreamServer )
       {
  @@ -51,7 +39,8 @@
        * @exception IOException if an error reading from socket occurs
        * @exception ProtocolException if an error handling connection occurs
        */
  -    public void handleConnection( Socket connection ) throws IOException, ProtocolException
  +    public void handleConnection( Socket connection )
  +        throws IOException, ProtocolException
       {
           m_PartialSockeStreamServer.handleConnection( connection );
       }
  
  
  
  1.12      +3 -3      jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/publishing/RmiPublisher.java
  
  Index: RmiPublisher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/publishing/RmiPublisher.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- RmiPublisher.java	18 May 2002 13:30:09 -0000	1.11
  +++ RmiPublisher.java	12 Jul 2002 00:13:11 -0000	1.12
  @@ -52,9 +52,9 @@
       public void initialize() throws Exception
       {
   
  -        m_abstractServer = new RmiServer( m_host, m_port );
  +        setAbstractServer( new RmiServer( m_host, m_port ) );
   
  -        setupLogger( m_abstractServer );
  +        setupLogger( getAbstractServer() );
           super.initialize();
       }
   
  
  
  
  1.5       +29 -36    jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/publishing/SocketStreamPublisher.java
  
  Index: SocketStreamPublisher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/publishing/SocketStreamPublisher.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SocketStreamPublisher.java	18 May 2002 13:30:09 -0000	1.4
  +++ SocketStreamPublisher.java	12 Jul 2002 00:13:11 -0000	1.5
  @@ -1,4 +1,3 @@
  -
   /*
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -8,28 +7,21 @@
    */
   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.ConnectionHandler;
   import org.apache.avalon.cornerstone.services.connection.ConnectionHandlerFactory;
   import org.apache.avalon.cornerstone.services.connection.ConnectionManager;
  -import org.apache.avalon.cornerstone.services.connection.ConnectionHandler;
   import org.apache.avalon.cornerstone.services.sockets.ServerSocketFactory;
   import org.apache.avalon.cornerstone.services.sockets.SocketManager;
  -import org.apache.avalon.framework.component.ComponentException;
  -import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.ServiceException;
  -import org.apache.excalibur.altrmi.server.impl.socket.PartialSocketCustomStreamServer;
  +import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.excalibur.altrmi.server.impl.socket.AbstractPartialSocketStreamServer;
  -
  +import org.apache.excalibur.altrmi.server.impl.socket.PartialSocketCustomStreamServer;
   
   /**
    * @phoenix:block
  @@ -44,12 +36,12 @@
       extends AbstractPublisher
       implements ConnectionHandlerFactory
   {
  -    protected SocketManager m_socketManager;
  -    protected ConnectionManager m_connectionManager;
  +    private SocketManager m_socketManager;
  +    private ConnectionManager m_connectionManager;
       private int m_port;
       private InetAddress m_bindTo;
       private String m_socketStreamServerClass;
  -    boolean m_allAddresses = false;
  +    private boolean m_allAddresses = false;
   
       /**
        * Pass the <code>Configuration</code> to the <code>Configurable</code>
  @@ -58,18 +50,18 @@
        *
        * @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();
   
  -            if ("*".equals(bindAddress))
  +            if( "*".equals( bindAddress ) )
               {
                   m_allAddresses = true;
                   m_bindTo = null;
  @@ -77,15 +69,15 @@
               else
               {
                   m_allAddresses = false;
  -                m_bindTo = InetAddress.getByName(bindAddress);
  +                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 );
           }
   
  -        m_socketStreamServerClass = configuration.getChild("socketStreamServerClass").getValue();
  +        m_socketStreamServerClass = configuration.getChild( "socketStreamServerClass" ).getValue();
       }
   
       /**
  @@ -93,27 +85,28 @@
        * @phoenix:dependency name="org.apache.avalon.cornerstone.services.sockets.SocketManager"
        * @phoenix:dependency name="org.apache.avalon.cornerstone.services.connection.ConnectionManager"
        */
  -    public final void service( final ServiceManager manager)
  +    public final void service( final ServiceManager manager )
           throws ServiceException
       {
  -        super.service(manager);
  +        super.service( 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
  +    protected ServerSocket makeServerSocket()
  +        throws IOException, Exception
       {
   
  -        final ServerSocketFactory factory = m_socketManager.getServerSocketFactory("plain");
  +        final ServerSocketFactory factory = m_socketManager.getServerSocketFactory( "plain"
);
   
  -        if (m_allAddresses)
  +        if( m_allAddresses )
           {
  -            return factory.createServerSocket(m_port, 5);
  +            return factory.createServerSocket( m_port, 5 );
           }
           else
           {
  -            return factory.createServerSocket(m_port, 5, m_bindTo);
  +            return factory.createServerSocket( m_port, 5, m_bindTo );
           }
       }
   
  @@ -127,7 +120,7 @@
       {
           final PartialSocketStreamConnectionHandler handler =
               new PartialSocketStreamConnectionHandler(
  -                (AbstractPartialSocketStreamServer) m_abstractServer );
  +                (AbstractPartialSocketStreamServer)getAbstractServer() );
   
           setupLogger( handler );
   
  @@ -151,9 +144,9 @@
        */
       public void initialize() throws Exception
       {
  -        m_abstractServer = (AbstractPartialSocketStreamServer) Class.forName(m_socketStreamServerClass).newInstance();
  +        setAbstractServer( (AbstractPartialSocketStreamServer)Class.forName( m_socketStreamServerClass
).newInstance() );
   
  -        setupLogger( m_abstractServer );
  +        setupLogger( getAbstractServer() );
           super.initialize();
           m_connectionManager.connect( "SocketStreamListener", makeServerSocket(), this );
       }
  
  
  

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