You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by ha...@apache.org on 2003/01/05 19:10:53 UTC

cvs commit: jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/stream ClientObjectStreamReadWriter.java

hammant     2003/01/05 10:10:53

  Modified:    altrmi/src/java/org/apache/excalibur/altrmi/client/impl/socket
                        AbstractSocketStreamSSHInvocationHandler.java
                        AltrmiUserInfo.java
                        SocketCustomStreamSSHHostContext.java
                        SocketCustomStreamSSHInvocationHandler.java
               altrmi/src/java/org/apache/excalibur/altrmi/client/impl/stream
                        ClientObjectStreamReadWriter.java
  Added:       altrmi/src/java/org/apache/excalibur/altrmi/client/impl/socket
                        SocketObjectStreamSSHHostContext.java
                        SocketObjectStreamSSHInvocationHandler.java
  Log:
  ObjectStream has SSH form now. Small typos and some JavaDocs fixed.
  
  Revision  Changes    Path
  1.2       +9 -2      jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/socket/AbstractSocketStreamSSHInvocationHandler.java
  
  Index: AbstractSocketStreamSSHInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/socket/AbstractSocketStreamSSHInvocationHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractSocketStreamSSHInvocationHandler.java	5 Jan 2003 11:41:40 -0000	1.1
  +++ AbstractSocketStreamSSHInvocationHandler.java	5 Jan 2003 18:10:53 -0000	1.2
  @@ -15,7 +15,6 @@
   import org.apache.excalibur.altrmi.client.impl.ClientStreamReadWriter;
   import org.apache.excalibur.altrmi.client.impl.stream.StreamInvocationHandler;
   import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
  -import org.apache.excalibur.altrmi.common.ConnectionRefusedException;
   import com.jcraft.jsch.JSch;
   import com.jcraft.jsch.Session;
   import com.jcraft.jsch.JSchException;
  @@ -24,6 +23,12 @@
   /**
    * Class SocketCustomStreamInvocationHandler
    *
  + * JSch :- http://www.jcraft.com/jsch/
  + * "JSch is a pure Java implementation of SSH2.
  + * JSch allows you to connect to an sshd server and use port forwarding,
  + * X11 forwarding, file transfer, etc., and you can integrate its functionality
  + * into your own Java programs. JSch is licensed under GNU LGPL."
  + * LGPL :- http://www.gnu.org/copyleft/lesser.txt
    *
    * @author Paul Hammant
    * @version $Revision$
  @@ -42,6 +47,8 @@
        *
        * @param host The host to connect to
        * @param port The port to conenct to
  +     * @param userID The user ID to use for the SSH authentiaction
  +     * @param password The password to use for SSH Authentication
        * @param classLoader The class loader
        *
        * @throws AltrmiConnectionException If a problem connecting
  
  
  
  1.2       +12 -1     jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/socket/AltrmiUserInfo.java
  
  Index: AltrmiUserInfo.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/socket/AltrmiUserInfo.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AltrmiUserInfo.java	5 Jan 2003 11:41:40 -0000	1.1
  +++ AltrmiUserInfo.java	5 Jan 2003 18:10:53 -0000	1.2
  @@ -12,6 +12,12 @@
   /**
    * Class AltrmiUserInfo
    *
  + * JSch :- http://www.jcraft.com/jsch/
  + * "JSch is a pure Java implementation of SSH2.
  + * JSch allows you to connect to an sshd server and use port forwarding,
  + * X11 forwarding, file transfer, etc., and you can integrate its functionality
  + * into your own Java programs. JSch is licensed under GNU LGPL."
  + * LGPL :- http://www.gnu.org/copyleft/lesser.txt
    *
    * @author Paul Hammant
    * @version $Revision$
  @@ -21,6 +27,11 @@
       private String m_userID;
       private String m_password;
   
  +    /**
  +     *
  +     * @param userID The user ID to use for the SSH authentiaction
  +     * @param password The password to use for SSH Authentication
  +     */
       public AltrmiUserInfo(String userID, String password)
       {
           m_userID = userID;
  
  
  
  1.2       +7 -3      jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/socket/SocketCustomStreamSSHHostContext.java
  
  Index: SocketCustomStreamSSHHostContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/socket/SocketCustomStreamSSHHostContext.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SocketCustomStreamSSHHostContext.java	5 Jan 2003 11:41:40 -0000	1.1
  +++ SocketCustomStreamSSHHostContext.java	5 Jan 2003 18:10:53 -0000	1.2
  @@ -29,11 +29,13 @@
       private int m_port;
   
       /**
  -     * Constructor SocketCustomStreamHostContext
  +     * Constructor SocketCustomStreamSSHHostContext
        *
        *
        * @param host
        * @param port
  +     * @param userID The user ID to use for the SSH authentiaction
  +     * @param password The password to use for SSH Authentication
        *
        * @throws AltrmiConnectionException
        *
  @@ -48,11 +50,13 @@
       }
   
       /**
  -     * Constructor SocketCustomStreamHostContext
  +     * Constructor SocketCustomStreamSSHHostContext
        *
        *
        * @param host
        * @param port
  +     * @param userID The user ID to use for the SSH authentiaction
  +     * @param password The password to use for SSH Authentication
        * @param classLoader
        *
        * @throws AltrmiConnectionException
  
  
  
  1.2       +5 -5      jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/socket/SocketCustomStreamSSHInvocationHandler.java
  
  Index: SocketCustomStreamSSHInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/socket/SocketCustomStreamSSHInvocationHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SocketCustomStreamSSHInvocationHandler.java	5 Jan 2003 11:41:40 -0000	1.1
  +++ SocketCustomStreamSSHInvocationHandler.java	5 Jan 2003 18:10:53 -0000	1.2
  @@ -14,7 +14,7 @@
   import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
   
   /**
  - * Class SocketCustomStreamInvocationHandler
  + * Class SocketCustomStreamSSHInvocationHandler
    *
    *
    * @author Paul Hammant
  @@ -25,13 +25,13 @@
   {
   
       /**
  -     * Constructor SocketCustomStreamInvocationHandler
  +     * Constructor SocketCustomStreamSSHInvocationHandler
        *
        *
        * @param host the host name
        * @param port the port
  -     * @param userID the User ID
  -     * @param password the password
  +     * @param userID The user ID to use for the SSH authentiaction
  +     * @param password The password to use for SSH Authentication
        * @param classLoader the classloader for deserialization hints.
        *
        * @throws AltrmiConnectionException if a problem
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/socket/SocketObjectStreamSSHHostContext.java
  
  Index: SocketObjectStreamSSHHostContext.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.excalibur.altrmi.client.impl.socket;
  
  import org.apache.excalibur.altrmi.client.impl.piped.PipedCustomStreamHostContext;
  import org.apache.excalibur.altrmi.client.impl.AbstractSameVmBindableHostContext;
  import org.apache.excalibur.altrmi.client.impl.AbstractHostContext;
  import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
  
  import java.io.PipedInputStream;
  import java.io.PipedOutputStream;
  import java.lang.reflect.Method;
  
  /**
   * Class SocketObjectStreamSSHHostContext
   *
   *
   * @author Paul Hammant
   * @version $Revision: 1.1 $
   */
  public class SocketObjectStreamSSHHostContext extends AbstractSameVmBindableHostContext
  {
  
      private int m_port;
  
      /**
       * Constructor SocketObjectStreamSSHHostContext
       *
       *
       * @param host
       * @param port
       * @param userID The user ID to use for the SSH authentiaction
       * @param password The password to use for SSH Authentication
       *
       * @throws AltrmiConnectionException
       *
       */
      public SocketObjectStreamSSHHostContext( String host, int port, String userID, String password ) throws AltrmiConnectionException
      {
          this(host, port, userID, password, "java.io.ObjectInputStream", "java.io.ObjectOutputStream");
      }
  
      /**
       * Constructor SocketObjectStreamSSHHostContext
       *
       *
       * @param host
       * @param port
       * @param userID The user ID to use for the SSH authentiaction
       * @param password The password to use for SSH Authentication
       * @param objectInputStreamClassName
       * @param objectOutputStreamClassName
       *
       * @throws AltrmiConnectionException
       *
       */
      public SocketObjectStreamSSHHostContext( String host, int port, String userID, String password,
           String objectInputStreamClassName, String objectOutputStreamClassName) throws AltrmiConnectionException
      {
  
          super( new SocketObjectStreamSSHInvocationHandler( host, port, userID, password,
                  objectInputStreamClassName, objectOutputStreamClassName,
                                                          SocketObjectStreamSSHHostContext.class
                                                          .getClassLoader() ) );
          m_port = port;
      }
  
  
      /**
       * Constructor SocketCustomStreamHostContext
       *
       *
       * @param host
       * @param port
       * @param userID The user ID to use for the SSH authentiaction
       * @param password The password to use for SSH Authentication
       * @param objectInputStreamClassName
       * @param objectOutputStreamClassName
       * @param classLoader
       *
       * @throws AltrmiConnectionException
       *
       */
      public SocketObjectStreamSSHHostContext( String host, int port, String userID, String password,
          String objectInputStreamClassName, String objectOutputStreamClassName, ClassLoader classLoader )
          throws AltrmiConnectionException
      {
          super( new SocketObjectStreamSSHInvocationHandler( host, port, userID, password,
                  objectInputStreamClassName, objectOutputStreamClassName, classLoader ) );
          m_port = port;
      }
  
      /**
       * Make a HostContext for this using SameVM connections nstead of socket based ones.
       * @return the HostContext
       * @throws AltrmiConnectionException if a problem
       */
      public AbstractHostContext makeSameVmHostContext() throws AltrmiConnectionException
      {
          PipedInputStream in = new PipedInputStream();
          PipedOutputStream out = new PipedOutputStream();
          try
          {
              Object binder = getOptmization("port=" + m_port);
              if (binder == null)
              {
                  return null;
              }
              Object bound = bind(binder, in, out);
              if (bound == null)
              {
                  return null;
              }
              PipedCustomStreamHostContext pipedCustomStreamHostContext
                      = new PipedCustomStreamHostContext(in, out);
              pipedCustomStreamHostContext.initialize();
              return pipedCustomStreamHostContext;
          }
          catch (Exception e)
          {
              throw new AltrmiConnectionException("Naming exception during bind :" + e.getMessage());
          }
      }
  
      private Object bind(Object object, PipedInputStream inputStream,
                         PipedOutputStream outputStream)
      {
  
          try
          {
              Object[] parms = new Object[]{ inputStream, outputStream };
              Method method = object.getClass().getMethod("bind", new Class[] { parms.getClass() });
              return method.invoke(object, new Object[] { parms });
          }
          catch (Exception e)
          {
              return null;
          }
      }
  
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/socket/SocketObjectStreamSSHInvocationHandler.java
  
  Index: SocketObjectStreamSSHInvocationHandler.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.excalibur.altrmi.client.impl.socket;
  
  import java.io.InputStream;
  import java.io.OutputStream;
  import org.apache.excalibur.altrmi.client.impl.stream.ClientObjectStreamReadWriter;
  import org.apache.excalibur.altrmi.client.impl.ClientStreamReadWriter;
  import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
  
  /**
   * Class SocketObjectStreamSSHInvocationHandler
   *
   *
   * @author Paul Hammant
   * @version $Revision: 1.1 $
   */
  public final class SocketObjectStreamSSHInvocationHandler
      extends AbstractSocketStreamSSHInvocationHandler
  {
      private String m_objectInputStreamClassName;
      private String m_objectOutputStreamClassName;
  
      /**
       * Constructor SocketObjectStreamSSHInvocationHandler
       *
       *
       * @param host the host name
       * @param port the port
       * @param userID The user ID to use for the SSH authentiaction
       * @param password The password to use for SSH Authentication
       * @param objectInputStreamClassName
       * @param objectOutputStreamClassName
       * @param classLoader the classloader for deserialization hints.
       *
       * @throws AltrmiConnectionException if a problem
       *
       */
      public SocketObjectStreamSSHInvocationHandler( String host, int port, String userID,
                                                     String password,
                                                     String objectInputStreamClassName, String objectOutputStreamClassName,
                                                     ClassLoader classLoader )
          throws AltrmiConnectionException
      {
          super( host, port, userID, password, classLoader );
          m_objectInputStreamClassName = objectInputStreamClassName;
          m_objectOutputStreamClassName = objectOutputStreamClassName;
      }
  
      /**
       * Create a client stream read/writer
       * @param in the input stream
       * @param out the output stream
       * @return the read/writer
       * @throws AltrmiConnectionException if a problem
       */
      protected ClientStreamReadWriter createClientStreamReadWriter(
          InputStream in, OutputStream out ) throws AltrmiConnectionException
      {
          //TODO pass on classloader and use it during deserialization (PH).
  
          return new ClientObjectStreamReadWriter( in, out, m_objectOutputStreamClassName,
                  m_objectInputStreamClassName);
      }
  }
  
  
  
  1.8       +4 -2      jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/stream/ClientObjectStreamReadWriter.java
  
  Index: ClientObjectStreamReadWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/stream/ClientObjectStreamReadWriter.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ClientObjectStreamReadWriter.java	4 Jan 2003 22:17:19 -0000	1.7
  +++ ClientObjectStreamReadWriter.java	5 Jan 2003 18:10:53 -0000	1.8
  @@ -35,6 +35,7 @@
       private ObjectOutputStream m_objectOutputStream;
       private String m_objectOutputStreamClassName = "java.io.ObjectOutputStream";
       private String m_objectInputStreamClassName = "java.io.ObjectInputStream";
  +    private ClassLoader m_interfacesClassLoader;
   
       /**
        * Constructor ClientObjectStreamReadWriter
  @@ -49,7 +50,8 @@
        *
        */
       public ClientObjectStreamReadWriter(
  -        InputStream inputStream, OutputStream outputStream, String objectOutputStreamClassName, String objectInputStreamClassName )
  +        InputStream inputStream, OutputStream outputStream,
  +        String objectOutputStreamClassName, String objectInputStreamClassName)
           throws AltrmiConnectionException
       {
   
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>