jochen 2005/05/11 18:58:53
Modified: src/java/org/apache/xmlrpc Tag: b20050512_streaming XmlRpcHandler.java XmlRpcRequest.java XmlRpcException.java src/java/org/apache/xmlrpc/util Tag: b20050512_streaming HttpUtil.java . Tag: b20050512_streaming .classpath Added: src/java/org/apache/xmlrpc/parser Tag: b20050512_streaming I8Parser.java NullParser.java AtomicParser.java TypeParserImpl.java RecursiveTypeParserImpl.java FloatParser.java MapParser.java DateParser.java ObjectArrayParser.java LongParser.java XmlRpcRequestParser.java I4Parser.java TypeParser.java DoubleParser.java XmlRpcResponseParser.java BooleanParser.java I2Parser.java I1Parser.java src/java/org/apache/xmlrpc/client Tag: b20050512_streaming XmlRpcLocalTransportFactory.java XmlRpcLocalStreamTransportFactory.java XmlRpcClientConfig.java XmlRpcTransportFactoryImpl.java XmlRpcClientException.java XmlRpcHttpClientConfig.java XmlRpcLocalTransport.java XmlRpcClientConfigImpl.java XmlRpcClientWorkerFactory.java XmlRpcClient.java XmlRpcTransportFactory.java XmlRpcStreamTransport.java XmlRpcHttpTransportFactory.java XmlRpcTransport.java XmlRpcTransportImpl.java XmlRpcHttpTransport.java XmlRpcLocalClientConfig.java XmlRpcStreamTransportFactory.java AsyncCallback.java XmlRpcClientWorker.java XmlRpcClientRequestImpl.java XmlRpcLocalStreamTransport.java src/java/org/apache/xmlrpc/server Tag: b20050512_streaming XmlRpcServerWorkerFactory.java XmlRpcServerConfigImpl.java XmlRpcHandlerMapping.java PropertyHandlerMapping.java XmlRpcServerConfig.java XmlRpcServerWorker.java XmlRpcNoSuchHandlerException.java XmlRpcHttpServerConfig.java XmlRpcStreamServer.java XmlRpcServer.java src/test/org/apache/xmlrpc/test Tag: b20050512_streaming LocalStreamTransportTest.java BaseTestCase.java HttpTransportTest.java LocalTransportTest.java BaseTestCase.properties src/java/org/apache/xmlrpc/common Tag: b20050512_streaming TypeFactory.java XmlRpcStreamConfig.java XmlRpcStreamRequestConfig.java XmlRpcController.java XmlRpcWorker.java XmlRpcHttpRequestConfig.java XmlRpcNotAuthorizedException.java TypeFactoryImpl.java XmlRpcHttpRequestConfigImpl.java XmlRpcHttpConfig.java XmlRpcWorkerFactory.java XmlRpcExtensionException.java src/java/org/apache/xmlrpc Tag: b20050512_streaming XmlRpcConfigImpl.java XmlRpcConfig.java XmlRpcLoadException.java XmlRpcRequestConfig.java src/java/org/apache/xmlrpc/serializer Tag: b20050512_streaming MapSerializer.java StringSerializer.java XmlRpcWriter.java I4Serializer.java TypeSerializer.java XmlWriterFactory.java ListSerializer.java NullSerializer.java I1Serializer.java I8Serializer.java ObjectArraySerializer.java BaseXmlWriterFactory.java TypeSerializerImpl.java CharSetXmlWriterFactory.java BooleanSerializer.java DateSerializer.java DoubleSerializer.java I2Serializer.java ByteArraySerializer.java FloatSerializer.java DefaultXMLWriterFactory.java src/java/org/apache/xmlrpc/webserver Tag: b20050512_streaming WebServer.java RequestData.java ServerInputStream.java ConnectionServer.java Connection.java src/java/org/apache/xmlrpc/util Tag: b20050512_streaming ThreadPool.java Base64.java .settings Tag: b20050512_streaming org.eclipse.jdt.core.prefs Log: First, as of yet unusable, implementation of a streaming client and server. Revision Changes Path No revision No revision 1.1.2.1 +33 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/parser/Attic/I8Parser.java 1.1.2.1 +39 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/parser/Attic/NullParser.java 1.1.2.1 +73 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/parser/Attic/AtomicParser.java 1.1.2.1 +85 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/parser/Attic/TypeParserImpl.java 1.1.2.1 +172 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/parser/Attic/RecursiveTypeParserImpl.java 1.1.2.1 +33 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/parser/Attic/FloatParser.java 1.1.2.1 +158 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/parser/Attic/MapParser.java 1.1.2.1 +38 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/parser/Attic/DateParser.java 1.1.2.1 +106 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/parser/Attic/ObjectArrayParser.java 1.1.2.1 +33 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/parser/Attic/LongParser.java 1.1.2.1 +174 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/parser/Attic/XmlRpcRequestParser.java 1.1.2.1 +33 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/parser/Attic/I4Parser.java 1.1.2.1 +31 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/parser/Attic/TypeParser.java 1.1.2.1 +33 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/parser/Attic/DoubleParser.java 1.1.2.1 +209 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/parser/Attic/XmlRpcResponseParser.java 1.1.2.1 +36 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/parser/Attic/BooleanParser.java 1.1.2.1 +33 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/parser/Attic/I2Parser.java 1.1.2.1 +33 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/parser/Attic/I1Parser.java No revision No revision 1.1.2.1 +38 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcLocalTransportFactory.java 1.1.2.1 +37 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcLocalStreamTransportFactory.java 1.1.2.1 +30 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcClientConfig.java 1.1.2.1 +35 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcTransportFactoryImpl.java 1.1.2.1 +42 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcClientException.java 1.1.2.1 +33 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcHttpClientConfig.java 1.1.2.1 +75 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcLocalTransport.java 1.1.2.1 +65 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcClientConfigImpl.java 1.1.2.1 +24 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcClientWorkerFactory.java 1.1.2.1 +246 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcClient.java 1.1.2.1 +30 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcTransportFactory.java 1.1.2.1 +225 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcStreamTransport.java 1.1.2.1 +36 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcHttpTransportFactory.java 1.1.2.1 +35 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcTransport.java 1.1.2.1 +35 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcTransportImpl.java 1.1.2.1 +107 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcHttpTransport.java 1.1.2.1 +32 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcLocalClientConfig.java 1.1.2.1 +25 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcStreamTransportFactory.java 1.1.2.1 +36 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/AsyncCallback.java 1.1.2.1 +93 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcClientWorker.java 1.1.2.1 +72 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcClientRequestImpl.java 1.1.2.1 +105 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/client/Attic/XmlRpcLocalStreamTransport.java No revision No revision 1.1.2.1 +35 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/server/Attic/XmlRpcServerWorkerFactory.java 1.1.2.1 +35 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/server/Attic/XmlRpcServerConfigImpl.java 1.1.2.1 +35 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/server/Attic/XmlRpcHandlerMapping.java 1.1.2.1 +173 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/server/Attic/PropertyHandlerMapping.java 1.1.2.1 +25 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/server/Attic/XmlRpcServerConfig.java 1.1.2.1 +45 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/server/Attic/XmlRpcServerWorker.java 1.1.2.1 +32 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/server/Attic/XmlRpcNoSuchHandlerException.java 1.1.2.1 +27 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/server/Attic/XmlRpcHttpServerConfig.java 1.1.2.1 +178 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/server/Attic/XmlRpcStreamServer.java 1.1.2.1 +67 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/server/Attic/XmlRpcServer.java No revision No revision 1.1.2.1 +31 -0 ws-xmlrpc/src/test/org/apache/xmlrpc/test/Attic/LocalStreamTransportTest.java 1.1.2.1 +560 -0 ws-xmlrpc/src/test/org/apache/xmlrpc/test/Attic/BaseTestCase.java 1.1.2.1 +50 -0 ws-xmlrpc/src/test/org/apache/xmlrpc/test/Attic/HttpTransportTest.java 1.1.2.1 +38 -0 ws-xmlrpc/src/test/org/apache/xmlrpc/test/Attic/LocalTransportTest.java 1.1.2.1 +1 -0 ws-xmlrpc/src/test/org/apache/xmlrpc/test/Attic/BaseTestCase.properties No revision No revision 1.1.2.1 +44 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/common/Attic/TypeFactory.java 1.1.2.1 +34 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/common/Attic/XmlRpcStreamConfig.java 1.1.2.1 +39 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/common/Attic/XmlRpcStreamRequestConfig.java 1.1.2.1 +85 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/common/Attic/XmlRpcController.java 1.1.2.1 +45 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/common/Attic/XmlRpcWorker.java 1.1.2.1 +36 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/common/Attic/XmlRpcHttpRequestConfig.java 1.1.2.1 +32 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/common/Attic/XmlRpcNotAuthorizedException.java 1.1.2.1 +172 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/common/Attic/TypeFactoryImpl.java 1.1.2.1 +74 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/common/Attic/XmlRpcHttpRequestConfigImpl.java 1.1.2.1 +36 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/common/Attic/XmlRpcHttpConfig.java 1.1.2.1 +99 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/common/Attic/XmlRpcWorkerFactory.java 1.1.2.1 +33 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/common/Attic/XmlRpcExtensionException.java No revision No revision 1.3.2.1 +9 -18 ws-xmlrpc/src/java/org/apache/xmlrpc/XmlRpcHandler.java Index: XmlRpcHandler.java =================================================================== RCS file: /home/cvs/ws-xmlrpc/src/java/org/apache/xmlrpc/XmlRpcHandler.java,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -r1.3 -r1.3.2.1 --- XmlRpcHandler.java 22 Apr 2005 10:25:57 -0000 1.3 +++ XmlRpcHandler.java 12 May 2005 01:58:52 -0000 1.3.2.1 @@ -13,27 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.apache.xmlrpc; -import java.util.Vector; -/** - * The XML-RPC server uses this interface to call a method of an RPC handler. - * This should be implemented by any class that wants to directly take control - * when it is called over RPC. Classes not implementing this interface will be - * wrapped into an Invoker object that tries to find the matching method - * for an XML-RPC request. - * - * @author <a href="mailto:[EMAIL PROTECTED]">Hannes Wallnoefer</a> - * @version $Id$ + +/** The XML-RPC server uses this interface to call a method of an RPC handler. */ -public interface XmlRpcHandler -{ - /** - * Return the result, or throw an Exception if something went wrong. +public interface XmlRpcHandler { + /** Performs the request and returns the result object. + * @param pRequest The request being performed (method name and + * parameters.) + * @return The result object. + * @throws XmlRpcException Performing the request failed. */ - public Object execute (String method, Vector params) - throws Exception; + public Object execute(XmlRpcRequest pRequest) throws XmlRpcException; } 1.5.2.1 +22 -40 ws-xmlrpc/src/java/org/apache/xmlrpc/XmlRpcRequest.java Index: XmlRpcRequest.java =================================================================== RCS file: /home/cvs/ws-xmlrpc/src/java/org/apache/xmlrpc/XmlRpcRequest.java,v retrieving revision 1.5 retrieving revision 1.5.2.1 diff -u -r1.5 -r1.5.2.1 --- XmlRpcRequest.java 22 Apr 2005 10:25:57 -0000 1.5 +++ XmlRpcRequest.java 12 May 2005 01:58:52 -0000 1.5.2.1 @@ -13,48 +13,30 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.apache.xmlrpc; -import java.util.Vector; -/** - * Default implementation of an XML-RPC request for both client and server. - * - * @author <a href="mailto:[EMAIL PROTECTED]">Andrew Evers</a> - * @version $Id$ - * @since 1.2 +/** Interface to an XML-RPC request made by a client. Replaces the + * class <code>org.apache.xmlrpc.XmlRpcClientRequest</code> from + * Apache XML-RPC 2.0. + * @since 3.0 */ -public class XmlRpcRequest -implements XmlRpcServerRequest, XmlRpcClientRequest -{ - protected final String methodName; - protected final Vector parameters; - - public XmlRpcRequest(String methodName, Vector parameters) - { - this.parameters = parameters; - this.methodName = methodName; - } - - public int getParameterCount() - { - return parameters.size(); - } - - public Vector getParameters() - { - return parameters; - } - - public Object getParameter(int index) - { - return parameters.elementAt(index); - } - - public String getMethodName() - { - return methodName; - } +public interface XmlRpcRequest { + /** Returns the request configuration. + * @return The request configuration. + */ + XmlRpcRequestConfig getConfig(); + /** Returns the requests method name. + * @return Name of the method being invoked. + */ + String getMethodName(); + /** Returns the number of parameters. + * @return Number of parameters. + */ + int getParameterCount(); + /** Returns the parameter with index <code>pIndex</code>. + * @param pIndex Number between 0 and [EMAIL PROTECTED] #getParameterCount()}-1. + * @return Parameter being sent to the server. + */ + public Object getParameter(int pIndex); } 1.3.2.1 +62 -21 ws-xmlrpc/src/java/org/apache/xmlrpc/XmlRpcException.java Index: XmlRpcException.java =================================================================== RCS file: /home/cvs/ws-xmlrpc/src/java/org/apache/xmlrpc/XmlRpcException.java,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -r1.3 -r1.3.2.1 --- XmlRpcException.java 22 Apr 2005 10:25:57 -0000 1.3 +++ XmlRpcException.java 12 May 2005 01:58:52 -0000 1.3.2.1 @@ -13,35 +13,76 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.apache.xmlrpc; -/** - * This is thrown by the XmlRpcClient if the remote server reported an error. - * If something went wrong at a lower level (e.g. no http connection) an - * IOException will be thrown instead. - * - * @author <a href="mailto:[EMAIL PROTECTED]">Hannes Wallnoefer</a> - * @version $Id$ +import java.io.PrintStream; +import java.io.PrintWriter; + +/** This exception is thrown by the XmlRpcClient, if an invocation of the + * remote method failed. Failure may have two reasons: The invocation + * failed on the remote side (for example, an exception was thrown within + * the server) or the communication with the server failed. The latter + * is indicated by throwing an instance of + * [EMAIL PROTECTED] org.apache.xmlrpc.client.XmlRpcClientException}. */ -public class XmlRpcException extends Exception -{ - /** - * The fault code of the exception. For servers based on this library, this +public class XmlRpcException extends Exception { + private static final long serialVersionUID = 3258693217049325618L; + + /** The fault code of the exception. For servers based on this library, this * will always be 0. (If there are predefined error codes, they should be in * the XML-RPC spec.) */ public final int code; - /** - * - * @param code - * @param message + /** If the transport was able to catch a remote exception + * (as is the case, if the local transport is used or if extensions + * are enabled and the server returned a serialized exception), + * then this field contains the trapped exception. + */ + public final Throwable linkedException; + + /** Creates a new instance with the given error code and error message. + * @param pCode Error code. + * @param pMessage Detail message. */ - public XmlRpcException(int code, String message) - { - super(message); - this.code = code; + public XmlRpcException(int pCode, String pMessage) { + this(pCode, pMessage, null); } + + /** Creates a new instance with the given error message + * and cause. + * @param pMessage Detail message. + * @param pLinkedException The errors cause. + */ + public XmlRpcException(String pMessage, Throwable pLinkedException) { + this(0, pMessage, pLinkedException); + } + + /** Creates a new instance with the given error code, error message + * and cause. + * @param pCode Error code. + * @param pMessage Detail message. + * @param pLinkedException The errors cause. + */ + public XmlRpcException(int pCode, String pMessage, Throwable pLinkedException) { + super(pMessage); + code = pCode; + linkedException = pLinkedException; + } + + public void printStackTrace(PrintStream pStream) { + super.printStackTrace(pStream); + if (linkedException != null) { + pStream.println("Caused by:"); + } + linkedException.printStackTrace(pStream); + } + + public void printStackTrace(PrintWriter pWriter) { + super.printStackTrace(pWriter); + if (linkedException != null) { + pWriter.println("Caused by:"); + linkedException.printStackTrace(pWriter); + } + } } No revision Index: XmlRpcException.java =================================================================== RCS file: /home/cvs/ws-xmlrpc/src/java/org/apache/xmlrpc/XmlRpcException.java,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -r1.3 -r1.3.2.1 --- XmlRpcException.java 22 Apr 2005 10:25:57 -0000 1.3 +++ XmlRpcException.java 12 May 2005 01:58:52 -0000 1.3.2.1 @@ -13,35 +13,76 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.apache.xmlrpc; -/** - * This is thrown by the XmlRpcClient if the remote server reported an error. - * If something went wrong at a lower level (e.g. no http connection) an - * IOException will be thrown instead. - * - * @author <a href="mailto:[EMAIL PROTECTED]">Hannes Wallnoefer</a> - * @version $Id$ +import java.io.PrintStream; +import java.io.PrintWriter; + +/** This exception is thrown by the XmlRpcClient, if an invocation of the + * remote method failed. Failure may have two reasons: The invocation + * failed on the remote side (for example, an exception was thrown within + * the server) or the communication with the server failed. The latter + * is indicated by throwing an instance of + * [EMAIL PROTECTED] org.apache.xmlrpc.client.XmlRpcClientException}. */ -public class XmlRpcException extends Exception -{ - /** - * The fault code of the exception. For servers based on this library, this +public class XmlRpcException extends Exception { + private static final long serialVersionUID = 3258693217049325618L; + + /** The fault code of the exception. For servers based on this library, this * will always be 0. (If there are predefined error codes, they should be in * the XML-RPC spec.) */ public final int code; - /** - * - * @param code - * @param message + /** If the transport was able to catch a remote exception + * (as is the case, if the local transport is used or if extensions + * are enabled and the server returned a serialized exception), + * then this field contains the trapped exception. + */ + public final Throwable linkedException; + + /** Creates a new instance with the given error code and error message. + * @param pCode Error code. + * @param pMessage Detail message. */ - public XmlRpcException(int code, String message) - { - super(message); - this.code = code; + public XmlRpcException(int pCode, String pMessage) { + this(pCode, pMessage, null); } + + /** Creates a new instance with the given error message + * and cause. + * @param pMessage Detail message. + * @param pLinkedException The errors cause. + */ + public XmlRpcException(String pMessage, Throwable pLinkedException) { + this(0, pMessage, pLinkedException); + } + + /** Creates a new instance with the given error code, error message + * and cause. + * @param pCode Error code. + * @param pMessage Detail message. + * @param pLinkedException The errors cause. + */ + public XmlRpcException(int pCode, String pMessage, Throwable pLinkedException) { + super(pMessage); + code = pCode; + linkedException = pLinkedException; + } + + public void printStackTrace(PrintStream pStream) { + super.printStackTrace(pStream); + if (linkedException != null) { + pStream.println("Caused by:"); + } + linkedException.printStackTrace(pStream); + } + + public void printStackTrace(PrintWriter pWriter) { + super.printStackTrace(pWriter); + if (linkedException != null) { + pWriter.println("Caused by:"); + linkedException.printStackTrace(pWriter); + } + } } No revision Index: XmlRpcException.java =================================================================== RCS file: /home/cvs/ws-xmlrpc/src/java/org/apache/xmlrpc/XmlRpcException.java,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -r1.3 -r1.3.2.1 --- XmlRpcException.java 22 Apr 2005 10:25:57 -0000 1.3 +++ XmlRpcException.java 12 May 2005 01:58:52 -0000 1.3.2.1 @@ -13,35 +13,76 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - - package org.apache.xmlrpc; -/** - * This is thrown by the XmlRpcClient if the remote server reported an error. - * If something went wrong at a lower level (e.g. no http connection) an - * IOException will be thrown instead. - * - * @author <a href="mailto:[EMAIL PROTECTED]">Hannes Wallnoefer</a> - * @version $Id$ +import java.io.PrintStream; +import java.io.PrintWriter; + +/** This exception is thrown by the XmlRpcClient, if an invocation of the + * remote method failed. Failure may have two reasons: The invocation + * failed on the remote side (for example, an exception was thrown within + * the server) or the communication with the server failed. The latter + * is indicated by throwing an instance of + * [EMAIL PROTECTED] org.apache.xmlrpc.client.XmlRpcClientException}. */ -public class XmlRpcException extends Exception -{ - /** - * The fault code of the exception. For servers based on this library, this +public class XmlRpcException extends Exception { + private static final long serialVersionUID = 3258693217049325618L; + + /** The fault code of the exception. For servers based on this library, this * will always be 0. (If there are predefined error codes, they should be in * the XML-RPC spec.) */ public final int code; - /** - * - * @param code - * @param message + /** If the transport was able to catch a remote exception + * (as is the case, if the local transport is used or if extensions + * are enabled and the server returned a serialized exception), + * then this field contains the trapped exception. + */ + public final Throwable linkedException; + + /** Creates a new instance with the given error code and error message. + * @param pCode Error code. + * @param pMessage Detail message. */ - public XmlRpcException(int code, String message) - { - super(message); - this.code = code; + public XmlRpcException(int pCode, String pMessage) { + this(pCode, pMessage, null); } + + /** Creates a new instance with the given error message + * and cause. + * @param pMessage Detail message. + * @param pLinkedException The errors cause. + */ + public XmlRpcException(String pMessage, Throwable pLinkedException) { + this(0, pMessage, pLinkedException); + } + + /** Creates a new instance with the given error code, error message + * and cause. + * @param pCode Error code. + * @param pMessage Detail message. + * @param pLinkedException The errors cause. + */ + public XmlRpcException(int pCode, String pMessage, Throwable pLinkedException) { + super(pMessage); + code = pCode; + linkedException = pLinkedException; + } + + public void printStackTrace(PrintStream pStream) { + super.printStackTrace(pStream); + if (linkedException != null) { + pStream.println("Caused by:"); + } + linkedException.printStackTrace(pStream); + } + + public void printStackTrace(PrintWriter pWriter) { + super.printStackTrace(pWriter); + if (linkedException != null) { + pWriter.println("Caused by:"); + linkedException.printStackTrace(pWriter); + } + } } 1.1.2.1 +72 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/Attic/XmlRpcConfigImpl.java 1.1.2.1 +33 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/Attic/XmlRpcConfig.java 1.1.2.1 +31 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/Attic/XmlRpcLoadException.java 1.1.2.1 +26 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/Attic/XmlRpcRequestConfig.java No revision No revision 1.1.2.1 +72 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/serializer/Attic/MapSerializer.java 1.1.2.1 +28 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/serializer/Attic/StringSerializer.java 1.1.2.1 +113 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/serializer/Attic/XmlRpcWriter.java 1.1.2.1 +31 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/serializer/Attic/I4Serializer.java 1.1.2.1 +33 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/serializer/Attic/TypeSerializer.java 1.1.2.1 +40 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/serializer/Attic/XmlWriterFactory.java 1.1.2.1 +42 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/serializer/Attic/ListSerializer.java 1.1.2.1 +38 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/serializer/Attic/NullSerializer.java 1.1.2.1 +35 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/serializer/Attic/I1Serializer.java 1.1.2.1 +35 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/serializer/Attic/I8Serializer.java 1.1.2.1 +64 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/serializer/Attic/ObjectArraySerializer.java 1.1.2.1 +56 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/serializer/Attic/BaseXmlWriterFactory.java 1.1.2.1 +57 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/serializer/Attic/TypeSerializerImpl.java 1.1.2.1 +30 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/serializer/Attic/CharSetXmlWriterFactory.java 1.1.2.1 +33 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/serializer/Attic/BooleanSerializer.java 1.1.2.1 +33 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/serializer/Attic/DateSerializer.java 1.1.2.1 +32 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/serializer/Attic/DoubleSerializer.java 1.1.2.1 +35 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/serializer/Attic/I2Serializer.java 1.1.2.1 +66 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/serializer/Attic/ByteArraySerializer.java 1.1.2.1 +35 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/serializer/Attic/FloatSerializer.java 1.1.2.1 +61 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/serializer/Attic/DefaultXMLWriterFactory.java No revision No revision 1.1.2.1 +363 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/webserver/Attic/WebServer.java 1.1.2.1 +113 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/webserver/Attic/RequestData.java 1.1.2.1 +91 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/webserver/Attic/ServerInputStream.java 1.1.2.1 +71 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/webserver/Attic/ConnectionServer.java 1.1.2.1 +321 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/webserver/Attic/Connection.java No revision No revision 1.4.2.1 +41 -39 ws-xmlrpc/src/java/org/apache/xmlrpc/util/HttpUtil.java Index: HttpUtil.java =================================================================== RCS file: /home/cvs/ws-xmlrpc/src/java/org/apache/xmlrpc/util/HttpUtil.java,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -r1.4 -r1.4.2.1 --- HttpUtil.java 22 Apr 2005 10:25:58 -0000 1.4 +++ HttpUtil.java 12 May 2005 01:58:53 -0000 1.4.2.1 @@ -13,54 +13,56 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +package org.apache.xmlrpc.util; +import java.io.UnsupportedEncodingException; +import java.util.StringTokenizer; -package org.apache.xmlrpc.util; +import org.apache.xmlrpc.common.XmlRpcStreamConfig; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.codec.EncoderException; -/** - * Provides utility functions useful in HTTP communications - * - * @author <a href="mailto:[EMAIL PROTECTED]">Ryan Hoegg</a> +/** Provides utility functions useful in HTTP communications */ -public class HttpUtil -{ - private static final Base64 base64; - - static { - base64 = new Base64(); - } - - private HttpUtil() - { - // private because currently we only offer static methods. +public class HttpUtil { + /** Creates the Base64 encoded credentials for HTTP Basic Authentication. + * @param pUser User name, or null, if no Basic Authentication is being used. + * @param pPassword Users password, or null, if no Basic Authentication is being used. + * @param pEncoding Encoding being used for conversion of the credential string into a byte array. + * @return Base64 encoded credentials, for use in the HTTP header + * @throws UnsupportedEncodingException The encoding <code>pEncoding</code> is invalid. + */ + public static String encodeBasicAuthentication(String pUser, String pPassword, String pEncoding) throws UnsupportedEncodingException { + if (pUser == null) { + return null; + } + String s = pUser + ':' + pPassword; + if (pEncoding == null) { + pEncoding = XmlRpcStreamConfig.DEFAULT_ENCODING; + } + return new String(Base64.encode(s.getBytes(pEncoding))); } - - public static String encodeBasicAuthentication(String user, String password) - { - String auth; - if (user == null || password == null) - { - auth = null; + + /** Returns, whether the HTTP header value <code>pHeaderValue</code> + * indicates, that GZIP encoding is used or may be used. + * @param pHeaderValue The HTTP header value being parser. This is typically + * the value of "Content-Encoding", or "Accept-Encoding". + * @return True, if the header value suggests that GZIP encoding is or may + * be used. + */ + public static boolean isUsingGzipEncoding(String pHeaderValue) { + if (pHeaderValue == null) { + return false; } - else - { - try - { - Object bytes = (user + ':' + password).getBytes(); - auth = new String((byte[]) base64.encode(bytes)).trim(); + for (StringTokenizer st = new StringTokenizer(pHeaderValue, ","); st.hasMoreTokens(); ) { + String encoding = st.nextToken(); + int offset = encoding.indexOf(';'); + if (offset >= 0) { + encoding = encoding.substring(0, offset); } - catch (EncoderException e) - { - // EncoderException is never thrown in the body of - // Base64.encode(byte[]) in Commons Codec 1.1. - throw new RuntimeException("Possibly incompatible version of '" - + Base64.class.getName() + - "' used: " + e); + if ("gzip".equalsIgnoreCase(encoding.trim())) { + return true; } } - return auth; + return false; } } No revision Index: HttpUtil.java =================================================================== RCS file: /home/cvs/ws-xmlrpc/src/java/org/apache/xmlrpc/util/HttpUtil.java,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -r1.4 -r1.4.2.1 --- HttpUtil.java 22 Apr 2005 10:25:58 -0000 1.4 +++ HttpUtil.java 12 May 2005 01:58:53 -0000 1.4.2.1 @@ -13,54 +13,56 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +package org.apache.xmlrpc.util; +import java.io.UnsupportedEncodingException; +import java.util.StringTokenizer; -package org.apache.xmlrpc.util; +import org.apache.xmlrpc.common.XmlRpcStreamConfig; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.codec.EncoderException; -/** - * Provides utility functions useful in HTTP communications - * - * @author <a href="mailto:[EMAIL PROTECTED]">Ryan Hoegg</a> +/** Provides utility functions useful in HTTP communications */ -public class HttpUtil -{ - private static final Base64 base64; - - static { - base64 = new Base64(); - } - - private HttpUtil() - { - // private because currently we only offer static methods. +public class HttpUtil { + /** Creates the Base64 encoded credentials for HTTP Basic Authentication. + * @param pUser User name, or null, if no Basic Authentication is being used. + * @param pPassword Users password, or null, if no Basic Authentication is being used. + * @param pEncoding Encoding being used for conversion of the credential string into a byte array. + * @return Base64 encoded credentials, for use in the HTTP header + * @throws UnsupportedEncodingException The encoding <code>pEncoding</code> is invalid. + */ + public static String encodeBasicAuthentication(String pUser, String pPassword, String pEncoding) throws UnsupportedEncodingException { + if (pUser == null) { + return null; + } + String s = pUser + ':' + pPassword; + if (pEncoding == null) { + pEncoding = XmlRpcStreamConfig.DEFAULT_ENCODING; + } + return new String(Base64.encode(s.getBytes(pEncoding))); } - - public static String encodeBasicAuthentication(String user, String password) - { - String auth; - if (user == null || password == null) - { - auth = null; + + /** Returns, whether the HTTP header value <code>pHeaderValue</code> + * indicates, that GZIP encoding is used or may be used. + * @param pHeaderValue The HTTP header value being parser. This is typically + * the value of "Content-Encoding", or "Accept-Encoding". + * @return True, if the header value suggests that GZIP encoding is or may + * be used. + */ + public static boolean isUsingGzipEncoding(String pHeaderValue) { + if (pHeaderValue == null) { + return false; } - else - { - try - { - Object bytes = (user + ':' + password).getBytes(); - auth = new String((byte[]) base64.encode(bytes)).trim(); + for (StringTokenizer st = new StringTokenizer(pHeaderValue, ","); st.hasMoreTokens(); ) { + String encoding = st.nextToken(); + int offset = encoding.indexOf(';'); + if (offset >= 0) { + encoding = encoding.substring(0, offset); } - catch (EncoderException e) - { - // EncoderException is never thrown in the body of - // Base64.encode(byte[]) in Commons Codec 1.1. - throw new RuntimeException("Possibly incompatible version of '" - + Base64.class.getName() + - "' used: " + e); + if ("gzip".equalsIgnoreCase(encoding.trim())) { + return true; } } - return auth; + return false; } } No revision Index: HttpUtil.java =================================================================== RCS file: /home/cvs/ws-xmlrpc/src/java/org/apache/xmlrpc/util/HttpUtil.java,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -r1.4 -r1.4.2.1 --- HttpUtil.java 22 Apr 2005 10:25:58 -0000 1.4 +++ HttpUtil.java 12 May 2005 01:58:53 -0000 1.4.2.1 @@ -13,54 +13,56 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +package org.apache.xmlrpc.util; +import java.io.UnsupportedEncodingException; +import java.util.StringTokenizer; -package org.apache.xmlrpc.util; +import org.apache.xmlrpc.common.XmlRpcStreamConfig; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.codec.EncoderException; -/** - * Provides utility functions useful in HTTP communications - * - * @author <a href="mailto:[EMAIL PROTECTED]">Ryan Hoegg</a> +/** Provides utility functions useful in HTTP communications */ -public class HttpUtil -{ - private static final Base64 base64; - - static { - base64 = new Base64(); - } - - private HttpUtil() - { - // private because currently we only offer static methods. +public class HttpUtil { + /** Creates the Base64 encoded credentials for HTTP Basic Authentication. + * @param pUser User name, or null, if no Basic Authentication is being used. + * @param pPassword Users password, or null, if no Basic Authentication is being used. + * @param pEncoding Encoding being used for conversion of the credential string into a byte array. + * @return Base64 encoded credentials, for use in the HTTP header + * @throws UnsupportedEncodingException The encoding <code>pEncoding</code> is invalid. + */ + public static String encodeBasicAuthentication(String pUser, String pPassword, String pEncoding) throws UnsupportedEncodingException { + if (pUser == null) { + return null; + } + String s = pUser + ':' + pPassword; + if (pEncoding == null) { + pEncoding = XmlRpcStreamConfig.DEFAULT_ENCODING; + } + return new String(Base64.encode(s.getBytes(pEncoding))); } - - public static String encodeBasicAuthentication(String user, String password) - { - String auth; - if (user == null || password == null) - { - auth = null; + + /** Returns, whether the HTTP header value <code>pHeaderValue</code> + * indicates, that GZIP encoding is used or may be used. + * @param pHeaderValue The HTTP header value being parser. This is typically + * the value of "Content-Encoding", or "Accept-Encoding". + * @return True, if the header value suggests that GZIP encoding is or may + * be used. + */ + public static boolean isUsingGzipEncoding(String pHeaderValue) { + if (pHeaderValue == null) { + return false; } - else - { - try - { - Object bytes = (user + ':' + password).getBytes(); - auth = new String((byte[]) base64.encode(bytes)).trim(); + for (StringTokenizer st = new StringTokenizer(pHeaderValue, ","); st.hasMoreTokens(); ) { + String encoding = st.nextToken(); + int offset = encoding.indexOf(';'); + if (offset >= 0) { + encoding = encoding.substring(0, offset); } - catch (EncoderException e) - { - // EncoderException is never thrown in the body of - // Base64.encode(byte[]) in Commons Codec 1.1. - throw new RuntimeException("Possibly incompatible version of '" - + Base64.class.getName() + - "' used: " + e); + if ("gzip".equalsIgnoreCase(encoding.trim())) { + return true; } } - return auth; + return false; } } 1.1.2.1 +182 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/util/Attic/ThreadPool.java 1.1.2.1 +357 -0 ws-xmlrpc/src/java/org/apache/xmlrpc/util/Attic/Base64.java No revision No revision 1.1.2.1 +55 -0 ws-xmlrpc/.settings/Attic/org.eclipse.jdt.core.prefs No revision No revision 1.4.2.1 +4 -12 ws-xmlrpc/.classpath Index: .classpath =================================================================== RCS file: /home/cvs/ws-xmlrpc/.classpath,v retrieving revision 1.4 retrieving revision 1.4.2.1 diff -u -r1.4 -r1.4.2.1 --- .classpath 26 Apr 2005 09:55:57 -0000 1.4 +++ .classpath 12 May 2005 01:58:53 -0000 1.4.2.1 @@ -1,34 +1,26 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="examples/echo"> - <attributes> - </attributes> - </classpathentry> <classpathentry kind="src" path="src/java"> <attributes> </attributes> </classpathentry> - <classpathentry kind="src" path="src/test"> - <attributes> - </attributes> - </classpathentry> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"> <attributes> </attributes> </classpathentry> - <classpathentry kind="lib" path="lib/commons-httpclient-2.0.2.jar"> + <classpathentry sourcepath="lib/ws-commons-java5-src.zip" kind="lib" path="lib/ws-commons-java5.jar"> <attributes> </attributes> </classpathentry> - <classpathentry kind="lib" path="lib/junit-3.8.1.jar"> + <classpathentry sourcepath="lib/ws-commons-util-src.zip" kind="lib" path="lib/ws-commons-util.jar"> <attributes> </attributes> </classpathentry> - <classpathentry kind="lib" path="lib/servletapi-2.2.jar"> + <classpathentry kind="src" path="src/test"> <attributes> </attributes> </classpathentry> - <classpathentry kind="lib" path="lib/commons-codec-1.3.jar"> + <classpathentry kind="lib" path="lib/junit-3.8.1.jar"> <attributes> </attributes> </classpathentry>