commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject cvs commit: jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/socket CompleteSocketObjectStreamServer.java PartialSocketObjectStreamServer.java PlainSocketServer.java
Date Wed, 09 Jan 2002 22:42:56 GMT
hammant     02/01/09 14:42:56

  Added:       altrmi/src/java/org/apache/commons/altrmi/server/impl/socket
                        CompleteSocketObjectStreamServer.java
                        PartialSocketObjectStreamServer.java
  Removed:     altrmi/src/java/org/apache/commons/altrmi/server/impl/socket
                        PlainSocketServer.java
  Log:
  split of socket handler into two impls.  One is friendly to third party connection handling
(Avalon).
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/socket/CompleteSocketObjectStreamServer.java
  
  Index: CompleteSocketObjectStreamServer.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.commons.altrmi.server.impl.socket;
  
  
  
  import org.apache.commons.altrmi.server.AltrmiServer;
  import org.apache.commons.altrmi.server.AltrmiServerException;
  import org.apache.commons.altrmi.server.impl.AbstractServer;
  import org.apache.commons.altrmi.server.impl.ObjectStreamServerConnection;
  import org.apache.commons.altrmi.common.AltrmiRequest;
  import org.apache.commons.altrmi.common.AltrmiReply;
  
  import java.net.ServerSocket;
  import java.net.Socket;
  
  import java.io.IOException;
  
  
  /**
   * Class CompleteSocketObjectStreamServer
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class CompleteSocketObjectStreamServer extends AbstractServer implements Runnable
{
  
      private ServerSocket mServerSocket;
  
      private Thread mThread;
  
      /**
       * Constructor CompleteSocketObjectStreamServer
       *
       *
       * @param port
       *
       * @throws AltrmiServerException
       *
       */
      public CompleteSocketObjectStreamServer(int port) throws AltrmiServerException {
  
          try {
              mServerSocket = new ServerSocket(port);
          } catch (IOException ioe) {
              throw new AltrmiServerException("Some problem setting up server : " + ioe.getMessage());
          }
      }
  
      /**
       * Method run
       *
       *
       */
      public void run() {
  
          try {
              while (mState == STARTED) {
                  Socket sock = mServerSocket.accept();
                  SocketObjectStreamServerConnection ossc = new SocketObjectStreamServerConnection(this,
sock,
                          sock.getInputStream(), sock.getOutputStream());
                  Thread thread = new Thread(ossc);
  
                  thread.start();
              }
          } catch (IOException ioe) {
              System.err.println("Some problem connecting client via sockets.");
          }
      }
  
      /**
       * Method start
       *
       */
      public void start() {
          mState = STARTED;
          getThread().start();
      }
  
      /**
       * Method stop
       *
       */
      public void stop() {
          mState = SHUTTINGDOWN;
          killAllConnections();
          getThread().interrupt();
          mState = STOPPED;
      }
  
      private Thread getThread() {
          if (mThread == null) {
              mThread = new Thread(this);
          }
          return mThread;
      }
  
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/socket/PartialSocketObjectStreamServer.java
  
  Index: PartialSocketObjectStreamServer.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.commons.altrmi.server.impl.socket;
  
  import org.apache.commons.altrmi.server.impl.AbstractServer;
  import org.apache.commons.altrmi.server.AltrmiServerException;
  
  import java.net.Socket;
  import java.io.IOException;
  
  
  /**
   * Class PartialSocketObjectStreamServer
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class PartialSocketObjectStreamServer extends AbstractServer {
  
      /**
       * Constructor PartialSocketObjectStreamServer
       *
       *
       * @throws AltrmiServerException
       *
       */
      public PartialSocketObjectStreamServer() throws AltrmiServerException {
      }
  
      /**
       * Method handleConnection
       *
       * @param sock
       *
       */
      public void handleConnection( final Socket sock ) {
  
          try {
              if (mState == STARTED) {
                  SocketObjectStreamServerConnection ossc = new SocketObjectStreamServerConnection(this,
sock, sock.getInputStream(), sock.getOutputStream());
                  ossc.run();
              }
          } catch (IOException ioe) {
              System.err.println("Some problem connecting client via sockets.");
          }
      }
  
      /**
       * Method start
       *
       */
      public void start() {
          mState = STARTED;
      }
  
      /**
       * Method stop
       *
       */
      public void stop() {
          mState = SHUTTINGDOWN;
          killAllConnections();
          mState = STOPPED;
      }
  
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message