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/armi/src/java/org/apache/commons/armi/test DirectTest.java PipeTest.java RmiServerTest.java SocketServerTest.java TestClient.java
Date Thu, 03 Jan 2002 10:49:38 GMT
hammant     02/01/03 02:49:38

  Modified:    armi/src/java/org/apache/commons/armi/client
                        ArmiConnectionListener.java
               armi/src/java/org/apache/commons/armi/client/impl
                        BaseServedObject.java
                        DefaultArmiConnectionListener.java
                        ObjectStreamInvocationHandler.java
               armi/src/java/org/apache/commons/armi/client/impl/direct
                        DirectInvocationHandler.java
               armi/src/java/org/apache/commons/armi/client/impl/rmi
                        RmiInvocationHandler.java
               armi/src/java/org/apache/commons/armi/client/impl/socket
                        PlainSocketInvocationHandler.java
               armi/src/java/org/apache/commons/armi/common ArmiReply.java
                        ClassReply.java ExceptionReply.java
                        MethodReply.java NotPublishedReply.java
                        RequestFailedReply.java SuspendedReply.java
                        TryLaterReply.java
               armi/src/java/org/apache/commons/armi/server ArmiServer.java
               armi/src/java/org/apache/commons/armi/server/impl
                        AbstractServer.java DefaultInvocationHandler.java
                        ObjectStreamServerConnection.java
               armi/src/java/org/apache/commons/armi/server/impl/direct
                        DirectServer.java
               armi/src/java/org/apache/commons/armi/server/impl/piped
                        PipedServer.java
               armi/src/java/org/apache/commons/armi/server/impl/rmi
                        RmiServer.java
               armi/src/java/org/apache/commons/armi/server/impl/socket
                        PlainSocketServer.java
               armi/src/java/org/apache/commons/armi/test DirectTest.java
                        PipeTest.java RmiServerTest.java
                        SocketServerTest.java TestClient.java
  Added:       armi/src/java/org/apache/commons/armi/common
                        EndConnectionReply.java
               armi/src/java/org/apache/commons/armi/server
                        ArmiServerConnection.java
               armi/src/java/org/apache/commons/armi/server/impl/piped
                        PipedObjectStreamServerConnection.java
               armi/src/java/org/apache/commons/armi/server/impl/socket
                        SocketObjectStreamServerConnection.java
  Removed:     armi/src/java/org/apache/commons/armi/common
                        ProblemReply.java
  Log:
  start() and stop() added. Performance improved (via less instanceof).
  
  Revision  Changes    Path
  1.2       +17 -7     jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/ArmiConnectionListener.java
  
  Index: ArmiConnectionListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/ArmiConnectionListener.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ArmiConnectionListener.java	1 Jan 2002 23:12:46 -0000	1.1
  +++ ArmiConnectionListener.java	3 Jan 2002 10:49:37 -0000	1.2
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/ArmiConnectionListener.java,v 1.1 2002/01/01 23:12:46 hammant Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/01/01 23:12:46 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/ArmiConnectionListener.java,v 1.2 2002/01/03 10:49:37 hammant Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/01/03 10:49:37 $
    *
    * ====================================================================
    *
  @@ -72,7 +72,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version * $Revision: 1.1 $
  + * @version * $Revision: 1.2 $
    */
   public interface ArmiConnectionListener {
   
  @@ -83,24 +83,34 @@
        * @return
        *
        */
  -    void armiMethodCalled(String methodSignature, long duration);
  +    void methodCalled(String methodSignature, long duration);
  +
  +
  +    /**
  +     * Method methodLogging tests if the implementing class intends to do method logging.
  +     *
  +     *
  +     * @return
  +     *
  +     */
  +    boolean methodLogging();
   
       /**
  -     * Method armiServiceSuspended
  +     * Method serviceSuspended
        *
        *
        * @return
        *
        */
  -    void armiServiceSuspended(ArmiRequest armiRequest, int attempt, int suggestedWaitMillis);
  +    void serviceSuspended(ArmiRequest armiRequest, int attempt, int suggestedWaitMillis);
   
       /**
  -     * Method armiServiceAbend
  +     * Method serviceAbend
        *
        *
        * @return
        *
        */
  -    void armiServiceAbend(int attempt);
  +    void serviceAbend(int attempt);
   
   }
  
  
  
  1.2       +11 -13    jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/BaseServedObject.java
  
  Index: BaseServedObject.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/BaseServedObject.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BaseServedObject.java	28 Dec 2001 18:08:37 -0000	1.1
  +++ BaseServedObject.java	3 Jan 2002 10:49:37 -0000	1.2
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/BaseServedObject.java,v 1.1 2001/12/28 18:08:37 hammant Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/12/28 18:08:37 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/BaseServedObject.java,v 1.2 2002/01/03 10:49:37 hammant Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/01/03 10:49:37 $
    *
    * ====================================================================
    *
  @@ -77,7 +77,7 @@
    *
    *
    * @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 BaseServedObject {
   
  @@ -145,18 +145,17 @@
           synchronized (syncObject) {
               ArmiReply reply = mInvocationHandler.handleInvocation(request);
   
  -            if (reply instanceof MethodReply) {
  +            if (reply.getReplyCode() == ArmiReply.METHODREPLY) {
                   MethodReply or = (MethodReply) reply;
  -
                   return or.getReplyObject();
  -            } else if (reply instanceof ExceptionReply) {
  +            } else if (reply.getReplyCode() == ArmiReply.EXCEPTIONREPLY) {
                   ExceptionReply er = (ExceptionReply) reply;
  -
                   throw er.getReplyException();
  +            } else {
  +                throw new ArmiInvocationException("Internal Error : Unknown reply type :"
  +                                                  + reply.getClass().getName());
               }
           }
  -
  -        return null;
       }
   
       /**
  @@ -172,15 +171,14 @@
       public void armiProcessVoidRequest(String methodSignature, Object[] args) throws Throwable {
   
           MethodRequest request = new MethodRequest(mPublishedObjectName, methodSignature, args);
  -
           synchronized (syncObject) {
               ArmiReply reply = mInvocationHandler.handleInvocation(request);
   
  -            if (reply instanceof MethodReply) {
  +            if (reply.getReplyCode() == ArmiReply.METHODREPLY) {
                   MethodReply or = (MethodReply) reply;
   
                   return;
  -            } else if (reply instanceof ExceptionReply) {
  +            } else if (reply.getReplyCode() == ArmiReply.EXCEPTIONREPLY) {
                   ExceptionReply er = (ExceptionReply) reply;
   
                   throw er.getReplyException();
  
  
  
  1.2       +18 -7     jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/DefaultArmiConnectionListener.java
  
  Index: DefaultArmiConnectionListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/DefaultArmiConnectionListener.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultArmiConnectionListener.java	1 Jan 2002 23:12:47 -0000	1.1
  +++ DefaultArmiConnectionListener.java	3 Jan 2002 10:49:37 -0000	1.2
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/DefaultArmiConnectionListener.java,v 1.1 2002/01/01 23:12:47 hammant Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/01/01 23:12:47 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/DefaultArmiConnectionListener.java,v 1.2 2002/01/03 10:49:37 hammant Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/01/03 10:49:37 $
    *
    * ====================================================================
    *
  @@ -74,7 +74,7 @@
    *
    *
    * @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 DefaultArmiConnectionListener implements ArmiConnectionListener {
   
  @@ -85,18 +85,29 @@
        * @return
        *
        */
  -    public void armiMethodCalled(final String methodSignature, final long duration) {
  +    public void methodCalled(final String methodSignature, final long duration) {
           // do mothing in default impl, could do logging.
       }
   
       /**
  -     * Method armiServiceSuspended
  +     * Method methodLogging tests if the implementing class intends to do method logging.
        *
        *
        * @return
        *
        */
  -    public void armiServiceSuspended(final ArmiRequest armiRequest, final int attempt, final int suggestedWaitMillis) {
  +    public boolean methodLogging() {
  +        return false;
  +    }
  +
  +    /**
  +     * Method serviceSuspended
  +     *
  +     *
  +     * @return
  +     *
  +     */
  +    public void serviceSuspended(final ArmiRequest armiRequest, final int attempt, final int suggestedWaitMillis) {
           // Lets say that ten retries is too many.
           if (attempt == 10) {
               throw new ArmiInvocationException("Too many retries on suspended service");
  @@ -111,13 +122,13 @@
       }
   
       /**
  -     * Method armiServiceAbend
  +     * Method serviceAbend
        *
        *
        * @return
        *
        */
  -    public void armiServiceAbend(int attempt) {
  +    public void serviceAbend(int attempt) {
           // Lets say that ten retries is too many.
           if (attempt == 3) {
               throw new ArmiInvocationException("Too many retries on abended service");
  
  
  
  1.6       +33 -13    jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/ObjectStreamInvocationHandler.java
  
  Index: ObjectStreamInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/ObjectStreamInvocationHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ObjectStreamInvocationHandler.java	1 Jan 2002 23:12:47 -0000	1.5
  +++ ObjectStreamInvocationHandler.java	3 Jan 2002 10:49:37 -0000	1.6
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/ObjectStreamInvocationHandler.java,v 1.5 2002/01/01 23:12:47 hammant Exp $
  - * $Revision: 1.5 $
  - * $Date: 2002/01/01 23:12:47 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/ObjectStreamInvocationHandler.java,v 1.6 2002/01/03 10:49:37 hammant Exp $
  + * $Revision: 1.6 $
  + * $Date: 2002/01/03 10:49:37 $
    *
    * ====================================================================
    *
  @@ -73,6 +73,7 @@
   import org.apache.commons.armi.common.NotPublishedException;
   import org.apache.commons.armi.common.PublishedNameRequest;
   import org.apache.commons.armi.common.ProblemReply;
  +import org.apache.commons.armi.client.ArmiConnectionListener;
   
   import java.io.IOException;
   import java.io.ObjectOutputStream;
  @@ -85,12 +86,25 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.5 $
  + * @version $Revision: 1.6 $
    */
   public abstract class ObjectStreamInvocationHandler extends ArmiClientInvocationHandler {
   
  -    ObjectInputStream mOIS;
  -    ObjectOutputStream mOOS;
  +    private ObjectInputStream mOIS;
  +    private ObjectOutputStream mOOS;
  +    private boolean mMethodLogging = false;
  +
  +    /**
  +     * Method setArmiConnectionListener
  +     *
  +     *
  +     * @param armiConnectionListener
  +     *
  +     */
  +    public void setArmiConnectionListener(ArmiConnectionListener armiConnectionListener) {
  +        super.setArmiConnectionListener(armiConnectionListener);
  +        mMethodLogging = armiConnectionListener.methodLogging();
  +    }
   
       /**
        * Method setObjectInputStream
  @@ -132,19 +146,23 @@
                   boolean again = true;
                   ArmiReply reply = null;
                   int tries = 0;
  -                long start = System.currentTimeMillis();
  +                long start = 0;
  +                if (mMethodLogging) {
  +                    start = System.currentTimeMillis();
  +                }
                   while (again) {
                       tries++;
                       again = false;
                       try {
  +                        long t1 = System.currentTimeMillis();
                           mOOS.writeObject(request);
                           mOOS.flush();
                           reply = (ArmiReply) mOIS.readObject();
  -                        if (!(reply instanceof ProblemReply)) {
  -                            // speed?
  +                        long t2 = System.currentTimeMillis();
  +                        if (reply.getReplyCode() >= 100) {
                               if (reply instanceof TryLaterReply) {
                                   int millis = ((TryLaterReply) reply).getSuggestedDelayMillis();
  -                                mArmiConnectionListener.armiServiceSuspended(request,tries,millis);
  +                                mArmiConnectionListener.serviceSuspended(request,tries,millis);
                                   again = true;
                               } else if (reply instanceof NotPublishedReply) {
                                   throw new NotPublishedException(((PublishedNameRequest) request).getPublishedObjectName());
  @@ -154,7 +172,7 @@
                           if (ioe instanceof SocketException) {
                               int retryConnectTries = 0;
                               while (!tryReconnect()) {
  -                                mArmiConnectionListener.armiServiceAbend(retryConnectTries);
  +                                mArmiConnectionListener.serviceAbend(retryConnectTries);
                                   retryConnectTries++;
                               }
                           } else {
  @@ -163,8 +181,10 @@
                           }
                       }
                   }
  -                if (request instanceof MethodRequest) {
  -                    mArmiConnectionListener.armiMethodCalled(((MethodRequest) request).getMethodSignature(), System.currentTimeMillis() - start);
  +                if (mMethodLogging) {
  +                    if (request instanceof MethodRequest) {
  +                        mArmiConnectionListener.methodCalled(((MethodRequest) request).getMethodSignature(), System.currentTimeMillis() - start);
  +                    }
                   }
                   return reply;
               }
  
  
  
  1.6       +30 -11    jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/direct/DirectInvocationHandler.java
  
  Index: DirectInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/direct/DirectInvocationHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DirectInvocationHandler.java	1 Jan 2002 23:12:47 -0000	1.5
  +++ DirectInvocationHandler.java	3 Jan 2002 10:49:37 -0000	1.6
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/direct/DirectInvocationHandler.java,v 1.5 2002/01/01 23:12:47 hammant Exp $
  - * $Revision: 1.5 $
  - * $Date: 2002/01/01 23:12:47 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/direct/DirectInvocationHandler.java,v 1.6 2002/01/03 10:49:37 hammant Exp $
  + * $Revision: 1.6 $
  + * $Date: 2002/01/03 10:49:37 $
    *
    * ====================================================================
    *
  @@ -75,6 +75,7 @@
   import org.apache.commons.armi.common.ProblemReply;
   import org.apache.commons.armi.common.MethodRequest;
   import org.apache.commons.armi.client.impl.ArmiClientInvocationHandler;
  +import org.apache.commons.armi.client.ArmiConnectionListener;
   
   
   /**
  @@ -82,11 +83,12 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.5 $
  + * @version $Revision: 1.6 $
    */
   public final class DirectInvocationHandler extends ArmiClientInvocationHandler {
   
  -    ArmiInvocationHandler mArmiInvocationHandler;
  +    private ArmiInvocationHandler mArmiInvocationHandler;
  +    private boolean mMethodLogging = false;
   
       /**
        * Constructor DirectInvocationHandler
  @@ -103,6 +105,18 @@
       }
   
       /**
  +     * Method setArmiConnectionListener
  +     *
  +     *
  +     * @param armiConnectionListener
  +     *
  +     */
  +    public void setArmiConnectionListener(ArmiConnectionListener armiConnectionListener) {
  +        super.setArmiConnectionListener(armiConnectionListener);
  +        mMethodLogging = armiConnectionListener.methodLogging();
  +    }
  +
  +    /**
        * Method handleInvocation
        *
        *
  @@ -115,24 +129,29 @@
           boolean again = true;
           ArmiReply reply = null;
           int tries = 0;
  -        long start = System.currentTimeMillis();
  +        long start = 0;
  +        if (mMethodLogging) {
  +            start = System.currentTimeMillis();
  +        }
           while (again) {
               tries++;
               again = false;
               reply = mArmiInvocationHandler.handleInvocation(request);
  -            if (!(reply instanceof ProblemReply)) {
  -                // speed?
  +            //if ((reply instanceof ProblemReply)) { // slower by 11%
  +            if (reply.getReplyCode() >= 100) {
                   if (reply instanceof TryLaterReply) {
                       int millis = ((TryLaterReply) reply).getSuggestedDelayMillis();
  -                    mArmiConnectionListener.armiServiceSuspended(request,tries,millis);
  +                    mArmiConnectionListener.serviceSuspended(request,tries,millis);
                       again = true;
                   } else if (reply instanceof NotPublishedReply) {
                       throw new NotPublishedException(((PublishedNameRequest) request).getPublishedObjectName());
                   }
               }
           }
  -        if (request instanceof MethodRequest) {
  -            mArmiConnectionListener.armiMethodCalled(((MethodRequest) request).getMethodSignature(), System.currentTimeMillis() - start);
  +        if (mMethodLogging) {
  +            if (request instanceof MethodRequest) {
  +                mArmiConnectionListener.methodCalled(((MethodRequest) request).getMethodSignature(), System.currentTimeMillis() - start);
  +            }
           }
           return reply;
       }
  
  
  
  1.6       +34 -21    jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/rmi/RmiInvocationHandler.java
  
  Index: RmiInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/rmi/RmiInvocationHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- RmiInvocationHandler.java	1 Jan 2002 23:12:47 -0000	1.5
  +++ RmiInvocationHandler.java	3 Jan 2002 10:49:37 -0000	1.6
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/rmi/RmiInvocationHandler.java,v 1.5 2002/01/01 23:12:47 hammant Exp $
  - * $Revision: 1.5 $
  - * $Date: 2002/01/01 23:12:47 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/rmi/RmiInvocationHandler.java,v 1.6 2002/01/03 10:49:37 hammant Exp $
  + * $Revision: 1.6 $
  + * $Date: 2002/01/03 10:49:37 $
    *
    * ====================================================================
    *
  @@ -61,28 +61,24 @@
    */
   package org.apache.commons.armi.client.impl.rmi;
   
  -
  -
  -import org.apache.commons.armi.common.ArmiInvocationHandler;
  +import org.apache.commons.armi.client.impl.ArmiClientInvocationHandler;
  +import org.apache.commons.armi.client.ArmiConnectionListener;
   import org.apache.commons.armi.common.RmiArmiInvocationHandler;
  +import org.apache.commons.armi.common.ArmiConnectionException;
   import org.apache.commons.armi.common.ArmiReply;
   import org.apache.commons.armi.common.ArmiRequest;
  -import org.apache.commons.armi.common.ArmiInvocationException;
  -import org.apache.commons.armi.common.ArmiConnectionException;
   import org.apache.commons.armi.common.TryLaterReply;
   import org.apache.commons.armi.common.NotPublishedReply;
   import org.apache.commons.armi.common.NotPublishedException;
   import org.apache.commons.armi.common.PublishedNameRequest;
  +import org.apache.commons.armi.common.ArmiInvocationException;
   import org.apache.commons.armi.common.MethodRequest;
  -import org.apache.commons.armi.common.ProblemReply;
  -import org.apache.commons.armi.client.impl.ArmiClientInvocationHandler;
   
   import java.rmi.Naming;
  -import java.rmi.RemoteException;
   import java.rmi.NotBoundException;
  -import java.rmi.ConnectException;
  +import java.rmi.RemoteException;
   import java.rmi.ConnectIOException;
  -
  +import java.rmi.ConnectException;
   import java.net.MalformedURLException;
   
   
  @@ -91,12 +87,13 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.5 $
  + * @version $Revision: 1.6 $
    */
   public final class RmiInvocationHandler extends ArmiClientInvocationHandler {
   
       private RmiArmiInvocationHandler mRmiArmiInvocationHandler;
       private String mURL;
  +    private boolean mMethodLogging = false;
   
       /**
        * Constructor RmiInvocationHandler
  @@ -127,6 +124,18 @@
       }
   
       /**
  +     * Method setArmiConnectionListener
  +     *
  +     *
  +     * @param armiConnectionListener
  +     *
  +     */
  +    public void setArmiConnectionListener(ArmiConnectionListener armiConnectionListener) {
  +        super.setArmiConnectionListener(armiConnectionListener);
  +        mMethodLogging = armiConnectionListener.methodLogging();
  +    }
  +
  +    /**
        * Method tryReconnect
        *
        * @return
  @@ -155,18 +164,20 @@
           boolean again = true;
           ArmiReply reply = null;
           int tries = 0;
  -        long start = System.currentTimeMillis();
  +        long start = 0;
  +        if (mMethodLogging) {
  +            start = System.currentTimeMillis();
  +        }
           while (again) {
               tries++;
               again = false;
               try {
   
                   reply = mRmiArmiInvocationHandler.handleInvocation(request);
  -                if (!(reply instanceof ProblemReply)) {
  -                    // speed?
  +                if (reply.getReplyCode() >= 100) {
                       if (reply instanceof TryLaterReply) {
                           int millis = ((TryLaterReply) reply).getSuggestedDelayMillis();
  -                        mArmiConnectionListener.armiServiceSuspended(request,tries,millis);
  +                        mArmiConnectionListener.serviceSuspended(request,tries,millis);
                           again = true;
                       } else if (reply instanceof NotPublishedReply) {
                           throw new NotPublishedException(((PublishedNameRequest) request).getPublishedObjectName());
  @@ -177,7 +188,7 @@
                       int retryConnectTries = 0;
                       mRmiArmiInvocationHandler = null;
                       while (!tryReconnect()) {
  -                        mArmiConnectionListener.armiServiceAbend(retryConnectTries);
  +                        mArmiConnectionListener.serviceAbend(retryConnectTries);
                           retryConnectTries++;
                       }
                   } else {
  @@ -185,8 +196,10 @@
                   }
               }
           }
  -        if (request instanceof MethodRequest) {
  -            mArmiConnectionListener.armiMethodCalled(((MethodRequest) request).getMethodSignature(), System.currentTimeMillis() - start);
  +        if (mMethodLogging) {
  +            if (request instanceof MethodRequest) {
  +                mArmiConnectionListener.methodCalled(((MethodRequest) request).getMethodSignature(), System.currentTimeMillis() - start);
  +            }
           }
           return reply;
       }
  
  
  
  1.3       +5 -4      jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/socket/PlainSocketInvocationHandler.java
  
  Index: PlainSocketInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/socket/PlainSocketInvocationHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PlainSocketInvocationHandler.java	1 Jan 2002 23:12:47 -0000	1.2
  +++ PlainSocketInvocationHandler.java	3 Jan 2002 10:49:37 -0000	1.3
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/socket/PlainSocketInvocationHandler.java,v 1.2 2002/01/01 23:12:47 hammant Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/01/01 23:12:47 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/client/impl/socket/PlainSocketInvocationHandler.java,v 1.3 2002/01/03 10:49:37 hammant Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/01/03 10:49:37 $
    *
    * ====================================================================
    *
  @@ -75,7 +75,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.3 $
    */
   public final class PlainSocketInvocationHandler extends ObjectStreamInvocationHandler {
   
  @@ -115,6 +115,7 @@
        * @return connected or not.
        */
       protected boolean tryReconnect() {
  +        System.out.println("Tryin....");
           try {
               Socket socket = new Socket(mHost, mPort);
               ObjectOutputStream oOS = new ObjectOutputStream(socket.getOutputStream());
  
  
  
  1.2       +26 -4     jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ArmiReply.java
  
  Index: ArmiReply.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ArmiReply.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ArmiReply.java	28 Dec 2001 18:08:38 -0000	1.1
  +++ ArmiReply.java	3 Jan 2002 10:49:37 -0000	1.2
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ArmiReply.java,v 1.1 2001/12/28 18:08:38 hammant Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/12/28 18:08:38 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ArmiReply.java,v 1.2 2002/01/03 10:49:37 hammant Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/01/03 10:49:37 $
    *
    * ====================================================================
    *
  @@ -71,14 +71,36 @@
    *
    *
    * @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 ArmiReply implements Serializable {
   
  +    public static final int CLASSREPLY = 1;
  +    public static final int METHODREPLY = 2;
  +    public static final int EXCEPTIONREPLY = 3;
  +
  +    public static final int PROBLEMREPLY = 100;
  +    public static final int NOTPUBLISHEDREPLY = 102;
  +    public static final int REQUESTFAILEDREPLY = 103;
  +    public static final int SUSPENDEDREPLY = 104;
  +    public static final int ENDCONNECTIONREPLY = 105;
  +
  +
  +
       /**
        * Constructor ArmiReply
        *
        *
        */
       ArmiReply() {}
  +
  +    /**
  +     * Method getReplyCode.  This is quicker than instanceof for type checking.
  +     *
  +     *
  +     * @return
  +     *
  +     */
  +    public abstract int getReplyCode();
  +
   }
  
  
  
  1.2       +13 -2     jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ClassReply.java
  
  Index: ClassReply.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ClassReply.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ClassReply.java	30 Dec 2001 00:42:10 -0000	1.1
  +++ ClassReply.java	3 Jan 2002 10:49:37 -0000	1.2
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ClassReply.java,v 1.1 2001/12/30 00:42:10 hammant Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/12/30 00:42:10 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ClassReply.java,v 1.2 2002/01/03 10:49:37 hammant Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/01/03 10:49:37 $
    *
    * ====================================================================
    *
  @@ -68,7 +68,7 @@
    *
    *
    * @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 ClassReply extends ArmiReply {
   
  @@ -94,5 +94,16 @@
        */
       public byte[] getClassBytes() {
           return mClassBytes;
  +    }
  +
  +    /**
  +     * Method getReplyCode.  This is quicker than instanceof for type checking.
  +     *
  +     *
  +     * @return
  +     *
  +     */
  +    public int getReplyCode() {
  +        return CLASSREPLY;
       }
   }
  
  
  
  1.2       +15 -4     jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ExceptionReply.java
  
  Index: ExceptionReply.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ExceptionReply.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExceptionReply.java	28 Dec 2001 18:08:38 -0000	1.1
  +++ ExceptionReply.java	3 Jan 2002 10:49:37 -0000	1.2
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ExceptionReply.java,v 1.1 2001/12/28 18:08:38 hammant Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/12/28 18:08:38 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/ExceptionReply.java,v 1.2 2002/01/03 10:49:37 hammant Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/01/03 10:49:37 $
    *
    * ====================================================================
    *
  @@ -68,7 +68,7 @@
    *
    *
    * @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 ExceptionReply extends ArmiReply {
   
  @@ -94,5 +94,16 @@
        */
       public Throwable getReplyException() {
           return mReplyExcpt;
  +    }
  +
  +    /**
  +     * Method getReplyCode.  This is quicker than instanceof for type checking.
  +     *
  +     *
  +     * @return
  +     *
  +     */
  +    public int getReplyCode() {
  +        return EXCEPTIONREPLY;
       }
   }
  
  
  
  1.2       +15 -4     jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/MethodReply.java
  
  Index: MethodReply.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/MethodReply.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MethodReply.java	28 Dec 2001 18:08:38 -0000	1.1
  +++ MethodReply.java	3 Jan 2002 10:49:37 -0000	1.2
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/MethodReply.java,v 1.1 2001/12/28 18:08:38 hammant Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/12/28 18:08:38 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/MethodReply.java,v 1.2 2002/01/03 10:49:37 hammant Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/01/03 10:49:37 $
    *
    * ====================================================================
    *
  @@ -68,7 +68,7 @@
    *
    *
    * @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 MethodReply extends ArmiReply {
   
  @@ -94,5 +94,16 @@
        */
       public Object getReplyObject() {
           return mReplyObj;
  +    }
  +
  +    /**
  +     * Method getReplyCode.  This is quicker than instanceof for type checking.
  +     *
  +     *
  +     * @return
  +     *
  +     */
  +    public int getReplyCode() {
  +        return METHODREPLY;
       }
   }
  
  
  
  1.3       +16 -5     jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/NotPublishedReply.java
  
  Index: NotPublishedReply.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/NotPublishedReply.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- NotPublishedReply.java	1 Jan 2002 23:12:47 -0000	1.2
  +++ NotPublishedReply.java	3 Jan 2002 10:49:37 -0000	1.3
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/NotPublishedReply.java,v 1.2 2002/01/01 23:12:47 hammant Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/01/01 23:12:47 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/NotPublishedReply.java,v 1.3 2002/01/03 10:49:37 hammant Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/01/03 10:49:37 $
    *
    * ====================================================================
    *
  @@ -66,9 +66,9 @@
    *
    *
    * @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 NotPublishedReply extends ProblemReply {
  +public class NotPublishedReply extends ArmiReply {
   
   
       /**
  @@ -76,6 +76,17 @@
        *
        */
       public NotPublishedReply() {
  +    }
  +
  +    /**
  +     * Method getReplyCode.  This is quicker than instanceof for type checking.
  +     *
  +     *
  +     * @return
  +     *
  +     */
  +    public int getReplyCode() {
  +        return NOTPUBLISHEDREPLY;
       }
   
   }
  
  
  
  1.3       +16 -5     jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/RequestFailedReply.java
  
  Index: RequestFailedReply.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/RequestFailedReply.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RequestFailedReply.java	1 Jan 2002 23:12:47 -0000	1.2
  +++ RequestFailedReply.java	3 Jan 2002 10:49:37 -0000	1.3
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/RequestFailedReply.java,v 1.2 2002/01/01 23:12:47 hammant Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/01/01 23:12:47 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/RequestFailedReply.java,v 1.3 2002/01/03 10:49:37 hammant Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/01/03 10:49:37 $
    *
    * ====================================================================
    *
  @@ -68,9 +68,9 @@
    *
    *
    * @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 RequestFailedReply extends ProblemReply {
  +public class RequestFailedReply extends ArmiReply {
   
       private final String mFailureReason;
   
  @@ -94,5 +94,16 @@
        */
       public String getFailureReason() {
           return mFailureReason;
  +    }
  +
  +    /**
  +     * Method getReplyCode.  This is quicker than instanceof for type checking.
  +     *
  +     *
  +     * @return
  +     *
  +     */
  +    public int getReplyCode() {
  +        return REQUESTFAILEDREPLY;
       }
   }
  
  
  
  1.2       +13 -2     jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/SuspendedReply.java
  
  Index: SuspendedReply.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/SuspendedReply.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SuspendedReply.java	1 Jan 2002 17:53:06 -0000	1.1
  +++ SuspendedReply.java	3 Jan 2002 10:49:37 -0000	1.2
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/SuspendedReply.java,v 1.1 2002/01/01 17:53:06 hammant Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/01/01 17:53:06 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/SuspendedReply.java,v 1.2 2002/01/03 10:49:37 hammant Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/01/03 10:49:37 $
    *
    * ====================================================================
    *
  @@ -67,8 +67,19 @@
    *
    *
    * @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 SuspendedReply extends TryLaterReply {
  +
  +    /**
  +     * Method getReplyCode.  This is quicker than instanceof for type checking.
  +     *
  +     *
  +     * @return
  +     *
  +     */
  +    public int getReplyCode() {
  +        return SUSPENDEDREPLY;
  +    }
   
   }
  
  
  
  1.4       +5 -5      jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/TryLaterReply.java
  
  Index: TryLaterReply.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/TryLaterReply.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TryLaterReply.java	1 Jan 2002 23:12:47 -0000	1.3
  +++ TryLaterReply.java	3 Jan 2002 10:49:37 -0000	1.4
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/TryLaterReply.java,v 1.3 2002/01/01 23:12:47 hammant Exp $
  - * $Revision: 1.3 $
  - * $Date: 2002/01/01 23:12:47 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/TryLaterReply.java,v 1.4 2002/01/03 10:49:37 hammant Exp $
  + * $Revision: 1.4 $
  + * $Date: 2002/01/03 10:49:37 $
    *
    * ====================================================================
    *
  @@ -68,9 +68,9 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
  -public class TryLaterReply extends ProblemReply {
  +public abstract class TryLaterReply extends ArmiReply {
   
       private final int mSuggestedDelayMillis;
   
  
  
  
  1.1                  jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/EndConnectionReply.java
  
  Index: EndConnectionReply.java
  ===================================================================
  
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/common/EndConnectionReply.java,v 1.1 2002/01/03 10:49:37 hammant Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/03 10:49:37 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.armi.common;
  
  /**
   * Class EndConnectionReply
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class EndConnectionReply extends ArmiReply {
  
  
      /**
       * Constructor EndConnectionReply
       *
       */
      public EndConnectionReply() {
      }
  
      /**
       * Method getReplyCode.  This is quicker than instanceof for type checking.
       *
       *
       * @return
       *
       */
      public int getReplyCode() {
          return ENDCONNECTIONREPLY;
      }
  }
  
  
  
  1.4       +19 -4     jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/ArmiServer.java
  
  Index: ArmiServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/ArmiServer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ArmiServer.java	2 Jan 2002 12:11:56 -0000	1.3
  +++ ArmiServer.java	3 Jan 2002 10:49:37 -0000	1.4
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/ArmiServer.java,v 1.3 2002/01/02 12:11:56 hammant Exp $
  - * $Revision: 1.3 $
  - * $Date: 2002/01/02 12:11:56 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/ArmiServer.java,v 1.4 2002/01/03 10:49:37 hammant Exp $
  + * $Revision: 1.4 $
  + * $Date: 2002/01/03 10:49:37 $
    *
    * ====================================================================
    *
  @@ -72,7 +72,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version * $Revision: 1.3 $
  + * @version * $Revision: 1.4 $
    */
   public interface ArmiServer {
   
  @@ -142,5 +142,20 @@
        *
        */
       void resume();
  +
  +    /**
  +     * Method start
  +     *
  +     */
  +    void start() throws ArmiServerException ;
  +
  +    /**
  +     * Method stop
  +     *
  +     */
  +    void stop();
  +
  +
  +
   
   }
  
  
  
  1.1                  jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/ArmiServerConnection.java
  
  Index: ArmiServerConnection.java
  ===================================================================
  
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/ArmiServerConnection.java,v 1.1 2002/01/03 10:49:37 hammant Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/03 10:49:37 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.armi.server;
  
  public interface ArmiServerConnection {
  
      void endConnection();
  
  }
  
  
  
  1.7       +41 -5     jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/AbstractServer.java
  
  Index: AbstractServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/AbstractServer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractServer.java	2 Jan 2002 12:11:56 -0000	1.6
  +++ AbstractServer.java	3 Jan 2002 10:49:38 -0000	1.7
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/AbstractServer.java,v 1.6 2002/01/02 12:11:56 hammant Exp $
  - * $Revision: 1.6 $
  - * $Date: 2002/01/02 12:11:56 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/AbstractServer.java,v 1.7 2002/01/03 10:49:38 hammant Exp $
  + * $Revision: 1.7 $
  + * $Date: 2002/01/03 10:49:38 $
    *
    * ====================================================================
    *
  @@ -65,6 +65,7 @@
   
   import org.apache.commons.armi.server.ArmiServer;
   import org.apache.commons.armi.server.ArmiPublicationException;
  +import org.apache.commons.armi.server.ArmiServerConnection;
   import org.apache.commons.armi.common.ArmiInvocationHandler;
   import org.apache.commons.armi.common.ArmiRequest;
   import org.apache.commons.armi.common.ArmiReply;
  @@ -83,6 +84,7 @@
   
   import java.util.HashMap;
   import java.util.Vector;
  +import java.util.Iterator;
   
   
   /**
  @@ -90,12 +92,20 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.6 $
  + * @version $Revision: 1.7 $
    */
  -public class AbstractServer extends AbstractMethodHandler implements ArmiServer {
  +public abstract class AbstractServer extends AbstractMethodHandler implements ArmiServer {
   
       private HashMap mPublishedObjects = new HashMap();
       private boolean mSuspend = false;
  +    private Vector mConnections = new Vector();
  +
  +    protected static final int SHUTTINGDOWN = 11;
  +    protected static final int STARTED = 22;
  +    protected static final int STOPPED = 33;
  +    protected static final int UNSTARTED = 44;
  +
  +    protected int mState = UNSTARTED;
   
       /**
        * Method publish
  @@ -252,4 +262,30 @@
       public void resume() {
           mSuspend = false;
       }
  +
  +    /**
  +     * Method connectionStart
  +     *
  +     */
  +    protected void connectionStart(ArmiServerConnection armiConnection) {
  +        mConnections.add(armiConnection);
  +    }
  +
  +    /**
  +     * Method connectionCompleted
  +     *
  +     */
  +    protected void connectionCompleted(ArmiServerConnection armiConnection) {
  +        mConnections.remove(armiConnection);
  +    }
  +
  +    protected void killAllConnections() {
  +        Iterator it = mConnections.iterator();
  +        while (it.hasNext()) {
  +            ArmiServerConnection asc = (ArmiServerConnection) it.next();
  +            asc.endConnection();
  +        }
  +    }
  +
  +
   }
  
  
  
  1.3       +4 -5      jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/DefaultInvocationHandler.java
  
  Index: DefaultInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/DefaultInvocationHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultInvocationHandler.java	2 Jan 2002 12:11:56 -0000	1.2
  +++ DefaultInvocationHandler.java	3 Jan 2002 10:49:38 -0000	1.3
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/DefaultInvocationHandler.java,v 1.2 2002/01/02 12:11:56 hammant Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/01/02 12:11:56 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/DefaultInvocationHandler.java,v 1.3 2002/01/03 10:49:38 hammant Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/01/03 10:49:38 $
    *
    * ====================================================================
    *
  @@ -84,7 +84,7 @@
    *
    *
    * @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 DefaultInvocationHandler implements ArmiInvocationHandler {
   
  @@ -141,7 +141,6 @@
        *
        */
       public ArmiReply handleInvocation(ArmiRequest request) {
  -
           MethodRequest mr = (MethodRequest) request;
           String methodSignature = mr.getMethodSignature();
   
  
  
  
  1.2       +36 -7     jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/ObjectStreamServerConnection.java
  
  Index: ObjectStreamServerConnection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/ObjectStreamServerConnection.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ObjectStreamServerConnection.java	28 Dec 2001 18:08:38 -0000	1.1
  +++ ObjectStreamServerConnection.java	3 Jan 2002 10:49:38 -0000	1.2
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/ObjectStreamServerConnection.java,v 1.1 2001/12/28 18:08:38 hammant Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/12/28 18:08:38 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/ObjectStreamServerConnection.java,v 1.2 2002/01/03 10:49:38 hammant Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/01/03 10:49:38 $
    *
    * ====================================================================
    *
  @@ -65,6 +65,8 @@
   
   import org.apache.commons.armi.common.ArmiRequest;
   import org.apache.commons.armi.common.ArmiReply;
  +import org.apache.commons.armi.common.EndConnectionReply;
  +import org.apache.commons.armi.server.ArmiServerConnection;
   
   import java.io.ObjectInputStream;
   import java.io.ObjectOutputStream;
  @@ -81,13 +83,14 @@
    *
    *
    * @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 ObjectStreamServerConnection implements Runnable {
  +public abstract class ObjectStreamServerConnection implements Runnable, ArmiServerConnection {
   
       private InputStream mInputStream;
       private OutputStream mOutputStream;
       private AbstractServer mAbstractServer;
  +    private boolean mEndConnection = false;
   
       /**
        * Constructor ObjectStreamServerConnection
  @@ -113,6 +116,8 @@
        */
       public void run() {
   
  +        mAbstractServer.connectionStart(this);
  +
           try {
               ObjectInputStream oIS = new ObjectInputStream(mInputStream);
               ObjectOutputStream oOS = new ObjectOutputStream(mOutputStream);
  @@ -122,11 +127,16 @@
                   try {
                       ArmiRequest request = (ArmiRequest) oIS.readObject();
                       ArmiReply reply = mAbstractServer.processRequest(request);
  -
                       oOS.writeObject(reply);
                       oOS.flush();
  -                } catch (IOException ioe) {
   
  +                    if (mEndConnection) {
  +                        oOS.writeObject(new EndConnectionReply());
  +                        oOS.flush();
  +                        more = false;
  +                    }
  +
  +                } catch (IOException ioe) {
                       // pipe closed?
                       more = false;
                   }
  @@ -136,5 +146,24 @@
           } catch (ClassNotFoundException e) {
               e.printStackTrace();
           }
  +
  +        mAbstractServer.connectionCompleted(this);
  +    }
  +
  +    /**
  +     * Method endConnection
  +     *
  +     *
  +     */
  +    public void endConnection() {
  +        mEndConnection = true;
       }
  +
  +    /**
  +     * Method killConnection
  +     *
  +     *
  +     */
  +    protected abstract void killConnection();
  +
   }
  
  
  
  1.2       +47 -5     jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/direct/DirectServer.java
  
  Index: DirectServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/direct/DirectServer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DirectServer.java	28 Dec 2001 18:08:38 -0000	1.1
  +++ DirectServer.java	3 Jan 2002 10:49:38 -0000	1.2
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/direct/DirectServer.java,v 1.1 2001/12/28 18:08:38 hammant Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/12/28 18:08:38 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/direct/DirectServer.java,v 1.2 2002/01/03 10:49:38 hammant Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/01/03 10:49:38 $
    *
    * ====================================================================
    *
  @@ -64,6 +64,10 @@
   
   
   import org.apache.commons.armi.server.impl.AbstractServer;
  +import org.apache.commons.armi.server.ArmiServerException;
  +import org.apache.commons.armi.common.ArmiReply;
  +import org.apache.commons.armi.common.ArmiRequest;
  +import org.apache.commons.armi.common.ArmiInvocationException;
   
   
   /**
  @@ -71,6 +75,44 @@
    *
    *
    * @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 DirectServer extends AbstractServer {}
  +public class DirectServer extends AbstractServer {
  +
  +
  +
  +    /**
  +     * Method start
  +     *
  +     */
  +    public void start() {
  +        mState = STARTED;
  +    }
  +
  +    /**
  +     * Method stop
  +     *
  +     */
  +    public void stop() {
  +        mState = SHUTTINGDOWN;
  +        killAllConnections();
  +        mState = STOPPED;
  +    }
  +
  +    /**
  +     * Method processRequest
  +     *
  +     *
  +     * @param request
  +     *
  +     * @return
  +     *
  +     */
  +    public ArmiReply processRequest(ArmiRequest request) {
  +        if (mState == STARTED) {
  +            return super.processRequest(request);
  +        } else {
  +            throw new ArmiInvocationException("Service is not started");
  +        }
  +    }
  +}
  
  
  
  1.2       +32 -6     jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/piped/PipedServer.java
  
  Index: PipedServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/piped/PipedServer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PipedServer.java	28 Dec 2001 18:08:38 -0000	1.1
  +++ PipedServer.java	3 Jan 2002 10:49:38 -0000	1.2
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/piped/PipedServer.java,v 1.1 2001/12/28 18:08:38 hammant Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/12/28 18:08:38 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/piped/PipedServer.java,v 1.2 2002/01/03 10:49:38 hammant Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/01/03 10:49:38 $
    *
    * ====================================================================
    *
  @@ -78,7 +78,7 @@
    *
    *
    * @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 PipedServer extends AbstractServer implements ArmiPipeConnector {
   
  @@ -95,6 +95,12 @@
        */
       public PipedInputStream connect(PipedOutputStream clientPOS) throws ArmiConnectionException {
   
  +        if (mState == UNSTARTED) {
  +            throw new ArmiConnectionException("Server not started yet");
  +        } else if (mState == SHUTTINGDOWN) {
  +            throw new ArmiConnectionException("Server is Shutting down");
  +        }
  +
           try {
               PipedInputStream pIS = new PipedInputStream();
   
  @@ -105,8 +111,8 @@
   
               clientPIS.connect(pOS);
   
  -            ObjectStreamServerConnection dsc = new ObjectStreamServerConnection(this, pIS, pOS);
  -            Thread thread = new Thread(dsc);
  +            PipedObjectStreamServerConnection ossc = new PipedObjectStreamServerConnection(this, pIS, pOS);
  +            Thread thread = new Thread(ossc);
   
               thread.start();
   
  @@ -116,4 +122,24 @@
                                                 + pe.getMessage());
           }
       }
  +
  +    /**
  +     * Method start
  +     *
  +     */
  +    public void start() {
  +        mState = STARTED;
  +    }
  +
  +    /**
  +     * Method stop
  +     *
  +     */
  +    public void stop() {
  +        mState = SHUTTINGDOWN;
  +        killAllConnections();
  +        mState = STOPPED;
  +    }
  +
  +
   }
  
  
  
  1.1                  jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/piped/PipedObjectStreamServerConnection.java
  
  Index: PipedObjectStreamServerConnection.java
  ===================================================================
  
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/piped/PipedObjectStreamServerConnection.java,v 1.1 2002/01/03 10:49:38 hammant Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/03 10:49:38 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.armi.server.impl.piped;
  
  
  
  import org.apache.commons.armi.server.impl.ObjectStreamServerConnection;
  import org.apache.commons.armi.server.impl.AbstractServer;
  
  import java.net.Socket;
  
  import java.io.InputStream;
  import java.io.OutputStream;
  import java.io.IOException;
  import java.io.PipedInputStream;
  import java.io.PipedOutputStream;
  
  
  /**
   * Class PipedObjectStreamServerConnection
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class PipedObjectStreamServerConnection extends ObjectStreamServerConnection {
  
      private PipedInputStream mPipedIn;
      private PipedOutputStream mPipedOut;
  
      /**
       * Constructor PipedObjectStreamServerConnection
       *
       *
       * @param abstractServer
       * @param socket
       *
       * @throws IOException
       *
       */
      public PipedObjectStreamServerConnection(AbstractServer abstractServer, PipedInputStream pipedIn, PipedOutputStream pipedOut)
              throws IOException {
  
          super(abstractServer, pipedIn, pipedOut);
  
          mPipedIn = pipedIn;
          mPipedOut = pipedOut;
      }
  
      protected void killConnection() {
          try {
              mPipedIn.close();
              mPipedOut.close();
          } catch (IOException e) {}
      }
  }
  
  
  
  1.2       +39 -6     jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/rmi/RmiServer.java
  
  Index: RmiServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/rmi/RmiServer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RmiServer.java	28 Dec 2001 18:08:39 -0000	1.1
  +++ RmiServer.java	3 Jan 2002 10:49:38 -0000	1.2
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/rmi/RmiServer.java,v 1.1 2001/12/28 18:08:39 hammant Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/12/28 18:08:39 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/rmi/RmiServer.java,v 1.2 2002/01/03 10:49:38 hammant Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/01/03 10:49:38 $
    *
    * ====================================================================
    *
  @@ -71,6 +71,7 @@
   import java.rmi.registry.LocateRegistry;
   import java.rmi.registry.Registry;
   import java.rmi.RemoteException;
  +import java.rmi.NotBoundException;
   
   
   /**
  @@ -78,12 +79,16 @@
    *
    *
    * @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 RmiServer extends AbstractServer {
   
       private RmiArmiInovcationAdapter mRmiArmiInovcationAdapter;
   
  +    private String mHost;
  +    private int mPort;
  +    private Registry mRegistry;
  +
       /**
        * Constructor RmiServer
        *
  @@ -96,16 +101,44 @@
        */
       public RmiServer(String host, int port) throws ArmiServerException {
   
  +        mHost = host;
  +        mPort = port;
  +
  +    }
  +
  +    /**
  +     * Method start
  +     *
  +     */
  +    public void start() throws ArmiServerException {
  +        mState = STARTED;
           try {
               mRmiArmiInovcationAdapter = new RmiArmiInovcationAdapter(this);
   
               UnicastRemoteObject.exportObject(mRmiArmiInovcationAdapter);
   
  -            Registry registry = LocateRegistry.createRegistry(port);
  +            mRegistry = LocateRegistry.createRegistry(mPort);
   
  -            registry.rebind(RmiArmiInvocationHandler.class.getName(), mRmiArmiInovcationAdapter);
  +            mRegistry.rebind(RmiArmiInvocationHandler.class.getName(), mRmiArmiInovcationAdapter);
           } catch (RemoteException re) {
               throw new ArmiServerException("Some problem setting up server : " + re.getMessage());
           }
  +
  +    }
  +
  +    /**
  +     * Method stop
  +     *
  +     */
  +    public void stop() {
  +        mState = SHUTTINGDOWN;
  +        killAllConnections();
  +        try {
  +            mRegistry.unbind(RmiArmiInvocationHandler.class.getName());
  +        } catch (RemoteException re) {
  +        } catch (NotBoundException nbe) {
  +            //TODO ?
  +        }
  +        mState = STOPPED;
       }
   }
  
  
  
  1.2       +39 -9     jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/socket/PlainSocketServer.java
  
  Index: PlainSocketServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/socket/PlainSocketServer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PlainSocketServer.java	28 Dec 2001 18:08:39 -0000	1.1
  +++ PlainSocketServer.java	3 Jan 2002 10:49:38 -0000	1.2
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/socket/PlainSocketServer.java,v 1.1 2001/12/28 18:08:39 hammant Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/12/28 18:08:39 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/socket/PlainSocketServer.java,v 1.2 2002/01/03 10:49:38 hammant Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/01/03 10:49:38 $
    *
    * ====================================================================
    *
  @@ -81,12 +81,14 @@
    *
    *
    * @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 PlainSocketServer extends AbstractServer implements Runnable {
   
       private ServerSocket mServerSocket;
   
  +    private Thread mThread;
  +
       /**
        * Constructor PlainSocketServer
        *
  @@ -113,12 +115,11 @@
       public void run() {
   
           try {
  -            while (true) {
  +            while (mState == STARTED) {
                   Socket sock = mServerSocket.accept();
  -                ObjectStreamServerConnection dsc = new ObjectStreamServerConnection(this,
  -                                                       sock.getInputStream(),
  -                                                       sock.getOutputStream());
  -                Thread thread = new Thread(dsc);
  +                SocketObjectStreamServerConnection ossc = new SocketObjectStreamServerConnection(this, sock,
  +                        sock.getInputStream(), sock.getOutputStream());
  +                Thread thread = new Thread(ossc);
   
                   thread.start();
               }
  @@ -126,4 +127,33 @@
               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/armi/src/java/org/apache/commons/armi/server/impl/socket/SocketObjectStreamServerConnection.java
  
  Index: SocketObjectStreamServerConnection.java
  ===================================================================
  
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/server/impl/socket/SocketObjectStreamServerConnection.java,v 1.1 2002/01/03 10:49:38 hammant Exp $
   * $Revision: 1.1 $
   * $Date: 2002/01/03 10:49:38 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.commons.armi.server.impl.socket;
  
  
  
  import org.apache.commons.armi.server.impl.ObjectStreamServerConnection;
  import org.apache.commons.armi.server.impl.AbstractServer;
  
  import java.net.Socket;
  
  import java.io.InputStream;
  import java.io.OutputStream;
  import java.io.IOException;
  
  
  /**
   * Class SocketObjectStreamServerConnection
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class SocketObjectStreamServerConnection extends ObjectStreamServerConnection {
  
      private Socket mSocket;
  
      /**
       * Constructor SocketObjectStreamServerConnection
       *
       *
       * @param abstractServer
       * @param socket
       *
       * @throws IOException
       *
       */
      public SocketObjectStreamServerConnection(final AbstractServer abstractServer, final Socket socket, InputStream inStream, OutputStream outStream)
              throws IOException {
  
          super(abstractServer, inStream, outStream);
  
          mSocket = socket;
      }
  
      protected void killConnection() {
          try {
             mSocket.close();
          } catch (IOException e) {}
      }
  }
  
  
  
  1.5       +6 -5      jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/DirectTest.java
  
  Index: DirectTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/DirectTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DirectTest.java	31 Dec 2001 12:07:31 -0000	1.4
  +++ DirectTest.java	3 Jan 2002 10:49:38 -0000	1.5
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/DirectTest.java,v 1.4 2001/12/31 12:07:31 hammant Exp $
  - * $Revision: 1.4 $
  - * $Date: 2001/12/31 12:07:31 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/DirectTest.java,v 1.5 2002/01/03 10:49:38 hammant Exp $
  + * $Revision: 1.5 $
  + * $Date: 2002/01/03 10:49:38 $
    *
    * ====================================================================
    *
  @@ -79,7 +79,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    */
   public class DirectTest {
   
  @@ -104,6 +104,7 @@
           TestInterfaceImpl ti = new TestInterfaceImpl();
   
           ds.publish(ti, "Hello", TestInterface.class);
  +        ds.start();
   
           DirectTestClient dtc = new DirectTestClient(new DirectArmiInovcationAdapter(ds));
           Thread thread = new Thread(dtc);
  @@ -116,7 +117,7 @@
        *
        *
        * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  -     * @version $Revision: 1.4 $
  +     * @version $Revision: 1.5 $
        */
       static class DirectTestClient implements Runnable {
   
  
  
  
  1.5       +6 -5      jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/PipeTest.java
  
  Index: PipeTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/PipeTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PipeTest.java	31 Dec 2001 12:07:31 -0000	1.4
  +++ PipeTest.java	3 Jan 2002 10:49:38 -0000	1.5
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/PipeTest.java,v 1.4 2001/12/31 12:07:31 hammant Exp $
  - * $Revision: 1.4 $
  - * $Date: 2001/12/31 12:07:31 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/PipeTest.java,v 1.5 2002/01/03 10:49:38 hammant Exp $
  + * $Revision: 1.5 $
  + * $Date: 2002/01/03 10:49:38 $
    *
    * ====================================================================
    *
  @@ -80,7 +80,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    */
   public class PipeTest {
   
  @@ -105,6 +105,7 @@
           TestInterfaceImpl ti = new TestInterfaceImpl();
   
           ps.publish(ti, "Hello", TestInterface.class);
  +        ps.start();
   
           PipedTestClient ptc = new PipedTestClient(ps);
           Thread thread = new Thread(ptc);
  @@ -117,7 +118,7 @@
        *
        *
        * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  -     * @version $Revision: 1.4 $
  +     * @version $Revision: 1.5 $
        */
       static class PipedTestClient implements Runnable {
   
  
  
  
  1.3       +5 -4      jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/RmiServerTest.java
  
  Index: RmiServerTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/RmiServerTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RmiServerTest.java	30 Dec 2001 01:12:04 -0000	1.2
  +++ RmiServerTest.java	3 Jan 2002 10:49:38 -0000	1.3
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/RmiServerTest.java,v 1.2 2001/12/30 01:12:04 hammant Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/12/30 01:12:04 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/RmiServerTest.java,v 1.3 2002/01/03 10:49:38 hammant Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/01/03 10:49:38 $
    *
    * ====================================================================
    *
  @@ -73,7 +73,7 @@
    *
    *
    * @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 RmiServerTest {
   
  @@ -94,5 +94,6 @@
           TestInterfaceImpl ti = new TestInterfaceImpl();
   
           rs.publish(ti, "Hello", TestInterface.class);
  +        rs.start();
       }
   }
  
  
  
  1.3       +7 -7      jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/SocketServerTest.java
  
  Index: SocketServerTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/SocketServerTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SocketServerTest.java	30 Dec 2001 01:12:04 -0000	1.2
  +++ SocketServerTest.java	3 Jan 2002 10:49:38 -0000	1.3
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/SocketServerTest.java,v 1.2 2001/12/30 01:12:04 hammant Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/12/30 01:12:04 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/SocketServerTest.java,v 1.3 2002/01/03 10:49:38 hammant Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/01/03 10:49:38 $
    *
    * ====================================================================
    *
  @@ -73,7 +73,7 @@
    *
    *
    * @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 SocketServerTest {
   
  @@ -90,10 +90,10 @@
   
           System.out.println("Stream over Socket Server");
   
  -        PlainSocketServer ds = new PlainSocketServer(1234);
  +        PlainSocketServer pss = new PlainSocketServer(1234);
           TestInterfaceImpl ti = new TestInterfaceImpl();
   
  -        ds.publish(ti, "Hello", TestInterface.class);
  -        ds.run();
  +        pss.publish(ti, "Hello", TestInterface.class);
  +        pss.start();
       }
   }
  
  
  
  1.4       +7 -7      jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestClient.java
  
  Index: TestClient.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestClient.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestClient.java	30 Dec 2001 01:12:04 -0000	1.3
  +++ TestClient.java	3 Jan 2002 10:49:38 -0000	1.4
  @@ -1,8 +1,8 @@
   
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestClient.java,v 1.3 2001/12/30 01:12:04 hammant Exp $
  - * $Revision: 1.3 $
  - * $Date: 2001/12/30 01:12:04 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/armi/src/java/org/apache/commons/armi/test/TestClient.java,v 1.4 2002/01/03 10:49:38 hammant Exp $
  + * $Revision: 1.4 $
  + * $Date: 2002/01/03 10:49:38 $
    *
    * ====================================================================
    *
  @@ -77,7 +77,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public class TestClient {
   
  @@ -110,7 +110,7 @@
   
           System.out.println("CLT: " + ti.hello4((float) 1.3, 2.1));
   
  -        System.out.println("Two timings about to start, please stand by...");
  +        System.out.println("CLT: Two timings about to start, please stand by...");
   
           ti.testSpeed(); // to ignore for timing
           long start = System.currentTimeMillis();
  @@ -118,7 +118,7 @@
               ti.testSpeed();
           }
           long end = System.currentTimeMillis();
  -        System.out.println("Total time take for 100,000 simple calls (millis) = " + (end - start));
  +        System.out.println("CLT: Total time take for 100,000 simple calls (millis) = " + (end - start));
   
           String rv = ti.testSpeed2("toIgnoreForTiming");
           start = System.currentTimeMillis();
  @@ -126,7 +126,7 @@
               rv = ti.testSpeed2("qwerty");
           }
           end = System.currentTimeMillis();
  -        System.out.println("Total time take for 100,000 retval/param calls (millis) = " + (end - start));
  +        System.out.println("CLT: Total time take for 100,000 retval/param calls (millis) = " + (end - start));
   
   
       }
  
  
  

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