Author: jochen Date: Tue Feb 21 17:13:32 2006 New Revision: 379645 URL: http://svn.apache.org/viewcvs?rev=379645&view=rev Log: Splitting the project into the subprojects common, client, server, and tests.
Added: webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/ClientStreamConnection.java webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/LocalStreamConnection.java webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/ServerStreamConnection.java webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/XmlRpcRequestProcessor.java webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/XmlRpcRequestProcessorFactory.java webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/XmlRpcStreamRequestProcessor.java webservices/xmlrpc/trunk/server/src/main/java/org/apache/xmlrpc/server/XmlRpcLocalStreamServer.java Added: webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/ClientStreamConnection.java URL: http://svn.apache.org/viewcvs/webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/ClientStreamConnection.java?rev=379645&view=auto ============================================================================== --- webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/ClientStreamConnection.java (added) +++ webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/ClientStreamConnection.java Tue Feb 21 17:13:32 2006 @@ -0,0 +1,11 @@ +package org.apache.xmlrpc.common; + + +/** Interface of an object, to which an XML-RPC + * request may be written as an XML stream. + * Additionally, the object may provide an + * XML stream with the response. + */ +public interface ClientStreamConnection { + +} Added: webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/LocalStreamConnection.java URL: http://svn.apache.org/viewcvs/webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/LocalStreamConnection.java?rev=379645&view=auto ============================================================================== --- webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/LocalStreamConnection.java (added) +++ webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/LocalStreamConnection.java Tue Feb 21 17:13:32 2006 @@ -0,0 +1,41 @@ +package org.apache.xmlrpc.common; + +import java.io.ByteArrayOutputStream; + + +/** Implementation of [EMAIL PROTECTED] StreamConnection} for + * use by the + * [EMAIL PROTECTED] org.apache.xmlrpc.client.XmlRpcLocalStreamTransport}. + */ +public class LocalStreamConnection + implements ClientStreamConnection, ServerStreamConnection { + private ByteArrayOutputStream ostream, istream; + + /** Returns the output stream, to which the response + * is being written. + */ + public ByteArrayOutputStream getOstream() { + return ostream; + } + + /** Sets the output stream, to which the response + * is being written. + */ + public void setOstream(ByteArrayOutputStream pOstream) { + ostream = pOstream; + } + + /** Returns the input stream, to which the request + * is being written. + */ + public ByteArrayOutputStream getIstream() { + return istream; + } + + /** Sets the input stream, to which the request + * is being written. + */ + public void setIstream(ByteArrayOutputStream pIstream) { + istream = pIstream; + } +} Added: webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/ServerStreamConnection.java URL: http://svn.apache.org/viewcvs/webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/ServerStreamConnection.java?rev=379645&view=auto ============================================================================== --- webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/ServerStreamConnection.java (added) +++ webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/ServerStreamConnection.java Tue Feb 21 17:13:32 2006 @@ -0,0 +1,11 @@ +package org.apache.xmlrpc.common; + + +/** Interface of an object, which is able to provide + * an XML stream, containing an XML-RPC request. + * Additionally, the object may also be used to + * write the response as an XML stream. + */ +public interface ServerStreamConnection { + +} Added: webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/XmlRpcRequestProcessor.java URL: http://svn.apache.org/viewcvs/webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/XmlRpcRequestProcessor.java?rev=379645&view=auto ============================================================================== --- webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/XmlRpcRequestProcessor.java (added) +++ webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/XmlRpcRequestProcessor.java Tue Feb 21 17:13:32 2006 @@ -0,0 +1,16 @@ +package org.apache.xmlrpc.common; + +import org.apache.xmlrpc.XmlRpcException; +import org.apache.xmlrpc.XmlRpcRequest; + + +/** Interface of an object, which is able to process + * XML-RPC requests. + */ +public interface XmlRpcRequestProcessor { + /** Processes the given request and returns a + * result object. + * @throws XmlRpcException Processing the request failed. + */ + Object execute(XmlRpcRequest pRequest) throws XmlRpcException; +} Added: webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/XmlRpcRequestProcessorFactory.java URL: http://svn.apache.org/viewcvs/webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/XmlRpcRequestProcessorFactory.java?rev=379645&view=auto ============================================================================== --- webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/XmlRpcRequestProcessorFactory.java (added) +++ webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/XmlRpcRequestProcessorFactory.java Tue Feb 21 17:13:32 2006 @@ -0,0 +1,14 @@ +package org.apache.xmlrpc.common; + + +/** Interface of an object, which may be used + * to create instances of [EMAIL PROTECTED] XmlRpcRequestProcessor}. + */ +public interface XmlRpcRequestProcessorFactory { + /** Returns the [EMAIL PROTECTED] XmlRpcRequestProcessor} being invoked. + * @return Server object being invoked. This will typically + * be a singleton instance, but could as well create a new + * instance with any call. + */ + XmlRpcRequestProcessor getXmlRpcServer(); +} Added: webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/XmlRpcStreamRequestProcessor.java URL: http://svn.apache.org/viewcvs/webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/XmlRpcStreamRequestProcessor.java?rev=379645&view=auto ============================================================================== --- webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/XmlRpcStreamRequestProcessor.java (added) +++ webservices/xmlrpc/trunk/common/src/main/java/org/apache/xmlrpc/common/XmlRpcStreamRequestProcessor.java Tue Feb 21 17:13:32 2006 @@ -0,0 +1,20 @@ +package org.apache.xmlrpc.common; + +import java.io.IOException; + +import org.apache.xmlrpc.XmlRpcException; + + +/** An instance of [EMAIL PROTECTED] XmlRpcRequestProcessor}, + * which is processing an XML stream. + */ +public interface XmlRpcStreamRequestProcessor extends XmlRpcRequestProcessor { + /** Reads an XML-RPC request from the connection + * object and processes the request, writing the + * result to the same connection object. + * @throws XmlRpcException Processing the request failed. + * @throws IOException An I/O error occurred while reading + * the response, or writing the result. + */ + void execute(XmlRpcStreamRequestConfig pConfig, ServerStreamConnection pConnection) throws IOException, XmlRpcException; +} Added: webservices/xmlrpc/trunk/server/src/main/java/org/apache/xmlrpc/server/XmlRpcLocalStreamServer.java URL: http://svn.apache.org/viewcvs/webservices/xmlrpc/trunk/server/src/main/java/org/apache/xmlrpc/server/XmlRpcLocalStreamServer.java?rev=379645&view=auto ============================================================================== --- webservices/xmlrpc/trunk/server/src/main/java/org/apache/xmlrpc/server/XmlRpcLocalStreamServer.java (added) +++ webservices/xmlrpc/trunk/server/src/main/java/org/apache/xmlrpc/server/XmlRpcLocalStreamServer.java Tue Feb 21 17:13:32 2006 @@ -0,0 +1,42 @@ +package org.apache.xmlrpc.server; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; + +import org.apache.xmlrpc.XmlRpcException; +import org.apache.xmlrpc.XmlRpcRequest; +import org.apache.xmlrpc.common.LocalStreamConnection; +import org.apache.xmlrpc.common.ServerStreamConnection; +import org.apache.xmlrpc.common.XmlRpcRequestProcessor; +import org.apache.xmlrpc.common.XmlRpcRequestProcessorFactory; +import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig; + + +/** Server part of a local stream transport. + */ +public class XmlRpcLocalStreamServer extends XmlRpcStreamServer { + public Object execute(XmlRpcRequest pRequest) throws XmlRpcException { + XmlRpcRequestProcessor server = ((XmlRpcRequestProcessorFactory) pRequest.getConfig()).getXmlRpcServer(); + return server.execute(pRequest); + } + protected InputStream newInputStream(XmlRpcStreamRequestConfig pConfig, ServerStreamConnection pConnection) throws IOException { + LocalStreamConnection lsc = (LocalStreamConnection) pConnection; + return new ByteArrayInputStream(lsc.getOstream().toByteArray()); + } + protected OutputStream newOutputStream(XmlRpcStreamRequestConfig pConfig, ServerStreamConnection pConnection) throws IOException { + LocalStreamConnection lsc = (LocalStreamConnection) pConnection; + ByteArrayOutputStream istream = new ByteArrayOutputStream(); + lsc.setIstream(istream); + return istream; + } + protected void closeConnection(ServerStreamConnection pConnection) throws IOException { + LocalStreamConnection lsc = (LocalStreamConnection) pConnection; + final ByteArrayOutputStream istream = lsc.getIstream(); + if (istream != null) { + try { istream.close(); } catch (Throwable ignore) {} + } + } +} \ No newline at end of file