commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject cvs commit: jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl ServerObjectStreamReadWriter.java
Date Fri, 18 Jan 2002 12:22:31 GMT
hammant     02/01/18 04:22:31

  Modified:    altrmi/src/java/org/apache/commons/altrmi/client/impl
                        ClientObjectStreamReadWriter.java
               altrmi/src/java/org/apache/commons/altrmi/client/impl/piped
                        PipedObjectStreamInvocationHandler.java
               altrmi/src/java/org/apache/commons/altrmi/client/impl/socket
                        AbstractSocketStreamInvocationHandler.java
                        SocketObjectStreamInvocationHandler.java
               altrmi/src/java/org/apache/commons/altrmi/server/impl
                        ServerObjectStreamReadWriter.java
  Log:
  Start of JSX compatability
  
  Revision  Changes    Path
  1.4       +26 -4     jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/ClientObjectStreamReadWriter.java
  
  Index: ClientObjectStreamReadWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/ClientObjectStreamReadWriter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ClientObjectStreamReadWriter.java	17 Jan 2002 17:48:45 -0000	1.3
  +++ ClientObjectStreamReadWriter.java	18 Jan 2002 12:22:31 -0000	1.4
  @@ -18,6 +18,7 @@
   import java.io.InputStream;
   import java.io.OutputStream;
   import java.io.IOException;
  +import java.lang.reflect.Constructor;
   
   
   /**
  @@ -25,12 +26,14 @@
    *
    *
    * @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 ClientObjectStreamReadWriter extends ClientStreamReadWriter {
   
       private ObjectInputStream mObjectInputStream;
       private ObjectOutputStream mObjectOutputStream;
  +    private String mObjectOutputStreamClassName = "java.io.ObjectOutputStream";
  +    private String mObjectInputStreamClassName = "java.io.ObjectInputStream";
   
       /**
        * Constructor ClientObjectStreamReadWriter
  @@ -38,14 +41,33 @@
        *
        * @param inputStream
        * @param outputStream
  +     * @param objectOutputStreamClassName
  +     * @param objectInputStreamClassName
        *
        * @throws IOException
        *
        */
  -    public ClientObjectStreamReadWriter(InputStream inputStream, OutputStream outputStream)
  +    public ClientObjectStreamReadWriter(InputStream inputStream, OutputStream outputStream,
String objectOutputStreamClassName, String objectInputStreamClassName)
               throws IOException {
  -        mObjectOutputStream = new ObjectOutputStream(outputStream);
  -        mObjectInputStream = new ObjectInputStream(inputStream);
  +        if (objectOutputStreamClassName != null) {
  +            mObjectOutputStreamClassName = objectOutputStreamClassName;
  +        }
  +        if (objectInputStreamClassName != null) {
  +            mObjectInputStreamClassName = objectInputStreamClassName;
  +        }
  +        try {
  +            Class clazz = Class.forName(mObjectOutputStreamClassName);
  +            Constructor con = clazz.getConstructor(new Class[] {OutputStream.class});
  +            mObjectOutputStream = (ObjectOutputStream) con.newInstance(new Object[] {outputStream});
  +
  +            clazz = Class.forName(mObjectInputStreamClassName);
  +            con = clazz.getConstructor(new Class[] {InputStream.class});
  +            mObjectInputStream = (ObjectInputStream) con.newInstance(new Object[] {inputStream});
  +
  +        } catch (Exception e) {
  +            e.printStackTrace();
  +            throw new IOException("Some problem instantiating ObjectStream classes: " +
e.getMessage());
  +        }
       }
   
       protected synchronized AltrmiReply postRequest(AltrmiRequest altrmiRequest)
  
  
  
  1.4       +2 -2      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/piped/PipedObjectStreamInvocationHandler.java
  
  Index: PipedObjectStreamInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/piped/PipedObjectStreamInvocationHandler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PipedObjectStreamInvocationHandler.java	17 Jan 2002 12:14:29 -0000	1.3
  +++ PipedObjectStreamInvocationHandler.java	18 Jan 2002 12:22:31 -0000	1.4
  @@ -26,7 +26,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 final class PipedObjectStreamInvocationHandler
           extends AbstractPipedStreamInvocationHandler {
  @@ -49,6 +49,6 @@
   
       protected ClientStreamReadWriter createClientStreamReadWriter(
               InputStream in, OutputStream out) throws IOException {
  -        return new ClientObjectStreamReadWriter(in, out);
  +        return new ClientObjectStreamReadWriter(in, out, null, null);
       }
   }
  
  
  
  1.4       +2 -2      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/socket/AbstractSocketStreamInvocationHandler.java
  
  Index: AbstractSocketStreamInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/socket/AbstractSocketStreamInvocationHandler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractSocketStreamInvocationHandler.java	17 Jan 2002 17:48:46 -0000	1.3
  +++ AbstractSocketStreamInvocationHandler.java	18 Jan 2002 12:22:31 -0000	1.4
  @@ -30,7 +30,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 abstract class AbstractSocketStreamInvocationHandler extends StreamInvocationHandler
{
   
  @@ -76,7 +76,7 @@
           try {
               Socket socket = new Socket(mHost, mPort);
   
  -            setObjectReadWriter(new ClientObjectStreamReadWriter(socket.getInputStream(),
  +            setObjectReadWriter(createClientStreamReadWriter(socket.getInputStream(),
                                                                    socket.getOutputStream()));
   
               return true;
  
  
  
  1.5       +2 -2      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/socket/SocketObjectStreamInvocationHandler.java
  
  Index: SocketObjectStreamInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/socket/SocketObjectStreamInvocationHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SocketObjectStreamInvocationHandler.java	17 Jan 2002 12:14:29 -0000	1.4
  +++ SocketObjectStreamInvocationHandler.java	18 Jan 2002 12:22:31 -0000	1.5
  @@ -24,7 +24,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 final class SocketObjectStreamInvocationHandler
           extends AbstractSocketStreamInvocationHandler {
  @@ -49,6 +49,6 @@
   
       protected ClientStreamReadWriter createClientStreamReadWriter(
               InputStream in, OutputStream out) throws IOException {
  -        return new ClientObjectStreamReadWriter(in, out);
  +        return new ClientObjectStreamReadWriter(in, out, null, null);
       }
   }
  
  
  
  1.4       +26 -3     jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/ServerObjectStreamReadWriter.java
  
  Index: ServerObjectStreamReadWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/ServerObjectStreamReadWriter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ServerObjectStreamReadWriter.java	17 Jan 2002 17:48:46 -0000	1.3
  +++ ServerObjectStreamReadWriter.java	18 Jan 2002 12:22:31 -0000	1.4
  @@ -18,6 +18,8 @@
   import java.io.InputStream;
   import java.io.OutputStream;
   import java.io.IOException;
  +import java.lang.reflect.Constructor;
  +import java.lang.reflect.InvocationTargetException;
   
   
   /**
  @@ -25,16 +27,37 @@
    *
    *
    * @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 ServerObjectStreamReadWriter extends ServerStreamReadWriter {
   
       private ObjectInputStream mObjectInputStream;
       private ObjectOutputStream mObjectOutputStream;
  +    private String mObjectOutputStreamClassName = "java.io.ObjectOutputStream";
  +    private String mObjectInputStreamClassName = "java.io.ObjectInputStream";
  +
  +    public ServerObjectStreamReadWriter() {
  +    }
  +
  +    public ServerObjectStreamReadWriter(String objectOutputStreamClassName, String objectInputStreamClassName)
{
  +        mObjectOutputStreamClassName = objectOutputStreamClassName;
  +        mObjectInputStreamClassName = objectInputStreamClassName;
  +    }
   
       protected void initialize() throws IOException {
  -        mObjectInputStream = new ObjectInputStream(mInputStream);
  -        mObjectOutputStream = new ObjectOutputStream(mOutputStream);
  +        try {
  +            Class clazz = Class.forName(mObjectInputStreamClassName);
  +            Constructor con = clazz.getConstructor(new Class[] {InputStream.class});
  +            mObjectInputStream = (ObjectInputStream) con.newInstance(new Object[] {mInputStream});
  +
  +            clazz = Class.forName(mObjectOutputStreamClassName);
  +            con = clazz.getConstructor(new Class[] {OutputStream.class});
  +            mObjectOutputStream = (ObjectOutputStream) con.newInstance(new Object[] {mOutputStream});
  +        } catch (Exception e) {
  +            e.printStackTrace();
  +            throw new IOException("Some problem instantiating ObjectStream classes: " +
e.getMessage());
  +        }
  +
       }
   
       protected synchronized AltrmiRequest writeReplyAndGetRequest(AltrmiReply altrmiReply)
throws IOException, ClassNotFoundException {
  
  
  

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