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 RmiSubscriber.xinfo SocketObjectStreamSubscriber.java SocketObjectStreamSubscriber.xinfo
Date Wed, 09 Jan 2002 21:40:04 GMT
hammant     02/01/09 13:40:04

  Added:       src/java/org/apache/avalon/cornerstone/blocks/transport/publishing
                        AbstractPublisher.java RmiPublisher.java
                        RmiPublisher.xinfo SocketObjectStreamPublisher.java
                        SocketObjectStreamPublisher.xinfo
               src/java/org/apache/avalon/cornerstone/blocks/transport/subscription
                        AbstractSubscriber.java RmiSubscriber.java
                        RmiSubscriber.xinfo
                        SocketObjectStreamSubscriber.java
                        SocketObjectStreamSubscriber.xinfo
  Log:
  First cut of AltRMI publication and subscription blocks
  
  Revision  Changes    Path
  1.1                  jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/publishing/AbstractPublisher.java
  
  Index: AbstractPublisher.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.txt file.
   */
  package org.apache.avalon.cornerstone.blocks.transport.publishing;
  
  
  
  import org.apache.commons.altrmi.server.AltrmiPublisher;
  import org.apache.commons.altrmi.server.AltrmiPublicationException;
  import org.apache.commons.altrmi.server.AltrmiServer;
  import org.apache.commons.altrmi.server.ClassRetriever;
  import org.apache.commons.altrmi.server.impl.JarFileClassRetriever;
  import org.apache.commons.altrmi.server.impl.BaseMobileClassRetriever;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.activity.Startable;
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.framework.configuration.Configurable;
  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;
  
  
  /**
   * Class AbstractPublisher
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  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 {
              throw new ConfigurationException("classRetrieverType must be 'baseMobileClass'
or 'jarFile'");
          }
      }
  
      /**
       * 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();
      }
  }
  
  
  
  1.1                  jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/publishing/RmiPublisher.java
  
  Index: RmiPublisher.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.txt file.
   */
  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.commons.altrmi.server.impl.rmi.RmiServer;
  
  
  /**
   * Class RmiPublisher
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  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);
  
          super.initialize();
      }
  }
  
  
  
  1.1                  jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/publishing/RmiPublisher.xinfo
  
  Index: RmiPublisher.xinfo
  ===================================================================
  <?xml version="1.0"?>
  
  <blockinfo>
  
    <!-- section to describe block -->
    <block>
      <version>1.0</version>
    </block>
  
    <!-- services that are offered by this block -->
    <services>
      <service name="org.apache.commons.altrmi.server.AltrmiPublisher" version="1.0" />
    </services>
  
  </blockinfo>
  
  
  
  1.1                  jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/publishing/SocketObjectStreamPublisher.java
  
  Index: SocketObjectStreamPublisher.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.txt file.
   */
  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.commons.altrmi.server.impl.socket.PlainSocketServer;
  
  
  /**
   * Class SocketObjectStreamPublisher
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class SocketObjectStreamPublisher extends AbstractPublisher {
  
      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();
      }
  
      /**
       * 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 PlainSocketServer(mPort);
  
          super.initialize();
      }
  }
  
  
  
  1.1                  jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/publishing/SocketObjectStreamPublisher.xinfo
  
  Index: SocketObjectStreamPublisher.xinfo
  ===================================================================
  <?xml version="1.0"?>
  
  <blockinfo>
  
    <!-- section to describe block -->
    <block>
      <version>1.0</version>
    </block>
  
    <!-- services that are offered by this block -->
    <services>
      <service name="org.apache.commons.altrmi.server.AltrmiPublisher" version="1.0" />
    </services>
  
  </blockinfo>
  
  
  
  1.1                  jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/subscription/AbstractSubscriber.java
  
  Index: AbstractSubscriber.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.txt file.
   */
  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;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.phoenix.Block;
  import org.apache.commons.altrmi.client.AltrmiInterfaceLookup;
  import org.apache.commons.altrmi.client.AltrmiFactory;
  import org.apache.commons.altrmi.client.AltrmiHostContext;
  import org.apache.commons.altrmi.client.impl.ServerClassAltrmiFactory;
  import org.apache.commons.altrmi.client.impl.ClientClassAltrmiFactory;
  import org.apache.commons.altrmi.common.AltrmiConnectionException;
  
  
  /**
   * Class AbstractSubscriber
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  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);
      }
  
  
  
      /**
       * 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);
      }
  
  }
  
  
  
  1.1                  jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/subscription/RmiSubscriber.java
  
  Index: RmiSubscriber.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.txt file.
   */
  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;
  
  
  /**
   * Class RmiSubscriber
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  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);
          super.initialize();
      }
  }
  
  
  
  1.1                  jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/subscription/RmiSubscriber.xinfo
  
  Index: RmiSubscriber.xinfo
  ===================================================================
  <?xml version="1.0"?>
  
  <blockinfo>
  
    <!-- section to describe block -->
    <block>
      <version>1.0</version>
    </block>
  
    <!-- services that are offered by this block -->
    <services>
      <service name="org.apache.commons.altrmi.client.AltrmiInterfaceLookup" version="1.0"
/>
    </services>
  
  </blockinfo>
  
  
  
  1.1                  jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/subscription/SocketObjectStreamSubscriber.java
  
  Index: SocketObjectStreamSubscriber.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.txt file.
   */
  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;
  import org.apache.commons.altrmi.client.impl.socket.PlainSocketAltrmiHostContext;
  
  
  /**
   * Class SocketObjectStreamSubscriber
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  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 PlainSocketAltrmiHostContext(mHost, mPort);
          super.initialize();
      }
  }
  
  
  
  1.1                  jakarta-avalon-cornerstone/src/java/org/apache/avalon/cornerstone/blocks/transport/subscription/SocketObjectStreamSubscriber.xinfo
  
  Index: SocketObjectStreamSubscriber.xinfo
  ===================================================================
  <?xml version="1.0"?>
  
  <blockinfo>
  
    <!-- section to describe block -->
    <block>
      <version>1.0</version>
    </block>
  
    <!-- services that are offered by this block -->
    <services>
      <service name="org.apache.commons.altrmi.client.AltrmiInterfaceLookup" version="1.0"
/>
    </services>
  
  </blockinfo>
  
  
  

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