hammant 02/01/16 09:59:23
Modified: altrmi/src/java/org/apache/commons/altrmi/client/impl/piped
PipedObjectStreamInvocationHandler.java
altrmi/src/java/org/apache/commons/altrmi/client/impl/socket
SocketObjectStreamHostContext.java
altrmi/src/java/org/apache/commons/altrmi/server/impl
DefaultAuthenticator.java
DefaultInvocationHandler.java
altrmi/src/java/org/apache/commons/altrmi/server/impl/piped
PipedObjectStreamServerConnection.java
PipedServer.java
altrmi/src/java/org/apache/commons/altrmi/server/impl/socket
CompleteSocketObjectStreamServer.java
SocketObjectStreamServerConnection.java
Added: altrmi/src/java/org/apache/commons/altrmi/client/impl
ClientCustomStreamReadWriter.java
ClientObjectReadWriter.java
ClientObjectStreamReadWriter.java
StreamInvocationHandler.java
altrmi/src/java/org/apache/commons/altrmi/client/impl/piped
AbstractPipedStreamInvocationHandler.java
PipedCustomStreamInvocationHandler.java
altrmi/src/java/org/apache/commons/altrmi/client/impl/socket
AbstractSocketStreamInvocationHandler.java
SocketCustomStreamInvocationHandler.java
altrmi/src/java/org/apache/commons/altrmi/server/impl
ServerCustomStreamReadWriter.java
ServerObjectReadWriter.java
ServerObjectStreamReadWriter.java
StreamServerConnection.java
Removed: altrmi/src/java/org/apache/commons/altrmi/client/impl
ObjectStreamInvocationHandler.java
altrmi/src/java/org/apache/commons/altrmi/client/impl/socket
SocketObjectStreamInvocationHandler.java
altrmi/src/java/org/apache/commons/altrmi/server/impl
ObjectStreamServerConnection.java
Log:
start of custom streaming transport plus renames to support same
Revision Changes Path
1.1
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/ClientCustomStreamReadWriter.java
Index: ClientCustomStreamReadWriter.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.client.impl;
import org.apache.commons.altrmi.common.AltrmiRequest;
import org.apache.commons.altrmi.common.AltrmiReply;
import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class ClientCustomStreamReadWriter extends ClientObjectReadWriter {
private ByteArrayOutputStream mBAOS = new ByteArrayOutputStream();
private ObjectOutputStream mObjectOutputStream;
private DataInputStream mDataInputStream;
private DataOutputStream mDataOutputStream;
public ClientCustomStreamReadWriter(InputStream inputStream, OutputStream
outputStream) throws IOException {
mDataOutputStream = new DataOutputStream(outputStream);
mDataInputStream = new DataInputStream(inputStream);
mObjectOutputStream = new ObjectOutputStream(mBAOS);
}
protected void writeRequest(AltrmiRequest altrmiRequest) throws IOException {
mObjectOutputStream.writeObject(altrmiRequest);
mObjectOutputStream.flush();
byte[] aBytes = mBAOS.toByteArray();
mObjectOutputStream.reset();
System.out.println("CLT Writing " + aBytes.length);
System.out.flush();
mDataOutputStream.write(aBytes.length);
mDataOutputStream.write(aBytes);
mDataOutputStream.flush();
}
protected AltrmiReply readReply() throws IOException, ClassNotFoundException {
int byteArraySize = mDataInputStream.readInt();
System.out.println("CLT Reading " + byteArraySize);
System.out.flush();
byte[] byteArray = new byte[byteArraySize];
mDataInputStream.read(byteArray);
ByteArrayInputStream bAIS = new ByteArrayInputStream(byteArray);
ObjectInputStream oOs = new ObjectInputStream(bAIS);
return (AltrmiReply) oOs.readObject();
}
}
1.1
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/ClientObjectReadWriter.java
Index: ClientObjectReadWriter.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.client.impl;
import org.apache.commons.altrmi.common.AltrmiRequest;
import org.apache.commons.altrmi.common.AltrmiReply;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
public abstract class ClientObjectReadWriter {
protected abstract void writeRequest(AltrmiRequest altrmiRequest) throws
IOException;
protected abstract AltrmiReply readReply() throws IOException,
ClassNotFoundException;
}
1.1
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/ClientObjectStreamReadWriter.java
Index: ClientObjectStreamReadWriter.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.client.impl;
import org.apache.commons.altrmi.common.AltrmiRequest;
import org.apache.commons.altrmi.common.AltrmiReply;
import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
public class ClientObjectStreamReadWriter extends ClientObjectReadWriter {
private ObjectInputStream mObjectInputStream;
private ObjectOutputStream mObjectOutputStream;
public ClientObjectStreamReadWriter(InputStream inputStream, OutputStream
outputStream) throws IOException {
mObjectOutputStream = new ObjectOutputStream(outputStream);
mObjectInputStream = new ObjectInputStream(inputStream);
}
protected void writeRequest(AltrmiRequest altrmiRequest) throws IOException {
mObjectOutputStream.writeObject(altrmiRequest);
mObjectOutputStream.flush();
//mObjectOutputStream.reset();
}
protected AltrmiReply readReply() throws IOException, ClassNotFoundException {
return (AltrmiReply) mObjectInputStream.readObject();
}
}
1.1
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/StreamInvocationHandler.java
Index: StreamInvocationHandler.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.client.impl;
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.MethodRequest;
import org.apache.commons.altrmi.common.AltrmiInvocationException;
import org.apache.commons.altrmi.common.TryLaterReply;
import org.apache.commons.altrmi.common.NotPublishedReply;
import org.apache.commons.altrmi.common.NotPublishedException;
import org.apache.commons.altrmi.common.PublishedNameRequest;
import org.apache.commons.altrmi.common.NoSuchReferenceReply;
import org.apache.commons.altrmi.common.NotSuchReferenceException;
import org.apache.commons.altrmi.client.AltrmiConnectionListener;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.io.EOFException;
import java.net.SocketException;
/**
* Class StreamInvocationHandler
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
* @version $Revision: 1.1 $
*/
public abstract class StreamInvocationHandler extends AltrmiClientInvocationHandler {
//private ObjectInputStream mOIS;
//private ObjectOutputStream mOOS;
private ClientObjectReadWriter mObjectReadWriter;
private boolean mMethodLogging = false;
/**
* Method setAltrmiConnectionListener
*
*
* @param altrmiConnectionListener
*
*/
public void setAltrmiConnectionListener(AltrmiConnectionListener
altrmiConnectionListener) {
super.setAltrmiConnectionListener(altrmiConnectionListener);
mMethodLogging = altrmiConnectionListener.methodLogging();
}
protected void setObjectReadWriter(ClientObjectReadWriter objectReadWriter) {
mObjectReadWriter = objectReadWriter;
}
protected void requestWritten() {}
/**
* Method handleInvocation
*
*
* @param request
*
* @return
*
*/
public synchronized AltrmiReply handleInvocation(AltrmiRequest request) {
try {
while (true) {
boolean again = true;
AltrmiReply reply = null;
int tries = 0;
long start = 0;
if (mMethodLogging) {
start = System.currentTimeMillis();
}
while (again) {
tries++;
again = false;
try {
long t1 = System.currentTimeMillis();
mObjectReadWriter.writeRequest(request);
reply = (AltrmiReply) mObjectReadWriter.readReply();
long t2 = System.currentTimeMillis();
if (reply.getReplyCode() >= 100) {
if (reply instanceof TryLaterReply) {
int millis = ((TryLaterReply)
reply).getSuggestedDelayMillis();
mAltrmiConnectionListener.serviceSuspended(request,tries,millis);
again = true;
} else if (reply instanceof NoSuchReferenceReply) {
throw new NotSuchReferenceException();
} else if (reply instanceof NotPublishedReply) {
PublishedNameRequest pnr = (PublishedNameRequest)
request;
throw new
NotPublishedException(pnr.getPublishedServiceName(),pnr.getObjectName());
}
}
} catch (IOException ioe) {
if (ioe instanceof SocketException | ioe instanceof
EOFException) {
int retryConnectTries = 0;
while (!tryReconnect()) {
mAltrmiConnectionListener.serviceAbend(retryConnectTries);
retryConnectTries++;
}
} else {
ioe.printStackTrace();
throw new AltrmiInvocationException("IO Exception during
invocation to server :"
+ ioe.getMessage());
}
}
}
if (mMethodLogging) {
if (request instanceof MethodRequest) {
mAltrmiConnectionListener.methodCalled(((MethodRequest)
request).getMethodSignature(), System.currentTimeMillis() - start);
}
}
return reply;
}
} catch (ClassNotFoundException e) {
throw new AltrmiInvocationException("Class definition missing on
Deserialization"
+ e.getMessage());
}
}
}
1.2 +9 -27
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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PipedObjectStreamInvocationHandler.java 10 Jan 2002 00:08:58 -0000 1.1
+++ PipedObjectStreamInvocationHandler.java 16 Jan 2002 17:59:23 -0000 1.2
@@ -7,28 +7,23 @@
*/
package org.apache.commons.altrmi.client.impl.piped;
-
-
-import org.apache.commons.altrmi.client.impl.ObjectStreamInvocationHandler;
-import org.apache.commons.altrmi.common.AltrmiConnectionException;
import org.apache.commons.altrmi.common.AltrmiPipeConnector;
-import org.apache.commons.altrmi.common.AltrmiInvocationException;
+import org.apache.commons.altrmi.common.AltrmiConnectionException;
+import org.apache.commons.altrmi.client.impl.ClientObjectReadWriter;
+import org.apache.commons.altrmi.client.impl.ClientObjectStreamReadWriter;
-import java.io.PipedOutputStream;
-import java.io.PipedInputStream;
-import java.io.ObjectOutputStream;
-import java.io.ObjectInputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.io.IOException;
-
/**
* Class PipedObjectStreamInvocationHandler
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
-public final class PipedObjectStreamInvocationHandler extends
ObjectStreamInvocationHandler {
+public final class PipedObjectStreamInvocationHandler extends
AbstractPipedStreamInvocationHandler {
/**
* Constructor PipedObjectStreamInvocationHandler
@@ -40,23 +35,10 @@
*
*/
public PipedObjectStreamInvocationHandler(AltrmiPipeConnector apc) throws
AltrmiConnectionException {
-
- try {
- PipedOutputStream pOS = new PipedOutputStream();
- PipedInputStream pIS = apc.connect(pOS);
- ObjectOutputStream oOS = new ObjectOutputStream(pOS);
- ObjectInputStream oIS = new ObjectInputStream(pIS);
-
- setObjectInputStream(oIS);
- setObjectOutputStream(oOS);
- } catch (IOException ioe) {
- throw new AltrmiConnectionException("Cannot bind the pipes together :"
- + ioe.getMessage());
- }
+ super(apc);
}
- protected boolean tryReconnect() {
- // blimey how do we reconnect this?
- throw new AltrmiInvocationException("Piped connection broken, unable to
reconnect.");
+ protected ClientObjectReadWriter createClientObjectReadWriter(InputStream in,
OutputStream out) throws IOException {
+ return new ClientObjectStreamReadWriter(in,out);
}
}
1.1
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/piped/AbstractPipedStreamInvocationHandler.java
Index: AbstractPipedStreamInvocationHandler.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.client.impl.piped;
import org.apache.commons.altrmi.client.impl.StreamInvocationHandler;
import org.apache.commons.altrmi.client.impl.ClientCustomStreamReadWriter;
import org.apache.commons.altrmi.client.impl.ClientObjectStreamReadWriter;
import org.apache.commons.altrmi.client.impl.ClientObjectReadWriter;
import org.apache.commons.altrmi.common.AltrmiConnectionException;
import org.apache.commons.altrmi.common.AltrmiPipeConnector;
import org.apache.commons.altrmi.common.AltrmiInvocationException;
import java.io.PipedOutputStream;
import java.io.PipedInputStream;
import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.InputStream;
/**
* Class AbstractPipedStreamInvocationHandler
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
* @version $Revision: 1.1 $
*/
public abstract class AbstractPipedStreamInvocationHandler extends
StreamInvocationHandler {
/**
* Constructor AbstractPipedStreamInvocationHandler
*
*
* @param apc
*
* @throws AltrmiConnectionException
*
*/
public AbstractPipedStreamInvocationHandler(AltrmiPipeConnector apc) throws
AltrmiConnectionException {
try {
PipedOutputStream pOS = new PipedOutputStream();
PipedInputStream pIS = apc.connect(pOS);
setObjectReadWriter(createClientObjectReadWriter(pIS, pOS));
} catch (IOException ioe) {
throw new AltrmiConnectionException("Cannot bind the pipes together :"
+ ioe.getMessage());
}
}
protected boolean tryReconnect() {
// blimey how do we reconnect this?
throw new AltrmiInvocationException("Piped connection broken, unable to
reconnect.");
}
protected abstract ClientObjectReadWriter
createClientObjectReadWriter(InputStream in, OutputStream out) throws IOException;
}
1.1
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/piped/PipedCustomStreamInvocationHandler.java
Index: PipedCustomStreamInvocationHandler.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.client.impl.piped;
import org.apache.commons.altrmi.common.AltrmiPipeConnector;
import org.apache.commons.altrmi.common.AltrmiConnectionException;
import org.apache.commons.altrmi.client.impl.ClientObjectReadWriter;
import org.apache.commons.altrmi.client.impl.ClientCustomStreamReadWriter;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
/**
* Class PipedCustomStreamInvocationHandler
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
* @version $Revision: 1.1 $
*/
public final class PipedCustomStreamInvocationHandler extends
AbstractPipedStreamInvocationHandler {
/**
* Constructor PipedCustomStreamInvocationHandler
*
*
* @param apc
*
* @throws AltrmiConnectionException
*
*/
public PipedCustomStreamInvocationHandler(AltrmiPipeConnector apc) throws
AltrmiConnectionException {
super(apc);
}
protected ClientObjectReadWriter createClientObjectReadWriter(InputStream in,
OutputStream out) throws IOException {
return new ClientCustomStreamReadWriter(in,out);
}
}
1.2 +1 -1
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/socket/SocketObjectStreamHostContext.java
Index: SocketObjectStreamHostContext.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/socket/SocketObjectStreamHostContext.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SocketObjectStreamHostContext.java 10 Jan 2002 00:08:58 -0000 1.1
+++ SocketObjectStreamHostContext.java 16 Jan 2002 17:59:23 -0000 1.2
@@ -20,7 +20,7 @@
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class SocketObjectStreamHostContext extends AbstractAltrmiHostContext {
@@ -35,6 +35,6 @@
*
*/
public SocketObjectStreamHostContext(String host, int port) throws
AltrmiConnectionException {
- super(new SocketObjectStreamInvocationHandler(host, port));
+ super(new SocketCustomStreamInvocationHandler(host, port));
}
}
1.1
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/socket/AbstractSocketStreamInvocationHandler.java
Index: AbstractSocketStreamInvocationHandler.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.client.impl.socket;
import org.apache.commons.altrmi.client.impl.StreamInvocationHandler;
import org.apache.commons.altrmi.client.impl.ClientCustomStreamReadWriter;
import org.apache.commons.altrmi.client.impl.ClientObjectStreamReadWriter;
import org.apache.commons.altrmi.client.impl.ClientObjectReadWriter;
import org.apache.commons.altrmi.common.AltrmiConnectionException;
import java.net.Socket;
import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* Class SocketCustomStreamInvocationHandler
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
* @version $Revision: 1.1 $
*/
public abstract class AbstractSocketStreamInvocationHandler extends
StreamInvocationHandler {
private String mHost;
private int mPort;
/**
* Constructor SocketCustomStreamInvocationHandler
*
*
* @param host
* @param port
*
* @throws AltrmiConnectionException
*
*/
public AbstractSocketStreamInvocationHandler(String host, int port) throws
AltrmiConnectionException {
mHost = host;
mPort = port;
try {
Socket socket = new Socket(host, port);
setObjectReadWriter(createClientObjectReadWriter(socket.getInputStream(),
socket.getOutputStream()));
} catch (IOException ioe) {
throw new AltrmiConnectionException("Cannot open Stream(s) for socket");
}
}
/**
* Method tryReconnect
*
*
* @return connected or not.
*/
protected boolean tryReconnect() {
try {
Socket socket = new Socket(mHost, mPort);
ObjectOutputStream oOS = new
ObjectOutputStream(socket.getOutputStream());
ObjectInputStream oIS = new ObjectInputStream(socket.getInputStream());
setObjectReadWriter(new
ClientObjectStreamReadWriter(socket.getInputStream(), socket.getOutputStream()));
return true;
} catch (IOException ioe) {
return false;
}
}
protected abstract ClientObjectReadWriter
createClientObjectReadWriter(InputStream in, OutputStream out) throws IOException;
}
1.1
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/socket/SocketCustomStreamInvocationHandler.java
Index: SocketCustomStreamInvocationHandler.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.client.impl.socket;
import org.apache.commons.altrmi.common.AltrmiConnectionException;
import org.apache.commons.altrmi.client.impl.ClientObjectReadWriter;
import org.apache.commons.altrmi.client.impl.ClientCustomStreamReadWriter;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
/**
* Class SocketCustomStreamInvocationHandler
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
* @version $Revision: 1.1 $
*/
public final class SocketCustomStreamInvocationHandler extends
AbstractSocketStreamInvocationHandler {
private String mHost;
private int mPort;
/**
* Constructor SocketCustomStreamInvocationHandler
*
*
* @param host
* @param port
*
* @throws AltrmiConnectionException
*
*/
public SocketCustomStreamInvocationHandler(String host, int port) throws
AltrmiConnectionException {
super(host, port);
}
protected ClientObjectReadWriter createClientObjectReadWriter(InputStream in,
OutputStream out) throws IOException {
return new ClientCustomStreamReadWriter(in,out);
}
}
1.3 +2 -2
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/DefaultAuthenticator.java
Index: DefaultAuthenticator.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/DefaultAuthenticator.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultAuthenticator.java 15 Jan 2002 01:15:24 -0000 1.2
+++ DefaultAuthenticator.java 16 Jan 2002 17:59:23 -0000 1.3
@@ -20,7 +20,7 @@
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class DefaultAuthenticator implements AltrmiAuthenticator {
@@ -43,7 +43,7 @@
// approve everything and set session identifier.
- return new Long (( SESSION++ * (2^31) ) + Math.round(Math.random()));
+ return new Long ((long) ( (long) SESSION++ << 32 ) + (long)
Math.round(Math.random()));
}
/**
1.4 +2 -2
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/DefaultInvocationHandler.java
Index: DefaultInvocationHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/DefaultInvocationHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultInvocationHandler.java 16 Jan 2002 11:32:20 -0000 1.3
+++ DefaultInvocationHandler.java 16 Jan 2002 17:59:23 -0000 1.4
@@ -35,7 +35,7 @@
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public class DefaultInvocationHandler implements AltrmiServerInvocationHandler {
@@ -108,7 +108,7 @@
public Long getOrMakeReferenceIDForBean(Object implBean) {
Long ref = (Long) mBeanRefs.get(implBean);
if (ref == null) {
- ref = new Long( (mNextReference++ * (2^31) ) +
Math.round(Math.random()) );
+ ref = new Long( (long) ((long) mNextReference++ << 32 ) + (long)
Math.round(Math.random()) );
mBeanRefs.put(implBean, ref);
mRefBeans.put(ref,implBean);
}
1.1
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/ServerCustomStreamReadWriter.java
Index: ServerCustomStreamReadWriter.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;
import org.apache.commons.altrmi.common.AltrmiRequest;
import org.apache.commons.altrmi.common.AltrmiReply;
import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class ServerCustomStreamReadWriter extends ServerObjectReadWriter {
private ByteArrayOutputStream mBAOS = new ByteArrayOutputStream();
private ObjectOutputStream mObjectOutputStream;
private DataInputStream mDataInputStream;
private DataOutputStream mDataOutputStream;
protected ServerCustomStreamReadWriter(InputStream inputStream, OutputStream
outputStream) throws IOException {
mDataInputStream = new DataInputStream(inputStream);
mDataOutputStream = new DataOutputStream(outputStream);
mObjectOutputStream = new ObjectOutputStream(mBAOS);
}
protected void writeReply(AltrmiReply altrmiReply) throws IOException {
mObjectOutputStream.writeObject(altrmiReply);
mObjectOutputStream.flush();
byte[] aBytes = mBAOS.toByteArray();
mObjectOutputStream.reset();
System.out.println("SVR Writing " + aBytes.length);
System.out.flush();
mDataOutputStream.write(aBytes.length);
mDataOutputStream.write(aBytes);
mDataOutputStream.flush();
}
protected AltrmiRequest readRequest() throws IOException, ClassNotFoundException
{
int byteArraySize = mDataInputStream.readInt();
System.out.println("SVR Reading1 " + byteArraySize);
int byteArraySize2 = mDataInputStream.readInt();
System.out.println("SVR Reading2 " + byteArraySize2);
System.out.flush();
byte[] byteArray = new byte[byteArraySize];
mDataInputStream.read(byteArray);
ByteArrayInputStream bAIS = new ByteArrayInputStream(byteArray);
ObjectInputStream oOs = new ObjectInputStream(bAIS);
return (AltrmiRequest) oOs.readObject();
}
}
1.1
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/ServerObjectReadWriter.java
Index: ServerObjectReadWriter.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;
import org.apache.commons.altrmi.common.AltrmiRequest;
import org.apache.commons.altrmi.common.AltrmiReply;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
public abstract class ServerObjectReadWriter {
protected abstract void writeReply(AltrmiReply altrmiReply) throws IOException;
protected abstract AltrmiRequest readRequest() throws IOException,
ClassNotFoundException;
}
1.1
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/ServerObjectStreamReadWriter.java
Index: ServerObjectStreamReadWriter.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;
import org.apache.commons.altrmi.common.AltrmiRequest;
import org.apache.commons.altrmi.common.AltrmiReply;
import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
public class ServerObjectStreamReadWriter extends ServerObjectReadWriter {
private ObjectInputStream mObjectInputStream;
private ObjectOutputStream mObjectOutputStream;
protected ServerObjectStreamReadWriter(InputStream inputStream, OutputStream
outputStream) throws IOException {
mObjectInputStream = new ObjectInputStream(inputStream);
mObjectOutputStream = new ObjectOutputStream(outputStream);
}
protected void writeReply(AltrmiReply altrmiReply) throws IOException {
mObjectOutputStream.writeObject(altrmiReply);
mObjectOutputStream.flush();
//mObjectOutputStream.reset();
}
protected AltrmiRequest readRequest() throws IOException, ClassNotFoundException
{
return (AltrmiRequest) mObjectInputStream.readObject();
}
}
1.1
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/StreamServerConnection.java
Index: StreamServerConnection.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;
import org.apache.commons.altrmi.common.AltrmiRequest;
import org.apache.commons.altrmi.common.AltrmiReply;
import org.apache.commons.altrmi.common.EndConnectionReply;
import org.apache.commons.altrmi.server.AltrmiServerConnection;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.InputStream;
import java.net.Socket;
import java.net.SocketException;
/**
* Class StreamServerConnection
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
* @version $Revision: 1.1 $
*/
public abstract class StreamServerConnection implements Runnable,
AltrmiServerConnection {
private InputStream mInputStream;
private OutputStream mOutputStream;
private AbstractServer mAbstractServer;
private boolean mEndConnection = false;
/**
* Constructor StreamServerConnection
*
*
* @param abstractServer
* @param inputStream
* @param outputStream
*
*/
public StreamServerConnection(AbstractServer abstractServer, InputStream
inputStream,
OutputStream outputStream) {
mAbstractServer = abstractServer;
mInputStream = inputStream;
mOutputStream = outputStream;
}
/**
* Method run
*
*
*/
public void run() {
mAbstractServer.connectionStart(this);
try {
ServerObjectReadWriter oRW = new
ServerObjectStreamReadWriter(mInputStream, mOutputStream);
boolean more = true;
while (more) {
try {
AltrmiRequest request = oRW.readRequest();
AltrmiReply reply = mAbstractServer.processRequest(request);
oRW.writeReply(reply);
//
http://developer.java.sun.com/developer/bugParade/bugs/4499841.html
// halves the performance though.
//oOS.reset();
if (mEndConnection) {
oRW.writeReply(new EndConnectionReply());
more = false;
}
} catch (IOException ioe) {
System.out.println("IOE in ObjStream");
ioe.printStackTrace();
// pipe closed?
more = false;
}
}
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
mAbstractServer.connectionCompleted(this);
}
/**
* Method endConnection
*
*
*/
public void endConnection() {
mEndConnection = true;
}
/**
* Method killConnection
*
*
*/
protected abstract void killConnection();
}
1.2 +2 -2
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/piped/PipedObjectStreamServerConnection.java
Index: PipedObjectStreamServerConnection.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/piped/PipedObjectStreamServerConnection.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PipedObjectStreamServerConnection.java 9 Jan 2002 19:25:56 -0000 1.1
+++ PipedObjectStreamServerConnection.java 16 Jan 2002 17:59:23 -0000 1.2
@@ -9,7 +9,7 @@
-import org.apache.commons.altrmi.server.impl.ObjectStreamServerConnection;
+import org.apache.commons.altrmi.server.impl.StreamServerConnection;
import org.apache.commons.altrmi.server.impl.AbstractServer;
import java.net.Socket;
@@ -26,9 +26,9 @@
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
-public class PipedObjectStreamServerConnection extends ObjectStreamServerConnection
{
+public class PipedObjectStreamServerConnection extends StreamServerConnection {
private PipedInputStream mPipedIn;
private PipedOutputStream mPipedOut;
1.2 +2 -2
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/piped/PipedServer.java
Index: PipedServer.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/piped/PipedServer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PipedServer.java 9 Jan 2002 19:25:56 -0000 1.1
+++ PipedServer.java 16 Jan 2002 17:59:23 -0000 1.2
@@ -10,7 +10,7 @@
import org.apache.commons.altrmi.server.impl.AbstractServer;
-import org.apache.commons.altrmi.server.impl.ObjectStreamServerConnection;
+import org.apache.commons.altrmi.server.impl.StreamServerConnection;
import org.apache.commons.altrmi.common.AltrmiPipeConnector;
import org.apache.commons.altrmi.common.AltrmiConnectionException;
@@ -24,7 +24,7 @@
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
public class PipedServer extends AbstractServer implements AltrmiPipeConnector {
1.3 +2 -2
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/socket/CompleteSocketObjectStreamServer.java
Index: CompleteSocketObjectStreamServer.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/socket/CompleteSocketObjectStreamServer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CompleteSocketObjectStreamServer.java 13 Jan 2002 10:30:23 -0000 1.2
+++ CompleteSocketObjectStreamServer.java 16 Jan 2002 17:59:23 -0000 1.3
@@ -12,7 +12,7 @@
import org.apache.commons.altrmi.server.AltrmiServer;
import org.apache.commons.altrmi.server.AltrmiServerException;
import org.apache.commons.altrmi.server.impl.AbstractServer;
-import org.apache.commons.altrmi.server.impl.ObjectStreamServerConnection;
+import org.apache.commons.altrmi.server.impl.StreamServerConnection;
import org.apache.commons.altrmi.common.AltrmiRequest;
import org.apache.commons.altrmi.common.AltrmiReply;
@@ -27,7 +27,7 @@
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class CompleteSocketObjectStreamServer extends AbstractServer implements
Runnable {
1.2 +2 -2
jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/socket/SocketObjectStreamServerConnection.java
Index: SocketObjectStreamServerConnection.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/socket/SocketObjectStreamServerConnection.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SocketObjectStreamServerConnection.java 9 Jan 2002 19:25:56 -0000 1.1
+++ SocketObjectStreamServerConnection.java 16 Jan 2002 17:59:23 -0000 1.2
@@ -9,7 +9,7 @@
-import org.apache.commons.altrmi.server.impl.ObjectStreamServerConnection;
+import org.apache.commons.altrmi.server.impl.StreamServerConnection;
import org.apache.commons.altrmi.server.impl.AbstractServer;
import java.net.Socket;
@@ -24,9 +24,9 @@
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
-public class SocketObjectStreamServerConnection extends
ObjectStreamServerConnection {
+public class SocketObjectStreamServerConnection extends StreamServerConnection {
private Socket mSocket;
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>