hammant     02/02/04 04:29:04

  Modified:    altrmi/src/java/org/apache/commons/altrmi/server/impl
                        AbstractServer.java
               altrmi/src/java/org/apache/commons/altrmi/server/impl/direct
                        DirectMarshalledServer.java DirectServer.java
               altrmi/src/java/org/apache/commons/altrmi/server/impl/socket
                        AbstractCompleteSocketStreamServer.java
                        CompleteSocketCustomStreamServer.java
               altrmi/src/java/org/apache/commons/altrmi/test
                        DirectMarshalledTest.java DirectTest.java
  Added:       altrmi/src/java/org/apache/commons/altrmi/server/impl/adapters
                        InvocationHandlerAdapter.java
                        MarshalledInvocationHandlerAdapter.java
               altrmi/src/java/org/apache/commons/altrmi/server/impl/socket
                        PartialSocketCustomStreamServer.java
  Removed:     altrmi/src/java/org/apache/commons/altrmi/server/impl/adapters
                        InovcationHandlerAdapter.java
                        MarshalledInovcationHandlerAdapter.java
  Log:
  adaptations for EOB
  
  Revision  Changes    Path
  1.19      +5 -5      
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/AbstractServer.java
  
  Index: AbstractServer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/AbstractServer.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- AbstractServer.java       29 Jan 2002 10:42:18 -0000      1.18
  +++ AbstractServer.java       4 Feb 2002 12:29:03 -0000       1.19
  @@ -18,7 +18,7 @@
   import org.apache.commons.altrmi.server.AltrmiServerConnection;
   import org.apache.commons.altrmi.server.PublicationException;
   import org.apache.commons.altrmi.server.MethodInvocationHandler;
  -import org.apache.commons.altrmi.server.impl.adapters.InovcationHandlerAdapter;
  +import org.apache.commons.altrmi.server.impl.adapters.InvocationHandlerAdapter;
   
   import java.util.Vector;
   import java.util.Iterator;
  @@ -29,13 +29,13 @@
    *
    *
    * @author Paul Hammant <a 
href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>
  - * @version $Revision: 1.18 $
  + * @version $Revision: 1.19 $
    */
   public abstract class AbstractServer extends AbstractMethodHandler implements 
AltrmiServer {
   
   
       private Vector mConnections = new Vector();
  -    protected InovcationHandlerAdapter mInovcationHandlerAdapter;
  +    protected InvocationHandlerAdapter mInovcationHandlerAdapter;
       protected static final int SHUTTINGDOWN = 11;
       protected static final int STARTED = 22;
       protected static final int STOPPED = 33;
  @@ -43,10 +43,10 @@
       protected int mState = UNSTARTED;
   
       public AbstractServer() {
  -        mInovcationHandlerAdapter = new InovcationHandlerAdapter();
  +        mInovcationHandlerAdapter = new InvocationHandlerAdapter();
       }
   
  -    public AbstractServer(InovcationHandlerAdapter inovcationHandlerAdapter) {
  +    public AbstractServer(InvocationHandlerAdapter inovcationHandlerAdapter) {
           mInovcationHandlerAdapter = inovcationHandlerAdapter;
       }
   
  
  
  
  1.1                  
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/adapters/InvocationHandlerAdapter.java
  
  Index: InvocationHandlerAdapter.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.adapters;
  
  
  
  import org.apache.commons.altrmi.common.AltrmiInvocationHandler;
  import org.apache.commons.altrmi.common.AltrmiReply;
  import org.apache.commons.altrmi.common.AltrmiRequest;
  import org.apache.commons.altrmi.common.SuspendedReply;
  import org.apache.commons.altrmi.common.MethodRequest;
  import org.apache.commons.altrmi.common.NotPublishedReply;
  import org.apache.commons.altrmi.common.MethodFacadeRequest;
  import org.apache.commons.altrmi.common.ExceptionReply;
  import org.apache.commons.altrmi.common.AltrmiInvocationException;
  import org.apache.commons.altrmi.common.RequestFailedReply;
  import org.apache.commons.altrmi.common.MethodReply;
  import org.apache.commons.altrmi.common.MethodFacadeReply;
  import org.apache.commons.altrmi.common.LookupRequest;
  import org.apache.commons.altrmi.common.AltrmiAuthenticationException;
  import org.apache.commons.altrmi.common.LookupReply;
  import org.apache.commons.altrmi.common.ClassRequest;
  import org.apache.commons.altrmi.common.ClassReply;
  import org.apache.commons.altrmi.common.ClassRetrievalFailedReply;
  import org.apache.commons.altrmi.common.OpenConnectionReply;
  import org.apache.commons.altrmi.common.PingReply;
  import org.apache.commons.altrmi.common.ListReply;
  import org.apache.commons.altrmi.common.MethodFacadeArrayReply;
  import org.apache.commons.altrmi.server.AltrmiServer;
  import org.apache.commons.altrmi.server.MethodInvocationHandler;
  import org.apache.commons.altrmi.server.ClassRetrievalException;
  import org.apache.commons.altrmi.server.ClassRetriever;
  import org.apache.commons.altrmi.server.AltrmiAuthenticator;
  import org.apache.commons.altrmi.server.impl.classretrievers.NoClassRetriever;
  import org.apache.commons.altrmi.server.impl.DefaultAuthenticator;
  import org.apache.commons.altrmi.server.impl.AbstractServer;
  
  import java.util.Vector;
  import java.util.HashMap;
  import java.util.Iterator;
  
  
  /**
   * Class InvocationHandlerAdapter
   *
   *
   * @author Paul Hammant <a 
href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>
   * @version $Revision: 1.1 $
   */
  public class InvocationHandlerAdapter extends PublicationAdapter
          implements AltrmiInvocationHandler {
  
      private static int SESSION = 0;
      private Long mLastSession = new Long(0);
      private Vector mSessions = new Vector();
      private boolean mSuspend = false;
      private ClassRetriever mClassRetriever = new NoClassRetriever();
      private AltrmiAuthenticator mAltrmiAuthenticator = new DefaultAuthenticator();
  
      /**
       * Method setClassRetriever
       *
       *
       * @param classRetriever
       *
       */
      public final void setClassRetriever(ClassRetriever classRetriever) {
          mClassRetriever = classRetriever;
      }
  
      /**
       * Method setAuthenticator
       *
       *
       * @param altrmiAuthenticator
       *
       */
      public final void setAuthenticator(AltrmiAuthenticator altrmiAuthenticator) {
          mAltrmiAuthenticator = altrmiAuthenticator;
      }
  
      /**
       * Method handleInvocation
       *
       *
       * @param request
       *
       * @return
       *
       */
      public AltrmiReply handleInvocation(AltrmiRequest request) {
  
          if (mSuspend == true) {
              return new SuspendedReply();
          }
  
          // Method request is positionid first as
          // it is the one we want to be most speedy.
          if (request.getRequestCode() == AltrmiRequest.METHODREQUEST) {
              MethodRequest mReq = (MethodRequest) request;
              String publishedThing = mReq.getPublishedServiceName() + "_" + 
mReq.getObjectName();
  
              if (!mPublishedObjects.containsKey(publishedThing)) {
                  return new NotPublishedReply();
              }
  
              AltrmiInvocationHandler ih =
                  (AltrmiInvocationHandler) mPublishedObjects.get(publishedThing);
  
              return ih.handleInvocation(mReq);
          } else if (request.getRequestCode() == AltrmiRequest.METHODFACADEREQUEST) {
              MethodFacadeRequest mFacReq = (MethodFacadeRequest) request;
              String publishedThing = mFacReq.getPublishedServiceName() + "_" + 
mFacReq.getObjectName();
  
              if (!mPublishedObjects.containsKey(publishedThing)) {
                  return new NotPublishedReply();
              }
  
              if (!sessionExists(mFacReq.getSession())) {
                  return new ExceptionReply(
                      new AltrmiInvocationException("TODO - you dirty rat/hacker"));
              }
  
              MethodInvocationHandler asih =
                  (MethodInvocationHandler) mPublishedObjects.get(publishedThing);
              AltrmiReply ar = asih.handleInvocation(mFacReq);
  
              if (ar.getReplyCode() == AltrmiReply.EXCEPTIONREPLY) {
                  return ar;
              } else if (ar.getReplyCode() >= AltrmiReply.PROBLEMREPLY) {
                  return ar;
              } else if (ar.getReplyCode() != AltrmiReply.METHODREPLY) {
                  return new RequestFailedReply("TODO");
              }
  
              Object replyObject = ((MethodReply) ar).getReplyObject();
  
              if (!replyObject.getClass().isArray()) {
  
                  Object beanImpl = replyObject;
  
                  MethodInvocationHandler asih2 =
                      (MethodInvocationHandler) mPublishedObjects.get(
                       mFacReq.getPublishedServiceName() + "_" + 
mFacReq.getBaseReturnClassNameEncoded());
  
                  if (asih2 == null) {
                      return new NotPublishedReply();
                  }
  
                  if (!sessionExists(mFacReq.getSession())) {
                      return new ExceptionReply(
                          new AltrmiInvocationException("TODO - you dirty 
rat/hacker"));
                  }
  
                  //TODO a decent ref number for main?
                  Long newRef = asih2.getOrMakeReferenceIDForBean(beanImpl);
  
                  //long newRef2 = asih2.getOrMakeReferenceIDForBean(beanImpl);
                  return new MethodFacadeReply(newRef);
              } else {
                  Object[] beanImpls = (Object[]) replyObject;
                  Long[] refs = new Long[beanImpls.length];
                  for (int i = 0; i < beanImpls.length; i++) {
                      Object impl = beanImpls[i];
                      MethodInvocationHandler asih2 =
                          (MethodInvocationHandler) mPublishedObjects.get(
                           mFacReq.getPublishedServiceName() + "_" + 
mFacReq.getBaseReturnClassNameEncoded());
  
                      if (asih2 == null) {
                          return new NotPublishedReply();
                      }
  
                      if (!sessionExists(mFacReq.getSession())) {
                          return new ExceptionReply(
                              new AltrmiInvocationException("TODO - you dirty 
rat/hacker"));
                      }
  
                      //TODO a decent ref number for main?
                      refs[i] = asih2.getOrMakeReferenceIDForBean(beanImpls[i]);
  
                  }
                  return new MethodFacadeArrayReply(refs);
              }
          } else if (request.getRequestCode() == AltrmiRequest.LOOKUPREQUEST) {
              LookupRequest lr = (LookupRequest) request;
  
              try {
                  mAltrmiAuthenticator.checkAuthority(lr.getAltrmiAuthentication(),
                                                      lr.getPublishedServiceName());
              } catch (AltrmiAuthenticationException aae) {
                  return new ExceptionReply(aae);
              }
  
              //TODO a decent ref number for main?
              return new LookupReply(new Long(0));
          } else if (request.getRequestCode() == AltrmiRequest.CLASSREQUEST) {
              ClassRequest cr = (ClassRequest) request;
              String publishedThing = cr.getPublishedServiceName() + "_" + 
cr.getObjectName();
  
              try {
                  return new ClassReply(mClassRetriever.getBeanBytes(publishedThing),
                                        mClassRetriever
                                            
.getInterfaceImplementationBytes(publishedThing));
              } catch (ClassRetrievalException e) {
                  return new ClassRetrievalFailedReply();
              }
          } else if (request.getRequestCode() == AltrmiRequest.OPENCONNECTIONREQUEST) {
              Long session = getNewSession();
  
              mSessions.add(session);
  
              return new OpenConnectionReply(mAltrmiAuthenticator.getTextToSign(), 
session);
          } else if (request.getRequestCode() == AltrmiRequest.PINGREQUEST) {
  
              // we could communicate back useful state info in this transaction.
              return new PingReply();
          } else if (request.getRequestCode() == AltrmiRequest.LISTREQUEST) {
  
              //return the list of published objects to the server
              Iterator iterator = mPublishedObjects.keySet().iterator();
              Vector vecOfPublishedObjectNames = new Vector();
  
              while (iterator.hasNext()) {
                  final String item = (String) iterator.next();
  
                  if (item.endsWith("_Main")) {
                      vecOfPublishedObjectNames.add(item.substring(0, 
item.lastIndexOf("_Main")));
                  }
              }
  
              String[] _listOfPublishedObjectNames = new 
String[vecOfPublishedObjectNames.size()];
  
              System.arraycopy(vecOfPublishedObjectNames.toArray(), 0, 
_listOfPublishedObjectNames,
                               0, vecOfPublishedObjectNames.size());
  
              return new ListReply(_listOfPublishedObjectNames);
          } else {
              return new RequestFailedReply("Unknown request :" + 
request.getClass().getName());
          }
      }
  
      private boolean sessionExists(Long session) {
  
          if (mLastSession.equals(session)) {
  
              // buffer last session for performance.
              return true;
          } else {
              if (mSessions.contains(session)) {
                  mLastSession = session;
  
                  return true;
              }
          }
  
          return false;
      }
  
      private Long getNewSession() {
  
          // approve everything and set session identifier.
          return new Long((long) ((long) SESSION++ << 32) + (long) 
Math.round(Math.random()));
      }
  
      /**
       * Method suspend
       *
       */
      public void suspend() {
          mSuspend = true;
      }
  
      /**
       * Method resume
       *
       */
      public void resume() {
          mSuspend = false;
      }
  }
  
  
  
  1.1                  
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/adapters/MarshalledInvocationHandlerAdapter.java
  
  Index: MarshalledInvocationHandlerAdapter.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.adapters;
  
  
  
  import org.apache.commons.altrmi.common.AltrmiInvocationHandler;
  import org.apache.commons.altrmi.common.AltrmiReply;
  import org.apache.commons.altrmi.common.AltrmiRequest;
  import org.apache.commons.altrmi.common.AltrmiMarshalledInvocationHandler;
  import org.apache.commons.altrmi.common.SerializationHelper;
  import org.apache.commons.altrmi.server.AltrmiServer;
  
  import java.io.IOException;
  
  
  /**
   * Class MarshalledInvocationHandlerAdapter
   *
   *
   * @author Paul Hammant <a 
href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>
   * @version $Revision: 1.1 $
   */
  public class MarshalledInvocationHandlerAdapter implements 
AltrmiMarshalledInvocationHandler {
  
      private AltrmiInvocationHandler mAltrmiInvocationHandler;
      private ClassLoader mClassLoader;
  
      /**
       * Constructor MarshalledInvocationHandlerAdapter
       *
       *
       * @param altrmiInvocationHandler
       *
       */
      public MarshalledInvocationHandlerAdapter(AltrmiInvocationHandler 
altrmiInvocationHandler) {
          mAltrmiInvocationHandler = altrmiInvocationHandler;
          mClassLoader = getClass().getClassLoader();
      }
  
      public MarshalledInvocationHandlerAdapter(AltrmiInvocationHandler 
altrmiInvocationHandler, ClassLoader classLoader) {
          mAltrmiInvocationHandler = altrmiInvocationHandler;
          mClassLoader = classLoader;
      }
  
  
      /**
       * Method handleInvocation
       *
       *
       * @param request
       *
       * @return
       *
       */
      public byte[] handleInvocation(byte[] request) {
          try {
              AltrmiRequest ar = (AltrmiRequest) 
SerializationHelper.getInstanceFromBytes(request, mClassLoader);
              AltrmiReply reply = mAltrmiInvocationHandler.handleInvocation(ar);
              return SerializationHelper.getBytesFromInstance(reply);
          } catch (IOException e) {
              e.printStackTrace();
              return null;
          } catch (ClassNotFoundException e) {
              e.printStackTrace();
              return null;
          }
  
      }
  }
  
  
  
  1.4       +12 -12    
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/direct/DirectMarshalledServer.java
  
  Index: DirectMarshalledServer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/direct/DirectMarshalledServer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DirectMarshalledServer.java       29 Jan 2002 10:42:18 -0000      1.3
  +++ DirectMarshalledServer.java       4 Feb 2002 12:29:03 -0000       1.4
  @@ -11,8 +11,8 @@
   
   
   import org.apache.commons.altrmi.server.impl.AbstractServer;
  -import org.apache.commons.altrmi.server.impl.adapters.InovcationHandlerAdapter;
  -import 
org.apache.commons.altrmi.server.impl.adapters.MarshalledInovcationHandlerAdapter;
  +import org.apache.commons.altrmi.server.impl.adapters.InvocationHandlerAdapter;
  +import 
org.apache.commons.altrmi.server.impl.adapters.MarshalledInvocationHandlerAdapter;
   import org.apache.commons.altrmi.server.AltrmiServerException;
   import org.apache.commons.altrmi.common.AltrmiReply;
   import org.apache.commons.altrmi.common.AltrmiRequest;
  @@ -25,38 +25,38 @@
    *
    *
    * @author Paul Hammant <a 
href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public class DirectMarshalledServer extends AbstractServer
           implements AltrmiMarshalledInvocationHandler {
   
  -    MarshalledInovcationHandlerAdapter mMarshalledInovcationHandlerAdapter;
  +    MarshalledInvocationHandlerAdapter mMarshalledInovcationHandlerAdapter;
   
       /**
  -     * Constructor DirectMarshalledServer makes a new InovcationHandlerAdapter.
  +     * Constructor DirectMarshalledServer makes a new InvocationHandlerAdapter.
        *
        *
        */
       public DirectMarshalledServer() {
  -        mMarshalledInovcationHandlerAdapter = new 
MarshalledInovcationHandlerAdapter(this);
  +        mMarshalledInovcationHandlerAdapter = new 
MarshalledInvocationHandlerAdapter(this);
       }
   
       /**
  -     * Constructor DirectMarshalledServer for use with pre-exiting 
InovcationHandlerAdapter.
  +     * Constructor DirectMarshalledServer for use with pre-exiting 
InvocationHandlerAdapter.
        *
        *
        * @param inovcationHandlerAdapter
        *
        */
  -    public DirectMarshalledServer(InovcationHandlerAdapter 
inovcationHandlerAdapter) {
  +    public DirectMarshalledServer(InvocationHandlerAdapter 
inovcationHandlerAdapter) {
   
           super(inovcationHandlerAdapter);
   
  -        mMarshalledInovcationHandlerAdapter = new 
MarshalledInovcationHandlerAdapter(this);
  +        mMarshalledInovcationHandlerAdapter = new 
MarshalledInvocationHandlerAdapter(this);
       }
   
       /**
  -     * Constructor DirectMarshalledServer for use with pre-exiting 
InovcationHandlerAdapter and MarshalledInvocationHandler
  +     * Constructor DirectMarshalledServer for use with pre-exiting 
InvocationHandlerAdapter and MarshalledInvocationHandler
        *
        *
        * @param inovcationHandlerAdapter
  @@ -64,8 +64,8 @@
        *
        */
       public DirectMarshalledServer(
  -            InovcationHandlerAdapter inovcationHandlerAdapter,
  -            MarshalledInovcationHandlerAdapter marshalledInovcationHandlerAdapter) {
  +            InvocationHandlerAdapter inovcationHandlerAdapter,
  +            MarshalledInvocationHandlerAdapter marshalledInovcationHandlerAdapter) {
   
           super(inovcationHandlerAdapter);
   
  
  
  
  1.4       +5 -5      
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/direct/DirectServer.java
  
  Index: DirectServer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/direct/DirectServer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DirectServer.java 29 Jan 2002 10:42:18 -0000      1.3
  +++ DirectServer.java 4 Feb 2002 12:29:03 -0000       1.4
  @@ -11,7 +11,7 @@
   
   
   import org.apache.commons.altrmi.server.impl.AbstractServer;
  -import org.apache.commons.altrmi.server.impl.adapters.InovcationHandlerAdapter;
  +import org.apache.commons.altrmi.server.impl.adapters.InvocationHandlerAdapter;
   import org.apache.commons.altrmi.server.AltrmiServerException;
   import org.apache.commons.altrmi.common.AltrmiReply;
   import org.apache.commons.altrmi.common.AltrmiRequest;
  @@ -23,25 +23,25 @@
    *
    *
    * @author Paul Hammant <a 
href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public class DirectServer extends AbstractServer {
   
       /**
  -     * Constructor DirectServer makes a new InovcationHandlerAdapter.
  +     * Constructor DirectServer makes a new InvocationHandlerAdapter.
        *
        *
        */
       public DirectServer() {}
   
       /**
  -     * Constructor DirectServer for use with pre-exiting InovcationHandlerAdapter.
  +     * Constructor DirectServer for use with pre-exiting InvocationHandlerAdapter.
        *
        *
        * @param inovcationHandlerAdapter
        *
        */
  -    public DirectServer(InovcationHandlerAdapter inovcationHandlerAdapter) {
  +    public DirectServer(InvocationHandlerAdapter inovcationHandlerAdapter) {
           super(inovcationHandlerAdapter);
       }
   
  
  
  
  1.2       +26 -1     
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/socket/AbstractCompleteSocketStreamServer.java
  
  Index: AbstractCompleteSocketStreamServer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/socket/AbstractCompleteSocketStreamServer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractCompleteSocketStreamServer.java   17 Jan 2002 12:14:30 -0000      1.1
  +++ AbstractCompleteSocketStreamServer.java   4 Feb 2002 12:29:03 -0000       1.2
  @@ -15,6 +15,7 @@
   import org.apache.commons.altrmi.server.impl.AbstractServer;
   import org.apache.commons.altrmi.server.impl.StreamServerConnection;
   import org.apache.commons.altrmi.server.impl.ServerStreamReadWriter;
  +import org.apache.commons.altrmi.server.impl.adapters.InvocationHandlerAdapter;
   import org.apache.commons.altrmi.common.AltrmiRequest;
   import org.apache.commons.altrmi.common.AltrmiReply;
   
  @@ -29,7 +30,7 @@
    *
    *
    * @author Paul Hammant <a 
href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public abstract class AbstractCompleteSocketStreamServer extends AbstractServer
           implements Runnable {
  @@ -47,6 +48,30 @@
        *
        */
       public AbstractCompleteSocketStreamServer(int port) throws 
AltrmiServerException {
  +
  +        try {
  +            mServerSocket = new ServerSocket(port);
  +        } catch (IOException ioe) {
  +            throw new AltrmiServerException("Some problem setting up server : "
  +                                            + ioe.getMessage());
  +        }
  +    }
  +
  +    /**
  +     * Constructor AbstractCompleteSocketStreamServer
  +     *
  +     *
  +     * @param invocationHandlerAdapter
  +     * @param port
  +     *
  +     * @throws AltrmiServerException
  +     *
  +     */
  +    public AbstractCompleteSocketStreamServer(
  +            InvocationHandlerAdapter invocationHandlerAdapter, int port)
  +                throws AltrmiServerException {
  +
  +        super(invocationHandlerAdapter);
   
           try {
               mServerSocket = new ServerSocket(port);
  
  
  
  1.2       +8 -1      
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/socket/CompleteSocketCustomStreamServer.java
  
  Index: CompleteSocketCustomStreamServer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/socket/CompleteSocketCustomStreamServer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CompleteSocketCustomStreamServer.java     17 Jan 2002 12:14:30 -0000      1.1
  +++ CompleteSocketCustomStreamServer.java     4 Feb 2002 12:29:03 -0000       1.2
  @@ -16,6 +16,7 @@
   import org.apache.commons.altrmi.server.impl.StreamServerConnection;
   import org.apache.commons.altrmi.server.impl.ServerStreamReadWriter;
   import org.apache.commons.altrmi.server.impl.ServerCustomStreamReadWriter;
  +import org.apache.commons.altrmi.server.impl.adapters.InvocationHandlerAdapter;
   import org.apache.commons.altrmi.common.AltrmiRequest;
   import org.apache.commons.altrmi.common.AltrmiReply;
   
  @@ -30,7 +31,7 @@
    *
    *
    * @author Paul Hammant <a 
href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class CompleteSocketCustomStreamServer extends 
AbstractCompleteSocketStreamServer {
   
  @@ -46,6 +47,12 @@
       public CompleteSocketCustomStreamServer(int port) throws AltrmiServerException {
           super(port);
       }
  +
  +    public CompleteSocketCustomStreamServer(InvocationHandlerAdapter 
invocationHandlerAdapter, int port) throws AltrmiServerException {
  +        super(invocationHandlerAdapter, port);
  +    }
  +
  +
   
       protected ServerStreamReadWriter createServerStreamReadWriter() {
           return new ServerCustomStreamReadWriter();
  
  
  
  1.1                  
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/socket/PartialSocketCustomStreamServer.java
  
  Index: PartialSocketCustomStreamServer.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.impl.ServerStreamReadWriter;
  import org.apache.commons.altrmi.server.impl.ServerObjectStreamReadWriter;
  import org.apache.commons.altrmi.server.impl.adapters.InvocationHandlerAdapter;
  import org.apache.commons.altrmi.server.AltrmiServerException;
  
  import java.net.Socket;
  import java.net.SocketException;
  
  import java.io.IOException;
  
  
  /**
   * Class PartialSocketObjectStreamServer
   *
   *
   * @author Paul Hammant <a 
href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>
   * @version $Revision: 1.1 $
   */
  public class PartialSocketCustomStreamServer extends AbstractServer {
  
      /**
       * Constructor PartialSocketObjectStreamServer
       *
       *
       * @throws AltrmiServerException
       *
       */
      public PartialSocketCustomStreamServer() throws AltrmiServerException {}
  
      /**
       * Constructor PartialSocketCustomStreamServer
       *
       *
       * @param invocationHandlerAdapter
       *
       * @throws AltrmiServerException
       *
       */
      public PartialSocketCustomStreamServer(InvocationHandlerAdapter 
invocationHandlerAdapter)
              throws AltrmiServerException {
          super(invocationHandlerAdapter);
      }
  
      /**
       * Method handleConnection
       *
       * @param sock
       *
       */
      public void handleConnection(final Socket sock) {
  
          // see http://developer.java.sun.com/developer/bugParade/bugs/4508149.html
          try {
              sock.setSoTimeout(360000);
          } catch (SocketException se) {
              se.printStackTrace();
          }
  
          try {
              if (mState == STARTED) {
                  ServerStreamReadWriter ssrw = new ServerObjectStreamReadWriter();
  
                  ssrw.setStreams(sock.getInputStream(), sock.getOutputStream());
  
                  SocketStreamServerConnection sssc = new 
SocketStreamServerConnection(this, sock,
                                                          sock.getInputStream(),
                                                          sock.getOutputStream(), 
ssrw);
  
                  sssc.run();
              }
          } catch (IOException ioe) {
              System.err.println("Some problem connecting client via sockets.");
              ioe.printStackTrace();
          }
      }
  
      /**
       * Method start
       *
       */
      public void start() {
          mState = STARTED;
      }
  
      /**
       * Method stop
       *
       */
      public void stop() {
  
          mState = SHUTTINGDOWN;
  
          killAllConnections();
  
          mState = STOPPED;
      }
  }
  
  
  
  1.4       +4 -4      
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/DirectMarshalledTest.java
  
  Index: DirectMarshalledTest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/DirectMarshalledTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DirectMarshalledTest.java 29 Jan 2002 10:42:18 -0000      1.3
  +++ DirectMarshalledTest.java 4 Feb 2002 12:29:03 -0000       1.4
  @@ -10,8 +10,8 @@
   
   
   import org.apache.commons.altrmi.server.impl.direct.DirectServer;
  -import org.apache.commons.altrmi.server.impl.adapters.InovcationHandlerAdapter;
  -import 
org.apache.commons.altrmi.server.impl.adapters.MarshalledInovcationHandlerAdapter;
  +import org.apache.commons.altrmi.server.impl.adapters.InvocationHandlerAdapter;
  +import 
org.apache.commons.altrmi.server.impl.adapters.MarshalledInvocationHandlerAdapter;
   import org.apache.commons.altrmi.server.impl.direct.DirectMarshalledServer;
   import org.apache.commons.altrmi.server.impl.classretrievers.JarFileClassRetriever;
   import org.apache.commons.altrmi.common.AltrmiInvocationHandler;
  @@ -32,7 +32,7 @@
    *
    *
    * @author Paul Hammant <a 
href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public class DirectMarshalledTest {
   
  @@ -73,7 +73,7 @@
        *
        *
        * @author Paul Hammant <a 
href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>
  -     * @version $Revision: 1.3 $
  +     * @version $Revision: 1.4 $
        */
       static class DirectMarshalledTestClient implements Runnable {
   
  
  
  
  1.10      +3 -3      
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/DirectTest.java
  
  Index: DirectTest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/test/DirectTest.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DirectTest.java   29 Jan 2002 10:05:00 -0000      1.9
  +++ DirectTest.java   4 Feb 2002 12:29:03 -0000       1.10
  @@ -10,7 +10,7 @@
   
   
   import org.apache.commons.altrmi.server.impl.direct.DirectServer;
  -import org.apache.commons.altrmi.server.impl.adapters.InovcationHandlerAdapter;
  +import org.apache.commons.altrmi.server.impl.adapters.InvocationHandlerAdapter;
   import org.apache.commons.altrmi.server.impl.classretrievers.JarFileClassRetriever;
   import org.apache.commons.altrmi.common.AltrmiInvocationHandler;
   import org.apache.commons.altrmi.common.AltrmiConnectionException;
  @@ -28,7 +28,7 @@
    *
    *
    * @author Paul Hammant <a 
href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>
  - * @version $Revision: 1.9 $
  + * @version $Revision: 1.10 $
    */
   public class DirectTest {
   
  @@ -69,7 +69,7 @@
        *
        *
        * @author Paul Hammant <a 
href="mailto:[EMAIL PROTECTED]";>[EMAIL PROTECTED]</a>
  -     * @version $Revision: 1.9 $
  +     * @version $Revision: 1.10 $
        */
       static class DirectTestClient implements Runnable {
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to