hammant 2002/12/12 16:09:15
Modified: altrmi build.xml
altrmi/src/java/org/apache/excalibur/altrmi/client/impl/callback/socket
CallbackEnabledSocketCustomStreamInvocationHandler.java
altrmi/src/java/org/apache/excalibur/altrmi/client/impl/callback/stream
CallbackEnabledClientCustomStreamReadWriter.java
altrmi/src/java/org/apache/excalibur/altrmi/client/impl/piped
AbstractPipedStreamInvocationHandler.java
PipedCustomStreamInvocationHandler.java
PipedObjectStreamInvocationHandler.java
altrmi/src/java/org/apache/excalibur/altrmi/client/impl/socket
AbstractSocketStreamInvocationHandler.java
SocketCustomStreamInvocationHandler.java
SocketObjectStreamInvocationHandler.java
altrmi/src/java/org/apache/excalibur/altrmi/client/impl/stream
ClientCustomStreamReadWriter.java
ClientObjectStreamReadWriter.java
StreamInvocationHandler.java
altrmi/src/java/org/apache/excalibur/altrmi/server/impl/callback/socket
CallbackServerClientReadWriter.java
altrmi/src/java/org/apache/excalibur/altrmi/server/impl/callback/stream
CallbackStreamInvocationHandler.java
Added: altrmi/src/java/org/apache/excalibur/altrmi/client/impl
ClientStreamReadWriter.java
altrmi/src/java/org/apache/excalibur/altrmi/client/impl/http
ClientHttpReadWriter.java
CustomHttpHostContext.java
CustomHttpInvocationHandler.java
altrmi/src/java/org/apache/excalibur/altrmi/server/impl/http
CustomHttpServlet.java
altrmi/src/test/org/apache/excalibur/altrmi/test/http
CustomHttpServletTestCase.java KludgeServlet.java
Log:
start of http transport by paul and charles lowell. Left half done as we were
pairing before turning into pumpkins.
Revision Changes Path
1.47 +50 -2 jakarta-avalon-excalibur/altrmi/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/altrmi/build.xml,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- build.xml 3 Dec 2002 00:19:56 -0000 1.46
+++ build.xml 13 Dec 2002 00:09:13 -0000 1.47
@@ -10,6 +10,10 @@
<property file="${user.home}/.ant.properties"/>
<property file="default.properties"/>
+
+ <property name ="jetty.rel" value="4.2.2"/>
+ <property name="jetty.jars.dir" value="${lib.dir}/jetty-jars"/>
+
<!-- Classpath for product -->
<path id="project.class.path">
<pathelement location="${build.classes}"/>
@@ -20,7 +24,9 @@
<pathelement location="${qdox.jar}"/>
<pathelement location="${jakarta-bcel.jar}"/>
<pathelement path="${java.class.path}"/>
- <pathelement path="lib/servlet.jar"/>
+<!-- <pathelement path="lib/servlet.jar"/>-->
+ <pathelement
path="jetty-download/Jetty-${jetty.rel}/Jetty-${jetty.rel}/lib/javax.servlet.jar"/>
+ <pathelement
path="jetty-download/Jetty-${jetty.rel}/Jetty-${jetty.rel}/lib/org.mortbay.jetty.jar"/>
</path>
<path id="tools.class.path">
@@ -82,7 +88,7 @@
<!-- Compiles the source code -->
- <target name="compile" depends="dependencies" description="Compiles the source
code">
+ <target name="compile" depends="dependencies,checkNecessaryJars"
description="Compiles the source code">
<mkdir dir="${build.classes}"/>
@@ -495,5 +501,47 @@
<target name="real-clean" depends="clean" description="Cleans up the project,
including distributions">
<delete dir="${dist.base}" />
</target>
+ <target name="checkJettyJars">
+ <condition property="jetty.present">
+ <available file="jetty-download/Jetty-${jetty.rel}.zip"/>
+ </condition>
+
+ </target>
+
+ <target name="checkNecessaryJars" depends="checkJettyJars"
unless="jetty.present">
+ <echo>****************************</echo>
+ <echo>* Please execute target *</echo>
+ <echo>* 'get-jetty' in *</echo>
+ <echo>* jetty.xml build file *</echo>
+ <echo>* to download six mega- *</echo>
+ <echo>* bytes of Jetty from *</echo>
+ <echo>* Sourceforge *</echo>
+ <echo>****************************</echo>
+
+ <fail message="Jetty needed. See above."/>
+
+ </target>
+
+
+ <target name="get-jetty">
+
+ <mkdir dir="jetty-download"/>
+
+ <get
src="http://unc.dl.sourceforge.net/sourceforge/jetty/Jetty-${jetty.rel}.zip"
+ dest="jetty-download/Jetty-${jetty.rel}.zip"
+ verbose="true"
+ usetimestamp="true"/>
+
+ <unzip src="jetty-download/Jetty-${jetty.rel}.zip"
dest="jetty-download/Jetty-${jetty.rel}" />
+
+ <delete file="${jetty.jars.dir}/*.jar"/>
+
+ <copy todir="${jetty.jars.dir}" flatten="true">
+ <fileset dir="jetty-download/Jetty-${jetty.rel}">
+ <include name="**/lib/*.jar"/>
+ </fileset>
+ </copy>
+
+ </target>
</project>
1.8 +2 -2
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/callback/socket/CallbackEnabledSocketCustomStreamInvocationHandler.java
Index: CallbackEnabledSocketCustomStreamInvocationHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/callback/socket/CallbackEnabledSocketCustomStreamInvocationHandler.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- CallbackEnabledSocketCustomStreamInvocationHandler.java 26 Oct 2002 14:10:48
-0000 1.7
+++ CallbackEnabledSocketCustomStreamInvocationHandler.java 13 Dec 2002 00:09:13
-0000 1.8
@@ -14,7 +14,7 @@
import org.apache.excalibur.altrmi.client.CallbackEnabledClientInvocationHandler;
import
org.apache.excalibur.altrmi.client.impl.callback.stream.CallbackEnabledClientCustomStreamReadWriter;
import
org.apache.excalibur.altrmi.client.impl.socket.AbstractSocketStreamInvocationHandler;
-import org.apache.excalibur.altrmi.client.impl.stream.ClientStreamReadWriter;
+import org.apache.excalibur.altrmi.client.impl.ClientStreamReadWriter;
import org.apache.excalibur.altrmi.common.AltrmiCallbackException;
import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
import org.apache.excalibur.altrmi.common.ExposedObjectProxy;
1.8 +5 -6
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/callback/stream/CallbackEnabledClientCustomStreamReadWriter.java
Index: CallbackEnabledClientCustomStreamReadWriter.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/callback/stream/CallbackEnabledClientCustomStreamReadWriter.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- CallbackEnabledClientCustomStreamReadWriter.java 26 Oct 2002 14:10:48 -0000
1.7
+++ CallbackEnabledClientCustomStreamReadWriter.java 13 Dec 2002 00:09:13 -0000
1.8
@@ -15,7 +15,7 @@
import java.io.OutputStream;
import java.io.EOFException;
import java.util.HashMap;
-import org.apache.excalibur.altrmi.client.impl.stream.ClientStreamReadWriter;
+import org.apache.excalibur.altrmi.client.impl.ClientStreamReadWriter;
import org.apache.excalibur.altrmi.common.AltrmiCallbackException;
import org.apache.excalibur.altrmi.common.AltrmiReply;
import org.apache.excalibur.altrmi.common.AltrmiRequest;
@@ -36,8 +36,7 @@
* @version $Revision$
*/
public class CallbackEnabledClientCustomStreamReadWriter
- extends ClientStreamReadWriter
- implements Runnable
+ implements ClientStreamReadWriter, Runnable
{
//Mutex to block the client till a reply reaches back from server
private Object m_replyLock = new Object();
@@ -96,7 +95,7 @@
{
readingInt = true;
- int byteArraySize = (int)m_dataInputStream.readInt();
+ int byteArraySize = m_dataInputStream.readInt();
readingInt = false;
byte[] byteArray = new byte[ byteArraySize ];
@@ -175,7 +174,7 @@
/*
* @see ClientStreamReadWriter#postRequest(AltrmiRequest)
*/
- protected AltrmiReply postRequest( AltrmiRequest altrmiRequest )
+ public AltrmiReply postRequest( AltrmiRequest altrmiRequest )
throws IOException, ClassNotFoundException
{
if( m_isStopped )
1.7 +2 -2
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/piped/AbstractPipedStreamInvocationHandler.java
Index: AbstractPipedStreamInvocationHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/piped/AbstractPipedStreamInvocationHandler.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AbstractPipedStreamInvocationHandler.java 26 Oct 2002 14:10:49 -0000 1.6
+++ AbstractPipedStreamInvocationHandler.java 13 Dec 2002 00:09:13 -0000 1.7
@@ -12,7 +12,7 @@
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
-import org.apache.excalibur.altrmi.client.impl.stream.ClientStreamReadWriter;
+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.AltrmiInvocationException;
1.5 +3 -2
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/piped/PipedCustomStreamInvocationHandler.java
Index: PipedCustomStreamInvocationHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/piped/PipedCustomStreamInvocationHandler.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PipedCustomStreamInvocationHandler.java 26 Oct 2002 14:10:49 -0000 1.4
+++ PipedCustomStreamInvocationHandler.java 13 Dec 2002 00:09:13 -0000 1.5
@@ -13,7 +13,8 @@
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import org.apache.excalibur.altrmi.client.impl.stream.ClientCustomStreamReadWriter;
-import org.apache.excalibur.altrmi.client.impl.stream.ClientStreamReadWriter;
+import org.apache.excalibur.altrmi.client.impl.ClientStreamReadWriter;
+import org.apache.excalibur.altrmi.client.impl.ClientStreamReadWriter;
import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
import org.apache.excalibur.altrmi.common.AltrmiReply;
import org.apache.excalibur.altrmi.common.AltrmiRequest;
1.4 +2 -2
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/piped/PipedObjectStreamInvocationHandler.java
Index: PipedObjectStreamInvocationHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/piped/PipedObjectStreamInvocationHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PipedObjectStreamInvocationHandler.java 26 Oct 2002 14:10:49 -0000 1.3
+++ PipedObjectStreamInvocationHandler.java 13 Dec 2002 00:09:13 -0000 1.4
@@ -13,7 +13,7 @@
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import org.apache.excalibur.altrmi.client.impl.stream.ClientObjectStreamReadWriter;
-import org.apache.excalibur.altrmi.client.impl.stream.ClientStreamReadWriter;
+import org.apache.excalibur.altrmi.client.impl.ClientStreamReadWriter;
import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
/**
1.5 +2 -2
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/socket/AbstractSocketStreamInvocationHandler.java
Index: AbstractSocketStreamInvocationHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/socket/AbstractSocketStreamInvocationHandler.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AbstractSocketStreamInvocationHandler.java 26 Oct 2002 14:10:49 -0000
1.4
+++ AbstractSocketStreamInvocationHandler.java 13 Dec 2002 00:09:14 -0000
1.5
@@ -11,7 +11,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
-import org.apache.excalibur.altrmi.client.impl.stream.ClientStreamReadWriter;
+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;
1.5 +2 -2
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/socket/SocketCustomStreamInvocationHandler.java
Index: SocketCustomStreamInvocationHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/socket/SocketCustomStreamInvocationHandler.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SocketCustomStreamInvocationHandler.java 26 Oct 2002 14:10:49 -0000 1.4
+++ SocketCustomStreamInvocationHandler.java 13 Dec 2002 00:09:14 -0000 1.5
@@ -11,7 +11,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.excalibur.altrmi.client.impl.stream.ClientCustomStreamReadWriter;
-import org.apache.excalibur.altrmi.client.impl.stream.ClientStreamReadWriter;
+import org.apache.excalibur.altrmi.client.impl.ClientStreamReadWriter;
import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
import org.apache.excalibur.altrmi.common.AltrmiReply;
import org.apache.excalibur.altrmi.common.AltrmiRequest;
1.5 +2 -2
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/socket/SocketObjectStreamInvocationHandler.java
Index: SocketObjectStreamInvocationHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/socket/SocketObjectStreamInvocationHandler.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SocketObjectStreamInvocationHandler.java 26 Oct 2002 14:10:49 -0000 1.4
+++ SocketObjectStreamInvocationHandler.java 13 Dec 2002 00:09:14 -0000 1.5
@@ -11,7 +11,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.excalibur.altrmi.client.impl.stream.ClientObjectStreamReadWriter;
-import org.apache.excalibur.altrmi.client.impl.stream.ClientStreamReadWriter;
+import org.apache.excalibur.altrmi.client.impl.ClientStreamReadWriter;
import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
/**
1.5 +5 -4
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/stream/ClientCustomStreamReadWriter.java
Index: ClientCustomStreamReadWriter.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/stream/ClientCustomStreamReadWriter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ClientCustomStreamReadWriter.java 26 Oct 2002 14:10:49 -0000 1.4
+++ ClientCustomStreamReadWriter.java 13 Dec 2002 00:09:14 -0000 1.5
@@ -17,6 +17,7 @@
import org.apache.excalibur.altrmi.common.AltrmiRequest;
import org.apache.excalibur.altrmi.common.SerializationHelper;
import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
+import org.apache.excalibur.altrmi.client.impl.ClientStreamReadWriter;
/**
* Class ClientCustomStreamReadWriter
@@ -25,7 +26,7 @@
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
* @version $Revision$
*/
-public class ClientCustomStreamReadWriter extends ClientStreamReadWriter
+public class ClientCustomStreamReadWriter implements ClientStreamReadWriter
{
private DataInputStream mDataInputStream;
@@ -53,7 +54,7 @@
mInterfacesClassLoader = interfacesClassLoader;
}
- protected synchronized AltrmiReply postRequest( AltrmiRequest altrmiRequest )
+ public synchronized AltrmiReply postRequest( AltrmiRequest altrmiRequest )
throws IOException, ClassNotFoundException
{
@@ -77,7 +78,7 @@
private AltrmiReply readReply() throws IOException, ClassNotFoundException
{
- int byteArraySize = (int)mDataInputStream.readInt();
+ int byteArraySize = mDataInputStream.readInt();
byte[] byteArray = new byte[ byteArraySize ];
int pos = 0;
int cnt = 0;
1.6 +4 -3
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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ClientObjectStreamReadWriter.java 28 Oct 2002 21:58:55 -0000 1.5
+++ ClientObjectStreamReadWriter.java 13 Dec 2002 00:09:14 -0000 1.6
@@ -19,6 +19,7 @@
import org.apache.excalibur.altrmi.common.AltrmiRequest;
import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
import org.apache.excalibur.altrmi.common.BadConnectionException;
+import org.apache.excalibur.altrmi.client.impl.ClientStreamReadWriter;
/**
* Class ClientObjectStreamReadWriter
@@ -27,7 +28,7 @@
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
* @version $Revision$
*/
-public class ClientObjectStreamReadWriter extends ClientStreamReadWriter
+public class ClientObjectStreamReadWriter implements ClientStreamReadWriter
{
private ObjectInputStream mObjectInputStream;
@@ -86,7 +87,7 @@
}
}
- protected synchronized AltrmiReply postRequest( AltrmiRequest altrmiRequest )
+ public synchronized AltrmiReply postRequest( AltrmiRequest altrmiRequest )
throws IOException, ClassNotFoundException
{
1.8 +2 -1
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/stream/StreamInvocationHandler.java
Index: StreamInvocationHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/stream/StreamInvocationHandler.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- StreamInvocationHandler.java 22 Oct 2002 23:18:24 -0000 1.7
+++ StreamInvocationHandler.java 13 Dec 2002 00:09:14 -0000 1.8
@@ -13,6 +13,7 @@
import java.net.SocketException;
import org.apache.excalibur.altrmi.client.AltrmiConnectionListener;
import org.apache.excalibur.altrmi.client.impl.AbstractClientInvocationHandler;
+import org.apache.excalibur.altrmi.client.impl.ClientStreamReadWriter;
import org.apache.excalibur.altrmi.common.AltrmiInvocationException;
import org.apache.excalibur.altrmi.common.AltrmiReply;
import org.apache.excalibur.altrmi.common.AltrmiRequest;
1.4 +9 -10
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/callback/socket/CallbackServerClientReadWriter.java
Index: CallbackServerClientReadWriter.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/callback/socket/CallbackServerClientReadWriter.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CallbackServerClientReadWriter.java 24 Apr 2002 12:43:01 -0000 1.3
+++ CallbackServerClientReadWriter.java 13 Dec 2002 00:09:14 -0000 1.4
@@ -1,15 +1,14 @@
/*
- * Created by IntelliJ IDEA.
- * User: Administrator
- * Date: 20-Apr-02
- * Time: 14:04:24
- * To change template for new class use
- * Code Style | Class Templates options (Tools | IDE Options).
+ * 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.server.impl.callback.socket;
import java.io.IOException;
-import org.apache.excalibur.altrmi.client.impl.stream.ClientStreamReadWriter;
+import org.apache.excalibur.altrmi.client.impl.ClientStreamReadWriter;
import org.apache.excalibur.altrmi.common.AltrmiReply;
import org.apache.excalibur.altrmi.common.AltrmiRequest;
@@ -21,7 +20,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Vinay Chandran</a>
* @version $Revision$
*/
-public class CallbackServerClientReadWriter extends ClientStreamReadWriter
+public class CallbackServerClientReadWriter implements ClientStreamReadWriter
{
private CallbackEnabledSocketCustomStreamReadWriter
mCallbackEnabledCustomSocketStreamReadWriter;
@@ -40,7 +39,7 @@
callbackEnabledCustomSocketStreamReadWriter;
}
- protected AltrmiReply postRequest( AltrmiRequest altrmiRequest )
+ public AltrmiReply postRequest( AltrmiRequest altrmiRequest )
throws IOException, ClassNotFoundException
{
1.3 +2 -2
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/callback/stream/CallbackStreamInvocationHandler.java
Index: CallbackStreamInvocationHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/callback/stream/CallbackStreamInvocationHandler.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CallbackStreamInvocationHandler.java 24 Apr 2002 12:43:01 -0000 1.2
+++ CallbackStreamInvocationHandler.java 13 Dec 2002 00:09:14 -0000 1.3
@@ -7,7 +7,7 @@
*/
package org.apache.excalibur.altrmi.server.impl.callback.stream;
-import org.apache.excalibur.altrmi.client.impl.stream.ClientStreamReadWriter;
+import org.apache.excalibur.altrmi.client.impl.ClientStreamReadWriter;
import org.apache.excalibur.altrmi.client.impl.stream.StreamInvocationHandler;
/**
1.1
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/ClientStreamReadWriter.java
Index: ClientStreamReadWriter.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;
import java.io.IOException;
import org.apache.excalibur.altrmi.common.AltrmiReply;
import org.apache.excalibur.altrmi.common.AltrmiRequest;
/**
* Class ClientStreamReadWriter
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
* @version $Revision: 1.1 $
*/
public interface ClientStreamReadWriter
{
AltrmiReply postRequest( AltrmiRequest altrmiRequest ) throws IOException,
ClassNotFoundException;
}
1.1
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/http/ClientHttpReadWriter.java
Index: ClientHttpReadWriter.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.http;
import org.apache.excalibur.altrmi.client.impl.ClientStreamReadWriter;
import org.apache.excalibur.altrmi.common.AltrmiReply;
import org.apache.excalibur.altrmi.common.AltrmiRequest;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
public class ClientHttpReadWriter implements ClientStreamReadWriter
{
private String m_host;
private int m_port;
public ClientHttpReadWriter(String host, int port)
{
m_host = host;
m_port = port;
}
public AltrmiReply postRequest(AltrmiRequest altrmiRequest)
throws IOException, ClassNotFoundException
{
URL url = new URL("http",m_host, m_port,"/mystuff/Dump/");
URLConnection connection = url.openConnection();
// OutputStream out = connection
// ObjectOutputStream out
return null;
}
}
1.1
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/client/impl/http/CustomHttpHostContext.java
Index: CustomHttpHostContext.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.http;
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.io.IOException;
import java.lang.reflect.Method;
/**
* Class SocketCustomStreamHostContext
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
* @version $Revision: 1.1 $
*/
public class CustomHttpHostContext extends AbstractSameVmBindableHostContext
{
private int m_port;
/**
* Constructor SocketCustomStreamHostContext
*
*
* @param host
* @param port
*
* @throws AltrmiConnectionException
*
*/
public CustomHttpHostContext( String host, int port ) throws
AltrmiConnectionException
{
super( new CustomHttpInvocationHandler( host, port,
CustomHttpHostContext.class
.getClassLoader() ) );
m_port = port;
}
/**
* Constructor SocketCustomStreamHostContext
*
*
* @param host
* @param port
* @param classLoader
*
* @throws AltrmiConnectionException
*
*/
public CustomHttpHostContext( String host, int port, ClassLoader classLoader )
throws AltrmiConnectionException
{
super( new CustomHttpInvocationHandler( host, port, 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/http/CustomHttpInvocationHandler.java
Index: CustomHttpInvocationHandler.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.http;
import org.apache.excalibur.altrmi.client.impl.stream.StreamInvocationHandler;
import org.apache.excalibur.altrmi.common.AltrmiConnectionException;
/**
* Class SocketCustomStreamInvocationHandler
*
*
* @author Paul Hammant <a
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
* @version $Revision: 1.1 $
*/
public final class CustomHttpInvocationHandler
extends StreamInvocationHandler
{
private int m_port;
private String m_host;
/**
* Constructor SocketCustomStreamInvocationHandler
*
*
* @param host the host name
* @param port the port
* @param classLoader the classloader for deserialization hints.
*
* @throws AltrmiConnectionException if a problem
*
*/
public CustomHttpInvocationHandler( String host, int port, ClassLoader
classLoader )
throws AltrmiConnectionException
{
super( classLoader );
m_host = host;
m_port = port;
setObjectReadWriter(new ClientHttpReadWriter(host,port));
}
protected boolean tryReconnect()
{
return false;
}
}
1.1
jakarta-avalon-excalibur/altrmi/src/java/org/apache/excalibur/altrmi/server/impl/http/CustomHttpServlet.java
Index: CustomHttpServlet.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.server.impl.http;
import org.apache.excalibur.altrmi.common.MethodRequest;
import org.apache.excalibur.altrmi.server.AltrmiPublisher;
import org.apache.excalibur.altrmi.server.MethodInvocationHandler;
import org.apache.excalibur.altrmi.server.PublicationDescription;
import org.apache.excalibur.altrmi.server.PublicationException;
import org.apache.excalibur.altrmi.server.impl.adapters.InvocationHandlerAdapter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class CustomHttpServlet extends HttpServlet implements AltrmiPublisher
{
InvocationHandlerAdapter inInvocationHandlerAdapter = new
InvocationHandlerAdapter();
public CustomHttpServlet()
{
}
public void doGet(HttpServletRequest httpServletRequest, HttpServletResponse
httpServletResponse) throws ServletException, IOException
{
super.doGet(httpServletRequest, httpServletResponse);
}
public void publish( Object impl, String asName, Class interfaceToExpose )
throws PublicationException
{
inInvocationHandlerAdapter.publish(impl, asName, interfaceToExpose);
}
public void publish( Object impl, String asName, PublicationDescription
publicationDescription )
throws PublicationException
{
inInvocationHandlerAdapter.publish(impl, asName, publicationDescription);
}
public void unPublish( Object impl, String publishedName ) throws
PublicationException
{
inInvocationHandlerAdapter.unPublish(impl, publishedName);
}
public void replacePublished( Object oldImpl, String publishedName, Object
withImpl )
throws PublicationException
{
inInvocationHandlerAdapter.replacePublished(oldImpl, publishedName,
withImpl);
}
public MethodInvocationHandler getMethodInvocationHandler( MethodRequest
methodRequest,
String objectName )
{
return inInvocationHandlerAdapter.getMethodInvocationHandler(methodRequest,
objectName);
}
public MethodInvocationHandler getMethodInvocationHandler( String publishedName )
{
return inInvocationHandlerAdapter.getMethodInvocationHandler(publishedName);
}
}
1.1
jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/http/CustomHttpServletTestCase.java
Index: CustomHttpServletTestCase.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.test.http;
import org.apache.excalibur.altrmi.client.impl.ClientClassAltrmiFactory;
import org.apache.excalibur.altrmi.client.impl.http.CustomHttpHostContext;
import org.apache.excalibur.altrmi.server.PublicationDescription;
import org.apache.excalibur.altrmi.server.impl.http.CustomHttpServlet;
import org.apache.excalibur.altrmi.test.AbstractHelloTestCase;
import org.apache.excalibur.altrmi.test.TestInterface;
import org.apache.excalibur.altrmi.test.TestInterface2;
import org.apache.excalibur.altrmi.test.TestInterface3;
import org.apache.excalibur.altrmi.test.TestInterfaceImpl;
import org.mortbay.http.HttpContext;
import org.mortbay.http.HttpServer;
import org.mortbay.http.SocketListener;
import org.mortbay.jetty.servlet.ServletHandler;
/**
* Test Custom Stream over sockets.
* @author Paul Hammant
*/
public class CustomHttpServletTestCase extends AbstractHelloTestCase
{
private static final int HTTP_PORT = 8181;
public CustomHttpServletTestCase(String name)
{
super(name);
}
protected void setUp() throws Exception
{
super.setUp();
CustomHttpServlet customHttpServlet = new CustomHttpServlet();
KludgeServlet.setRealServlet(customHttpServlet);
// Create the server
HttpServer server = new HttpServer();
// Create a port listener
SocketListener listener = new SocketListener();
listener.setPort(HTTP_PORT);
server.addListener(listener);
// Create a context
HttpContext context = new HttpContext();
context.setContextPath("/mystuff/*");
server.addContext(context);
// Create a servlet container
ServletHandler servlets = new ServletHandler();
context.addHandler(servlets);
// Map a servlet onto the container
servlets.addServlet("Dump", "/Dump/*",
"org.apache.excalibur.altrmi.server.impl.http.CustomHttpServlet");
// Serve static content from the context
// String home = System.getProperty("jetty.home", ".");
// context.setResourceBase(home + "/demo/webapps/jetty/tut/");
// context.addHandler(new ResourceHandler());
// Start the http server
server.start();
// server side setup.
testServer = new TestInterfaceImpl();
PublicationDescription pd = new PublicationDescription(TestInterface.class,
new Class[]{TestInterface3.class, TestInterface2.class});
customHttpServlet.publish(testServer, "Hello", pd);
// Client side setup
altrmiFactory = new ClientClassAltrmiFactory(false);
altrmiFactory.setHostContext(new CustomHttpHostContext("127.0.0.1",
HTTP_PORT), false);
testClient = (TestInterface) altrmiFactory.lookup("Hello");
// just a kludge for unit testing given we are intrinsically dealing with
// threads, AltRMI being a client/server thing
Thread.yield();
}
protected void tearDown() throws Exception
{
testClient = null;
System.gc();
Thread.yield();
altrmiFactory.close();
Thread.yield();
server.stop();
Thread.yield();
server = null;
testServer = null;
super.tearDown();
}
}
1.1
jakarta-avalon-excalibur/altrmi/src/test/org/apache/excalibur/altrmi/test/http/KludgeServlet.java
Index: KludgeServlet.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.test.http;
import org.apache.excalibur.altrmi.server.impl.http.CustomHttpServlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class KludgeServlet extends CustomHttpServlet
{
private static CustomHttpServlet realServlet;
public static void setRealServlet(CustomHttpServlet realServlet)
{
KludgeServlet.realServlet = realServlet;
}
public void doGet(HttpServletRequest httpServletRequest, HttpServletResponse
httpServletResponse) throws ServletException, IOException
{
realServlet.doGet(httpServletRequest, httpServletResponse);
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>