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/subscription AbstractSubscriber.java RmiSubscriber.java SocketObjectStreamSubscriber.java
Date Thu, 10 Jan 2002 17:14:35 GMT
hammant     02/01/10 09:14:35

  Modified:    src/java/org/apache/avalon/cornerstone/blocks/transport/publishing
                        AbstractPublisher.java RmiPublisher.java
                        SocketObjectStreamConnectionHandler.java
                        SocketObjectStreamPublisher.java
               src/java/org/apache/avalon/cornerstone/blocks/transport/subscription
                        AbstractSubscriber.java RmiSubscriber.java
                        SocketObjectStreamSubscriber.java
  Added:       src/java/org/apache/avalon/cornerstone/blocks/transport/autopublishing
                        AutoPublisher.java
  Log:
  reformat to Cornerstone style
  
  Revision  Changes    Path
  1.1                  jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/autopublishing/AutoPublisher.java
  
  Index: AutoPublisher.java
  ===================================================================
  
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE file.
   */
  package org.apache.avalon.cornerstone.blocks.transport.autopublishing;
  
  import org.apache.commons.altrmi.server.AltrmiPublisher;
  import org.apache.commons.altrmi.server.AltrmiPublicationException;
  import org.apache.avalon.phoenix.BlockListener;
  import org.apache.avalon.phoenix.BlockEvent;
  import org.apache.avalon.phoenix.Block;
  import org.apache.avalon.phoenix.metainfo.BlockInfo;
  import org.apache.avalon.phoenix.metainfo.ServiceDescriptor;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  
  import java.util.Vector;
  
  /**
   * Class AutoPublisher
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class AutoPublisher
     implements BlockListener, Configurable
  {
     private AltrmiPublisher mAltrmiPublisher;
     private Vector          mServicesToPublish = new Vector();
     private Vector          mPublishAsNames    = new Vector();
  
     /**
      *
      *
      *      IN PROGRESS & UNFINISHED - PAUL H
      *
      *
      */
  
  
     /**
      * 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 (final Configuration configuration)
        throws ConfigurationException
     {
        System.out.println("AutoPublisher.configure() called!");
  
        Configuration[] publications =
           configuration.getChildren("publications");
  
        for (int i = 0; i < publications.length; i++)
        {
           Configuration publication = publications [i];
  
           System.out.println("publications " + publication);
        }
     }
  
     /**
      * Notification that a block has just been added
      * to Server Application.
      *
      * @param event the BlockEvent
      */
  
     public void blockAdded (final BlockEvent event)
     {
        try
        {
           if (mServicesToPublish.contains(event.getName()))
           {
              int                 ix         =
                 mServicesToPublish.indexOf(event.getName());
              Block               block      = event.getBlock();
              BlockInfo           bi         = event.getBlockInfo();
              ServiceDescriptor[] sd         = bi.getServices();
              Vector              classNames = new Vector();
  
              for (int i = 0; i < sd.length; i++)
              {
                 ServiceDescriptor descriptor = sd [i];
                 Class             clazz      =
                    Class.forName(descriptor.getName());
  
                 classNames.add(clazz);
              }
  
              Class[] classes = new Class [classNames.size()];
  
              classNames.copyInto(classes);
              //mAltrmiPublisher.publish(block,
              //                         ( String ) mPublishAsNames.elementAt(ix),
              //                         classes);
           }
        }
        catch (ClassNotFoundException cnfe)
        {
           cnfe.printStackTrace();
  
           // TODO ?
        }
        catch (AltrmiPublicationException ape)
        {
           ape.printStackTrace();
  
           // TODO ?
        }
     }
  
     /**
      * Notification that a block is just about to be
      * removed from Server Application.
      *
      * @param event the BlockEvent
      */
  
     public void blockRemoved (final BlockEvent event)
     {
        System.out.println("Removed block '" + event.getName() + "'");
     }
  }
  
  
  
  1.3       +228 -183  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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractPublisher.java	10 Jan 2002 11:18:24 -0000	1.2
  +++ AbstractPublisher.java	10 Jan 2002 17:14:34 -0000	1.3
  @@ -24,10 +24,8 @@
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.phoenix.Block;
  -
   import java.util.StringTokenizer;
   import java.util.Vector;
  -
   import java.net.MalformedURLException;
   
   
  @@ -36,190 +34,237 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
  -public abstract class AbstractPublisher extends AbstractLogEnabled
  -        implements AltrmiPublisher, Startable, Configurable, Initializable, Block {
  -
  -    protected AltrmiServer mAltrmiServer;
  -    private ClassRetriever mClassRetriever;
   
  -    /**
  -     * 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 {
  -
  -        String classRetrieverType = configuration.getChild("classRetrieverType").getValue();
  -
  -        if (classRetrieverType.equals("jarFile")) {
  -            StringTokenizer st =
  -                new StringTokenizer(configuration.getChild("gerneratedClassJarURLs").getValue(),
  -                                    ",");
  -            Vector vector = new Vector();
  -
  -            while (st.hasMoreTokens()) {
  -                vector.add(st.nextToken());
  +public abstract class AbstractPublisher
  +   extends AbstractLogEnabled
  +   implements AltrmiPublisher, Startable, Configurable, Initializable, Block
  +{
  +   protected AltrmiServer mAltrmiServer;
  +   private ClassRetriever mClassRetriever;
  +
  +   /**
  +    * 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
  +   {
  +      String classRetrieverType =
  +         configuration.getChild("classRetrieverType").getValue();
  +
  +      if (classRetrieverType.equals("jarFile"))
  +      {
  +         StringTokenizer st     = new StringTokenizer(
  +            configuration.getChild("gerneratedClassJarURLs").getValue(), ",");
  +         Vector          vector = new Vector();
  +
  +         while (st.hasMoreTokens())
  +         {
  +            vector.add(st.nextToken());
  +         }
  +
  +         String[] urls = new String [vector.size()];
  +
  +         vector.copyInto(urls);
  +
  +         try
  +         {
  +            mClassRetriever = new JarFileClassRetriever(urls);
  +         }
  +         catch (MalformedURLException mufe)
  +         {
  +            throw new ConfigurationException("URL Invalid", mufe);
  +         }
  +      }
  +      else
  +         if (classRetrieverType.equals("baseMobileClass"))
  +         {
  +            mClassRetriever = new BaseMobileClassRetriever();
  +         }
  +         else
  +            if (classRetrieverType.equals("none"))
  +            {
  +               mClassRetriever = new NoClassRetriever();
               }
  +            else
  +            {
  +               throw new ConfigurationException(
  +                  "classRetrieverType must be 'baseMobileClass', 'jarFile' or 'none'");
  +            }
  +   }
   
  -            String[] urls = new String[vector.size()];
  +   /**
  +    * Initialialize the component. Initialization includes
  +    * allocating any resources required throughout the
  +    * components lifecycle.
  +    *
  +    * @exception Exception if an error occurs
  +    */
  +
  +   public void initialize ()
  +      throws Exception
  +   {
  +      mAltrmiServer.setClassRetriever(mClassRetriever);
  +   }
  +
  +   /**
  +    * Method publish
  +    *
  +    *
  +    * @param o
  +    * @param s
  +    * @param aClass
  +    *
  +    * @throws AltrmiPublicationException
  +    *
  +    */
  +
  +   public void publish (Object o, String s, Class aClass)
  +      throws AltrmiPublicationException
  +   {
  +      mAltrmiServer.publish(o, s, aClass);
  +   }
  +
  +   /**
  +    * Method publish
  +    *
  +    *
  +    * @param o
  +    * @param s
  +    * @param aClass
  +    * @param aClass1
  +    *
  +    * @throws AltrmiPublicationException
  +    *
  +    */
  +
  +   public void publish (Object o, String s, Class aClass, Class aClass1)
  +      throws AltrmiPublicationException
  +   {
  +      mAltrmiServer.publish(o, s, aClass, aClass1);
  +   }
  +
  +   /**
  +    * Method publish
  +    *
  +    *
  +    * @param o
  +    * @param s
  +    * @param aClass
  +    * @param classes
  +    *
  +    * @throws AltrmiPublicationException
  +    *
  +    */
  +
  +   public void publish (Object o, String s, Class aClass, Class[] classes)
  +      throws AltrmiPublicationException
  +   {
  +      mAltrmiServer.publish(o, s, aClass, classes);
  +   }
  +
  +   /**
  +    * Method publish
  +    *
  +    *
  +    * @param o
  +    * @param s
  +    * @param classes
  +    *
  +    * @throws AltrmiPublicationException
  +    *
  +    */
  +
  +   public void publish (Object o, String s, Class[] classes)
  +      throws AltrmiPublicationException
  +   {
  +      mAltrmiServer.publish(o, s, classes);
  +   }
  +
  +   /**
  +    * Method publish
  +    *
  +    *
  +    * @param o
  +    * @param s
  +    * @param classes
  +    * @param classes1
  +    *
  +    * @throws AltrmiPublicationException
  +    *
  +    */
  +
  +   public void publish (Object o, String s, Class[] classes, Class[] classes1)
  +      throws AltrmiPublicationException
  +   {
  +      mAltrmiServer.publish(o, s, classes, classes1);
  +   }
  +
  +   /**
  +    * Method unPublish
  +    *
  +    *
  +    * @param o
  +    * @param s
  +    *
  +    * @throws AltrmiPublicationException
  +    *
  +    */
  +
  +   public void unPublish (Object o, String s)
  +      throws AltrmiPublicationException
  +   {
  +      mAltrmiServer.unPublish(o, s);
  +   }
  +
  +   /**
  +    * Method replacePublished
  +    *
  +    *
  +    * @param o
  +    * @param s
  +    * @param o1
  +    *
  +    * @throws AltrmiPublicationException
  +    *
  +    */
  +
  +   public void replacePublished (Object o, String s, Object o1)
  +      throws AltrmiPublicationException
  +   {
  +      mAltrmiServer.replacePublished(o, s, o1);
  +   }
  +
  +   /**
  +    * Starts the component.
  +    *
  +    * @exception Exception if Component can not be started
  +    */
  +
  +   public void start ()
  +      throws Exception
  +   {
  +      mAltrmiServer.start();
  +   }
  +
  +   /**
  +    * Stops the component.
  +    *
  +    * @exception Exception if the Component can not be Stopped.
  +    */
  +
  +   public void stop ()
  +      throws Exception
  +   {
  +      mAltrmiServer.stop();
  +   }
  +}
   
  -            vector.copyInto(urls);
   
  -            try {
  -                mClassRetriever = new JarFileClassRetriever(urls);
  -            } catch (MalformedURLException mufe) {
  -                throw new ConfigurationException("URL Invalid", mufe);
  -            }
  -        } else if (classRetrieverType.equals("baseMobileClass")) {
  -            mClassRetriever = new BaseMobileClassRetriever();
  -        } else if (classRetrieverType.equals("none")) {
  -            mClassRetriever = new NoClassRetriever();
  -        } else {
  -            throw new ConfigurationException("classRetrieverType must be 'baseMobileClass',
'jarFile' or 'none'");
  -        }
  -    }
  -
  -    /**
  -     * Initialialize the component. Initialization includes
  -     * allocating any resources required throughout the
  -     * components lifecycle.
  -     *
  -     * @exception Exception if an error occurs
  -     */
  -    public void initialize() throws Exception {
  -        mAltrmiServer.setClassRetriever(mClassRetriever);
  -    }
  -
  -    /**
  -     * Method publish
  -     *
  -     *
  -     * @param o
  -     * @param s
  -     * @param aClass
  -     *
  -     * @throws AltrmiPublicationException
  -     *
  -     */
  -    public void publish(Object o, String s, Class aClass) throws AltrmiPublicationException
{
  -        mAltrmiServer.publish(o, s, aClass);
  -    }
  -
  -    /**
  -     * Method publish
  -     *
  -     *
  -     * @param o
  -     * @param s
  -     * @param aClass
  -     * @param aClass1
  -     *
  -     * @throws AltrmiPublicationException
  -     *
  -     */
  -    public void publish(Object o, String s, Class aClass, Class aClass1)
  -            throws AltrmiPublicationException {
  -        mAltrmiServer.publish(o, s, aClass, aClass1);
  -    }
  -
  -    /**
  -     * Method publish
  -     *
  -     *
  -     * @param o
  -     * @param s
  -     * @param aClass
  -     * @param classes
  -     *
  -     * @throws AltrmiPublicationException
  -     *
  -     */
  -    public void publish(Object o, String s, Class aClass, Class[] classes)
  -            throws AltrmiPublicationException {
  -        mAltrmiServer.publish(o, s, aClass, classes);
  -    }
  -
  -    /**
  -     * Method publish
  -     *
  -     *
  -     * @param o
  -     * @param s
  -     * @param classes
  -     *
  -     * @throws AltrmiPublicationException
  -     *
  -     */
  -    public void publish(Object o, String s, Class[] classes) throws AltrmiPublicationException
{
  -        mAltrmiServer.publish(o, s, classes);
  -    }
  -
  -    /**
  -     * Method publish
  -     *
  -     *
  -     * @param o
  -     * @param s
  -     * @param classes
  -     * @param classes1
  -     *
  -     * @throws AltrmiPublicationException
  -     *
  -     */
  -    public void publish(Object o, String s, Class[] classes, Class[] classes1)
  -            throws AltrmiPublicationException {
  -        mAltrmiServer.publish(o, s, classes, classes1);
  -    }
  -
  -    /**
  -     * Method unPublish
  -     *
  -     *
  -     * @param o
  -     * @param s
  -     *
  -     * @throws AltrmiPublicationException
  -     *
  -     */
  -    public void unPublish(Object o, String s) throws AltrmiPublicationException {
  -        mAltrmiServer.unPublish(o, s);
  -    }
  -
  -    /**
  -     * Method replacePublished
  -     *
  -     *
  -     * @param o
  -     * @param s
  -     * @param o1
  -     *
  -     * @throws AltrmiPublicationException
  -     *
  -     */
  -    public void replacePublished(Object o, String s, Object o1)
  -            throws AltrmiPublicationException {
  -        mAltrmiServer.replacePublished(o, s, o1);
  -    }
  -
  -    /**
  -     * Starts the component.
  -     *
  -     * @exception Exception if Component can not be started
  -     */
  -    public void start() throws Exception {
  -        mAltrmiServer.start();
  -    }
  -
  -    /**
  -     * Stops the component.
  -     *
  -     * @exception Exception if the Component can not be Stopped.
  -     */
  -    public void stop() throws Exception {
  -        mAltrmiServer.stop();
  -    }
  -}
  +/*------ Formatted by Jindent 3.24 Basic 1.0 --- http://www.jindent.de ------*/
  
  
  
  1.2       +40 -31    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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RmiPublisher.java	9 Jan 2002 21:40:04 -0000	1.1
  +++ RmiPublisher.java	10 Jan 2002 17:14:34 -0000	1.2
  @@ -20,39 +20,48 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
  -public class RmiPublisher extends AbstractPublisher {
   
  -    private String mHost;
  -    private int mPort;
  +public class RmiPublisher
  +   extends AbstractPublisher
  +{
  +   private String mHost;
  +   private int    mPort;
  +
  +   /**
  +    * 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
  +   {
  +      super.configure(configuration);
  +
  +      mPort = configuration.getChild("port").getValueAsInteger();
  +      mHost = configuration.getChild("host").getValue();
  +   }
  +
  +   /**
  +    * Initialialize the component. Initialization includes
  +    * allocating any resources required throughout the
  +    * components lifecycle.
  +    *
  +    * @exception Exception if an error occurs
  +    */
  +
  +   public void initialize ()
  +      throws Exception
  +   {
  +      mAltrmiServer = new RmiServer(mHost, mPort);
   
  -    /**
  -     * 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 {
  -
  -        super.configure(configuration);
  -
  -        mPort = configuration.getChild("port").getValueAsInteger();
  -        mHost = configuration.getChild("host").getValue();
  -    }
  -
  -    /**
  -     * Initialialize the component. Initialization includes
  -     * allocating any resources required throughout the
  -     * components lifecycle.
  -     *
  -     * @exception Exception if an error occurs
  -     */
  -    public void initialize() throws Exception {
  +      super.initialize();
  +   }
  +}
   
  -        mAltrmiServer = new RmiServer(mHost, mPort);
   
  -        super.initialize();
  -    }
  -}
  +/*------ Formatted by Jindent 3.24 Basic 1.0 --- http://www.jindent.de ------*/
  
  
  
  1.2       +33 -22    jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/publishing/SocketObjectStreamConnectionHandler.java
  
  Index: SocketObjectStreamConnectionHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/publishing/SocketObjectStreamConnectionHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SocketObjectStreamConnectionHandler.java	9 Jan 2002 22:48:45 -0000	1.1
  +++ SocketObjectStreamConnectionHandler.java	10 Jan 2002 17:14:34 -0000	1.2
  @@ -1,41 +1,52 @@
  +
   /*
    * Created by IntelliJ IDEA.
    * User: Administrator
    * Date: Jan 9, 2002
    * Time: 10:25:12 PM
  - * To change template for new class use 
  + * To change template for new class use
    * Code Style | Class Templates options (Tools | IDE Options).
    */
   package org.apache.avalon.cornerstone.blocks.transport.publishing;
   
  +
  +
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.cornerstone.services.connection.ConnectionHandler;
   import org.apache.commons.altrmi.server.impl.socket.PartialSocketObjectStreamServer;
  -
   import java.net.Socket;
   import java.net.ProtocolException;
   import java.io.IOException;
   
  -public class SocketObjectStreamConnectionHandler extends AbstractLogEnabled
  -    implements Component, ConnectionHandler {
   
  -    private PartialSocketObjectStreamServer m_PartialSocketObjectStreamServer;
  -
  -    public SocketObjectStreamConnectionHandler(PartialSocketObjectStreamServer partialSocketObjectStreamServer)
{
  -        m_PartialSocketObjectStreamServer = partialSocketObjectStreamServer;
  -    }
  -
  -    /**
  -     * Handle a connection.
  -     * This handler is responsible for processing connections as they occur.
  -     *
  -     * @param connection the connection
  -     * @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 {
  -        m_PartialSocketObjectStreamServer.handleConnection(connection);
  -    }
  +public class SocketObjectStreamConnectionHandler
  +   extends AbstractLogEnabled
  +   implements Component, ConnectionHandler
  +{
  +   private PartialSocketObjectStreamServer m_PartialSocketObjectStreamServer;
  +
  +   public SocketObjectStreamConnectionHandler (
  +           PartialSocketObjectStreamServer partialSocketObjectStreamServer)
  +   {
  +      m_PartialSocketObjectStreamServer = partialSocketObjectStreamServer;
  +   }
  +
  +   /**
  +    * Handle a connection.
  +    * This handler is responsible for processing connections as they occur.
  +    *
  +    * @param connection the connection
  +    * @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
  +   {
  +      m_PartialSocketObjectStreamServer.handleConnection(connection);
  +   }
   }
  +
  +
  +/*------ Formatted by Jindent 3.24 Basic 1.0 --- http://www.jindent.de ------*/
  
  
  
  1.3       +101 -75   jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/publishing/SocketObjectStreamPublisher.java
  
  Index: SocketObjectStreamPublisher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/publishing/SocketObjectStreamPublisher.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SocketObjectStreamPublisher.java	9 Jan 2002 22:48:45 -0000	1.2
  +++ SocketObjectStreamPublisher.java	10 Jan 2002 17:14:34 -0000	1.3
  @@ -8,6 +8,8 @@
    */
   package org.apache.avalon.cornerstone.blocks.transport.publishing;
   
  +
  +
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.component.Composable;
  @@ -19,7 +21,6 @@
   import org.apache.avalon.cornerstone.services.connection.ConnectionHandlerFactory;
   import org.apache.avalon.cornerstone.services.connection.ConnectionHandler;
   import org.apache.commons.altrmi.server.impl.socket.PartialSocketObjectStreamServer;
  -
   import java.net.InetAddress;
   import java.net.UnknownHostException;
   import java.net.ServerSocket;
  @@ -30,81 +31,106 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
  -public class SocketObjectStreamPublisher extends AbstractPublisher implements Composable,
ConnectionHandlerFactory {
   
  -    private SocketManager m_socketManager;
  -    private ConnectionManager m_connectionManager;
  -    private int m_port;
  -    private InetAddress m_bindTo;
  -
  -    /**
  -     * 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 {
  -
  -        super.configure(configuration);
  -        m_port = configuration.getChild("port").getValueAsInteger();
  -        try
  -        {
  -            final String bindAddress = configuration.getChild( "bind" ).getValue();
  -            m_bindTo = InetAddress.getByName( bindAddress );
  -        }
  -        catch( final UnknownHostException unhe )
  -        {
  -            throw new ConfigurationException( "Malformed bind parameter", unhe );
  -        }
  -
  -    }
  -
  -    public void compose(ComponentManager manager) throws ComponentException {
  -        m_socketManager = (SocketManager)manager.lookup( SocketManager.ROLE );
  -        m_connectionManager = (ConnectionManager)manager.lookup( ConnectionManager.ROLE
);
  -    }
  -
  -    /**
  -     * Construct an appropriate ConnectionHandler.
  -     *
  -     * @return the new ConnectionHandler
  -     * @exception Exception if an error occurs
  -     */
  -    public ConnectionHandler createConnectionHandler()
  -            throws Exception {
  -        final SocketObjectStreamConnectionHandler handler = new SocketObjectStreamConnectionHandler(
(PartialSocketObjectStreamServer) mAltrmiServer );
  -        setupLogger( handler );
  -        return handler;
  -    }
  -
  -    /**
  -     * Release a previously created ConnectionHandler.
  -     * e.g. for spooling.
  -     */
  -    public void releaseConnectionHandler(ConnectionHandler connectionHandler) {
  -    }
  -
  -    /**
  -     * Initialialize the component. Initialization includes
  -     * allocating any resources required throughout the
  -     * components lifecycle.
  -     *
  -     * @exception Exception if an error occurs
  -     */
  -    public void initialize() throws Exception {
  -
  -        mAltrmiServer = new PartialSocketObjectStreamServer();
  -
  -        super.initialize();
  -
  -        final ServerSocketFactory factory =
  -            m_socketManager.getServerSocketFactory( "plain" );
  -        final ServerSocket serverSocket = factory.createServerSocket( m_port, 5, m_bindTo
);
  +public class SocketObjectStreamPublisher
  +   extends AbstractPublisher
  +   implements Composable, ConnectionHandlerFactory
  +{
  +   private SocketManager     m_socketManager;
  +   private ConnectionManager m_connectionManager;
  +   private int               m_port;
  +   private InetAddress       m_bindTo;
  +
  +   /**
  +    * 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
  +   {
  +      super.configure(configuration);
  +
  +      m_port = configuration.getChild("port").getValueAsInteger();
  +
  +      try
  +      {
  +         final String bindAddress = configuration.getChild("bind").getValue();
  +
  +         m_bindTo = InetAddress.getByName(bindAddress);
  +      }
  +      catch (final UnknownHostException unhe)
  +      {
  +         throw new ConfigurationException("Malformed bind parameter", unhe);
  +      }
  +   }
  +
  +   public void compose (ComponentManager manager)
  +      throws ComponentException
  +   {
  +      m_socketManager     =
  +         ( SocketManager ) manager.lookup(SocketManager.ROLE);
  +      m_connectionManager =
  +         ( ConnectionManager ) manager.lookup(ConnectionManager.ROLE);
  +   }
  +
  +   /**
  +    * Construct an appropriate ConnectionHandler.
  +    *
  +    * @return the new ConnectionHandler
  +    * @exception Exception if an error occurs
  +    */
  +
  +   public ConnectionHandler createConnectionHandler ()
  +      throws Exception
  +   {
  +      final SocketObjectStreamConnectionHandler handler =
  +         new SocketObjectStreamConnectionHandler(
  +            ( PartialSocketObjectStreamServer ) mAltrmiServer);
  +
  +      setupLogger(handler);
  +
  +      return handler;
  +   }
  +
  +   /**
  +    * Release a previously created ConnectionHandler.
  +    * e.g. for spooling.
  +    */
  +
  +   public void releaseConnectionHandler (ConnectionHandler connectionHandler)
  +   {
  +   }
  +
  +   /**
  +    * Initialialize the component. Initialization includes
  +    * allocating any resources required throughout the
  +    * components lifecycle.
  +    *
  +    * @exception Exception if an error occurs
  +    */
  +
  +   public void initialize ()
  +      throws Exception
  +   {
  +      mAltrmiServer = new PartialSocketObjectStreamServer();
  +
  +      super.initialize();
  +
  +      final ServerSocketFactory factory      =
  +         m_socketManager.getServerSocketFactory("plain");
  +      final ServerSocket        serverSocket =
  +         factory.createServerSocket(m_port, 5, m_bindTo);
  +
  +      m_connectionManager.connect("SocketObjectStreamListener", serverSocket,
  +                                  this);
  +   }
  +}
   
  -        m_connectionManager.connect( "SocketObjectStreamListener", serverSocket, this );
   
  -    }
  -}
  +/*------ Formatted by Jindent 3.24 Basic 1.0 --- http://www.jindent.de ------*/
  
  
  
  1.2       +60 -41    jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/subscription/AbstractSubscriber.java
  
  Index: AbstractSubscriber.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/subscription/AbstractSubscriber.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractSubscriber.java	9 Jan 2002 21:40:04 -0000	1.1
  +++ AbstractSubscriber.java	10 Jan 2002 17:14:35 -0000	1.2
  @@ -8,6 +8,8 @@
    */
   package org.apache.avalon.cornerstone.blocks.transport.subscription;
   
  +
  +
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  @@ -27,49 +29,66 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
  -public abstract class AbstractSubscriber extends AbstractLogEnabled
  -        implements AltrmiInterfaceLookup, Configurable, Initializable, Block {
   
  -    protected AltrmiFactory mAltrmiFactory;
  -    protected AltrmiHostContext mHostContext;
  -
  -    /**
  -     * 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 {
  -
  -        String proxyClassLocation = configuration.getChild("proxyClassLocation").getValue();
  -
  -        if (proxyClassLocation.equals("client")) {
  -            mAltrmiFactory = new ClientClassAltrmiFactory();
  -        } else if (proxyClassLocation.equals("server")) {
  +public abstract class AbstractSubscriber
  +   extends AbstractLogEnabled
  +   implements AltrmiInterfaceLookup, Configurable, Initializable, Block
  +{
  +   protected AltrmiFactory     mAltrmiFactory;
  +   protected AltrmiHostContext mHostContext;
  +
  +   /**
  +    * 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
  +   {
  +      String proxyClassLocation =
  +         configuration.getChild("proxyClassLocation").getValue();
  +
  +      if (proxyClassLocation.equals("client"))
  +      {
  +         mAltrmiFactory = new ClientClassAltrmiFactory();
  +      }
  +      else
  +         if (proxyClassLocation.equals("server"))
  +         {
               mAltrmiFactory = new ServerClassAltrmiFactory();
  -        } else {
  -            throw new ConfigurationException("proxyClassLocation must be 'client' or 'server'");
  -        }
  -    }
  -
  -    public Object lookup(String s) throws AltrmiConnectionException {
  -        return mAltrmiFactory.lookup(s);
  -    }
  -
  -
  +         }
  +         else
  +         {
  +            throw new ConfigurationException(
  +               "proxyClassLocation must be 'client' or 'server'");
  +         }
  +   }
  +
  +   public Object lookup (String s)
  +      throws AltrmiConnectionException
  +   {
  +      return mAltrmiFactory.lookup(s);
  +   }
  +
  +   /**
  +    * Initialialize the component. Initialization includes
  +    * allocating any resources required throughout the
  +    * components lifecycle.
  +    *
  +    * @exception Exception if an error occurs
  +    */
  +
  +   public void initialize ()
  +      throws Exception
  +   {
  +      mAltrmiFactory.setHostContext(mHostContext);
  +   }
  +}
   
  -    /**
  -     * Initialialize the component. Initialization includes
  -     * allocating any resources required throughout the
  -     * components lifecycle.
  -     *
  -     * @exception Exception if an error occurs
  -     */
  -    public void initialize() throws Exception {
  -        mAltrmiFactory.setHostContext(mHostContext);
  -    }
   
  -}
  +/*------ Formatted by Jindent 3.24 Basic 1.0 --- http://www.jindent.de ------*/
  
  
  
  1.2       +43 -31    jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/subscription/RmiSubscriber.java
  
  Index: RmiSubscriber.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/subscription/RmiSubscriber.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RmiSubscriber.java	9 Jan 2002 21:40:04 -0000	1.1
  +++ RmiSubscriber.java	10 Jan 2002 17:14:35 -0000	1.2
  @@ -8,6 +8,8 @@
    */
   package org.apache.avalon.cornerstone.blocks.transport.subscription;
   
  +
  +
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.commons.altrmi.client.impl.rmi.RmiAltrmiHostContext;
  @@ -18,38 +20,48 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
  -public class RmiSubscriber extends AbstractSubscriber {
   
  -    private String mHost;
  -    private int mPort;
  +public class RmiSubscriber
  +   extends AbstractSubscriber
  +{
  +   private String mHost;
  +   private int    mPort;
  +
  +   /**
  +    * 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
  +   {
  +      super.configure(configuration);
  +
  +      mPort = configuration.getChild("port").getValueAsInteger();
  +      mHost = configuration.getChild("host").getValue();
  +   }
  +
  +   /**
  +    * Initialialize the component. Initialization includes
  +    * allocating any resources required throughout the
  +    * components lifecycle.
  +    *
  +    * @exception Exception if an error occurs
  +    */
  +
  +   public void initialize ()
  +      throws Exception
  +   {
  +      mHostContext = new RmiAltrmiHostContext(mHost, mPort);
   
  -    /**
  -     * 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 {
  -
  -        super.configure(configuration);
  -
  -        mPort = configuration.getChild("port").getValueAsInteger();
  -        mHost = configuration.getChild("host").getValue();
  -    }
  -
  -    /**
  -     * Initialialize the component. Initialization includes
  -     * allocating any resources required throughout the
  -     * components lifecycle.
  -     *
  -     * @exception Exception if an error occurs
  -     */
  -    public void initialize() throws Exception {
  -
  -        mHostContext = new RmiAltrmiHostContext(mHost, mPort);
  -        super.initialize();
  -    }
  +      super.initialize();
  +   }
   }
  +
  +
  +/*------ Formatted by Jindent 3.24 Basic 1.0 --- http://www.jindent.de ------*/
  
  
  
  1.3       +43 -31    jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/subscription/SocketObjectStreamSubscriber.java
  
  Index: SocketObjectStreamSubscriber.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/subscription/SocketObjectStreamSubscriber.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SocketObjectStreamSubscriber.java	10 Jan 2002 11:18:24 -0000	1.2
  +++ SocketObjectStreamSubscriber.java	10 Jan 2002 17:14:35 -0000	1.3
  @@ -8,6 +8,8 @@
    */
   package org.apache.avalon.cornerstone.blocks.transport.subscription;
   
  +
  +
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.commons.altrmi.client.impl.rmi.RmiAltrmiHostContext;
  @@ -19,38 +21,48 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
  -public class SocketObjectStreamSubscriber extends AbstractSubscriber {
   
  -    private String mHost;
  -    private int mPort;
  +public class SocketObjectStreamSubscriber
  +   extends AbstractSubscriber
  +{
  +   private String mHost;
  +   private int    mPort;
  +
  +   /**
  +    * 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
  +   {
  +      super.configure(configuration);
  +
  +      mPort = configuration.getChild("port").getValueAsInteger();
  +      mHost = configuration.getChild("host").getValue();
  +   }
  +
  +   /**
  +    * Initialialize the component. Initialization includes
  +    * allocating any resources required throughout the
  +    * components lifecycle.
  +    *
  +    * @exception Exception if an error occurs
  +    */
  +
  +   public void initialize ()
  +      throws Exception
  +   {
  +      mHostContext = new SocketObjectStreamHostContext(mHost, mPort);
   
  -    /**
  -     * 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 {
  -
  -        super.configure(configuration);
  -
  -        mPort = configuration.getChild("port").getValueAsInteger();
  -        mHost = configuration.getChild("host").getValue();
  -    }
  -
  -    /**
  -     * Initialialize the component. Initialization includes
  -     * allocating any resources required throughout the
  -     * components lifecycle.
  -     *
  -     * @exception Exception if an error occurs
  -     */
  -    public void initialize() throws Exception {
  -
  -        mHostContext = new SocketObjectStreamHostContext(mHost, mPort);
  -        super.initialize();
  -    }
  +      super.initialize();
  +   }
   }
  +
  +
  +/*------ Formatted by Jindent 3.24 Basic 1.0 --- http://www.jindent.de ------*/
  
  
  

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