This is thrown by many of the client classes if an error occured processing
- * and XML-RPC request or response due to client side processing..
- */
-public class XmlRpcClientException extends XmlRpcException {
- private static final long serialVersionUID = 3545798797134608691L;
-
- /**
- * Create an XmlRpcClientException with the given message and
- * underlying cause exception.
- *
- * @param pMessage the message for this exception.
- * @param pCause the cause of the exception.
- */
- public XmlRpcClientException(String pMessage, Throwable pCause) {
- super(0, pMessage, pCause);
- }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcClientRequestImpl.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcClientRequestImpl.java
deleted file mode 100644
index 5bcc484..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcClientRequestImpl.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequest;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequestConfig;
-
-import java.util.List;
-
-/**
- * Default implementation of
- * {@link XmlRpcRequest}.
- */
-public class XmlRpcClientRequestImpl implements XmlRpcRequest {
-
- private static final Object[] ZERO_PARAMS = new Object[0];
-
- private final XmlRpcRequestConfig config;
-
- private final String methodName;
-
- private final Object[] params;
-
- /**
- * Creates a new instance.
- * @param pConfig The request configuration.
- * @param pMethodName The method name being performed.
- * @param pParams The parameters.
- * @throws NullPointerException One of the parameters is null.
- */
- public XmlRpcClientRequestImpl(XmlRpcRequestConfig pConfig,
- String pMethodName, Object[] pParams) {
- config = pConfig;
- if (config == null) {
- throw new NullPointerException("The request configuration must not be null.");
- }
- methodName = pMethodName;
- if (methodName == null) {
- throw new NullPointerException("The method name must not be null.");
- }
- params = pParams == null ? ZERO_PARAMS : pParams;
- }
-
- /**
- * Creates a new instance.
- * @param pConfig The request configuration.
- * @param pMethodName The method name being performed.
- * @param pParams The parameters.
- * @throws NullPointerException The method name or the parameters are null.
- */
- public XmlRpcClientRequestImpl(XmlRpcRequestConfig pConfig,
- String pMethodName, List pParams) {
- this(pConfig, pMethodName, pParams == null ? null : pParams.toArray());
- }
-
- public String getMethodName() { return methodName; }
-
- public int getParameterCount() { return params.length; }
-
- public Object getParameter(int pIndex) { return params[pIndex]; }
-
- public XmlRpcRequestConfig getConfig() { return config; }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcClientWorker.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcClientWorker.java
deleted file mode 100644
index 540fa37..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcClientWorker.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcController;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequest;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcWorker;
-
-/** Object, which performs a request on the clients behalf.
- * The client maintains a pool of workers. The main purpose of the
- * pool is limitation of the maximum number of concurrent requests.
- */
-public class XmlRpcClientWorker implements XmlRpcWorker {
- private final XmlRpcClientWorkerFactory factory;
-
- /** Creates a new instance.
- * @param pFactory The factory, which is being notified, if
- * the worker's ready.
- */
- public XmlRpcClientWorker(XmlRpcClientWorkerFactory pFactory) {
- factory = pFactory;
- }
-
- public XmlRpcController getController() {
- return factory.getController();
- }
-
- /** Performs a synchronous request.
- * @param pRequest The request being performed.
- * @return The requests result.
- * @throws XmlRpcException Performing the request failed.
- */
- public Object execute(XmlRpcRequest pRequest)
- throws XmlRpcException {
- try {
- XmlRpcClient client = (XmlRpcClient) getController();
- return client.getTransportFactory().getTransport().sendRequest(pRequest);
- } finally {
- factory.releaseWorker(this);
- }
- }
-
- protected Thread newThread(Runnable pRunnable) {
- Thread result = new Thread(pRunnable);
- result.setDaemon(true);
- return result;
- }
-
- /** Performs an synchronous request.
- * @param pRequest The request being performed.
- * @param pCallback The callback being invoked, when the request is finished.
- */
- public void execute(final XmlRpcRequest pRequest,
- final AsyncCallback pCallback) {
- Runnable runnable = new Runnable(){
- public void run(){
- Object result = null;
- Throwable th = null;
- try {
- XmlRpcClient client = (XmlRpcClient) getController();
- result = client.getTransportFactory().getTransport().sendRequest(pRequest);
- } catch (Throwable t) {
- th = t;
- }
- factory.releaseWorker(XmlRpcClientWorker.this);
- if (th == null) {
- pCallback.handleResult(pRequest, result);
- } else {
- pCallback.handleError(pRequest, th);
- }
- }
- };
- newThread(runnable).start();
- }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcClientWorkerFactory.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcClientWorkerFactory.java
deleted file mode 100644
index 26807b6..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcClientWorkerFactory.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcWorker;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcWorkerFactory;
-
-/**
- * A worker factory for the client, creating instances of
- * {@link XmlRpcClientWorker}.
- */
-public class XmlRpcClientWorkerFactory extends XmlRpcWorkerFactory {
- /** Creates a new instance.
- * @param pClient The factory controller.
- */
- public XmlRpcClientWorkerFactory(XmlRpcClient pClient) {
- super(pClient);
- }
-
- /** Creates a new worker instance.
- * @return New instance of {@link XmlRpcClientWorker}.
- */
- protected XmlRpcWorker newWorker() {
- return new XmlRpcClientWorker(this);
- }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcCommonsTransport.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcCommonsTransport.java
deleted file mode 100644
index d371d5b..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcCommonsTransport.java
+++ /dev/null
@@ -1,242 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-import java.io.BufferedOutputStream;
-import java.io.FilterOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.commons.httpclient.Credentials;
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.HttpVersion;
-import org.apache.commons.httpclient.URI;
-import org.apache.commons.httpclient.URIException;
-import org.apache.commons.httpclient.UsernamePasswordCredentials;
-import org.apache.commons.httpclient.auth.AuthScope;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.RequestEntity;
-import org.apache.commons.httpclient.params.HttpMethodParams;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequest;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamConfig;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamRequestConfig;
-import org.xbib.netty.http.xmlrpc.common.util.HttpUtil;
-import org.xml.sax.SAXException;
-
-/**
- * An HTTP transport factory, which is based on the Jakarta Commons HTTP Client.
- */
-public class XmlRpcCommonsTransport extends XmlRpcHttpTransport {
- /**
- * Maximum number of allowed redirects.
- */
- private static final int MAX_REDIRECT_ATTEMPTS = 100;
-
- protected final HttpClient client;
- private static final String userAgent = USER_AGENT + " (Jakarta Commons httpclient Transport)";
- protected PostMethod method;
- private int contentLength = -1;
- private XmlRpcHttpClientConfig config;
-
- /** Creates a new instance.
- * @param pFactory The factory, which created this transport.
- */
- public XmlRpcCommonsTransport(XmlRpcCommonsTransportFactory pFactory) {
- super(pFactory.getClient(), userAgent);
- HttpClient httpClient = pFactory.getHttpClient();
- if (httpClient == null) {
- httpClient = newHttpClient();
- }
- client = httpClient;
- }
-
- protected void setContentLength(int pLength) {
- contentLength = pLength;
- }
-
- protected HttpClient newHttpClient() {
- return new HttpClient();
- }
-
- protected void initHttpHeaders(XmlRpcRequest pRequest) throws XmlRpcClientException {
- config = (XmlRpcHttpClientConfig) pRequest.getConfig();
- method = newPostMethod(config);
- super.initHttpHeaders(pRequest);
-
- if (config.getConnectionTimeout() != 0)
- client.getHttpConnectionManager().getParams().setConnectionTimeout(config.getConnectionTimeout());
-
- if (config.getReplyTimeout() != 0)
- client.getHttpConnectionManager().getParams().setSoTimeout(config.getReplyTimeout());
-
- method.getParams().setVersion(HttpVersion.HTTP_1_1);
- }
-
- protected PostMethod newPostMethod(XmlRpcHttpClientConfig pConfig) {
- return new PostMethod(pConfig.getServerURL().toString());
- }
-
- protected void setRequestHeader(String pHeader, String pValue) {
- method.setRequestHeader(new Header(pHeader, pValue));
- }
-
- protected boolean isResponseGzipCompressed() {
- Header h = method.getResponseHeader( "Content-Encoding" );
- if (h == null) {
- return false;
- } else {
- return HttpUtil.isUsingGzipEncoding(h.getValue());
- }
- }
-
- protected InputStream getInputStream() throws XmlRpcException {
- try {
- checkStatus(method);
- return method.getResponseBodyAsStream();
- } catch (HttpException e) {
- throw new XmlRpcClientException("Error in HTTP transport: " + e.getMessage(), e);
- } catch (IOException e) {
- throw new XmlRpcClientException("I/O error in server communication: " + e.getMessage(), e);
- }
- }
-
- protected void setCredentials(XmlRpcHttpClientConfig pConfig) throws XmlRpcClientException {
- String userName = pConfig.getBasicUserName();
- if (userName != null) {
- String enc = pConfig.getBasicEncoding();
- if (enc == null) {
- enc = XmlRpcStreamConfig.UTF8_ENCODING;
- }
- client.getParams().setParameter(HttpMethodParams.CREDENTIAL_CHARSET, enc);
- Credentials creds = new UsernamePasswordCredentials(userName, pConfig.getBasicPassword());
- AuthScope scope = new AuthScope(null, AuthScope.ANY_PORT, null, AuthScope.ANY_SCHEME);
- client.getState().setCredentials(scope, creds);
- client.getParams().setAuthenticationPreemptive(true);
- }
- }
-
- protected void close() throws XmlRpcClientException {
- method.releaseConnection();
- }
-
- protected boolean isResponseGzipCompressed(XmlRpcStreamRequestConfig pConfig) {
- Header h = method.getResponseHeader( "Content-Encoding" );
- if (h == null) {
- return false;
- } else {
- return HttpUtil.isUsingGzipEncoding(h.getValue());
- }
- }
-
- protected boolean isRedirectRequired() {
- switch (method.getStatusCode()) {
- case HttpStatus.SC_MOVED_TEMPORARILY:
- case HttpStatus.SC_MOVED_PERMANENTLY:
- case HttpStatus.SC_SEE_OTHER:
- case HttpStatus.SC_TEMPORARY_REDIRECT:
- return true;
- default:
- return false;
- }
- }
-
- protected void resetClientForRedirect()
- throws XmlRpcException {
- //get the location header to find out where to redirect to
- Header locationHeader = method.getResponseHeader("location");
- if (locationHeader == null) {
- throw new XmlRpcException("Invalid redirect: Missing location header");
- }
- String location = locationHeader.getValue();
-
- URI redirectUri = null;
- URI currentUri = null;
- try {
- currentUri = method.getURI();
- String charset = currentUri.getProtocolCharset();
- redirectUri = new URI(location, true, charset);
- method.setURI(redirectUri);
- } catch (URIException ex) {
- throw new XmlRpcException(ex.getMessage(), ex);
- }
-
- //And finally invalidate the actual authentication scheme
- method.getHostAuthState().invalidate();
- }
-
- protected void writeRequest(final ReqWriter pWriter) throws XmlRpcException {
- method.setRequestEntity(new RequestEntity(){
- public boolean isRepeatable() { return true; }
- public void writeRequest(OutputStream pOut) throws IOException {
- try {
- /* Make sure, that the socket is not closed by replacing it with our
- * own BufferedOutputStream.
- */
- OutputStream ostream;
- if (isUsingByteArrayOutput(config)) {
- // No need to buffer the output.
- ostream = new FilterOutputStream(pOut){
- public void close() throws IOException {
- flush();
- }
- };
- } else {
- ostream = new BufferedOutputStream(pOut){
- public void close() throws IOException {
- flush();
- }
- };
- }
- pWriter.write(ostream);
- } catch (XmlRpcException e) {
- throw new XmlRpcIOException(e);
- } catch (SAXException e) {
- throw new XmlRpcIOException(e);
- }
- }
- public long getContentLength() { return contentLength; }
- public String getContentType() { return "text/xml"; }
- });
- try {
- int redirectAttempts = 0;
- for (;;) {
- client.executeMethod(method);
- if (!isRedirectRequired()) {
- break;
- }
- if (redirectAttempts++ > MAX_REDIRECT_ATTEMPTS) {
- throw new XmlRpcException("Too many redirects.");
- }
- resetClientForRedirect();
- }
- } catch (XmlRpcIOException e) {
- Throwable t = e.getLinkedException();
- if (t instanceof XmlRpcException) {
- throw (XmlRpcException) t;
- } else {
- throw new XmlRpcException("Unexpected exception: " + t.getMessage(), t);
- }
- } catch (IOException e) {
- throw new XmlRpcException("I/O error while communicating with HTTP server: " + e.getMessage(), e);
- }
- }
-
- /**
- * Check the status of the HTTP request and throw an XmlRpcHttpTransportException if it
- * indicates that there is an error.
- * @param pMethod the method that has been executed
- * @throws XmlRpcHttpTransportException if the status of the method indicates that there is an error.
- */
- private void checkStatus(HttpMethod pMethod) throws XmlRpcHttpTransportException {
- final int status = pMethod.getStatusCode();
-
- // All status codes except SC_OK are handled as errors. Perhaps some should require special handling (e.g., SC_UNAUTHORIZED)
- if (status < 200 || status > 299) {
- throw new XmlRpcHttpTransportException(status, pMethod.getStatusText());
- }
- }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcCommonsTransportFactory.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcCommonsTransportFactory.java
deleted file mode 100644
index 58ce548..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcCommonsTransportFactory.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.xbib.netty.http.xmlrpc.client;
-
-import org.apache.commons.httpclient.HttpClient;
-
-
-/** An HTTP transport factory, which is based on the Jakarta Commons
- * HTTP Client.
- */
-public class XmlRpcCommonsTransportFactory extends XmlRpcTransportFactoryImpl {
- private HttpClient httpClient;
-
- /** Creates a new instance.
- * @param pClient The client, which is controlling the factory.
- */
- public XmlRpcCommonsTransportFactory(XmlRpcClient pClient) {
- super(pClient);
- }
-
- public XmlRpcTransport getTransport() {
- return new XmlRpcCommonsTransport(this);
- }
-
- /**
- * Sets the factories {@link HttpClient}. By default, a new instance
- * of {@link HttpClient} is created for any request.
- * Reusing the {@link HttpClient} is required, if you want to preserve
- * some state between requests. This applies, in particular, if you want
- * to use cookies: In that case, create an instance of {@link HttpClient},
- * give it to the factory, and use {@link HttpClient#getState()} to
- * read or set cookies.
- */
- public void setHttpClient(HttpClient pHttpClient) {
- httpClient = pHttpClient;
- }
-
- /**
- *
Returns the factories {@link HttpClient}. By default, a new instance
- * of {@link HttpClient} is created for any request.
- * Reusing the {@link HttpClient} is required, if you want to preserve
- * some state between requests. This applies, in particular, if you want
- * to use cookies: In that case, create an instance of {@link HttpClient},
- * give it to the factory, and use {@link HttpClient#getState()} to
- * read or set cookies.
- */
- public HttpClient getHttpClient() {
- return httpClient;
- }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcHttpClientConfig.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcHttpClientConfig.java
deleted file mode 100644
index 4c6ee7e..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcHttpClientConfig.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcHttpRequestConfig;
-
-import java.net.URL;
-
-/** Extension of {@link XmlRpcClientConfig}
- * for HTTP based transport. Provides details like server URL,
- * user credentials, and so on.
- */
-public interface XmlRpcHttpClientConfig extends XmlRpcHttpRequestConfig {
- /** Returns the HTTP servers URL.
- * @return XML-RPC servers URL; for example, this may be the URL of a
- * servlet
- */
- URL getServerURL();
-
- /**
- * Returns the user agent header to use
- * @return the http user agent header to set when doing xmlrpc requests
- */
- String getUserAgent();
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcHttpTransport.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcHttpTransport.java
deleted file mode 100644
index 4291243..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcHttpTransport.java
+++ /dev/null
@@ -1,147 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.net.URL;
-import java.util.Properties;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequest;
-import org.xbib.netty.http.xmlrpc.common.util.HttpUtil;
-import org.xml.sax.SAXException;
-
-
-/** Abstract base implementation of an HTTP transport. Base class for the
- * concrete implementations, like {@link XmlRpcSunHttpTransport},
- * or {@link XmlRpcCommonsTransport}.
- */
-public abstract class XmlRpcHttpTransport extends XmlRpcStreamTransport {
- protected class ByteArrayReqWriter implements ReqWriter {
- private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ByteArrayReqWriter(XmlRpcRequest pRequest)
- throws XmlRpcException, IOException, SAXException {
- new ReqWriterImpl(pRequest).write(baos);
- }
-
- protected int getContentLength() {
- return baos.size();
- }
-
- public void write(OutputStream pStream) throws IOException {
- try {
- baos.writeTo(pStream);
- pStream.close();
- pStream = null;
- } finally {
- if (pStream != null) { try { pStream.close(); } catch (Throwable ignore) {} }
- }
- }
- }
-
- /** The user agent string.
- */
- public static final String USER_AGENT;
- static {
- final String p = "XmlRpcClient.properties";
- final URL url = XmlRpcHttpTransport.class.getResource(p);
- if (url == null) {
- throw new IllegalStateException("Failed to locate resource: " + p);
- }
- InputStream stream = null;
- try {
- stream = url.openStream();
- final Properties props = new Properties();
- props.load(stream);
- USER_AGENT = props.getProperty("user.agent");
- if (USER_AGENT == null || USER_AGENT.trim().length() == 0) {
- throw new IllegalStateException("The property user.agent is not set.");
- }
- stream.close();
- stream = null;
- } catch (IOException e) {
- throw new UndeclaredThrowableException(e, "Failed to load resource " + url + ": " + e.getMessage());
- } finally {
- if (stream != null) { try { stream.close(); } catch (Throwable t) { /* Ignore me */ } }
- }
- }
-
- private String userAgent;
-
-
- protected XmlRpcHttpTransport(XmlRpcClient pClient, String pUserAgent) {
- super(pClient);
- userAgent = pUserAgent;
- }
-
- protected String getUserAgent() { return userAgent; }
-
- protected abstract void setRequestHeader(String pHeader, String pValue);
-
- protected void setCredentials(XmlRpcHttpClientConfig pConfig)
- throws XmlRpcClientException {
- String auth;
- try {
- auth = HttpUtil.encodeBasicAuthentication(pConfig.getBasicUserName(),
- pConfig.getBasicPassword(),
- pConfig.getBasicEncoding());
- } catch (UnsupportedEncodingException e) {
- throw new XmlRpcClientException("Unsupported encoding: " + pConfig.getBasicEncoding(), e);
- }
- if (auth != null) {
- setRequestHeader("Authorization", "Basic " + auth);
- }
- }
-
- protected void setContentLength(int pLength) {
- setRequestHeader("Content-Length", Integer.toString(pLength));
- }
-
- protected void setCompressionHeaders(XmlRpcHttpClientConfig pConfig) {
- if (pConfig.isGzipCompressing()) {
- setRequestHeader("Content-Encoding", "gzip");
- }
- if (pConfig.isGzipRequesting()) {
- setRequestHeader("Accept-Encoding", "gzip");
- }
- }
-
- protected void initHttpHeaders(XmlRpcRequest pRequest) throws XmlRpcClientException {
- XmlRpcHttpClientConfig config = (XmlRpcHttpClientConfig) pRequest.getConfig();
- setRequestHeader("Content-Type", "text/xml");
- if(config.getUserAgent() != null)
- setRequestHeader("User-Agent", config.getUserAgent());
- else
- setRequestHeader("User-Agent", getUserAgent());
- setCredentials(config);
- setCompressionHeaders(config);
- }
-
- public Object sendRequest(XmlRpcRequest pRequest) throws XmlRpcException {
- initHttpHeaders(pRequest);
- return super.sendRequest(pRequest);
- }
-
- protected boolean isUsingByteArrayOutput(XmlRpcHttpClientConfig pConfig) {
- return !pConfig.isEnabledForExtensions()
- || !pConfig.isContentLengthOptional();
- }
-
- protected ReqWriter newReqWriter(XmlRpcRequest pRequest)
- throws XmlRpcException, IOException, SAXException {
- final XmlRpcHttpClientConfig config = (XmlRpcHttpClientConfig) pRequest.getConfig();
- if (isUsingByteArrayOutput(config)) {
- ByteArrayReqWriter reqWriter = new ByteArrayReqWriter(pRequest);
- setContentLength(reqWriter.getContentLength());
- if (isCompressingRequest(config)) {
- return new GzipReqWriter(reqWriter);
- }
- return reqWriter;
- } else {
- return super.newReqWriter(pRequest);
- }
- }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcHttpTransportException.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcHttpTransportException.java
deleted file mode 100644
index 2772548..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcHttpTransportException.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-
-/**
- * Exception thrown if the HTTP status code sent by the server
- * indicates that the request could not be processed. In
- * general, the 400 and 500 level HTTP status codes will
- * result in an XmlRpcHttpTransportException being thrown.
- */
-public class XmlRpcHttpTransportException extends XmlRpcException {
- private static final long serialVersionUID = -6933992871198450027L;
-
- private final int status;
- private final String statusMessage;
-
- /**
- * Creates a new instance with the specified HTTP status code
- * and HTTP status message.
- * @param pCode The HTTP status code
- * @param pMessage The HTTP status message returned by the HTTP server
- */
- public XmlRpcHttpTransportException(int pCode, String pMessage) {
- this(pCode, pMessage, "HTTP server returned unexpected status: " + pMessage);
- }
-
- /**
- * Construct a new XmlRpcHttpTransportException with the specified HTTP status code,
- * HTTP status message, and exception message.
- * @param httpStatusCode the HTTP status code
- * @param httpStatusMessage the HTTP status message returned by the HTTP server
- * @param message the exception message.
- */
- public XmlRpcHttpTransportException(int httpStatusCode, String httpStatusMessage, String message) {
- super( message );
- this.status = httpStatusCode;
- this.statusMessage = httpStatusMessage;
- }
-
- /**
- * Get the HTTP status code that resulted in this exception.
- * @return the HTTP status code that resulted in this exception.
- */
- public int getStatusCode()
- {
- return status;
- }
-
- /**
- * Get the status message returned by the HTTP server.
- * @return the status message returned by the HTTP server.
- */
- public String getStatusMessage()
- {
- return statusMessage;
- }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcIOException.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcIOException.java
deleted file mode 100644
index d01699c..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcIOException.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-import java.io.IOException;
-
-/** This is a subclass of {@link IOException}, which
- * allows to attach a linked exception. Throwing this
- * particular instance of {@link IOException} allows
- * to catch it and throw the linked exception instead.
- */
-public class XmlRpcIOException extends IOException {
- private static final long serialVersionUID = -7704704099502077919L;
- private final Throwable linkedException;
-
- /** Creates a new instance of {@link XmlRpcIOException}
- * with the given cause.
- */
- public XmlRpcIOException(Throwable t) {
- super(t.getMessage());
- linkedException = t;
- }
-
- /** Returns the linked exception, which is the actual
- * cause for this exception.
- */
- public Throwable getLinkedException() {
- return linkedException;
- }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLite14HttpTransport.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLite14HttpTransport.java
deleted file mode 100644
index 7bfe7f8..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLite14HttpTransport.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-import java.io.IOException;
-import java.net.Socket;
-import java.net.UnknownHostException;
-
-import javax.net.ssl.SSLSocketFactory;
-
-/**
- * A "light" HTTP transport implementation for Java 1.4.
- */
-public class XmlRpcLite14HttpTransport extends XmlRpcLiteHttpTransport {
- private SSLSocketFactory sslSocketFactory;
-
- /**
- * Creates a new instance.
- * @param pClient The client controlling this instance.
- */
- public XmlRpcLite14HttpTransport(XmlRpcClient pClient) {
- super(pClient);
- }
-
- /**
- * Sets the SSL Socket Factory to use for https connections.
- */
- public SSLSocketFactory getSSLSocketFactory() {
- return sslSocketFactory;
- }
-
- /**
- * Returns the SSL Socket Factory to use for https connections.
- */
- public void setSSLSocketFactory(SSLSocketFactory pSSLSocketFactory) {
- sslSocketFactory = pSSLSocketFactory;
- }
-
- protected Socket newSocket(boolean pSSL, String pHostName, int pPort) throws UnknownHostException, IOException {
- if (pSSL) {
- SSLSocketFactory sslSockFactory = getSSLSocketFactory();
- if (sslSockFactory == null) {
- sslSockFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
- }
- return sslSockFactory.createSocket(pHostName, pPort);
- } else {
- return super.newSocket(pSSL, pHostName, pPort);
- }
- }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLite14HttpTransportFactory.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLite14HttpTransportFactory.java
deleted file mode 100644
index ab9ddd1..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLite14HttpTransportFactory.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-import javax.net.ssl.SSLSocketFactory;
-
-/**
- * Java 1.4 specific factory for the lite HTTP transport,
- * {@link XmlRpcLiteHttpTransport}.
- */
-public class XmlRpcLite14HttpTransportFactory extends XmlRpcLiteHttpTransportFactory {
- private SSLSocketFactory sslSocketFactory;
-
- /**
- * Creates a new instance.
- * @param pClient The client, which will invoke the factory.
- */
- public XmlRpcLite14HttpTransportFactory(XmlRpcClient pClient) {
- super(pClient);
- }
-
- /**
- * Sets the SSL Socket Factory to use for https connections.
- */
- public SSLSocketFactory getSSLSocketFactory() {
- return sslSocketFactory;
- }
-
- /**
- * Returns the SSL Socket Factory to use for https connections.
- */
- public void setSSLSocketFactory(SSLSocketFactory pSSLSocketFactory) {
- sslSocketFactory = pSSLSocketFactory;
- }
-
- public XmlRpcTransport getTransport() {
- XmlRpcLite14HttpTransport transport = new XmlRpcLite14HttpTransport(getClient());
- transport.setSSLSocketFactory(sslSocketFactory);
- return transport;
- }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLiteHttpTransport.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLiteHttpTransport.java
deleted file mode 100644
index 6b45376..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLiteHttpTransport.java
+++ /dev/null
@@ -1,260 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.ConnectException;
-import java.net.Socket;
-import java.net.URL;
-import java.net.UnknownHostException;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequest;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamRequestConfig;
-import org.xbib.netty.http.xmlrpc.common.util.HttpUtil;
-import org.xbib.netty.http.xmlrpc.common.util.LimitedInputStream;
-import org.xml.sax.SAXException;
-
-/**
- * A "light" HTTP transport implementation.
- */
-public class XmlRpcLiteHttpTransport extends XmlRpcHttpTransport {
- private static final String userAgent = USER_AGENT + " (Lite HTTP Transport)";
- private boolean ssl;
- private String hostname;
- private String host;
- private int port;
- private String uri;
- private Socket socket;
- private OutputStream output;
- private InputStream input;
- private final Map headers = new HashMap<>();
- private boolean responseGzipCompressed = false;
- private XmlRpcHttpClientConfig config;
-
- /**
- * Creates a new instance.
- * @param pClient The client controlling this instance.
- */
- public XmlRpcLiteHttpTransport(XmlRpcClient pClient) {
- super(pClient, userAgent);
- }
-
- public Object sendRequest(XmlRpcRequest pRequest) throws XmlRpcException {
- config = (XmlRpcHttpClientConfig) pRequest.getConfig();
- URL url = config.getServerURL();
- ssl = "https".equals(url.getProtocol());
- hostname = url.getHost();
- int p = url.getPort();
- port = p < 1 ? 80 : p;
- String u = url.getFile();
- uri = (u == null || "".equals(u)) ? "/" : u;
- host = port == 80 ? hostname : hostname + ":" + port;
- headers.put("Host", host);
- return super.sendRequest(pRequest);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected void setRequestHeader(String pHeader, String pValue) {
- Object value = headers.get(pHeader);
- if (value == null) {
- headers.put(pHeader, pValue);
- } else {
- List list;
- if (value instanceof String) {
- list = new ArrayList<>();
- list.add(value);
- headers.put(pHeader, list);
- } else {
- list = (List) value;
- }
- list.add(pValue);
- }
- }
-
- @Override
- protected void close() throws XmlRpcClientException {
- IOException e = null;
- if (input != null) {
- try {
- input.close();
- } catch (IOException ex) {
- e = ex;
- }
- }
- if (output != null) {
- try {
- output.close();
- } catch (IOException ex) {
- if (e != null) {
- e = ex;
- }
- }
- }
- if (socket != null) {
- try {
- socket.close();
- } catch (IOException ex) {
- if (e != null) {
- e = ex;
- }
- }
- }
- if (e != null) {
- throw new XmlRpcClientException("Failed to close connection: " + e.getMessage(), e);
- }
- }
-
- private OutputStream getOutputStream() throws XmlRpcException {
- try {
- final int retries = 3;
- final int delayMillis = 100;
-
- for (int tries = 0; ; tries++) {
- try {
- socket = newSocket(ssl, hostname, port);
- output = new BufferedOutputStream(socket.getOutputStream()){
- /** Closing the output stream would close the whole socket, which we don't want,
- * because the don't want until the request is processed completely.
- * A close will later occur within
- * {@link XmlRpcLiteHttpTransport#close()}.
- */
- @Override
- public void close() throws IOException {
- flush();
- socket.shutdownOutput();
- }
- };
- break;
- } catch (ConnectException e) {
- if (tries >= retries) {
- throw new XmlRpcException("Failed to connect to "
- + hostname + ":" + port + ": " + e.getMessage(), e);
- } else {
- try {
- Thread.sleep(delayMillis);
- } catch (InterruptedException ignore) {
- }
- }
- }
- }
- sendRequestHeaders(output);
- return output;
- } catch (IOException e) {
- throw new XmlRpcException("Failed to open connection to "
- + hostname + ":" + port + ": " + e.getMessage(), e);
- }
- }
-
- protected Socket newSocket(boolean pSSL, String pHostName, int pPort) throws UnknownHostException, IOException {
- if (pSSL) {
- throw new IOException("Unable to create SSL connections, use the XmlRpcLite14HttpTransportFactory.");
- }
- return new Socket(pHostName, pPort);
- }
-
- private byte[] toHTTPBytes(String pValue) throws UnsupportedEncodingException {
- return pValue.getBytes(StandardCharsets.US_ASCII);
- }
-
- private void sendHeader(OutputStream pOut, String pKey, String pValue) throws IOException {
- pOut.write(toHTTPBytes(pKey + ": " + pValue + "\r\n"));
- }
-
- @SuppressWarnings("unchecked")
- private void sendRequestHeaders(OutputStream pOut) throws IOException {
- pOut.write(("POST " + uri + " HTTP/1.0\r\n").getBytes(StandardCharsets.US_ASCII));
- for (Object o : headers.entrySet()) {
- Map.Entry entry = (Map.Entry) o;
- String key = entry.getKey();
- Object value = entry.getValue();
- if (value instanceof String) {
- sendHeader(pOut, key, (String) value);
- } else {
- List list = (List) value;
- for (Object item : list) {
- sendHeader(pOut, key, (String) item);
- }
- }
- }
- pOut.write(toHTTPBytes("\r\n"));
- }
-
- @Override
- protected boolean isResponseGzipCompressed(XmlRpcStreamRequestConfig pConfig) {
- return responseGzipCompressed;
- }
-
- @Override
- protected InputStream getInputStream() throws XmlRpcException {
- final byte[] buffer = new byte[2048];
- try {
- // If reply timeout specified, set the socket timeout accordingly
- if (config.getReplyTimeout() != 0)
- socket.setSoTimeout(config.getReplyTimeout());
- input = new BufferedInputStream(socket.getInputStream());
- // start reading server response headers
- String line = HttpUtil.readLine(input, buffer);
- StringTokenizer tokens = new StringTokenizer(line);
- tokens.nextToken(); // Skip HTTP version
- String statusCode = tokens.nextToken();
- String statusMsg = tokens.nextToken("\n\r");
- final int code;
- try {
- code = Integer.parseInt(statusCode);
- } catch (NumberFormatException e) {
- throw new XmlRpcClientException("Server returned invalid status code: "
- + statusCode + " " + statusMsg, null);
- }
- if (code < 200 || code > 299) {
- throw new XmlRpcHttpTransportException(code, statusMsg);
- }
- int contentLength = -1;
- for (;;) {
- line = HttpUtil.readLine(input, buffer);
- if ("".equals(line)) {
- break;
- }
- line = line.toLowerCase();
- if (line.startsWith("content-length:")) {
- contentLength = Integer.parseInt(line.substring("content-length:".length()).trim());
- } else if (line.startsWith("content-encoding:")) {
- responseGzipCompressed = HttpUtil.isUsingGzipEncoding(line.substring("content-encoding:".length()));
- }
- }
- InputStream result;
- if (contentLength == -1) {
- result = input;
- } else {
- result = new LimitedInputStream(input, contentLength);
- }
- return result;
- } catch (IOException e) {
- throw new XmlRpcClientException("Failed to read server response: " + e.getMessage(), e);
- }
- }
-
- @Override
- protected boolean isUsingByteArrayOutput(XmlRpcHttpClientConfig pConfig) {
- boolean result = super.isUsingByteArrayOutput(pConfig);
- if (!result) {
- throw new IllegalStateException("The Content-Length header is required with HTTP/1.0, and HTTP/1.1 is unsupported by the Lite HTTP Transport.");
- }
- return result;
- }
-
- @Override
- protected void writeRequest(ReqWriter pWriter) throws XmlRpcException, IOException, SAXException {
- pWriter.write(getOutputStream());
- }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLiteHttpTransportFactory.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLiteHttpTransportFactory.java
deleted file mode 100644
index ac40757..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLiteHttpTransportFactory.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-/** Factory for the lite HTTP transport,
- * {@link XmlRpcLiteHttpTransport}.
- */
-public class XmlRpcLiteHttpTransportFactory extends XmlRpcTransportFactoryImpl {
- /**
- * Creates a new instance.
- * @param pClient The client, which will invoke the factory.
- */
- public XmlRpcLiteHttpTransportFactory(XmlRpcClient pClient) {
- super(pClient);
- }
-
- public XmlRpcTransport getTransport() { return new XmlRpcLiteHttpTransport(getClient()); }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLocalClientConfig.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLocalClientConfig.java
deleted file mode 100644
index fb4e9f4..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLocalClientConfig.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequestProcessorFactory;
-
-/**
- * Interface of a client configuration for local rpc calls. Local
- * rpc calls are mainly useful for testing, because you don't need
- * a running server.
- */
-public interface XmlRpcLocalClientConfig extends XmlRpcClientConfig,
- XmlRpcRequestProcessorFactory {
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLocalStreamTransport.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLocalStreamTransport.java
deleted file mode 100644
index 5ddac22..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLocalStreamTransport.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.xbib.netty.http.xmlrpc.common.LocalStreamConnection;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequest;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamRequestConfig;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamRequestProcessor;
-import org.xml.sax.SAXException;
-
-/** Another local transport for debugging and testing. This one is
- * similar to the {@link XmlRpcLocalTransport},
- * except that it adds request serialization. In other words, it is
- * particularly well suited for development and testing of XML serialization
- * and parsing.
- */
-public class XmlRpcLocalStreamTransport extends XmlRpcStreamTransport {
- private final XmlRpcStreamRequestProcessor localServer;
- private LocalStreamConnection conn;
- private XmlRpcRequest request;
-
- /** Creates a new instance.
- * @param pClient The client, which is controlling the transport.
- * @param pServer An instance of {@link XmlRpcStreamRequestProcessor}.
- */
- public XmlRpcLocalStreamTransport(XmlRpcClient pClient,
- XmlRpcStreamRequestProcessor pServer) {
- super(pClient);
- localServer = pServer;
- }
-
- protected boolean isResponseGzipCompressed(XmlRpcStreamRequestConfig pConfig) {
- return pConfig.isGzipRequesting();
- }
-
- protected void close() throws XmlRpcClientException {
- }
-
- protected InputStream getInputStream() throws XmlRpcException {
- localServer.execute(conn.getConfig(), conn.getServerStreamConnection());
- return new ByteArrayInputStream(conn.getResponse().toByteArray());
- }
-
- protected ReqWriter newReqWriter(XmlRpcRequest pRequest)
- throws XmlRpcException, IOException, SAXException {
- request = pRequest;
- return super.newReqWriter(pRequest);
- }
-
- protected void writeRequest(ReqWriter pWriter)
- throws XmlRpcException, IOException, SAXException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- pWriter.write(baos);
- XmlRpcStreamRequestConfig config = (XmlRpcStreamRequestConfig) request.getConfig();
- conn = new LocalStreamConnection(config, new ByteArrayInputStream(baos.toByteArray()));
- }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLocalStreamTransportFactory.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLocalStreamTransportFactory.java
deleted file mode 100644
index 452eeef..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLocalStreamTransportFactory.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamRequestProcessor;
-
-/**
- * Another local transport factory for debugging and testing. This one is
- * similar to the {@link XmlRpcLocalTransportFactory},
- * except that it adds request serialization. In other words, it is
- * particularly well suited for development and testing of XML serialization
- * and parsing.
- */
-public class XmlRpcLocalStreamTransportFactory extends XmlRpcStreamTransportFactory {
-
- private final XmlRpcStreamRequestProcessor server;
-
- /** Creates a new instance.
- * @param pClient The client controlling the factory.
- * @param pServer An instance of {@link XmlRpcStreamRequestProcessor}.
- */
- public XmlRpcLocalStreamTransportFactory(XmlRpcClient pClient,
- XmlRpcStreamRequestProcessor pServer) {
- super(pClient);
- server = pServer;
- }
-
- public XmlRpcTransport getTransport() {
- return new XmlRpcLocalStreamTransport(getClient(), server);
- }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLocalTransport.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLocalTransport.java
deleted file mode 100644
index 01bbc74..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLocalTransport.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-import org.xbib.netty.http.xmlrpc.common.TypeConverter;
-import org.xbib.netty.http.xmlrpc.common.TypeConverterFactory;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcConfig;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcExtensionException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequest;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequestProcessor;
-
-import java.util.Collection;
-import java.util.Date;
-import java.util.Map;
-
-/**
- * The default implementation of a local transport.
- */
-public class XmlRpcLocalTransport extends XmlRpcTransportImpl {
-
- /**
- * Creates a new instance.
- * @param pClient The client, which creates the transport.
- */
- public XmlRpcLocalTransport(XmlRpcClient pClient) {
- super(pClient);
- }
-
- @SuppressWarnings("unchecked")
- private boolean isExtensionType(Object pObject) {
- if (pObject == null) {
- return true;
- } else if (pObject instanceof Object[]) {
- Object[] objects = (Object[]) pObject;
- for (Object object : objects) {
- if (isExtensionType(object)) {
- return true;
- }
- }
- return false;
- } else if (pObject instanceof Collection) {
- for (Object o : ((Collection) pObject)) {
- if (isExtensionType(o)) {
- return true;
- }
- }
- return false;
- } else if (pObject instanceof Map) {
- Map map = (Map) pObject;
- for (Object o : map.entrySet()) {
- Map.Entry entry = (Map.Entry) o;
- if (isExtensionType(entry.getKey()) || isExtensionType(entry.getValue())) {
- return true;
- }
- }
- return false;
- } else {
- return !(pObject instanceof Integer
- || pObject instanceof Date
- || pObject instanceof String
- || pObject instanceof byte[]
- || pObject instanceof Double);
- }
- }
-
- public Object sendRequest(XmlRpcRequest pRequest) throws XmlRpcException {
- XmlRpcConfig config = pRequest.getConfig();
- if (!config.isEnabledForExtensions()) {
- for (int i = 0; i < pRequest.getParameterCount(); i++) {
- if (isExtensionType(pRequest.getParameter(i))) {
- throw new XmlRpcExtensionException("Parameter " + i + " has invalid type, if isEnabledForExtensions() == false");
- }
- }
- }
- final XmlRpcRequestProcessor server = ((XmlRpcLocalClientConfig) config).getXmlRpcServer();
- Object result;
- try {
- result = server.execute(pRequest);
- } catch (XmlRpcException t) {
- throw t;
- } catch (Throwable t) {
- throw new XmlRpcClientException("Failed to invoke method " + pRequest.getMethodName()
- + ": " + t.getMessage(), t);
- }
- if (!config.isEnabledForExtensions()) {
- if (isExtensionType(result)) {
- throw new XmlRpcExtensionException("Result has invalid type, if isEnabledForExtensions() == false");
- }
- }
-
- if (result == null) {
- return null;
- }
- final TypeConverterFactory typeConverterFactory = server.getTypeConverterFactory();
- final TypeConverter typeConverter = typeConverterFactory.getTypeConverter(result.getClass());
- return typeConverter.backConvert(result);
- }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLocalTransportFactory.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLocalTransportFactory.java
deleted file mode 100644
index f066a18..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcLocalTransportFactory.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-/**
- * A transport factory being used for local XML-RPC calls. Local XML-RPC
- * calls are mainly useful for development and unit testing: Both client
- * and server are runing within the same JVM and communication is implemented
- * in simple method invokcations.
- * This class is thread safe and the returned instance of
- * {@link XmlRpcTransport} will always return the
- * same object, an instance of {@link XmlRpcLocalTransport}
- */
-public class XmlRpcLocalTransportFactory extends XmlRpcTransportFactoryImpl {
-
- /**
- * Creates a new instance, operated by the given client.
- * @param pClient The client, which will invoke the factory.
- */
- public XmlRpcLocalTransportFactory(XmlRpcClient pClient) {
- super(pClient);
- }
-
- private final XmlRpcTransport LOCAL_TRANSPORT = new XmlRpcLocalTransport(getClient());
-
- public XmlRpcTransport getTransport() { return LOCAL_TRANSPORT; }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcStreamTransport.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcStreamTransport.java
deleted file mode 100644
index 01a0959..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcStreamTransport.java
+++ /dev/null
@@ -1,195 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.zip.GZIPInputStream;
-import java.util.zip.GZIPOutputStream;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequest;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamConfig;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamRequestConfig;
-import org.xbib.netty.http.xmlrpc.common.parser.XmlRpcResponseParser;
-import org.xbib.netty.http.xmlrpc.common.serializer.XmlRpcWriter;
-import org.xbib.netty.http.xmlrpc.common.util.SAXParsers;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-
-/**
- * Implementation of a transport class, which is based on an output
- * stream for sending the request and an input stream for receiving
- * the response,
- */
-public abstract class XmlRpcStreamTransport extends XmlRpcTransportImpl {
-
- protected interface ReqWriter {
- /**
- * Writes the requests data to the given output stream.
- * The method ensures, that the target is being closed.
- */
- void write(OutputStream pStream) throws XmlRpcException, IOException, SAXException;
- }
-
- protected class ReqWriterImpl implements ReqWriter {
- private final XmlRpcRequest request;
-
- protected ReqWriterImpl(XmlRpcRequest pRequest) {
- request = pRequest;
- }
-
- /**
- * Writes the requests uncompressed XML data to the given
- * output stream. Ensures, that the output stream is being
- * closed.
- */
- public void write(OutputStream pStream)
- throws XmlRpcException, IOException, SAXException {
- final XmlRpcStreamConfig config = (XmlRpcStreamConfig) request.getConfig();
- try {
- ContentHandler h = getClient().getXmlWriterFactory().getXmlWriter(config, pStream);
- XmlRpcWriter xw = new XmlRpcWriter(config, h, getClient().getTypeFactory());
- xw.write(request);
- pStream.close();
- pStream = null;
- } finally {
- if (pStream != null) { try { pStream.close(); } catch (Throwable ignore) {} }
- }
- }
- }
-
- protected class GzipReqWriter implements ReqWriter {
- private final ReqWriter reqWriter;
- protected GzipReqWriter(ReqWriter pReqWriter) {
- reqWriter = pReqWriter;
- }
-
- public void write(OutputStream pStream) throws XmlRpcException, IOException, SAXException {
- try {
- GZIPOutputStream gStream = new GZIPOutputStream(pStream);
- reqWriter.write(gStream);
- pStream.close();
- pStream = null;
- } catch (IOException e) {
- throw new XmlRpcException("Failed to write request: " + e.getMessage(), e);
- } finally {
- if (pStream != null) { try { pStream.close(); } catch (Throwable ignore) {} }
- }
- }
- }
-
- /**
- * Creates a new instance on behalf of the given client.
- */
- protected XmlRpcStreamTransport(XmlRpcClient pClient) {
- super(pClient);
- }
-
- /**
- * Closes the connection and ensures, that all resources are being
- * released.
- */
- protected abstract void close() throws XmlRpcClientException;
-
- /**
- * Returns, whether the response is gzip compressed.
- * @param pConfig The clients configuration.
- * @return Whether the response stream is gzip compressed.
- */
- protected abstract boolean isResponseGzipCompressed(XmlRpcStreamRequestConfig pConfig);
-
- /**
- * Returns the input stream, from which the response is
- * being read.
- */
- protected abstract InputStream getInputStream() throws XmlRpcException;
-
- protected boolean isCompressingRequest(XmlRpcStreamRequestConfig pConfig) {
- return pConfig.isEnabledForExtensions()
- && pConfig.isGzipCompressing();
- }
-
- /**
- * Creates a new instance of {@link ReqWriter}.
- * @throws XmlRpcException Creating the instance failed.
- * @throws IOException Creating the instance failed, because
- * an {@link IOException} occurs.
- * @throws SAXException Creating the instance failed, because
- * the request could not be parsed.
- */
- protected ReqWriter newReqWriter(XmlRpcRequest pRequest)
- throws XmlRpcException, IOException, SAXException {
- ReqWriter reqWriter = new ReqWriterImpl(pRequest);
- if (isCompressingRequest((XmlRpcStreamRequestConfig) pRequest.getConfig())) {
- reqWriter = new GzipReqWriter(reqWriter);
- }
- return reqWriter;
- }
-
- protected abstract void writeRequest(ReqWriter pWriter)
- throws XmlRpcException, IOException, SAXException;
-
- public Object sendRequest(XmlRpcRequest pRequest) throws XmlRpcException {
- XmlRpcStreamRequestConfig config = (XmlRpcStreamRequestConfig) pRequest.getConfig();
- boolean closed = false;
- try {
- ReqWriter reqWriter = newReqWriter(pRequest);
- writeRequest(reqWriter);
- InputStream istream = getInputStream();
- if (isResponseGzipCompressed(config)) {
- istream = new GZIPInputStream(istream);
- }
- Object result = readResponse(config, istream);
- closed = true;
- close();
- return result;
- } catch (IOException e) {
- throw new XmlRpcException("Failed to read server's response: "
- + e.getMessage(), e);
- } catch (SAXException e) {
- Exception ex = e.getException();
- if (ex instanceof XmlRpcException) {
- throw (XmlRpcException) ex;
- }
- throw new XmlRpcException("Failed to generate request: "
- + e.getMessage(), e);
- } finally {
- if (!closed) { try { close(); } catch (Throwable ignore) {} }
- }
- }
-
- protected XMLReader newXMLReader() throws XmlRpcException {
- return SAXParsers.newXMLReader();
- }
-
- protected Object readResponse(XmlRpcStreamRequestConfig pConfig, InputStream pStream) throws XmlRpcException {
- InputSource isource = new InputSource(pStream);
- XMLReader xr = newXMLReader();
- XmlRpcResponseParser xp;
- try {
- xp = new XmlRpcResponseParser(pConfig, getClient().getTypeFactory());
- xr.setContentHandler(xp);
- xr.parse(isource);
- } catch (SAXException e) {
- throw new XmlRpcClientException("Failed to parse server's response: " + e.getMessage(), e);
- } catch (IOException e) {
- throw new XmlRpcClientException("Failed to read server's response: " + e.getMessage(), e);
- }
- if (xp.isSuccess()) {
- return xp.getResult();
- }
- Throwable t = xp.getErrorCause();
- if (t == null) {
- throw new XmlRpcException(xp.getErrorCode(), xp.getErrorMessage());
- }
- if (t instanceof XmlRpcException) {
- throw (XmlRpcException) t;
- }
- if (t instanceof RuntimeException) {
- throw (RuntimeException) t;
- }
- throw new XmlRpcException(xp.getErrorCode(), xp.getErrorMessage(), t);
- }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcStreamTransportFactory.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcStreamTransportFactory.java
deleted file mode 100644
index 9260369..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcStreamTransportFactory.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-/**
- * Abstract base implementation of a factory for stream transports.
- */
-public abstract class XmlRpcStreamTransportFactory extends XmlRpcTransportFactoryImpl {
- protected XmlRpcStreamTransportFactory(XmlRpcClient pClient) {
- super(pClient);
- }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcSun14HttpTransport.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcSun14HttpTransport.java
deleted file mode 100644
index 9f34cc4..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcSun14HttpTransport.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLConnection;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.SSLSocketFactory;
-
-/**
- * Default implementation of an HTTP transport in Java 1.4, based on the
- * {@link java.net.HttpURLConnection} class. Adds support for the
- * {@link SSLSocketFactory}.
- */
-public class XmlRpcSun14HttpTransport extends XmlRpcSunHttpTransport {
- private SSLSocketFactory sslSocketFactory;
-
- /**
- * Creates a new instance.
- * @param pClient The client controlling this instance.
- */
- public XmlRpcSun14HttpTransport(XmlRpcClient pClient) {
- super(pClient);
- }
-
- /**
- * Sets the SSLSocketFactory used to create secure sockets.
- * @param pSocketFactory The SSLSocketFactory to use.
- */
- public void setSSLSocketFactory(SSLSocketFactory pSocketFactory) {
- sslSocketFactory = pSocketFactory;
- }
-
- /**
- * Returns the SSLSocketFactory used to create secure sockets.
- */
- public SSLSocketFactory getSSLSocketFactory() {
- return sslSocketFactory;
- }
-
- protected URLConnection newURLConnection(URL pURL) throws IOException {
- final URLConnection conn = super.newURLConnection(pURL);
- final SSLSocketFactory sslSockFactory = getSSLSocketFactory();
- if ((sslSockFactory != null) && (conn instanceof HttpsURLConnection))
- ((HttpsURLConnection)conn).setSSLSocketFactory(sslSockFactory);
- return conn;
- }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcSun14HttpTransportFactory.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcSun14HttpTransportFactory.java
deleted file mode 100644
index dd42208..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcSun14HttpTransportFactory.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-import javax.net.ssl.SSLSocketFactory;
-
-/**
- * Default implementation of an HTTP transport factory in Java 1.4, based
- * on the {@link java.net.HttpURLConnection} class.
- */
-public class XmlRpcSun14HttpTransportFactory extends XmlRpcTransportFactoryImpl {
- private SSLSocketFactory sslSocketFactory;
-
- /**
- * Creates a new factory, which creates transports for the given client.
- * @param pClient The client, which is operating the factory.
- */
- public XmlRpcSun14HttpTransportFactory(XmlRpcClient pClient) {
- super(pClient);
- }
-
- /**
- * Sets the SSLSocketFactory to be used by transports.
- * @param pSocketFactory The SSLSocketFactory to use.
- */
- public void setSSLSocketFactory(SSLSocketFactory pSocketFactory) {
- sslSocketFactory = pSocketFactory;
- }
-
- /**
- * Returns the SSLSocketFactory to be used by transports.
- */
- public SSLSocketFactory getSSLSocketFactory() {
- return sslSocketFactory;
- }
-
- public XmlRpcTransport getTransport() {
- XmlRpcSun14HttpTransport transport = new XmlRpcSun14HttpTransport(getClient());
- transport.setSSLSocketFactory(sslSocketFactory);
- return transport;
- }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcSun15HttpTransport.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcSun15HttpTransport.java
deleted file mode 100644
index 0a7f016..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcSun15HttpTransport.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequest;
-
-import java.io.IOException;
-import java.net.Proxy;
-import java.net.URL;
-import java.net.URLConnection;
-
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.SSLSocketFactory;
-
-/**
- * Default implementation of an HTTP transport in Java 1.4, based on the
- * {@link java.net.HttpURLConnection} class. Adds support for the
- * {@link Proxy} class.
- */
-public class XmlRpcSun15HttpTransport extends XmlRpcSun14HttpTransport {
- /**
- * Creates a new instance.
- * @param pClient The client controlling this instance.
- */
- public XmlRpcSun15HttpTransport(XmlRpcClient pClient) {
- super(pClient);
- }
-
- private Proxy proxy;
-
- /**
- * Sets the proxy to use.
- */
- public void setProxy(Proxy pProxy) {
- proxy = pProxy;
- }
-
- /**
- * Returns the proxy to use.
- */
- public Proxy getProxy() {
- return proxy;
- }
-
- protected void initHttpHeaders(XmlRpcRequest pRequest)
- throws XmlRpcClientException {
- final XmlRpcHttpClientConfig config = (XmlRpcHttpClientConfig) pRequest.getConfig();
- int connectionTimeout = config.getConnectionTimeout();
- if (connectionTimeout > 0) {
- getURLConnection().setConnectTimeout(connectionTimeout);
- }
- int replyTimeout = config.getReplyTimeout();
- if (replyTimeout > 0) {
- getURLConnection().setReadTimeout(replyTimeout);
- }
- super.initHttpHeaders(pRequest);
- }
-
- protected URLConnection newURLConnection(URL pURL) throws IOException {
- final Proxy prox = getProxy();
- final URLConnection conn = prox == null ? pURL.openConnection() : pURL.openConnection(prox);
- final SSLSocketFactory sslSockFactory = getSSLSocketFactory();
- if (sslSockFactory != null && conn instanceof HttpsURLConnection) {
- ((HttpsURLConnection)conn).setSSLSocketFactory(sslSockFactory);
- }
- return conn;
- }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcSun15HttpTransportFactory.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcSun15HttpTransportFactory.java
deleted file mode 100644
index a64b5bf..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcSun15HttpTransportFactory.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.xbib.netty.http.xmlrpc.client;
-
-import java.net.InetSocketAddress;
-import java.net.Proxy;
-
-/**
- * Default implementation of an HTTP transport in Java 1.5, based on the
- * {@link java.net.HttpURLConnection} class.
- */
-public class XmlRpcSun15HttpTransportFactory extends XmlRpcSun14HttpTransportFactory {
- private Proxy proxy;
-
- /**
- * Creates a new factory, which creates transports for the given client.
- * @param pClient The client, which is operating the factory.
- */
- public XmlRpcSun15HttpTransportFactory(XmlRpcClient pClient) {
- super(pClient);
- }
-
- /**
- * Sets the proxy to use.
- * @param proxyHost The proxy hostname.
- * @param proxyPort The proxy port number.
- * @throws IllegalArgumentException if the proxyHost parameter is null or if
- * the proxyPort parameter is outside the range of valid port values.
- */
- public void setProxy(String proxyHost, int proxyPort) {
- setProxy(new Proxy(Proxy.Type.HTTP,new InetSocketAddress(proxyHost,proxyPort)));
- }
-
- /**
- * Sets the proxy to use.
- * @param pProxy The proxy settings.
- */
- public void setProxy(Proxy pProxy) {
- proxy = pProxy;
- }
-
- public XmlRpcTransport getTransport() {
- XmlRpcSun15HttpTransport transport = new XmlRpcSun15HttpTransport(getClient());
- transport.setSSLSocketFactory(getSSLSocketFactory());
- transport.setProxy(proxy);
- return transport;
- }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcSunHttpTransport.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcSunHttpTransport.java
deleted file mode 100644
index 3dbbb99..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcSunHttpTransport.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.net.URLConnection;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequest;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamRequestConfig;
-import org.xbib.netty.http.xmlrpc.common.util.HttpUtil;
-import org.xml.sax.SAXException;
-
-/**
- * Default implementation of an HTTP transport, based on the
- * {@link HttpURLConnection} class.
- */
-public class XmlRpcSunHttpTransport extends XmlRpcHttpTransport {
-
- private static final String userAgent = USER_AGENT + " (Sun HTTP Transport)";
-
- private URLConnection conn;
-
- /** Creates a new instance.
- * @param pClient The client controlling this instance.
- */
- public XmlRpcSunHttpTransport(XmlRpcClient pClient) {
- super(pClient, userAgent);
- }
-
- protected URLConnection newURLConnection(URL pURL) throws IOException {
- return pURL.openConnection();
- }
-
- /**
- * For use by subclasses.
- */
- protected URLConnection getURLConnection() {
- return conn;
- }
-
- public Object sendRequest(XmlRpcRequest pRequest) throws XmlRpcException {
- XmlRpcHttpClientConfig config = (XmlRpcHttpClientConfig) pRequest.getConfig();
- try {
- final URLConnection c = conn = newURLConnection(config.getServerURL());
- c.setUseCaches(false);
- c.setDoInput(true);
- c.setDoOutput(true);
- } catch (IOException e) {
- throw new XmlRpcException("Failed to create URLConnection: " + e.getMessage(), e);
- }
- return super.sendRequest(pRequest);
- }
-
- protected void setRequestHeader(String pHeader, String pValue) {
- getURLConnection().setRequestProperty(pHeader, pValue);
- }
-
- protected void close() {
- final URLConnection c = getURLConnection();
- if (c instanceof HttpURLConnection) {
- ((HttpURLConnection) c).disconnect();
- }
- }
-
- protected boolean isResponseGzipCompressed(XmlRpcStreamRequestConfig pConfig) {
- return HttpUtil.isUsingGzipEncoding(getURLConnection().getHeaderField("Content-Encoding"));
- }
-
- protected InputStream getInputStream() throws XmlRpcException {
- try {
- URLConnection connection = getURLConnection();
- if (connection instanceof HttpURLConnection ) {
- HttpURLConnection httpConnection = (HttpURLConnection) connection;
- int responseCode = httpConnection.getResponseCode();
- if (responseCode < 200 || responseCode > 299) {
- throw new XmlRpcHttpTransportException(responseCode, httpConnection.getResponseMessage());
- }
- }
- return connection.getInputStream();
- } catch (IOException e) {
- throw new XmlRpcException("Failed to create input stream: " + e.getMessage(), e);
- }
- }
-
- protected void writeRequest(ReqWriter pWriter) throws IOException, XmlRpcException, SAXException {
- pWriter.write(getURLConnection().getOutputStream());
- }
-}
\ No newline at end of file
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcSunHttpTransportFactory.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcSunHttpTransportFactory.java
deleted file mode 100644
index 322b5fe..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcSunHttpTransportFactory.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-/** Default implementation of a HTTP transport factory, based on the
- * {@link java.net.HttpURLConnection} class.
- */
-public class XmlRpcSunHttpTransportFactory extends XmlRpcTransportFactoryImpl {
- /** Creates a new factory, which creates transports for the given client.
- * @param pClient The client, which is operating the factory.
- */
- public XmlRpcSunHttpTransportFactory(XmlRpcClient pClient) {
- super(pClient);
- }
-
- public XmlRpcTransport getTransport() {
- return new XmlRpcSunHttpTransport(getClient());
- }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcTransport.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcTransport.java
deleted file mode 100644
index 0923f63..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcTransport.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequest;
-
-/**
- * Interface from XML-RPC to an underlying transport, most likely based on HTTP.
- */
-public interface XmlRpcTransport {
-
- /** Send an XML-RPC message. This method is called to send a message to the
- * other party.
- * @param pRequest The request being performed.
- * @return Result object, if invoking the remote method was successfull.
- * @throws XmlRpcException Performing the request failed.
- */
- Object sendRequest(XmlRpcRequest pRequest) throws XmlRpcException;
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcTransportFactory.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcTransportFactory.java
deleted file mode 100644
index 5a04c15..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcTransportFactory.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-/** Interface of an object creating instances of
- * {@link XmlRpcTransport}. The implementation
- * is typically based on singletons.
- */
-public interface XmlRpcTransportFactory {
- /** Returns an instance of {@link XmlRpcTransport}. This may
- * be a singleton, but the caller should not depend on that:
- * A new instance may as well be created for any request.
- * @return The configured transport.
- */
- public XmlRpcTransport getTransport();
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcTransportFactoryImpl.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcTransportFactoryImpl.java
deleted file mode 100644
index 1ada1c0..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcTransportFactoryImpl.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-/**
- * Abstract base implementation of an {@link XmlRpcTransportFactory}.
- */
-public abstract class XmlRpcTransportFactoryImpl implements XmlRpcTransportFactory {
- private final XmlRpcClient client;
-
- /** Creates a new instance.
- * @param pClient The client, which will invoke the factory.
- */
- protected XmlRpcTransportFactoryImpl(XmlRpcClient pClient) {
- client = pClient;
- }
-
- /** Returns the client operating this factory.
- * @return The client.
- */
- public XmlRpcClient getClient() { return client; }
-}
diff --git a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcTransportImpl.java b/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcTransportImpl.java
deleted file mode 100644
index 4123d96..0000000
--- a/netty-http-xmlrpc-client/src/main/java/org/xbib/netty/http/xmlrpc/client/XmlRpcTransportImpl.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client;
-
-/**
- * Abstract base implementation of an {@link XmlRpcTransport}.
- */
-public abstract class XmlRpcTransportImpl implements XmlRpcTransport {
- private final XmlRpcClient client;
-
- /** Creates a new instance.
- * @param pClient The client, which creates the transport.
- */
- protected XmlRpcTransportImpl(XmlRpcClient pClient) {
- client = pClient;
- }
-
- /** Returns the client, which created this transport.
- * @return The client.
- */
- public XmlRpcClient getClient() { return client; }
-}
diff --git a/netty-http-xmlrpc-client/src/main/resources/org/xbib/netty/http/xmlrpc/client/XmlRpcClient.properties b/netty-http-xmlrpc-client/src/main/resources/org/xbib/netty/http/xmlrpc/client/XmlRpcClient.properties
deleted file mode 100644
index 5d23b60..0000000
--- a/netty-http-xmlrpc-client/src/main/resources/org/xbib/netty/http/xmlrpc/client/XmlRpcClient.properties
+++ /dev/null
@@ -1 +0,0 @@
-user.agent=Apache XML RPC
diff --git a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/AuthenticationTest.java b/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/AuthenticationTest.java
deleted file mode 100644
index c169553..0000000
--- a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/AuthenticationTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client.test;
-
-import org.xbib.netty.http.xmlrpc.client.ClientFactory;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClient;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClientConfigImpl;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcHttpRequestConfig;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequestConfig;
-import org.xbib.netty.http.xmlrpc.server.AbstractReflectiveHandlerMapping;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcHandlerMapping;
-
-import java.io.IOException;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-/**
- * Test case for supported authentication variants.
- */
-public class AuthenticationTest extends XmlRpcTestCase {
-
- private static final String PASSWORD = "98765432109876543210987654321098765432109876543210";
-
- private static final String USER_NAME = "01234567890123456789012345678901234567890123456789"
- + "\u00C4\u00D6\u00DC\u00F6\u00FC\u00E4\u00DF";
-
- /** An interface, which is being implemented by the
- * server.
- */
- public interface Adder {
-
- /**
- * Returns the sum of the given integers.
- */
- int add(int pNum1, int pNum2);
- }
-
- /** Implementation of {@link DynamicProxyTest.Adder}, which is used by
- * the server.
- */
- public static class AdderImpl implements Adder {
- public int add(int pNum1, int pNum2) {
- return pNum1 + pNum2;
- }
- }
-
- protected XmlRpcHandlerMapping getHandlerMapping() throws IOException, XmlRpcException {
- XmlRpcHandlerMapping mapping = getHandlerMapping("AuthenticationTest.properties");
- ((AbstractReflectiveHandlerMapping) mapping).setAuthenticationHandler(pRequest -> {
- XmlRpcRequestConfig config = pRequest.getConfig();
- if (config instanceof XmlRpcHttpRequestConfig) {
- XmlRpcHttpRequestConfig httpRequestConfig = (XmlRpcHttpRequestConfig) config;
- return USER_NAME.equals(httpRequestConfig.getBasicUserName())
- && PASSWORD.equals(httpRequestConfig.getBasicPassword());
- }
- return true;
- });
- return mapping;
- }
-
- protected XmlRpcClientConfigImpl getConfig(ClientProvider pProvider) throws Exception {
- XmlRpcClientConfigImpl config = super.getConfig(pProvider);
- config.setBasicUserName(USER_NAME);
- config.setBasicPassword(PASSWORD);
- return config;
- }
-
- /** T
- * ests calling the {@link Adder#add(int,int)} method
- * by using an object, which has been created by the
- * {@link ClientFactory}.
- */
- public void testAdderCall() throws Exception {
- for (ClientProvider provider : providers) {
- testAdderCall(provider);
- }
- }
-
- private void testAdderCall(ClientProvider pProvider) throws Exception {
- ClientFactory factory = getClientFactory(pProvider);
- Adder adder = (Adder) factory.newInstance(Adder.class);
- assertEquals(6, adder.add(2, 4));
- }
-
- private ClientFactory getClientFactory(ClientProvider pProvider) throws Exception {
- XmlRpcClient client = pProvider.getClient();
- client.setConfig(getConfig(pProvider));
- return new ClientFactory(client);
- }
-
-}
diff --git a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/BaseTest.java b/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/BaseTest.java
deleted file mode 100644
index a8a8674..0000000
--- a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/BaseTest.java
+++ /dev/null
@@ -1,850 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client.test;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.io.StringReader;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.TimeZone;
-
-import javax.xml.namespace.QName;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClient;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcExtensionException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcInvocationException;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcHandlerMapping;
-import org.xml.sax.InputSource;
-
-/**
- * An abstract test case, to be implemented for the various
- * transport classes.
- */
-public class BaseTest extends XmlRpcTestCase {
-
- /** The remote class being invoked by the test case.
- */
- public static class Remote {
- /** Returns the argument, multiplied by two.
- * @param pArg The argument being doubled.
- * @return The argument, multiplied by two.
- */
- public int byteParam(byte pArg) { return pArg*2; }
- /** Returns the argument, multiplied by two.
- * @param pArg The argument being doubled.
- * @return The argument, multiplied by two.
- */
- public byte byteResult(byte pArg) { return (byte) (pArg*2); }
- /** Returns the argument, multiplied by two.
- * @param pArg The argument being doubled.
- * @return The argument, multiplied by two.
- */
- public int shortParam(short pArg) { return pArg*2; }
- /** Returns the argument, multiplied by two.
- * @param pArg The argument being doubled.
- * @return The argument, multiplied by two.
- */
- public short shortResult(short pArg) { return (short) (pArg*2); }
- /** Returns the argument, multiplied by two.
- * @param pArg The argument being doubled.
- * @return The argument, multiplied by two.
- */
- public int intParam(int pArg) { return pArg*2; }
- /** Returns the argument, multiplied by two.
- * @param pArg The argument being doubled.
- * @return The argument, multiplied by two.
- */
- public int longParam(long pArg) { return (int) (pArg*2); }
- /** Returns the argument, multiplied by two.
- * @param pArg The argument being doubled.
- * @return The argument, multiplied by two.
- */
- public long longResult(long pArg) { return pArg*2; }
- /** Returns the argument, multiplied by two.
- * @param pArg The argument being doubled.
- * @return The argument, multiplied by two.
- */
- public double floatParam(float pArg) { return pArg*2; }
- /** Returns the argument, multiplied by two.
- * @param pArg The argument being doubled.
- * @return The argument, multiplied by two.
- */
- public float floatResult(float pArg) { return pArg*2; }
- /** Returns the argument, multiplied by two.
- * @param pArg The argument being doubled.
- * @return The argument, multiplied by two.
- */
- public double doubleParam(double pArg) { return pArg*2; }
- /** Returns the argument, multiplied by two.
- * @param pArg The argument being doubled.
- * @return The argument, multiplied by two.
- */
- public double doubleResult(double pArg) { return pArg*2; }
- /** Returns the argument, concatenated with itself.
- * @param pArg The argument being concatenated.
- * @return The argument, concatenated with itself.
- */
- public String stringParam(String pArg) { return pArg+pArg; }
- /**
- * Throws a NullPointerException.
- */
- public Object throwNPE() {
- throw new NullPointerException();
- }
- /** Returns the argument, concatenated with itself.
- * @param pArg The argument being concatenated.
- * @return The argument, concatenated with itself.
- */
- public String nullableStringParam(String pArg) {
- if (pArg == null) {
- pArg = "";
- }
- return pArg+pArg;
- }
- /** Returns the argument, concatenated with itself.
- * @param pArg The argument being concatenated.
- * @return The argument, concatenated with itself.
- */
- public String nullableStringResult(String pArg) {
- if (pArg == null) {
- return null;
- }
- return pArg+pArg;
- }
- /** Returns the sum of the bytes in the given byte array.
- * @param pArg The array of bytes being added.
- * @return Sum over the bytes in the array.
- */
- public int byteArrayParam(byte[] pArg) {
- int sum = 0;
- for (byte b : pArg) {
- sum += b;
- }
- return sum;
- }
- /** Returns an array with the bytes 0..pArg.
- * @param pArg Requestes byte array length.
- * @return Byte array with 0..pArg.
- */
- public byte[] byteArrayResult(int pArg) {
- byte[] result = new byte[pArg];
- for (int i = 0; i < result.length; i++) {
- result[i] = (byte) i;
- }
- return result;
- }
- /** Returns the sum over the objects in the array.
- * @param pArg Object array being added
- * @return Sum over the objects in the array
- */
- public int objectArrayParam(Object[] pArg) {
- int sum = 0;
- for (Object o : pArg) {
- if (o instanceof Number) {
- sum += ((Number) o).intValue();
- } else {
- sum += Integer.parseInt((String) o);
- }
- }
- return sum;
- }
- /** Returns an array of integers with the values
- * 0..pArg.
- * @param pArg Requested array length.
- * @return Array of integers with the values 0..pArg
- */
- public Object[] objectArrayResult(int pArg) {
- Object[] result = new Object[pArg];
- for (int i = 0; i < result.length; i++) {
- result[i] = i;
- }
- return result;
- }
- /** Returns a sum over the entries in the map. Each
- * key is multiplied with its value.
- * @param pArg The map being iterated.
- * @return Sum of keys, multiplied by their values.
- */
- public int mapParam(Map pArg) {
- int sum = 0;
- for (Map.Entry entry : pArg.entrySet()) {
- String key = entry.getKey();
- Integer value = entry.getValue();
- sum += Integer.parseInt(key) * value;
- }
- return sum;
- }
- /** Returns a map with the stringified values 0..pArg as
- * keys and the corresponding integers as values.
- * @param pArg Requested map size.
- * @return Map with the keys "0".."pArg" and
- * 0..pArg as values.
- */
- public Map mapResult(int pArg) {
- Map result = new HashMap<>();
- for (int i = 0; i < pArg; i++) {
- result.put(Integer.toString(i), i);
- }
- return result;
- }
- /** Returns the sum of all "int" nodes in pNode
.
- * @param pNode The node being counted.
- * @return The sum of the values of all "int" nodes.
- */
- public int nodeParam(Node pNode) {
- if (pNode.getNodeType() != Node.DOCUMENT_NODE) {
- throw new IllegalStateException("Expected document node, got " + pNode);
- }
- Element e = ((Document) pNode).getDocumentElement();
- if (!ROOT_TAG.equals(e.getLocalName()) || !INT_URI.equals(e.getNamespaceURI())) {
- throw new IllegalStateException("Expected root element 'root', got "
- + new QName(e.getNamespaceURI(), e.getLocalName()));
- }
- return count(pNode);
- }
- private int count(Node pNode) {
- if (INT_TAG.equals(pNode.getLocalName()) && INT_URI.equals(pNode.getNamespaceURI())) {
- StringBuilder sb = new StringBuilder();
- for (Node child = pNode.getFirstChild(); child != null; child = child.getNextSibling()) {
- if (child.getNodeType() == Node.TEXT_NODE || child.getNodeType() == Node.CDATA_SECTION_NODE) {
- sb.append(child.getNodeValue());
- }
- }
- return Integer.parseInt(sb.toString());
- } else {
- int result = 0;
- for (Node child = pNode.getFirstChild(); child != null; child = child.getNextSibling()) {
- if (child.getNodeType() == Node.ELEMENT_NODE) {
- result += count(child);
- }
- }
- return result;
- }
- }
-
- /** Example of a Serializable instance.
- */
- static class CalendarWrapper implements Serializable {
- private static final long serialVersionUID = 8153663910532549627L;
- final Calendar cal;
- CalendarWrapper(Calendar pCalendar) {
- cal = pCalendar;
- }
- }
-
- /** Returns the calendar value in milliseconds.
- * @param pCal Calendar object
- * @return pCal.getTime().getTime()
.
- */
- public long serializableParam(CalendarWrapper pCal) {
- return pCal.cal.getTime().getTime();
- }
-
- /** Returns midnight of the following day.
- */
- Calendar calendarParam(Calendar pCal) {
- Calendar cal = (Calendar) pCal.clone();
- cal.add(Calendar.DAY_OF_MONTH, 1);
- cal.set(Calendar.HOUR_OF_DAY, 0);
- cal.set(Calendar.MINUTE, 0);
- cal.set(Calendar.SECOND, 0);
- cal.set(Calendar.MILLISECOND, 0);
- return cal;
- }
-
- /** Returns midnight of the following day.
- */
- public Date dateParam(Date pDate) {
- Calendar cal = Calendar.getInstance();
- cal.setTime(pDate);
- return calendarParam(cal).getTime();
- }
- }
-
- protected XmlRpcHandlerMapping getHandlerMapping() throws IOException, XmlRpcException {
- return getHandlerMapping("BaseTest.properties");
- }
-
- /** Test, whether we can invoke a method, passing a byte value.
- * @throws Exception The test failed.
- */
- public void testByteParam() throws Exception {
- for (ClientProvider provider : providers) {
- testByteParam(provider);
- }
- }
-
- private void testByteParam(ClientProvider pProvider) throws Exception {
- final String methodName = "Remote.byteParam";
- final Object[] params = new Object[]{(byte) 3};
- XmlRpcClient client = pProvider.getClient();
- Object result = client.execute(getExConfig(pProvider), methodName, params);
- assertEquals(6, result);
- try {
- client.execute(getConfig(pProvider), methodName, params);
- } catch (XmlRpcExtensionException e) {
- fail();
- }
- }
-
- /** Test, whether we can invoke a method, returning a byte.
- * @throws Exception The test failed.
- */
- public void testByteResult() throws Exception {
- for (ClientProvider provider : providers) {
- testByteResult(provider);
- }
- }
-
- private void testByteResult(ClientProvider pProvider) throws Exception {
- final String methodName = "Remote.byteResult";
- final Object[] params = new Object[]{(byte) 3};
- final XmlRpcClient client = pProvider.getClient();
- Object result = client.execute(getExConfig(pProvider), methodName, params);
- assertEquals((byte) 6, result);
- try {
- client.execute(getConfig(pProvider), methodName, params);
- } catch (XmlRpcExtensionException e) {
- fail();
- }
- }
-
- /** Test, whether we can invoke a method, passing a short value.
- * @throws Exception The test failed.
- */
- public void testShortParam() throws Exception {
- for (ClientProvider provider : providers) {
- testShortParam(provider);
- }
- }
-
- private void testShortParam(ClientProvider pProvider) throws Exception {
- final String methodName = "Remote.shortParam";
- final Object[] params = new Object[] { (short) 4 };
- final XmlRpcClient client = pProvider.getClient();
- Object result = client.execute(getExConfig(pProvider), methodName, params);
- assertEquals(8, result);
- try {
- client.execute(getConfig(pProvider), methodName, params);
- } catch (XmlRpcExtensionException e) {
- fail();
- }
- }
-
- /** Test, whether we can invoke a method, returning a short value.
- * @throws Exception The test failed.
- */
- public void testShortResult() throws Exception {
- for (ClientProvider provider : providers) {
- testShortResult(provider);
- }
- }
-
- private void testShortResult(ClientProvider pProvider) throws Exception {
- final String methodName = "Remote.shortResult";
- final Object[] params = new Object[] { (short) 4 };
- final XmlRpcClient client = pProvider.getClient();
- Object result = client.execute(getExConfig(pProvider), methodName, params);
- assertEquals((short) 8, result);
- try {
- client.execute(getConfig(pProvider), methodName, params);
- } catch (XmlRpcExtensionException e) {
- fail();
- }
- }
-
- /** Test, whether we can invoke a method, passing an
- * integer value.
- * @throws Exception The test failed.
- */
- public void testIntParam() throws Exception {
- for (ClientProvider provider : providers) {
- testIntParam(provider);
- }
- }
-
- private void testIntParam(ClientProvider pProvider) throws Exception {
- final String methodName = "Remote.intParam";
- final Object[] params = new Object[] { 5 };
- final XmlRpcClient client = pProvider.getClient();
- Object result = client.execute(getConfig(pProvider), methodName, params);
- assertEquals(10, result);
- result = client.execute(getExConfig(pProvider), methodName, params);
- assertEquals(10, result);
- }
-
- /** Test, whether we can invoke a method, passing a long value.
- * @throws Exception The test failed.
- */
- public void testLongParam() throws Exception {
- for (ClientProvider provider : providers) {
- testLongParam(provider);
- }
- }
-
- private void testLongParam(ClientProvider pProvider) throws Exception {
- final String methodName = "Remote.longParam";
- final Object[] params = new Object[] { 6L };
- final XmlRpcClient client = pProvider.getClient();
- Object result = client.execute(getExConfig(pProvider), methodName, params);
- assertEquals(12, result);
- try {
- client.execute(getConfig(pProvider), methodName, params);
- } catch (XmlRpcExtensionException e) {
- fail();
- }
- }
-
- /** Test, whether we can invoke a method, returning a long value.
- * @throws Exception The test failed.
- */
- public void testLongResult() throws Exception {
- for (ClientProvider provider : providers) {
- testLongResult(provider);
- }
- }
-
- private void testLongResult(ClientProvider pProvider) throws Exception {
- final String methodName = "Remote.longResult";
- final Object[] params = new Object[] { 6L };
- final XmlRpcClient client = pProvider.getClient();
- Object result = client.execute(getExConfig(pProvider), methodName, params);
- assertEquals(12L, result);
- try {
- client.execute(getConfig(pProvider), methodName, params);
- } catch (XmlRpcExtensionException e) {
- fail();
- }
- }
-
- /** Test, whether we can invoke a method, passing a
- * string value.
- * @throws Exception The test failed.
- */
- public void testStringParam() throws Exception {
- for (ClientProvider provider : providers) {
- testStringParam(provider);
- }
- }
-
- private void testStringParam(ClientProvider pProvider) throws Exception {
- final String methodName = "Remote.stringParam";
- final Object[] params = new Object[]{"abc"};
- final XmlRpcClient client = pProvider.getClient();
- Object result = client.execute(getConfig(pProvider), methodName, params);
- assertEquals("abcabc", result);
- result = client.execute(getExConfig(pProvider), methodName, params);
- assertEquals("abcabc", result);
- }
-
- /** Test, whether we can invoke a method, passing a
- * string value or null.
- * @throws Exception The test failed.
- */
- public void testNullableStringParam() throws Exception {
- for (ClientProvider provider : providers) {
- testNullableStringParam(provider);
- }
- }
-
- private void testNullableStringParam(ClientProvider pProvider) throws Exception {
- final String methodName = "Remote.nullableStringParam";
- final Object[] params = new Object[]{"abc"};
- final XmlRpcClient client = pProvider.getClient();
- Object result = client.execute(getConfig(pProvider), methodName, params);
- assertEquals("abcabc", result);
- result = client.execute(getExConfig(pProvider), methodName, params);
- assertEquals("abcabc", result);
- final Object[] nullParams = new Object[]{null};
- result = client.execute(getExConfig(pProvider), methodName, nullParams);
- assertEquals("", result);
- try {
- client.execute(getConfig(pProvider), methodName, nullParams);
- } catch (XmlRpcExtensionException e) {
- fail();
- }
- }
-
- /** Test, whether we can invoke a method, returning a
- * string value or null.
- * @throws Exception The test failed.
- */
- public void testNullableStringResult() throws Exception {
- for (ClientProvider provider : providers) {
- testNullableStringResult(provider);
- }
- }
-
- private void testNullableStringResult(ClientProvider pProvider) throws Exception {
- final String methodName = "Remote.nullableStringResult";
- final Object[] params = new Object[]{"abc"};
- final XmlRpcClient client = pProvider.getClient();
- Object result = client.execute(getConfig(pProvider), methodName, params);
- assertEquals("abcabc", result);
- result = client.execute(getExConfig(pProvider), methodName, params);
- assertEquals("abcabc", result);
- final Object[] nullParams = new Object[]{null};
- result = client.execute(getExConfig(pProvider), methodName, nullParams);
- assertNull(result);
- try {
- client.execute(getConfig(pProvider), methodName, nullParams);
- } catch (XmlRpcExtensionException e) {
- fail();
- }
- }
-
- /** Test, whether we can invoke a method, passing a float value.
- * @throws Exception The test failed.
- */
- public void testFloatParam() throws Exception {
- for (ClientProvider provider : providers) {
- testFloatParam(provider);
- }
- }
-
- private void testFloatParam(ClientProvider pProvider) throws Exception {
- final String methodName = "Remote.floatParam";
- final Object[] params = new Object[] { (float) 0.4 };
- final XmlRpcClient client = pProvider.getClient();
- Object result = client.execute(getExConfig(pProvider), methodName, params);
- assertEquals(8, Math.round((Double) result *10));
- try {
- client.execute(getConfig(pProvider), methodName, params);
- } catch (XmlRpcExtensionException e) {
- fail();
- }
- }
-
- /** Test, whether we can invoke a method, returning a float value.
- * @throws Exception The test failed.
- */
- public void testFloatResult() throws Exception {
- for (ClientProvider provider : providers) {
- testFloatResult(provider);
- }
- }
-
- private void testFloatResult(ClientProvider pProvider) throws Exception {
- final String methodName = "Remote.floatResult";
- final Object[] params = new Object[] { (float) 0.4 };
- final XmlRpcClient client = pProvider.getClient();
- Object result = client.execute(getExConfig(pProvider), methodName, params);
- assertEquals((float) 0.8, result);
- try {
- client.execute(getConfig(pProvider), methodName, params);
- } catch (XmlRpcExtensionException e) {
- fail();
- }
- }
-
- /** Test, whether we can invoke a method, passing a
- * double value.
- * @throws Exception The test failed.
- */
- public void testDoubleParam() throws Exception {
- for (ClientProvider provider : providers) {
- testDoubleParam(provider);
- }
- }
-
- private void testDoubleParam(ClientProvider pProvider) throws Exception {
- final String methodName = "Remote.doubleParam";
- final Object[] params = new Object[] { 0.6 };
- final XmlRpcClient client = pProvider.getClient();
- Object result = client.execute(getConfig(pProvider), methodName, params);
- assertEquals(1.2, result);
- result = client.execute(getExConfig(pProvider), methodName, params);
- assertEquals(1.2, result);
- }
-
- /** Test, whether we can invoke a method, returning a
- * double value.
- * @throws Exception The test failed.
- */
- public void testDoubleResult() throws Exception {
- for (ClientProvider provider : providers) {
- testDoubleResult(provider);
- }
- }
-
- private void testDoubleResult(ClientProvider pProvider) throws Exception {
- final String methodName = "Remote.doubleResult";
- final Object[] params = new Object[]{ 0.6 };
- final XmlRpcClient client = pProvider.getClient();
- Object result = client.execute(getConfig(pProvider), methodName, params);
- assertEquals(1.2, result);
- result = client.execute(getExConfig(pProvider), methodName, params);
- assertEquals(1.2, result);
- }
-
- /** Test, whether we can invoke a method, passing a
- * byte array.
- * @throws Exception The test failed.
- */
- public void testByteArrayParam() throws Exception {
- for (ClientProvider provider : providers) {
- testByteArrayParam(provider);
- }
- }
-
- private void testByteArrayParam(ClientProvider pProvider) throws Exception {
- final byte[] bytes = new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
- final String methodName = "Remote.byteArrayParam";
- final Object[] params = new Object[] { bytes };
- final XmlRpcClient client = pProvider.getClient();
- Object result = client.execute(getConfig(pProvider), methodName, params);
- assertEquals(1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9, result);
- result = client.execute(getExConfig(pProvider), methodName, params);
- assertEquals(1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9, result);
- }
-
- /** Test, whether we can invoke a method, returning a
- * byte array.
- * @throws Exception The test failed.
- */
- public void testByteArrayResult() throws Exception {
- for (ClientProvider provider : providers) {
- testByteArrayResult(provider);
- }
- }
-
- private void testByteArrayResult(ClientProvider pProvider) throws Exception {
- final byte[] bytes = new byte[]{0, 1, 2, 3, 4, 5, 6, 7};
- final String methodName = "Remote.byteArrayResult";
- final Object[] params = new Object[] { 8 };
- final XmlRpcClient client = pProvider.getClient();
- Object result = client.execute(getConfig(pProvider), methodName, params);
- assertTrue(Arrays.equals(bytes, (byte[]) result));
- result = client.execute(getExConfig(pProvider), methodName, params);
- assertTrue(Arrays.equals(bytes, (byte[]) result));
- }
-
- /** Test, whether we can invoke a method, passing an
- * object array.
- * @throws Exception The test failed.
- */
- public void testObjectArrayParam() throws Exception {
- for (ClientProvider provider : providers) {
- testObjectArrayParam(provider);
- }
- }
-
- private void testObjectArrayParam(ClientProvider pProvider) throws Exception {
- final Object[] objects = new Object[]{(byte) 1, (short) 2, 3, 4L, "5"};
- final String methodName = "Remote.objectArrayParam";
- final Object[] params = new Object[]{objects};
- final XmlRpcClient client = pProvider.getClient();
- boolean ok = false;
- try {
- client.execute(getConfig(pProvider), methodName, params);
- } catch (XmlRpcExtensionException e) {
- ok = true;
- }
- assertTrue(ok);
- Object result = client.execute(getExConfig(pProvider), methodName, params);
- assertEquals(15, result);
- }
-
- /** Test, whether we can invoke a method, returning an
- * object array.
- * @throws Exception The test failed.
- */
- public void testObjectArrayResult() throws Exception {
- for (ClientProvider provider : providers) {
- testObjectArrayResult(provider);
- }
- }
-
- private void testObjectArrayResult(ClientProvider pProvider) throws Exception {
- final Object[] objects = new Object[]{0, 1, 2, 3};
- final String methodName = "Remote.objectArrayResult";
- final Object[] params = new Object[] { 4 };
- final XmlRpcClient client = pProvider.getClient();
- Object result = client.execute(getConfig(pProvider), methodName, params);
- assertTrue(Arrays.equals(objects, (Object[]) result));
- result = client.execute(getExConfig(pProvider), methodName, params);
- assertTrue(Arrays.equals(objects, (Object[]) result));
- }
-
- /** Test, whether we can invoke a method, passing a map.
- * @throws Exception The test failed.
- */
- public void testMapParam() throws Exception {
- for (ClientProvider provider : providers) {
- testMapParam(provider);
- }
- }
-
- private void testMapParam(ClientProvider pProvider) throws Exception {
- final Map map = new HashMap<>();
- map.put("2", 3);
- map.put("3", 5);
- final String methodName = "Remote.mapParam";
- final Object[] params = new Object[]{ map };
- final XmlRpcClient client = pProvider.getClient();
- Object result = client.execute(getConfig(pProvider), methodName, params);
- assertEquals(21, result);
- result = client.execute(getExConfig(pProvider), methodName, params);
- assertEquals(21, result);
- }
-
- private void checkMap(Map pResult) {
- assertEquals(4, pResult.size());
- assertEquals(0, pResult.get("0"));
- assertEquals(1, pResult.get("1"));
- assertEquals(2, pResult.get("2"));
- assertEquals(3, pResult.get("3"));
- }
-
- /** Test, whether we can invoke a method, returning a map.
- * @throws Exception The test failed.
- */
- public void testMapResult() throws Exception {
- for (ClientProvider provider : providers) {
- testMapResult(provider);
- }
- }
-
- @SuppressWarnings("unchecked")
- private void testMapResult(ClientProvider pProvider) throws Exception {
- final String methodName = "Remote.mapResult";
- final Object[] params = new Object[] { 4 };
- final XmlRpcClient client = pProvider.getClient();
- Map result = (Map) client.execute(getConfig(pProvider), methodName, params);
- checkMap(result);
- result = (Map) client.execute(getExConfig(pProvider), methodName, params);
- checkMap(result);
- }
-
- /** Test, whether we can invoke a method, passing a DOM
- * node as parameter.
- * @throws Exception The test failed.
- */
- public void testNodeParam() throws Exception {
- for (ClientProvider provider : providers) {
- testNodeParam(provider);
- }
- }
-
- private static final String ROOT_TAG = "root";
-
- private static final String INT_TAG = "int";
-
- private static final String INT_URI = "http://ws.apache.org/xmlrpc/namespaces/testNodeParam";
-
- private void testNodeParam(ClientProvider pProvider) throws Exception {
- final String xml =
- "<" + ROOT_TAG + " xmlns='" + INT_URI +"'>" +
- " <" + INT_TAG + ">1" + INT_TAG + ">" +
- " <" + INT_TAG + ">2" + INT_TAG + ">" +
- " <" + INT_TAG + ">3" + INT_TAG + ">" +
- " <" + INT_TAG + ">4" + INT_TAG + ">" +
- " <" + INT_TAG + ">5" + INT_TAG + ">" +
- "" + ROOT_TAG + ">";
- final String methodName = "Remote.nodeParam";
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- dbf.setValidating(false);
- dbf.setNamespaceAware(true);
- Document doc = dbf.newDocumentBuilder().parse(new InputSource(new StringReader(xml)));
- final Object[] params = new Object[]{doc};
- final XmlRpcClient client = pProvider.getClient();
- Object result = client.execute(getExConfig(pProvider), methodName, params);
- assertEquals(1 + 2 + 3 + 4 + 5, result);
- try {
- client.execute(getConfig(pProvider), methodName, params);
- } catch (XmlRpcExtensionException e) {
- fail();
- }
- }
-
- /** Test, whether we can invoke a method, passing an instance of
- * {@link Serializable} as a parameter.
- * @throws Exception The test failed.
- */
- public void testSerializableParam() throws Exception {
- for (ClientProvider provider : providers) {
- testSerializableParam(provider);
- }
- }
-
- private void testSerializableParam(ClientProvider pProvider) throws Exception {
- final String methodName = "Remote.serializableParam";
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
- cal.set(2005, 5, 23, 8, 4, 0);
- cal.set(Calendar.MILLISECOND, 5);
- final Object[] params = new Object[]{new Remote.CalendarWrapper(cal)};
- final XmlRpcClient client = pProvider.getClient();
- Object result = client.execute(getExConfig(pProvider), methodName, params);
- assertEquals(cal.getTime().getTime(), result);
- try {
- client.execute(getConfig(pProvider), methodName, params);
- } catch (XmlRpcExtensionException e) {
- fail();
- }
- }
-
- private Calendar newCalendarResult() {
- Calendar cal2 = Calendar.getInstance(TimeZone.getDefault());
- cal2.set(2005, 5, 24, 0, 0, 0);
- cal2.set(Calendar.MILLISECOND, 0);
- return cal2;
- }
-
- private Calendar newCalendarParam() {
- Calendar cal1 = Calendar.getInstance(TimeZone.getDefault());
- cal1.set(2005, 5, 23, 8, 4, 0);
- cal1.set(Calendar.MILLISECOND, 5);
- return cal1;
- }
-
- /** Tests, whether we can invoke a method, passing an instance of
- * {@link Date} as a parameter.
- * @throws Exception The test failed.
- */
- public void testDateParam() throws Exception {
- for (ClientProvider provider : providers) {
- testDateParam(provider);
- }
- }
-
- private void testDateParam(ClientProvider pProvider) throws Exception {
- final String methodName = "Remote.dateParam";
- Date date1 = newCalendarParam().getTime();
- Calendar cal2 = newCalendarResult();
- final Object[] params = new Object[]{date1};
- final XmlRpcClient client = pProvider.getClient();
- Object result = client.execute(getExConfig(pProvider), methodName, params);
- assertEquals(cal2.getTime(), result);
- result = client.execute(getConfig(pProvider), methodName, params);
- assertEquals(cal2.getTime(), result);
- }
-
- /**
- * Tests, whether a NullPointerException, thrown by the server, can be
- * trapped by the client.
- */
- public void testCatchNPE() throws Exception {
- for (ClientProvider provider : providers) {
- testCatchNPE(provider);
- }
- }
-
- private void testCatchNPE(ClientProvider pProvider) throws Exception {
- final XmlRpcClient client = pProvider.getClient();
- final String methodName = "Remote.throwNPE";
- try {
- client.execute(getExConfig(pProvider), methodName, (Object[]) null);
- } catch (XmlRpcInvocationException e) {
- if (!(e.getCause() instanceof NullPointerException)) {
- throw e;
- }
- }
- }
-}
diff --git a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/ClientIpTest.java b/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/ClientIpTest.java
deleted file mode 100644
index a69c3a9..0000000
--- a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/ClientIpTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client.test;
-
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClient;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcHandler;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcHandlerMapping;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcNoSuchHandlerException;
-import org.xbib.netty.http.xmlrpc.servlet.XmlRpcServlet;
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * Test case for reading the clients IP address.
- */
-public class ClientIpTest extends XmlRpcTestCase {
- /**
- * An object, which provides additional information
- * about the client to the user.
- */
- public static class ClientInfo {
- private final String ipAddress;
-
- /**
- * Creates a new instance.
- */
- public ClientInfo(String pIpAddress) {
- ipAddress = pIpAddress;
- }
-
- /**
- * Returns the clients IP address.
- */
- public String getIpAddress() {
- return ipAddress;
- }
- }
-
- /**
- * An extension of the {@link XmlRpcServlet}, which
- * ensures the availability of a {@link ClientInfo}
- * object.
- */
- public static class ClientInfoServlet extends XmlRpcServlet {
-
- private static final long serialVersionUID = 8210342625908021538L;
-
- private static final ThreadLocal clientInfo = new ThreadLocal<>();
-
- /**
- * Returns the current threads. client info object.
- */
- static ClientInfo getClientInfo() {
- return clientInfo.get();
- }
-
- public void doPost(HttpServletRequest pRequest,
- HttpServletResponse pResponse) throws IOException,
- ServletException {
- clientInfo.set(new ClientInfo(pRequest.getRemoteAddr()));
- super.doPost(pRequest, pResponse);
- }
- }
-
- private static class ClientIpTestProvider extends ServletWebServerProvider {
- ClientIpTestProvider(XmlRpcHandlerMapping pMapping, boolean pContentLength)
- throws ServletException, IOException {
- super(pMapping, pContentLength);
- }
-
- protected XmlRpcServlet newXmlRpcServlet() {
- return new ClientInfoServlet();
- }
- }
-
- protected ClientProvider[] initProviders(XmlRpcHandlerMapping pMapping)
- throws ServletException, IOException {
- return new ClientProvider[]{
- new ClientIpTestProvider(pMapping, false),
- new ClientIpTestProvider(pMapping, true)
- };
- }
-
- protected XmlRpcHandlerMapping getHandlerMapping() {
- final XmlRpcHandler handler = pRequest -> {
- final ClientInfo clientInfo = ClientInfoServlet.getClientInfo();
- if (clientInfo == null) {
- return "";
- }
- final String ip = clientInfo.getIpAddress();
- if (ip == null) {
- return "";
- }
- return ip;
- };
- return new XmlRpcHandlerMapping(){
- public XmlRpcHandler getHandler(String pHandlerName)
- throws XmlRpcNoSuchHandlerException, XmlRpcException {
- return handler;
- }
- };
- }
-
- private void testClientIpAddress(ClientProvider pProvider) throws Exception {
- final XmlRpcClient client = pProvider.getClient();
- client.setConfig(getConfig(pProvider));
- final String ip = (String) client.execute("getIpAddress", new Object[]{});
- assertEquals("127.0.0.1", ip);
- }
-
- /** Test, whether we can invoke a method, returning a byte.
- * @throws Exception The test failed.
- */
- public void testClientIpAddress() throws Exception {
- for (int i = 0; i < providers.length; i++) {
- testClientIpAddress(providers[i]);
- }
- }
-}
diff --git a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/ClientProvider.java b/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/ClientProvider.java
deleted file mode 100644
index 260f370..0000000
--- a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/ClientProvider.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client.test;
-
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClient;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClientConfigImpl;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcServer;
-
-import java.io.IOException;
-
-/** This interface allows to perform a unit test with various
- * transports. Basically, the implementation creates the client,
- * including the transport, and the server, if required.
- */
-public interface ClientProvider {
- /** Returns the clients default configuration.
- * @return The clients configuration.
- * @throws Exception Creating the configuration failed.
- */
- XmlRpcClientConfigImpl getConfig() throws Exception;
-
- /** Returns a new client instance.
- * @return A client being used for performing the test.
- */
- XmlRpcClient getClient();
-
- /** Returns the providers server instance.
- * @return A server instance, which is being used for performing the test.
- */
- XmlRpcServer getServer();
-
- /** Performs a shutdown of the server.
- */
- void shutdown() throws IOException;
-}
diff --git a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/ClientProviderImpl.java b/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/ClientProviderImpl.java
deleted file mode 100644
index c245cec..0000000
--- a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/ClientProviderImpl.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client.test;
-
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClient;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClientConfigImpl;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcTransportFactory;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcHandlerMapping;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcServer;
-
-/** Abstract base implementation of {@link ClientProvider}.
- */
-public abstract class ClientProviderImpl implements ClientProvider {
-
- protected final XmlRpcHandlerMapping mapping;
-
- protected XmlRpcClientConfigImpl clientConfig;
-
- protected abstract XmlRpcTransportFactory getTransportFactory(XmlRpcClient pClient);
-
- /** Creates a new instance.
- * @param pMapping The test servers handler mapping.
- */
- protected ClientProviderImpl(XmlRpcHandlerMapping pMapping) {
- mapping = pMapping;
- }
-
- protected XmlRpcServer getXmlRpcServer() {
- XmlRpcServer server = new XmlRpcServer();
- server.setHandlerMapping(mapping);
- return server;
- }
-
- public XmlRpcClientConfigImpl getConfig() throws Exception {
- if (clientConfig == null) {
- clientConfig = new XmlRpcClientConfigImpl();
- }
- return clientConfig;
- }
-
- public XmlRpcClient getClient() {
- XmlRpcClient client = new XmlRpcClient();
- client.setTransportFactory(getTransportFactory(client));
- return client;
- }
-
-}
diff --git a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/CommonsProvider.java b/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/CommonsProvider.java
deleted file mode 100644
index 2de3791..0000000
--- a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/CommonsProvider.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client.test;
-
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClient;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcCommonsTransport;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcCommonsTransportFactory;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcTransportFactory;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcHandlerMapping;
-
-/**
- * Provider for testing the
- * {@link XmlRpcCommonsTransport}.
- */
-public class CommonsProvider extends WebServerProvider {
- /** Creates a new instance.
- * @param pMapping The test servers handler mapping.
- */
- public CommonsProvider(XmlRpcHandlerMapping pMapping) {
- super(pMapping, true);
- }
-
- protected XmlRpcTransportFactory getTransportFactory(XmlRpcClient pClient) {
- return new XmlRpcCommonsTransportFactory(pClient);
- }
-}
diff --git a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/CustomTypesTest.java b/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/CustomTypesTest.java
deleted file mode 100644
index 2a764a7..0000000
--- a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/CustomTypesTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client.test;
-
-import java.io.IOException;
-import java.text.DateFormat;
-import java.text.Format;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClient;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClientConfigImpl;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClientRequestImpl;
-import org.xbib.netty.http.xmlrpc.common.TypeFactory;
-import org.xbib.netty.http.xmlrpc.common.TypeFactoryImpl;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcController;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequest;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamConfig;
-import org.xbib.netty.http.xmlrpc.common.parser.DateParser;
-import org.xbib.netty.http.xmlrpc.common.parser.TypeParser;
-import org.xbib.netty.http.xmlrpc.common.serializer.DateSerializer;
-import org.xbib.netty.http.xmlrpc.common.serializer.TypeSerializer;
-import org.xbib.netty.http.xmlrpc.common.util.NamespaceContextImpl;
-import org.xbib.netty.http.xmlrpc.server.PropertyHandlerMapping;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcHandlerMapping;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcServer;
-import org.xml.sax.SAXException;
-
-/**
- * Test suite for working with custom types.
- */
-public class CustomTypesTest extends XmlRpcTestCase {
- /**
- * Sample date converter
- */
- public static class DateConverter {
- /**
- * Adds one day to the given date.
- */
- public Date tomorrow(Date pDate) {
- Calendar cal = Calendar.getInstance();
- cal.setTime(pDate);
- cal.add(Calendar.DAY_OF_MONTH, 1);
- return cal.getTime();
- }
- }
-
- protected XmlRpcHandlerMapping getHandlerMapping() throws IOException, XmlRpcException {
- PropertyHandlerMapping mapping = new PropertyHandlerMapping();
- mapping.addHandler("DateConverter", DateConverter.class);
- return mapping;
- }
-
- /** Tests using a custom date format.
- */
- public void testCustomDateFormat() throws Exception {
- for (int i = 0; i < providers.length; i++) {
- testCustomDateFormat(providers[i]);
- }
- }
-
- private TypeFactory getCustomDateTypeFactory(XmlRpcController pController, final Format pFormat) {
- return new TypeFactoryImpl(pController){
- private TypeSerializer dateSerializer = new DateSerializer(pFormat);
-
- public TypeParser getParser(XmlRpcStreamConfig pConfig, NamespaceContextImpl pContext, String pURI, String pLocalName) {
- if (DateSerializer.DATE_TAG.equals(pLocalName)) {
- return new DateParser(pFormat);
- } else {
- return super.getParser(pConfig, pContext, pURI, pLocalName);
- }
- }
-
- public TypeSerializer getSerializer(XmlRpcStreamConfig pConfig, Object pObject) throws SAXException {
- if (pObject instanceof Date) {
- return dateSerializer;
- } else {
- return super.getSerializer(pConfig, pObject);
- }
- }
-
- };
- }
-
- private void testCustomDateFormat(ClientProvider pProvider) throws Exception {
- final DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
- XmlRpcClient client = pProvider.getClient();
- XmlRpcClientConfigImpl config = getConfig(pProvider);
- client.setConfig(config);
- TypeFactory typeFactory = getCustomDateTypeFactory(client, format);
- client.setTypeFactory(typeFactory);
- Calendar cal1 = Calendar.getInstance();
- XmlRpcRequest request = new XmlRpcClientRequestImpl(config, "DateConverter.tomorrow", new Object[]{cal1.getTime()});
- final String got = XmlRpcTestCase.writeRequest(client, request);
- final String expect = ""
- + "DateConverter.tomorrow "
- + "" + format.format(cal1.getTime())
- + " ";
- assertEquals(expect, got);
-
- XmlRpcServer server = pProvider.getServer();
- server.setTypeFactory(getCustomDateTypeFactory(server, format));
- Date date = (Date) client.execute(request);
- Calendar cal2 = Calendar.getInstance();
- cal2.setTime(date);
- cal1.add(Calendar.DAY_OF_MONTH, 1);
- assertEquals(cal1, cal2);
- }
-}
diff --git a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/DynamicProxyTest.java b/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/DynamicProxyTest.java
deleted file mode 100644
index 80f4985..0000000
--- a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/DynamicProxyTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client.test;
-
-import java.io.IOException;
-
-import org.xbib.netty.http.xmlrpc.client.ClientFactory;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClient;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcHandlerMapping;
-import org.xml.sax.SAXException;
-
-/** Test case for the {@link ClientFactory}.
- */
-public class DynamicProxyTest extends XmlRpcTestCase {
- /** An interface, which is being implemented by the
- * server.
- */
- public interface Adder {
- /** Returns the sum of the given integers.
- */
- public int add(int pNum1, int pNum2);
-
- /**
- * Throws a SAXException.
- */
- public Object parse(String pMessage) throws SAXException;
-
- /**
- * A void method; these are disabled without support for
- * extensions, but enabled when extensions are on.
- */
- public void ping();
- }
-
- /** Implementation of {@link Adder}, which is used by
- * the server.
- */
- public static class AdderImpl implements Adder {
- public int add(int pNum1, int pNum2) {
- return pNum1 + pNum2;
- }
- public Object parse(String pMessage) throws SAXException {
- throw new SAXException("Failed to parse message: " + pMessage);
- }
- public void ping() {
- }
- }
-
- protected XmlRpcHandlerMapping getHandlerMapping() throws IOException, XmlRpcException {
- return getHandlerMapping("DynamicProxyTest.properties");
- }
-
- private ClientFactory getClientFactory(ClientProvider pProvider) throws Exception {
- XmlRpcClient client = pProvider.getClient();
- client.setConfig(getConfig(pProvider));
- return new ClientFactory(client);
- }
-
- private ClientFactory getExClientFactory(ClientProvider pProvider) throws Exception {
- XmlRpcClient client = pProvider.getClient();
- client.setConfig(getExConfig(pProvider));
- return new ClientFactory(client);
- }
-
- /** Tests calling the {@link Adder#add(int,int)} method
- * by using an object, which has been created by the
- * {@link ClientFactory}.
- */
- public void testAdderCall() throws Exception {
- for (int i = 0; i < providers.length; i++) {
- testAdderCall(providers[i]);
- }
- }
-
- private void testAdderCall(ClientProvider pProvider) throws Exception {
- ClientFactory factory = getClientFactory(pProvider);
- Adder adder = (Adder) factory.newInstance(Adder.class);
- assertEquals(6, adder.add(2, 4));
- }
-
- /** Tests trapping a SAXException.
- */
- public void testParseCall() throws Exception {
- for (int i = 0; i < providers.length; i++) {
- testParseCall(providers[i]);
- }
- }
-
- private void testParseCall(ClientProvider pProvider) throws Exception {
- ClientFactory factory = getExClientFactory(pProvider);
- Adder adder = (Adder) factory.newInstance(Adder.class);
- try {
- adder.parse("foo");
- fail("Expected SAXException");
- } catch (SAXException e) {
- // Ok
- }
- }
-
- /**
- * Tests invoking a "void" method.
- */
- public void testVoidMethod() throws Exception {
- for (int i = 0; i < providers.length; i++) {
- testVoidMethod(providers[i]);
- }
- }
-
- private void testVoidMethod(ClientProvider pProvider) throws Exception {
- ClientFactory factory = getExClientFactory(pProvider);
- Adder adder = (Adder) factory.newInstance(Adder.class);
- adder.ping();
- }
-}
diff --git a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/JiraTest.java b/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/JiraTest.java
deleted file mode 100644
index 1d9d274..0000000
--- a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/JiraTest.java
+++ /dev/null
@@ -1,387 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client.test;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.util.Collections;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Vector;
-
-import org.xbib.netty.http.xmlrpc.client.ClientFactory;
-import org.xbib.netty.http.xmlrpc.client.TimingOutCallback;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClient;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcHttpClientConfig;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamRequestConfig;
-import org.xbib.netty.http.xmlrpc.common.parser.XmlRpcResponseParser;
-import org.xbib.netty.http.xmlrpc.common.util.SAXParsers;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcHandlerMapping;
-import org.xml.sax.InputSource;
-import org.xml.sax.XMLReader;
-
-
-/**
- * Test case for various jira issues.
- */
-public class JiraTest extends XmlRpcTestCase {
- /** Interface of the handler for {@link JiraTest#testXMLRPC89()}
- */
- public interface XMLRPC89Handler {
- /**
- * Returns the reversed vector.
- */
- Vector reverse(Vector pVector);
- /**
- * Returns the same hashtable, but doubles the
- * values.
- */
- Hashtable doubledValues(Hashtable pMap);
- /**
- * Returns the same properties, but doubles the
- * values.
- */
- Properties doubledPropertyValues(Properties pMap);
- }
-
- /**
- * Handler for {@link JiraTest#testXMLRPC89()}
- */
- public static class XMLRPC89HandlerImpl implements XMLRPC89Handler {
- public Vector reverse(Vector pVector) {
- Vector result = new Vector<>(pVector.size());
- result.addAll(pVector);
- Collections.reverse(result);
- return result;
- }
- public Hashtable doubledValues(Hashtable pMap) {
- final Hashtable result;
- if (pMap instanceof Properties) {
- result = new Properties();
- } else {
- result = new Hashtable<>();
- }
- result.putAll(pMap);
- for (Map.Entry entry : result.entrySet()) {
- Object value = entry.getValue();
- final Integer i;
- if (pMap instanceof Properties) {
- i = Integer.valueOf((String) value);
- } else {
- i = (Integer) value;
- }
- Integer iDoubled = i * 2;
- if (pMap instanceof Properties) {
- entry.setValue(iDoubled.toString());
- } else {
- entry.setValue(iDoubled);
- }
- }
- return result;
- }
- public Properties doubledPropertyValues(Properties pProperties) {
- return (Properties) doubledValues(pProperties);
- }
- }
-
- protected XmlRpcHandlerMapping getHandlerMapping() throws IOException,
- XmlRpcException {
- return getHandlerMapping("JiraTest.properties");
- }
-
- /**
- * Test case for
- * XMLRPC-89
- */
- public void testXMLRPC89() throws Exception {
- for (ClientProvider provider : providers) {
- testXMLRPC89Vector(provider);
- testXMLRPC89Hashtable(provider);
- testXMLRPC89Properties(provider);
- }
- }
-
- private void testXMLRPC89Vector(ClientProvider pProvider) throws Exception {
- Vector values = new Vector<>();
- for (int i = 0; i < 3; i++) {
- values.add(i);
- }
- Vector params = new Vector<>();
- params.add(values);
- XmlRpcClient client = pProvider.getClient();
- client.setConfig(getConfig(pProvider));
- Object res = client.execute(XMLRPC89Handler.class.getName() + ".reverse", params);
- Object[] result = (Object[]) res;
- assertNotNull(result);
- assertEquals(3, result.length);
- for (int i = 0; i < 3; i++) {
- assertEquals(2 - i, result[i]);
- }
-
- ClientFactory factory = new ClientFactory(client);
- XMLRPC89Handler handler = (XMLRPC89Handler) factory.newInstance(XMLRPC89Handler.class);
- Vector resultVector = handler.reverse(values);
- assertNotNull(resultVector);
- assertEquals(3, resultVector.size());
- for (int i = 0; i < 3; i++) {
- assertEquals(2 - i, resultVector.get(i));
- }
- }
-
- private void verifyXMLRPC89Hashtable(Map pMap) {
- assertNotNull(pMap);
- assertEquals(3, pMap.size());
- for (int i = 0; i < 3; i++) {
- Integer j = (Integer) pMap.get(String.valueOf(i));
- assertEquals(i*2, j.intValue());
- }
- }
-
- @SuppressWarnings("unchecked")
- private void testXMLRPC89Hashtable(ClientProvider pProvider) throws Exception {
- Hashtable values = new Hashtable<>();
- for (int i = 0; i < 3; i++) {
- values.put(String.valueOf(i), i);
- }
- XmlRpcClient client = pProvider.getClient();
- client.setConfig(getConfig(pProvider));
- Map res = (Map) client.execute(XMLRPC89Handler.class.getName() + ".doubledValues", new Object[]{values});
- verifyXMLRPC89Hashtable(res);
-
- ClientFactory factory = new ClientFactory(client);
- XMLRPC89Handler handler = (XMLRPC89Handler) factory.newInstance(XMLRPC89Handler.class);
- Hashtable result = handler.doubledValues(values);
- verifyXMLRPC89Hashtable(result);
- }
-
- private void verifyXMLRPC89Properties(Map pMap) {
- assertNotNull(pMap);
- assertEquals(3, pMap.size());
- for (int i = 0; i < 3; i++) {
- String j = (String) pMap.get(String.valueOf(i));
- assertEquals(i*2, Integer.parseInt(j));
- }
- }
-
- @SuppressWarnings("unchecked")
- private void testXMLRPC89Properties(ClientProvider pProvider) throws Exception {
- Properties values = new Properties();
- for (int i = 0; i < 3; i++) {
- values.put(String.valueOf(i), String.valueOf(i));
- }
- XmlRpcClient client = pProvider.getClient();
- client.setConfig(getConfig(pProvider));
- Map res = (Map) client.execute(XMLRPC89Handler.class.getName() + ".doubledPropertyValues", new Object[]{values});
- verifyXMLRPC89Properties(res);
- ClientFactory factory = new ClientFactory(client);
- XMLRPC89Handler handler = (XMLRPC89Handler) factory.newInstance(XMLRPC89Handler.class);
- Properties result = handler.doubledPropertyValues(values);
- verifyXMLRPC89Properties(result);
- }
-
- /**
- * Handler for XMLRPC-96
- */
- public static class XMLRPC96Handler {
- /**
- * Returns the "Hello, world!" string.
- */
- public String getHelloWorld() {
- return "Hello, world!";
- }
- }
-
- /**
- * Test case for
- * XMLRPC-96
- */
- public void testXMLRPC96() throws Exception {
- for (ClientProvider provider : providers) {
- testXMLRPC96(provider);
- }
- }
-
- private void testXMLRPC96(ClientProvider pProvider) throws Exception {
- XmlRpcClient client = pProvider.getClient();
- client.setConfig(getConfig(pProvider));
- String s = (String) client.execute(XMLRPC96Handler.class.getName() + ".getHelloWorld", new Object[0]);
- assertEquals("Hello, world!", s);
- s = (String) client.execute(XMLRPC96Handler.class.getName() + ".getHelloWorld", (Object[]) null);
- assertEquals("Hello, world!", s);
- }
-
- /**
- * Test case for
- * XMLRPC-112
- */
- public void testXMLRPC112() throws Exception {
- for (ClientProvider provider : providers) {
- testXMLRPC112(provider);
- }
- }
-
- /**
- * Test case for
- * XMLRPC-113
- */
- public void testXMLRPC113() throws Exception {
- for (ClientProvider provider : providers) {
- testXMLRPC113(provider);
- }
- }
-
-
- private void testXMLRPC112(ClientProvider pProvider) throws Exception {
- XmlRpcClient client = pProvider.getClient();
- client.setConfig(getConfig(pProvider));
- TimingOutCallback toc = new TimingOutCallback(5000);
- final String methodName = XMLRPC89Handler.class.getName() + ".reverse";
- client.executeAsync(methodName, new Object[]{new Object[]{"1", "2", "3"}}, toc);
- Object o;
- try {
- o = toc.waitForResponse();
- } catch (Exception e) {
- throw e;
- } catch (Throwable t) {
- throw new UndeclaredThrowableException(t);
- }
- checkXMLRPC112Result(o);
- checkXMLRPC112Result(client.execute(methodName, new Object[]{new Object[]{"1", "2", "3"}}));
- checkXMLRPC112Result(client.execute(methodName, new Object[]{new Object[]{"1", "2", "3"}}));
- }
-
- private void checkXMLRPC112Result(Object pObject) {
- Object[] args = (Object[]) pObject;
- assertEquals(3, args.length);
- assertEquals("3", args[0]);
- assertEquals("2", args[1]);
- assertEquals("1", args[2]);
- }
-
- /**
- * Handler interface for {@link JiraTest#testXMLRPC113()}
- */
- public interface XMLRPC113Handler {
- /**
- * Throws an {@link XmlRpcException} with the given error code.
- */
- Object throwCode(int pCode) throws XmlRpcException;
- }
-
- /**
- * Handler for {@link JiraTest#testXMLRPC113()}
- */
- public static class XMLRPC113HandlerImpl implements XMLRPC113Handler {
- public Object throwCode(int pCode) throws XmlRpcException {
- throw new XmlRpcException(pCode, "Message: " + pCode);
- }
- }
-
- private void testXMLRPC113(ClientProvider pProvider) throws Exception {
- XmlRpcClient client = pProvider.getClient();
- client.setConfig(getConfig(pProvider));
- XMLRPC113Handler handler = (XMLRPC113Handler) new ClientFactory(client).newInstance(XMLRPC113Handler.class);
- for (int i = 0; i < 5; i++) {
- try {
- client.execute(XMLRPC113Handler.class.getName() + ".throwCode", new Object[] { i });
- fail("Excpected exception");
- } catch (XmlRpcException e) {
- assertEquals(i, e.code);
- }
- try {
- handler.throwCode(i);
- } catch (XmlRpcException e) {
- assertEquals(i, e.code);
- }
- }
- }
-
- /**
- * Handler for {@link JiraTest#testXMLRPC115()}
- */
- public static class XMLRPC115Handler {
- /**
- * Does nothing, just for checking, whether the server is alive.
- */
- public Object[] ping() {
- return new Object[0];
- }
- }
-
- /**
- * Test case for
- * XMLRPC-115
- */
- public void testXMLRPC115() throws Exception {
- for (ClientProvider provider : providers) {
- testXMLRPC115(provider);
- }
- }
-
- private void testXMLRPC115(ClientProvider pProvider) throws Exception {
- if (pProvider instanceof SunHttpTransportProvider) {
- XmlRpcClient client = pProvider.getClient();
- client.setConfig(getConfig(pProvider));
- URL url = ((XmlRpcHttpClientConfig) client.getConfig()).getServerURL();
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- conn.setDoInput(true);
- conn.setDoOutput(true);
- conn.setRequestMethod("POST");
- conn.setRequestProperty("content-type", "text/xml");
- OutputStream ostream = conn.getOutputStream();
- Writer w = new OutputStreamWriter(ostream, StandardCharsets.UTF_8);
- w.write("" + XMLRPC115Handler.class.getName() + ".ping"
- + " ");
- w.close();
- InputStream istream = conn.getInputStream();
- XmlRpcResponseParser parser = new XmlRpcResponseParser((XmlRpcStreamRequestConfig) client.getClientConfig(), client.getTypeFactory());
- XMLReader xr = SAXParsers.newXMLReader();
- xr.setContentHandler(parser);
- xr.parse(new InputSource(istream));
- istream.close();
- assertTrue(parser.getResult() instanceof Object[]);
- assertEquals(0, ((Object[]) parser.getResult()).length);
- }
- }
-
- /**
- * Test case for
- * XMLRPC-119
- */
- public void testXMLRPC119() throws Exception {
- for (ClientProvider provider : providers) {
- testXMLRPC119(provider);
- }
- }
-
- /** Handler for XMLRPC-119
- */
- public static class XMLRPC119Handler {
- /** Returns a string with a length of "num" Kilobytes.
- */
- public String getString(int pSize) {
- StringBuilder sb = new StringBuilder(pSize*1024);
- for (int i = 0; i < pSize*1024; i++) {
- sb.append('&');
- }
- return sb.toString();
- }
- }
-
- private void testXMLRPC119(ClientProvider pProvider) throws Exception {
- XmlRpcClient client = pProvider.getClient();
- client.setConfig(getConfig(pProvider));
- for (int i = 0; i < 100; i+= 10) {
- String s = (String) client.execute(XMLRPC119Handler.class.getName() + ".getString",
- new Object[] { i });
- assertEquals(i*1024, s.length());
- }
- }
-}
diff --git a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/LiteTransportProvider.java b/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/LiteTransportProvider.java
deleted file mode 100644
index 55d1c45..0000000
--- a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/LiteTransportProvider.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client.test;
-
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClient;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcLiteHttpTransport;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcLiteHttpTransportFactory;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcTransportFactory;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcHandlerMapping;
-
-/** Provider for testing the
- * {@link XmlRpcLiteHttpTransport}.
- */
-public class LiteTransportProvider extends WebServerProvider {
- /** Creates a new instance.
- * @param pMapping The test servers handler mapping.
- * @param pContentLength Whether a Content-Length header is required.
- */
- public LiteTransportProvider(XmlRpcHandlerMapping pMapping,
- boolean pContentLength) {
- super(pMapping, pContentLength);
- }
-
- protected XmlRpcTransportFactory getTransportFactory(XmlRpcClient pClient) {
- return new XmlRpcLiteHttpTransportFactory(pClient);
- }
-}
diff --git a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/LocalStreamTransportProvider.java b/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/LocalStreamTransportProvider.java
deleted file mode 100644
index f0c25e8..0000000
--- a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/LocalStreamTransportProvider.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client.test;
-
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClient;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcLocalStreamTransport;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcLocalStreamTransportFactory;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcTransportFactory;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcHandlerMapping;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcLocalStreamServer;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcServer;
-
-/** Implementation of {@link BaseTest}
- * for testing the {@link XmlRpcLocalStreamTransport}.
- */
-public class LocalStreamTransportProvider extends LocalTransportProvider {
- private XmlRpcLocalStreamServer server;
-
- /** Creates a new instance.
- * @param pMapping The test servers handler mapping.
- */
- public LocalStreamTransportProvider(XmlRpcHandlerMapping pMapping) {
- super(pMapping);
- }
-
- protected XmlRpcTransportFactory getTransportFactory(XmlRpcClient pClient) {
- server = new XmlRpcLocalStreamServer();
- XmlRpcLocalStreamTransportFactory factory
- = new XmlRpcLocalStreamTransportFactory(pClient, server);
- return factory;
- }
-
- public XmlRpcServer getServer() {
- return server;
- }
-}
diff --git a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/LocalTransportProvider.java b/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/LocalTransportProvider.java
deleted file mode 100644
index ad22782..0000000
--- a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/LocalTransportProvider.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client.test;
-
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClient;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClientConfigImpl;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcLocalTransport;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcLocalTransportFactory;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcTransportFactory;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcHandlerMapping;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcServer;
-
-/**
- * Implementation of {@link BaseTest}
- * for testing the {@link XmlRpcLocalTransport}.
- */
-public class LocalTransportProvider extends ClientProviderImpl {
- private XmlRpcServer server;
-
- /** Creates a new instance.
- * @param pMapping The test servers handler mapping.
- */
- public LocalTransportProvider(XmlRpcHandlerMapping pMapping) {
- super(pMapping);
- }
-
- protected XmlRpcTransportFactory getTransportFactory(XmlRpcClient pClient) {
- XmlRpcLocalTransportFactory factory = new XmlRpcLocalTransportFactory(pClient);
- return factory;
- }
-
- public XmlRpcClientConfigImpl getConfig() throws Exception {
- XmlRpcClientConfigImpl config = super.getConfig();
- server = getXmlRpcServer();
- config.setXmlRpcServer(server);
- return config;
- }
-
- public XmlRpcServer getServer() {
- return server;
- }
-
- public void shutdown() {
- // Does nothing
- }
-}
diff --git a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/MetadataTest.java b/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/MetadataTest.java
deleted file mode 100644
index 63baac8..0000000
--- a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/MetadataTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client.test;
-
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClient;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClientConfig;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.server.PropertyHandlerMapping;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcHandlerMapping;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcSystemImpl;
-
-import java.text.Collator;
-import java.util.Arrays;
-import java.util.Locale;
-
-/**
- * Test class for the introspection stuff.
- */
-public class MetadataTest extends XmlRpcTestCase {
-
- @Override
- protected XmlRpcHandlerMapping getHandlerMapping() throws XmlRpcException {
- PropertyHandlerMapping mapping = new PropertyHandlerMapping();
- mapping.addHandler("Adder", AuthenticationTest.AdderImpl.class);
- XmlRpcSystemImpl.addSystemHandler(mapping);
- return mapping;
- }
-
- /**
- * Test, whether the actual handlers are working.
- */
- public void testAdder() throws Exception {
- for (ClientProvider provider : providers) {
- testAdder(provider);
- }
- }
-
- private void testAdder(ClientProvider pProvider) throws Exception {
- XmlRpcClient client = pProvider.getClient();
- XmlRpcClientConfig config = getConfig(pProvider);
- client.setConfig(config);
- Object o = client.execute("Adder.add", new Object[]{3, 5});
- assertEquals(8, o);
- }
-
- /**
- * Test for system.listMethods.
- */
- public void testListMethods() throws Exception {
- for (ClientProvider provider : providers) {
- testListMethods(provider);
- }
- }
-
- private void testListMethods(ClientProvider pProvider) throws Exception {
- XmlRpcClient client = pProvider.getClient();
- XmlRpcClientConfig config = getConfig(pProvider);
- client.setConfig(config);
- Object o = client.execute("system.listMethods", new Object[0]);
- Object[] methodList = (Object[]) o;
- Arrays.sort(methodList, Collator.getInstance(Locale.US));
- assertEquals(4, methodList.length);
- assertEquals("Adder.add", methodList[0]);
- assertEquals("system.listMethods", methodList[1]);
- assertEquals("system.methodHelp", methodList[2]);
- assertEquals("system.methodSignature", methodList[3]);
- }
-
- /**
- * Test for system.methodHelp.
- */
- public void testMethodHelp() throws Exception {
- for (ClientProvider provider : providers) {
- testMethodHelp(provider);
- }
- }
-
- private void testMethodHelp(ClientProvider pProvider) throws Exception {
- XmlRpcClient client = pProvider.getClient();
- XmlRpcClientConfig config = getConfig(pProvider);
- client.setConfig(config);
- String help = (String) client.execute("system.methodHelp", new Object[]{"Adder.add"});
- assertEquals("Invokes the method org.xbib.netty.http.xmlrpc.client.test.AuthenticationTest$AdderImpl.add(int, int).", help);
- }
-
- /**
- * Test for system.methodSignature.
- */
- public void testMethodSignature() throws Exception {
- for (ClientProvider provider : providers) {
- testMethodSignature(provider);
- }
- }
-
- private void testMethodSignature(ClientProvider pProvider) throws Exception {
- XmlRpcClient client = pProvider.getClient();
- XmlRpcClientConfig config = getConfig(pProvider);
- client.setConfig(config);
- Object[] signatures = (Object[]) client.execute("system.methodSignature", new Object[]{"Adder.add"});
- assertEquals(signatures.length, 1);
- Object[] signature = (Object[]) signatures[0];
- assertEquals(3, signature.length);
- assertEquals("int", signature[0]);
- assertEquals("int", signature[1]);
- assertEquals("int", signature[2]);
- }
-}
diff --git a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/ParserTest.java b/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/ParserTest.java
deleted file mode 100644
index 847fafe..0000000
--- a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/ParserTest.java
+++ /dev/null
@@ -1,150 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client.test;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.text.ParseException;
-import java.util.TimeZone;
-
-import junit.framework.TestCase;
-
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClient;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClientConfigImpl;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcHttpRequestConfigImpl;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamConfig;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamRequestConfig;
-import org.xbib.netty.http.xmlrpc.common.parser.DateParser;
-import org.xbib.netty.http.xmlrpc.common.parser.XmlRpcRequestParser;
-import org.xbib.netty.http.xmlrpc.common.parser.XmlRpcResponseParser;
-import org.xbib.netty.http.xmlrpc.common.util.SAXParsers;
-import org.xbib.netty.http.xmlrpc.common.util.XmlRpcDateTimeFormat;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.XMLReader;
-
-
-/** Test for the various parsers.
- */
-public class ParserTest extends TestCase {
- private Object parseResponse(final String s) throws XmlRpcException, IOException, SAXException {
- return parseResponse(new InputSource(new StringReader(s)));
- }
-
- private Object parseResponse(InputSource isource) throws XmlRpcException,
- IOException, SAXException {
- XmlRpcStreamRequestConfig config = new XmlRpcClientConfigImpl();
- XmlRpcClient client = new XmlRpcClient();
- XmlRpcResponseParser parser = new XmlRpcResponseParser(config, client.getTypeFactory());
- XMLReader xr = SAXParsers.newXMLReader();
- xr.setContentHandler(parser);
- xr.parse(isource);
- Object o = parser.getResult();
- return o;
- }
-
- private XmlRpcRequestParser parseRequest(final String s) throws XmlRpcException, IOException, SAXException {
- XmlRpcStreamConfig config = new XmlRpcHttpRequestConfigImpl();
- XmlRpcClient client = new XmlRpcClient();
- XmlRpcRequestParser parser = new XmlRpcRequestParser(config, client.getTypeFactory());
- XMLReader xr = SAXParsers.newXMLReader();
- xr.setContentHandler(parser);
- xr.parse(new InputSource(new StringReader(s)));
- return parser;
- }
-
- /** Tests, whether strings can be parsed with,
- * or without, the "string" tag.
- */
- public void testStringType() throws Exception {
- final String[] strings = new String[]{
- "3", "3 ",
- " 3 "
- };
- for (int i = 0; i < strings.length; i++) {
- final String s =
- "\n"
- + " \n"
- + "" + strings[i] + " \n"
- + " \n";
- Object o = parseResponse(s);
- assertEquals("3", o);
- }
- }
-
- /** Tests, whether nested arrays can be parsed.
- */
- public void testNestedObjectArrays() throws Exception {
- final String s =
- "\n"
- + " \n"
- + "\n"
- + "array \n"
- + "string \n"
- + " \n"
- + " \n";
- Object o = parseResponse(s);
- assertTrue(o instanceof Object[]);
- Object[] outer = (Object[]) o;
- assertEquals(1, outer.length);
- o = outer[0];
- assertTrue(o instanceof Object[]);
- Object[] inner = (Object[]) o;
- assertEquals(2, inner.length);
- assertEquals("array", inner[0]);
- assertEquals("string", inner[1]);
- }
-
- /**
- * Tests, whether a request may omit the tag.
- */
- public void testOptionalParams() throws Exception {
- final String s1 = " ";
- Object o1 = parseResponse(s1);
- assertNull(o1);
-
- final String s2 = " ";
- Object o2 = parseResponse(s2);
- assertNull(o2);
-
- final String s3 = "foo ";
- XmlRpcRequestParser p3 = parseRequest(s3);
- assertEquals("foo", p3.getMethodName());
- assertNull(p3.getParams());
-
- final String s4 = "bar ";
- XmlRpcRequestParser p4 = parseRequest(s4);
- assertEquals("bar", p4.getMethodName());
- assertNotNull(p4.getParams());
- assertTrue(p4.getParams().size() == 0);
- }
-
- /**
- * Test for XMLRPC-140.
- */
- public void testXMLRPC140() throws Exception {
- DateParser parser = new DateParser(new XmlRpcDateTimeFormat(){
- private static final long serialVersionUID = 0L;
- protected TimeZone getTimeZone() {
- return TimeZone.getDefault();
- }
- }){
- public void setResult(Object pObject){
- try {
- super.setResult((String) pObject);
- } catch (SAXException e) {
- throw new UndeclaredThrowableException(e);
- }
- }
- };
- try {
- parser.setResult("20070316T162808Z");
- fail("Expected exception");
- } catch (UndeclaredThrowableException e) {
- SAXParseException spe = (SAXParseException) e.getUndeclaredThrowable();
- ParseException pe = (ParseException) spe.getException();
- assertEquals(11, pe.getErrorOffset());
- }
- }
-}
diff --git a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/ScalabilityTest.java b/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/ScalabilityTest.java
deleted file mode 100644
index 6feff23..0000000
--- a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/ScalabilityTest.java
+++ /dev/null
@@ -1,214 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client.test;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-
-import junit.framework.TestCase;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClient;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClientConfigImpl;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.server.PropertyHandlerMapping;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcHandlerMapping;
-import org.xbib.netty.http.xmlrpc.servlet.ServletWebServer;
-import org.xbib.netty.http.xmlrpc.servlet.ThreadPool;
-import org.xbib.netty.http.xmlrpc.servlet.WebServer;
-import org.xbib.netty.http.xmlrpc.servlet.XmlRpcServlet;
-
-/**
- * Tests the frameworks scalability.
- */
-public class ScalabilityTest extends TestCase {
-
- private static final Logger logger = Logger.getLogger(ScalabilityTest.class.getName());
-
- /**
- * Primitive handler class
- */
- public static class Adder {
- /**
- * Returns the sum of the numbers p1 and p2.
- */
- public int add(int p1, int p2) {
- return p1 + p2;
- }
- }
-
- private static final int BASE = 1;
-
- private static final Integer THREE = 3;
-
- private static final Integer FIVE = 5;
-
- private static final Integer EIGHT = 8;
-
- private XmlRpcServlet servlet;
-
- private MyServletWebServer server;
-
- private MyWebServer webServer;
-
- private XmlRpcHandlerMapping newXmlRpcHandlerMapping() throws XmlRpcException {
- PropertyHandlerMapping mapping = new PropertyHandlerMapping();
- mapping.addHandler("Adder", Adder.class);
- return mapping;
- }
-
- private void initServletWebServer() throws Exception {
- servlet = new XmlRpcServlet() {
-
- private static final long serialVersionUID = -2040521497373327817L;
-
- @Override
- protected XmlRpcHandlerMapping newXmlRpcHandlerMapping() throws XmlRpcException {
- return ScalabilityTest.this.newXmlRpcHandlerMapping();
- }
- };
- server = new MyServletWebServer(servlet, 8080);
- server.getXmlRpcServer().setMaxThreads(25);
- server.start();
- }
-
- private void shutdownServletWebServer() throws IOException {
- server.shutdown();
- }
-
- private void initWebServer() throws Exception {
- webServer = new MyWebServer(8080);
- webServer.getXmlRpcServer().setHandlerMapping(newXmlRpcHandlerMapping());
- webServer.getXmlRpcServer().setMaxThreads(25);
- webServer.start();
- }
-
- private void shutdownWebServer() throws IOException {
- webServer.shutdown();
- }
-
- /**
- * Runs the servlet test with a single client.
- */
- public void testSingleServletClient() throws Exception {
- initServletWebServer();
- try {
- long now = System.currentTimeMillis();
- servlet.getXmlRpcServletServer().setMaxThreads(1);
- new MyClient(100 * BASE, server.getPort()).run();
- logger.log(Level.INFO,
- "Single servlet client: " + (System.currentTimeMillis() - now) + ", " + server.getNumThreads());
- } finally {
- shutdownServletWebServer();
- }
- }
-
- /**
- * Runs the web server test with a single client.
- */
- public void testSingleWebServerClient() throws Exception {
- initWebServer();
- try {
- long now = System.currentTimeMillis();
- webServer.getXmlRpcServer().setMaxThreads(1);
- new MyClient(100 * BASE, webServer.getPort()).run();
- logger.log(Level.INFO,
- "Single web server client: " + (System.currentTimeMillis( ) -now) + ", " + webServer.getNumThreads());
- } finally {
- shutdownWebServer();
- }
- }
-
- /**
- * Runs the test with ten clients.
- */
- public void testTenClient() throws Exception {
- initServletWebServer();
- try {
- final Thread[] threads = new Thread[10];
- servlet.getXmlRpcServletServer().setMaxThreads(10);
- long now = System.currentTimeMillis();
- for (int i = 0; i < threads.length; i++) {
- threads[i] = new Thread(new MyClient(10 * BASE, server.getPort()));
- threads[i].start();
- }
- for (Thread thread : threads) {
- thread.join();
- }
- logger.log(Level.INFO, "Ten clients: " + (System.currentTimeMillis() - now) + ", " + server.getNumThreads());
- shutdownServletWebServer();
- } finally {
- shutdownServletWebServer();
- }
- }
-
- private static class MyClient implements Runnable {
-
- private final int iterations;
-
- private final int port;
-
- MyClient(int pIterations, int pPort) {
- iterations = pIterations;
- port = pPort;
- }
-
- @Override
- public void run() {
- int i = 0;
- try {
- XmlRpcClient client = new XmlRpcClient();
- XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
- config.setServerURL(new URL("http://localhost:" + port + "/"));
- client.setConfig(config);
- for (i = 0; i < iterations; i++) {
- assertEquals(EIGHT, client.execute("Adder.add", new Object[] {
- THREE, FIVE
- }));
- }
- } catch (Throwable t) {
- throw new RuntimeException("i=" + i, t);
- }
- }
- }
-
- private class MyServletWebServer extends ServletWebServer {
-
- ThreadPool pool;
-
- MyServletWebServer(HttpServlet pServlet, int pPort) throws ServletException {
- super(pServlet, pPort);
- }
-
- @Override
- public ThreadPool newThreadPool(){
- pool = new ThreadPool(getXmlRpcServer().getMaxThreads(), "XML-RPC");
- return pool;
- }
-
- int getNumThreads() {
- return pool.getNumThreads();
- }
- }
-
- private class MyWebServer extends WebServer {
-
- ThreadPool pool;
-
- MyWebServer(int pPort) {
- super(pPort);
- }
-
- @Override
- public ThreadPool newThreadPool(){
- pool = new ThreadPool(getXmlRpcServer().getMaxThreads(), "XML-RPC");
- return pool;
- }
-
- int getNumThreads() {
- return pool.getNumThreads();
- }
- }
-
-}
diff --git a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/SerializerTest.java b/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/SerializerTest.java
deleted file mode 100644
index 3a84a4e..0000000
--- a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/SerializerTest.java
+++ /dev/null
@@ -1,184 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client.test;
-
-import java.io.StringReader;
-import java.util.Calendar;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.TimeZone;
-
-import javax.xml.parsers.SAXParserFactory;
-
-import junit.framework.TestCase;
-
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClient;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClientConfig;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClientConfigImpl;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClientRequestImpl;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcSunHttpTransportFactory;
-import org.xbib.netty.http.xmlrpc.common.TypeFactoryImpl;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequest;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamRequestConfig;
-import org.xbib.netty.http.xmlrpc.common.parser.XmlRpcRequestParser;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcServer;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcServerConfigImpl;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-
-/** A test case for the various serializers.
- */
-public class SerializerTest extends TestCase {
- private final XmlRpcClient client;
-
- /** Creates a new instance.
- */
- public SerializerTest() {
- client = new XmlRpcClient();
- client.setTransportFactory(new XmlRpcSunHttpTransportFactory(client));
- }
-
- protected XmlRpcClientConfigImpl getConfig() {
- XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
- return config;
- }
-
- protected XmlRpcStreamRequestConfig getExConfig() {
- XmlRpcClientConfigImpl config = getConfig();
- config.setEnabledForExtensions(true);
- return config;
- }
-
- protected String writeRequest(XmlRpcStreamRequestConfig pConfig, XmlRpcRequest pRequest)
- throws SAXException {
- client.setConfig((XmlRpcClientConfig) pConfig);
- return XmlRpcTestCase.writeRequest(client, pRequest);
- }
-
- /** Test serialization of a byte parameter.
- * @throws Exception The test failed.
- */
- public void testByteParam() throws Exception {
- XmlRpcStreamRequestConfig config = getExConfig();
- XmlRpcRequest request = new XmlRpcClientRequestImpl(config, "byteParam", new Object[] { (byte) 3} );
- String got = writeRequest(config, request);
- String expect =
- ""
- + ""
- + "byteParam 3 ";
- assertEquals(expect, got);
- }
-
- /** Test serialization of an integer parameter.
- * @throws Exception The test failed.
- */
- public void testIntParam() throws Exception {
- XmlRpcStreamRequestConfig config = getConfig();
- XmlRpcRequest request = new XmlRpcClientRequestImpl(config, "intParam", new Object[] { 3 } );
- String got = writeRequest(config, request);
- String expect =
- ""
- + ""
- + "intParam 3 ";
- assertEquals(expect, got);
- }
-
- /** Test serialization of a byte array.
- * @throws Exception The test failed.
- */
- public void testByteArrayParam() throws Exception {
- byte[] bytes = new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
- XmlRpcStreamRequestConfig config = getConfig();
- XmlRpcRequest request = new XmlRpcClientRequestImpl(config, "byteArrayParam", new Object[]{ bytes });
- String got = writeRequest(config, request);
- String expect =
- ""
- + ""
- + "byteArrayParam AAECAwQFBgcICQ== ";
- assertEquals(expect, got);
- }
-
- /** Test serialization of a map.
- * @throws Exception The test failed.
- */
- public void testMapParam() throws Exception {
- final Map map = new LinkedHashMap<>();
- map.put("2", 3);
- map.put("3", 5);
- final Object[] params = new Object[]{map};
- XmlRpcStreamRequestConfig config = getConfig();
- XmlRpcRequest request = new XmlRpcClientRequestImpl(config, "mapParam", params);
- String got = writeRequest(config, request);
- String expect = ""
- + "mapParam "
- + ""
- + "2 3 "
- + "3 5 "
- + " ";
- assertEquals(expect, got);
- }
-
- /** Tests serialization of a calendar instance.
- */
- public void testCalendarParam() throws Exception {
- TimeZone tz = TimeZone.getTimeZone("GMT");
- Calendar cal1 = Calendar.getInstance(tz);
- cal1.set(1933, 5, 12, 11, 7, 21);
- cal1.set(Calendar.MILLISECOND, 311);
- Calendar cal2 = Calendar.getInstance(TimeZone.getDefault());
- cal2.set(1933, 5, 12, 11, 7, 21);
- cal2.set(Calendar.MILLISECOND, 311);
- XmlRpcStreamRequestConfig config = getExConfig();
- XmlRpcRequest request = new XmlRpcClientRequestImpl(config, "dateParam", new Object[]{cal1, cal2.getTime()});
- String got = writeRequest(config, request);
- String expect =
- ""
- + ""
- + "dateParam "
- + "1933-06-12T11:07:21.311Z "
- + "19330612T11:07:21 "
- + " ";
- assertEquals(expect, got);
- }
-
- /**
- * Test for XMLRPC-127: Is it possible to transmit a
- * map with integers as the keys?
- */
- @SuppressWarnings("unchecked")
- public void testIntegerKeyMap() throws Exception {
- Map map = new HashMap<>();
- map.put(1, "one");
- XmlRpcStreamRequestConfig config = getExConfig();
- XmlRpcRequest request = new XmlRpcClientRequestImpl(config, "integerKeyMap", new Object[]{map});
- String got = writeRequest(config, request);
- String expect =
- ""
- + ""
- + "integerKeyMap "
- + ""
- + "1 "
- + "one "
- + " "
- + " ";
- assertEquals(expect, got);
- XmlRpcServer server = new XmlRpcServer();
- XmlRpcServerConfigImpl serverConfig = new XmlRpcServerConfigImpl();
- serverConfig.setEnabledForExtensions(true);
- server.setConfig(serverConfig);
- XmlRpcRequestParser parser = new XmlRpcRequestParser(serverConfig, new TypeFactoryImpl(server));
- SAXParserFactory spf = SAXParserFactory.newInstance();
- spf.setValidating(false);
- spf.setNamespaceAware(true);
- XMLReader xr = spf.newSAXParser().getXMLReader();
- xr.setContentHandler(parser);
- xr.parse(new InputSource(new StringReader(expect)));
- assertEquals("integerKeyMap", parser.getMethodName());
- List params = parser.getParams();
- assertEquals(1, params.size());
- Map paramMap = (Map) params.get(0);
- assertEquals(1, paramMap.size());
- assertEquals("one", paramMap.get(1));
- }
-}
diff --git a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/ServletWebServerProvider.java b/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/ServletWebServerProvider.java
deleted file mode 100644
index fdf2af7..0000000
--- a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/ServletWebServerProvider.java
+++ /dev/null
@@ -1,83 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client.test;
-
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClient;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClientConfigImpl;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcSunHttpTransportFactory;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcTransportFactory;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcHandlerMapping;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcServer;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcServerConfigImpl;
-import org.xbib.netty.http.xmlrpc.servlet.ServletWebServer;
-import org.xbib.netty.http.xmlrpc.servlet.XmlRpcServlet;
-
-import javax.servlet.ServletException;
-import java.io.IOException;
-import java.net.URL;
-
-/**
- * A provider class for testing the {@link ServletWebServer}.
- */
-public class ServletWebServerProvider extends ClientProviderImpl {
-
- protected final ServletWebServer webServer;
-
- protected final XmlRpcServlet servlet;
-
- private final boolean contentLength;
-
- private int port;
-
- /**
- * Creates a new instance of {@link XmlRpcServlet}.
- */
- protected XmlRpcServlet newXmlRpcServlet() {
- return new XmlRpcServlet();
- }
-
- /** Creates a new instance.
- * @param pMapping The test servers handler mapping.
- * @throws ServletException
- * @throws IOException
- */
- protected ServletWebServerProvider(XmlRpcHandlerMapping pMapping, boolean pContentLength) throws ServletException, IOException {
- super(pMapping);
- contentLength = pContentLength;
- servlet = newXmlRpcServlet();
- webServer = new ServletWebServer(servlet, 0);
- try {
- XmlRpcServer server = servlet.getXmlRpcServletServer();
- server.setHandlerMapping(mapping);
- XmlRpcServerConfigImpl serverConfig = (XmlRpcServerConfigImpl) server.getConfig();
- serverConfig.setEnabledForExtensions(true);
- serverConfig.setContentLengthOptional(!contentLength);
- serverConfig.setEnabledForExceptions(true);
- webServer.start();
- port = webServer.getPort();
- } catch (Exception e) {
- webServer.shutdown();
- }
- }
-
- public final XmlRpcClientConfigImpl getConfig() throws Exception {
- return getConfig(new URL("http://localhost:" + port + "/"));
- }
-
- protected XmlRpcClientConfigImpl getConfig(URL pServerURL) throws Exception {
- XmlRpcClientConfigImpl config = super.getConfig();
- config.setServerURL(pServerURL);
- config.setContentLengthOptional(!contentLength);
- return config;
- }
-
- protected XmlRpcTransportFactory getTransportFactory(XmlRpcClient pClient) {
- return new XmlRpcSunHttpTransportFactory(pClient);
- }
-
- public XmlRpcServer getServer() {
- return servlet.getXmlRpcServletServer();
- }
-
- public void shutdown() throws IOException {
- webServer.shutdown();
- }
-}
diff --git a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/SunHttpTransportProvider.java b/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/SunHttpTransportProvider.java
deleted file mode 100644
index 5322f26..0000000
--- a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/SunHttpTransportProvider.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client.test;
-
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClient;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcSunHttpTransport;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcSunHttpTransportFactory;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcTransportFactory;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcHandlerMapping;
-
-/** Implementation of {@link BaseTest} for testing the
- * {@link XmlRpcSunHttpTransport}.
- */
-public class SunHttpTransportProvider extends WebServerProvider {
- /** Creates a new instance.
- * @param pMapping The test servers handler mapping.
- * @param pContentLength Number of bytes being transmitted.
- */
- public SunHttpTransportProvider(XmlRpcHandlerMapping pMapping, boolean pContentLength) {
- super(pMapping, pContentLength);
- }
-
- protected XmlRpcTransportFactory getTransportFactory(XmlRpcClient pClient) {
- return new XmlRpcSunHttpTransportFactory(pClient);
- }
-}
diff --git a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/WebServerProvider.java b/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/WebServerProvider.java
deleted file mode 100644
index 7780c37..0000000
--- a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/WebServerProvider.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client.test;
-
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClientConfigImpl;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcHandlerMapping;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcServer;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcServerConfigImpl;
-import org.xbib.netty.http.xmlrpc.servlet.WebServer;
-
-import java.io.IOException;
-import java.net.URL;
-
-/** Abstract base class for providers, which require a webserver.
- */
-public abstract class WebServerProvider extends ClientProviderImpl {
-
- private WebServer webServer;
-
- private final boolean contentLength;
-
- /** Creates a new instance.
- * @param pMapping The test servers handler mapping.
- */
- WebServerProvider(XmlRpcHandlerMapping pMapping, boolean pContentLength) {
- super(pMapping);
- contentLength = pContentLength;
- }
-
- public final XmlRpcClientConfigImpl getConfig() throws Exception {
- initWebServer();
- return getConfig(new URL("http://localhost:" + webServer.getPort() + "/"));
- }
-
- protected XmlRpcClientConfigImpl getConfig(URL pServerURL) throws Exception {
- XmlRpcClientConfigImpl config = super.getConfig();
- config.setServerURL(pServerURL);
- config.setContentLengthOptional(!contentLength);
- return config;
- }
-
- private void initWebServer() throws Exception {
- if (webServer == null || webServer.isShutDown()) {
- webServer = new WebServer(0);
- XmlRpcServer server = webServer.getXmlRpcServer();
- server.setHandlerMapping(mapping);
- XmlRpcServerConfigImpl serverConfig = (XmlRpcServerConfigImpl) server.getConfig();
- serverConfig.setEnabledForExtensions(true);
- serverConfig.setContentLengthOptional(!contentLength);
- serverConfig.setEnabledForExceptions(true);
- webServer.start();
- }
- }
-
- @Override
- public XmlRpcServer getServer() {
- return webServer.getXmlRpcServer();
- }
-
- @Override
- public void shutdown() throws IOException {
- webServer.shutdown();
- }
-}
diff --git a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/XmlRpcTestCase.java b/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/XmlRpcTestCase.java
deleted file mode 100644
index 5b28fad..0000000
--- a/netty-http-xmlrpc-client/src/test/java/org/xbib/netty/http/xmlrpc/client/test/XmlRpcTestCase.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package org.xbib.netty.http.xmlrpc.client.test;
-
-import java.io.IOException;
-import java.io.StringWriter;
-
-import junit.framework.TestCase;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClient;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClientConfig;
-import org.xbib.netty.http.xmlrpc.client.XmlRpcClientConfigImpl;
-import org.xbib.netty.http.xmlrpc.common.TypeConverterFactory;
-import org.xbib.netty.http.xmlrpc.common.TypeConverterFactoryImpl;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequest;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamConfig;
-import org.xbib.netty.http.xmlrpc.common.serializer.XmlRpcWriter;
-import org.xbib.netty.http.xmlrpc.common.util.XMLWriter;
-import org.xbib.netty.http.xmlrpc.common.util.XMLWriterImpl;
-import org.xbib.netty.http.xmlrpc.server.PropertyHandlerMapping;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcHandlerMapping;
-import org.xml.sax.SAXException;
-
-import javax.servlet.ServletException;
-
-/**
- * Abstract base class for deriving test cases.
- */
-public abstract class XmlRpcTestCase extends TestCase {
-
- protected ClientProvider[] providers;
-
- protected abstract XmlRpcHandlerMapping getHandlerMapping() throws IOException, XmlRpcException;
-
- protected XmlRpcClientConfigImpl getConfig(ClientProvider pProvider) throws Exception {
- return pProvider.getConfig();
- }
-
- XmlRpcClientConfig getExConfig(ClientProvider pProvider) throws Exception {
- XmlRpcClientConfigImpl config = getConfig(pProvider);
- config.setEnabledForExtensions(true);
- config.setEnabledForExceptions(true);
- return config;
- }
-
- XmlRpcHandlerMapping getHandlerMapping(String pResource) throws IOException, XmlRpcException {
- PropertyHandlerMapping mapping = new PropertyHandlerMapping();
- mapping.setVoidMethodEnabled(true);
- mapping.load(getClass().getClassLoader(), getClass().getResource(pResource));
- mapping.setTypeConverterFactory(getTypeConverterFactory());
- return mapping;
- }
-
- protected ClientProvider[] initProviders(XmlRpcHandlerMapping pMapping) throws ServletException, IOException {
- return new ClientProvider[]{
- new LocalTransportProvider(pMapping),
- //new LocalStreamTransportProvider(pMapping),
- //new LiteTransportProvider(pMapping, true),
- //// new LiteTransportProvider(mapping, false), Doesn't support HTTP/1.1
- //new SunHttpTransportProvider(pMapping, true),
- //new SunHttpTransportProvider(pMapping, false),
- //new CommonsProvider(pMapping),
- //new ServletWebServerProvider(pMapping, true),
- //new ServletWebServerProvider(pMapping, false)
- };
- }
-
- @Override
- public void setUp() throws Exception {
- if (providers == null) {
- providers = initProviders(getHandlerMapping());
- }
- }
-
- @Override
- public void tearDown() throws IOException {
- if (providers != null) {
- for (ClientProvider provider : providers) {
- provider.shutdown();
- }
- }
- }
-
- protected TypeConverterFactory getTypeConverterFactory() {
- return new TypeConverterFactoryImpl();
- }
-
- static String writeRequest(XmlRpcClient pClient, XmlRpcRequest pRequest)
- throws SAXException {
- StringWriter sw = new StringWriter();
- XMLWriter xw = new XMLWriterImpl();
- xw.setEncoding("US-ASCII");
- xw.setDeclarating(true);
- xw.setIndenting(false);
- xw.setWriter(sw);
- XmlRpcWriter xrw = new XmlRpcWriter((XmlRpcStreamConfig) pClient.getConfig(), xw, pClient.getTypeFactory());
- xrw.write(pRequest);
- return sw.toString();
- }
-}
diff --git a/netty-http-xmlrpc-client/src/test/resources/logging.properties b/netty-http-xmlrpc-client/src/test/resources/logging.properties
deleted file mode 100644
index b955428..0000000
--- a/netty-http-xmlrpc-client/src/test/resources/logging.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-handlers = java.util.logging.ConsoleHandler
-.level = FINE
-java.util.logging.ConsoleHandler.level = FINE
-java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
-java.util.logging.SimpleFormatter.format = %1$tFT%1$tT.%1$tL%1$tz [%4$-11s] [%3$s] %5$s %6$s%n
diff --git a/netty-http-xmlrpc-client/src/test/resources/org/xbib/netty/http/xmlrpc/client/test/AuthenticationTest.properties b/netty-http-xmlrpc-client/src/test/resources/org/xbib/netty/http/xmlrpc/client/test/AuthenticationTest.properties
deleted file mode 100644
index d16d888..0000000
--- a/netty-http-xmlrpc-client/src/test/resources/org/xbib/netty/http/xmlrpc/client/test/AuthenticationTest.properties
+++ /dev/null
@@ -1 +0,0 @@
-org.xbib.netty.http.xmlrpc.client.test.AuthenticationTest$Adder=org.xbib.netty.http.xmlrpc.client.test.AuthenticationTest$AdderImpl
diff --git a/netty-http-xmlrpc-client/src/test/resources/org/xbib/netty/http/xmlrpc/client/test/BaseTest.properties b/netty-http-xmlrpc-client/src/test/resources/org/xbib/netty/http/xmlrpc/client/test/BaseTest.properties
deleted file mode 100644
index 7a9ed28..0000000
--- a/netty-http-xmlrpc-client/src/test/resources/org/xbib/netty/http/xmlrpc/client/test/BaseTest.properties
+++ /dev/null
@@ -1 +0,0 @@
-Remote=org.xbib.netty.http.xmlrpc.client.test.BaseTest$Remote
diff --git a/netty-http-xmlrpc-client/src/test/resources/org/xbib/netty/http/xmlrpc/client/test/DynamicProxyTest.properties b/netty-http-xmlrpc-client/src/test/resources/org/xbib/netty/http/xmlrpc/client/test/DynamicProxyTest.properties
deleted file mode 100644
index d557968..0000000
--- a/netty-http-xmlrpc-client/src/test/resources/org/xbib/netty/http/xmlrpc/client/test/DynamicProxyTest.properties
+++ /dev/null
@@ -1 +0,0 @@
-org.xbib.netty.http.xmlrpc.client.test.DynamicProxyTest$Adder=org.xbib.netty.http.xmlrpc.client.test.DynamicProxyTest$AdderImpl
diff --git a/netty-http-xmlrpc-client/src/test/resources/org/xbib/netty/http/xmlrpc/client/test/JiraTest.properties b/netty-http-xmlrpc-client/src/test/resources/org/xbib/netty/http/xmlrpc/client/test/JiraTest.properties
deleted file mode 100644
index 77b230a..0000000
--- a/netty-http-xmlrpc-client/src/test/resources/org/xbib/netty/http/xmlrpc/client/test/JiraTest.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-org.xbib.netty.http.xmlrpc.client.test.JiraTest$XMLRPC89Handler=org.xbib.netty.http.xmlrpc.client.test.JiraTest$XMLRPC89HandlerImpl
-org.xbib.netty.http.xmlrpc.client.test.JiraTest$XMLRPC96Handler=org.xbib.netty.http.xmlrpc.client.test.JiraTest$XMLRPC96Handler
-org.xbib.netty.http.xmlrpc.client.test.JiraTest$XMLRPC113Handler=org.xbib.netty.http.xmlrpc.client.test.JiraTest$XMLRPC113HandlerImpl
-org.xbib.netty.http.xmlrpc.client.test.JiraTest$XMLRPC115Handler=org.xbib.netty.http.xmlrpc.client.test.JiraTest$XMLRPC115Handler
-org.xbib.netty.http.xmlrpc.client.test.JiraTest$XMLRPC119Handler=org.xbib.netty.http.xmlrpc.client.test.JiraTest$XMLRPC119Handler
diff --git a/netty-http-xmlrpc-client/src/test/resources/org/xbib/netty/http/xmlrpc/servlet/XmlRpcServlet.properties b/netty-http-xmlrpc-client/src/test/resources/org/xbib/netty/http/xmlrpc/servlet/XmlRpcServlet.properties
deleted file mode 100644
index 7a9ed28..0000000
--- a/netty-http-xmlrpc-client/src/test/resources/org/xbib/netty/http/xmlrpc/servlet/XmlRpcServlet.properties
+++ /dev/null
@@ -1 +0,0 @@
-Remote=org.xbib.netty.http.xmlrpc.client.test.BaseTest$Remote
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/LocalStreamConnection.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/LocalStreamConnection.java
deleted file mode 100644
index 79cfb16..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/LocalStreamConnection.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * Implementation of {@link ServerStreamConnection}
- */
-public class LocalStreamConnection {
- private class LocalServerStreamConnection implements ServerStreamConnection {
- public InputStream newInputStream() throws IOException {
- return request;
- }
-
- public OutputStream newOutputStream() throws IOException {
- return response;
- }
-
- public void close() throws IOException {
- response.close();
- }
- }
-
- private final InputStream request;
- private final XmlRpcStreamRequestConfig config;
- private final ByteArrayOutputStream response = new ByteArrayOutputStream();
- private final ServerStreamConnection serverStreamConnection;
-
- /**
- * Creates a new instance with the given request stream.
- * @param pConfig config
- * @param pRequest request
- */
- public LocalStreamConnection(XmlRpcStreamRequestConfig pConfig,
- InputStream pRequest) {
- config = pConfig;
- request = pRequest;
- serverStreamConnection = new LocalServerStreamConnection();
- }
-
- /**
- * Returns the request stream.
- * @return stream
- */
- public InputStream getRequest() {
- return request;
- }
-
- /**
- * Returns the request configuration.
- * @return config
- */
- public XmlRpcStreamRequestConfig getConfig() {
- return config;
- }
-
- /**
- * Returns an output stream, to which the response
- * may be written.
- * @return response
- */
- public ByteArrayOutputStream getResponse() {
- return response;
- }
-
- /**
- * Returns the server connection.
- * @return server connection
- */
- public ServerStreamConnection getServerStreamConnection() {
- return serverStreamConnection;
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/ServerStreamConnection.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/ServerStreamConnection.java
deleted file mode 100644
index a9136a3..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/ServerStreamConnection.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * 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 {
-
- /**
- * Returns the connection input stream.
- * @return input stream
- * @throws IOException if connection fails
- */
- InputStream newInputStream() throws IOException;
-
- /**
- * Returns the connection output stream.
- * @return output stream
- * @throws IOException if connection fails
- */
- OutputStream newOutputStream() throws IOException;
-
- /**
- * Closes the connection, and frees resources.
- * @throws IOException if close fails
- */
- void close() throws IOException;
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/TypeConverter.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/TypeConverter.java
deleted file mode 100644
index c603ef6..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/TypeConverter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-import java.util.List;
-import java.util.Vector;
-
-/**
- * A {@link TypeConverter} is used when actually calling the
- * handler method or actually returning the result object. It's
- * purpose is to convert a single parameter or the return value
- * from a generic representation (for example an array of objects)
- * to an alternative representation, which is actually used in
- * the methods signature (for example {@link List}, or
- * {@link Vector}.
- */
-public interface TypeConverter {
-
- /**
- * Returns true whether the {@link TypeConverter} is
- * ready to handle the given object. If so,
- * {@link #convert(Object)} may be called.
- * @param pObject object
- * @return true
- */
- boolean isConvertable(Object pObject);
-
- /**
- * Converts the given object into the required
- * representation.
- * @param pObject object
- * @return object
- */
- Object convert(Object pObject);
-
- /**
- * Converts the given object into its generic
- * representation.
- * @param result result
- * @return object
- */
- Object backConvert(Object result);
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/TypeConverterFactory.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/TypeConverterFactory.java
deleted file mode 100644
index 7a5a117..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/TypeConverterFactory.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-/**
- * A {@link TypeConverterFactory} is called for creating instances
- * of {@link TypeConverter}.
- */
-public interface TypeConverterFactory {
-
- /**
- * Creates an instance of {@link TypeFactory}, which may be
- * used to create instances of the given class.
- * @param pClass class
- * @return type converter
- */
- TypeConverter getTypeConverter(Class> pClass);
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/TypeConverterFactoryImpl.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/TypeConverterFactoryImpl.java
deleted file mode 100644
index d7e47ca..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/TypeConverterFactoryImpl.java
+++ /dev/null
@@ -1,322 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Vector;
-
-import org.w3c.dom.Document;
-
-/**
- * Default implementation of {@link TypeConverterFactory}.
- */
-public class TypeConverterFactoryImpl implements TypeConverterFactory {
-
- private static class IdentityTypeConverter implements TypeConverter {
-
- private final Class> clazz;
-
- IdentityTypeConverter(Class> pClass) {
- clazz = pClass;
- }
-
- @Override
- public boolean isConvertable(Object pObject) {
- return pObject == null || clazz.isAssignableFrom(pObject.getClass());
- }
-
- @Override
- public Object convert(Object pObject) {
- return pObject;
- }
-
- @Override
- public Object backConvert(Object pObject) {
- return pObject;
- }
- }
-
- private static abstract class ListTypeConverter implements TypeConverter {
-
- private final Class> clazz;
-
- ListTypeConverter(Class> pClass) {
- clazz = pClass;
- }
-
- protected abstract List newList(int pSize);
-
- @Override
- public boolean isConvertable(Object pObject) {
- return pObject == null || pObject instanceof Object[] || pObject instanceof Collection;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Object convert(Object pObject) {
- if (pObject == null) {
- return null;
- }
- if (clazz.isAssignableFrom(pObject.getClass())) {
- return pObject;
- }
- if (pObject instanceof Object[]) {
- Object[] objects = (Object[]) pObject;
- List result = newList(objects.length);
- result.addAll(Arrays.asList(objects));
- return result;
- }
- Collection collection = (Collection) pObject;
- List result = newList(collection.size());
- result.addAll(collection);
- return result;
- }
-
- @Override
- public Object backConvert(Object pObject) {
- return ((List) pObject).toArray();
- }
- }
-
- private static class PrimitiveTypeConverter implements TypeConverter {
-
- private final Class> clazz;
-
- PrimitiveTypeConverter(Class> pClass) {
- clazz = pClass;
- }
-
- @Override
- public boolean isConvertable(Object pObject) {
- return pObject != null && pObject.getClass().isAssignableFrom(clazz);
- }
-
- @Override
- public Object convert(Object pObject) {
- return pObject;
- }
-
- @Override
- public Object backConvert(Object pObject) {
- return pObject;
- }
- }
-
- private static final TypeConverter voidTypeConverter = new IdentityTypeConverter(void.class);
- private static final TypeConverter mapTypeConverter = new IdentityTypeConverter(Map.class);
- private static final TypeConverter objectArrayTypeConverter = new IdentityTypeConverter(Object[].class);
- private static final TypeConverter byteArrayTypeConverter = new IdentityTypeConverter(byte[].class);
- private static final TypeConverter stringTypeConverter = new IdentityTypeConverter(String.class);
- private static final TypeConverter booleanTypeConverter = new IdentityTypeConverter(Boolean.class);
- private static final TypeConverter characterTypeConverter = new IdentityTypeConverter(Character.class);
- private static final TypeConverter byteTypeConverter = new IdentityTypeConverter(Byte.class);
- private static final TypeConverter shortTypeConverter = new IdentityTypeConverter(Short.class);
- private static final TypeConverter integerTypeConverter = new IdentityTypeConverter(Integer.class);
- private static final TypeConverter longTypeConverter = new IdentityTypeConverter(Long.class);
- private static final TypeConverter bigDecimalTypeConverter = new IdentityTypeConverter(BigDecimal.class);
- private static final TypeConverter bigIntegerTypeConverter = new IdentityTypeConverter(BigInteger.class);
- private static final TypeConverter floatTypeConverter = new IdentityTypeConverter(Float.class);
- private static final TypeConverter doubleTypeConverter = new IdentityTypeConverter(Double.class);
- private static final TypeConverter dateTypeConverter = new IdentityTypeConverter(Date.class);
- private static final TypeConverter calendarTypeConverter = new IdentityTypeConverter(Calendar.class);
- private static final TypeConverter domTypeConverter = new IdentityTypeConverter(Document.class);
- private static final TypeConverter primitiveBooleanTypeConverter = new PrimitiveTypeConverter(Boolean.class);
- private static final TypeConverter primitiveCharTypeConverter = new PrimitiveTypeConverter(Character.class);
- private static final TypeConverter primitiveByteTypeConverter = new PrimitiveTypeConverter(Byte.class);
- private static final TypeConverter primitiveShortTypeConverter = new PrimitiveTypeConverter(Short.class);
- private static final TypeConverter primitiveIntTypeConverter = new PrimitiveTypeConverter(Integer.class);
- private static final TypeConverter primitiveLongTypeConverter = new PrimitiveTypeConverter(Long.class);
- private static final TypeConverter primitiveFloatTypeConverter = new PrimitiveTypeConverter(Float.class);
- private static final TypeConverter primitiveDoubleTypeConverter = new PrimitiveTypeConverter(Double.class);
-
- private static final TypeConverter propertiesTypeConverter = new TypeConverter() {
-
- @Override
- public boolean isConvertable(Object pObject) {
- return pObject == null || pObject instanceof Map;
- }
-
- @Override
- public Object convert(Object pObject) {
- if (pObject == null) {
- return null;
- }
- Properties props = new Properties();
- props.putAll((Map) pObject);
- return props;
- }
-
- @Override
- public Object backConvert(Object pObject) {
- return pObject;
- }
- };
-
- private static final TypeConverter hashTableTypeConverter = new TypeConverter() {
- @Override
- public boolean isConvertable(Object pObject) {
- return pObject == null || pObject instanceof Map;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Object convert(Object pObject) {
- if (pObject == null) {
- return null;
- }
- return new Hashtable<>((Map) pObject);
- }
-
- @Override
- public Object backConvert(Object pObject) {
- return pObject;
- }
- };
-
- private static final TypeConverter listTypeConverter = new ListTypeConverter(List.class) {
- @Override
- protected List newList(int pSize) {
- return new ArrayList<>(pSize);
- }
- };
-
- private static final TypeConverter vectorTypeConverter = new ListTypeConverter(Vector.class) {
- @Override
- protected List newList(int pSize) {
- return new Vector<>(pSize);
- }
- };
-
- private static class CastCheckingTypeConverter implements TypeConverter {
-
- private final Class> clazz;
-
- CastCheckingTypeConverter(Class> pClass) {
- clazz = pClass;
- }
-
- @Override
- public boolean isConvertable(Object pObject) {
- return pObject == null || clazz.isAssignableFrom(pObject.getClass());
- }
-
- @Override
- public Object convert(Object pObject) {
- return pObject;
- }
-
- @Override
- public Object backConvert(Object pObject) {
- return pObject;
- }
- }
-
- /** Returns a type converter for the given class.
- */
- @Override
- public TypeConverter getTypeConverter(Class> pClass) {
- if (void.class.equals(pClass)) {
- return voidTypeConverter;
- }
- if (pClass.isAssignableFrom(boolean.class)) {
- return primitiveBooleanTypeConverter;
- }
- if (pClass.isAssignableFrom(char.class)) {
- return primitiveCharTypeConverter;
- }
- if (pClass.isAssignableFrom(byte.class)) {
- return primitiveByteTypeConverter;
- }
- if (pClass.isAssignableFrom(short.class)) {
- return primitiveShortTypeConverter;
- }
- if (pClass.isAssignableFrom(int.class)) {
- return primitiveIntTypeConverter;
- }
- if (pClass.isAssignableFrom(long.class)) {
- return primitiveLongTypeConverter;
- }
- if (pClass.isAssignableFrom(float.class)) {
- return primitiveFloatTypeConverter;
- }
- if (pClass.isAssignableFrom(double.class)) {
- return primitiveDoubleTypeConverter;
- }
- if (pClass.isAssignableFrom(String.class)) {
- return stringTypeConverter;
- }
- if (pClass.isAssignableFrom(Boolean.class)) {
- return booleanTypeConverter;
- }
- if (pClass.isAssignableFrom(Character.class)) {
- return characterTypeConverter;
- }
- if (pClass.isAssignableFrom(Byte.class)) {
- return byteTypeConverter;
- }
- if (pClass.isAssignableFrom(Short.class)) {
- return shortTypeConverter;
- }
- if (pClass.isAssignableFrom(Integer.class)) {
- return integerTypeConverter;
- }
- if (pClass.isAssignableFrom(Long.class)) {
- return longTypeConverter;
- }
- if (pClass.isAssignableFrom(BigDecimal.class)) {
- return bigDecimalTypeConverter;
- }
- if (pClass.isAssignableFrom(BigInteger.class)) {
- return bigIntegerTypeConverter;
- }
- if (pClass.isAssignableFrom(Float.class)) {
- return floatTypeConverter;
- }
- if (pClass.isAssignableFrom(Double.class)) {
- return doubleTypeConverter;
- }
- if (pClass.isAssignableFrom(Date.class)) {
- return dateTypeConverter;
- }
- if (pClass.isAssignableFrom(Calendar.class)) {
- return calendarTypeConverter;
- }
- if (pClass.isAssignableFrom(Object[].class)) {
- return objectArrayTypeConverter;
- }
- if (pClass.isAssignableFrom(List.class)) {
- return listTypeConverter;
- }
- if (pClass.isAssignableFrom(Vector.class)) {
- return vectorTypeConverter;
- }
- if (pClass.isAssignableFrom(Map.class)) {
- return mapTypeConverter;
- }
- if (pClass.isAssignableFrom(Hashtable.class)) {
- return hashTableTypeConverter;
- }
- if (pClass.isAssignableFrom(Properties.class)) {
- return propertiesTypeConverter;
- }
- if (pClass.isAssignableFrom(byte[].class)) {
- return byteArrayTypeConverter;
- }
- if (pClass.isAssignableFrom(Document.class)) {
- return domTypeConverter;
- }
- if (Serializable.class.isAssignableFrom(pClass)) {
- return new CastCheckingTypeConverter(pClass);
- }
- throw new IllegalStateException("Invalid parameter or result type: " + pClass.getName());
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/TypeFactory.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/TypeFactory.java
deleted file mode 100644
index 95678cf..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/TypeFactory.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-import org.xbib.netty.http.xmlrpc.common.parser.TypeParser;
-import org.xbib.netty.http.xmlrpc.common.serializer.TypeSerializer;
-import org.xbib.netty.http.xmlrpc.common.util.NamespaceContextImpl;
-import org.xml.sax.SAXException;
-
-/**
- * A type factory creates serializers or handlers, based on the object
- * type.
- */
-public interface TypeFactory {
-
- /**
- * Creates a serializer for the object pObject
.
- * @param pConfig The request configuration.
- * @param pObject The object being serialized.
- * @return A serializer for pObject
.
- * @throws SAXException Creating the serializer failed.
- */
- TypeSerializer getSerializer(XmlRpcStreamConfig pConfig, Object pObject) throws SAXException;
-
- /**
- * Creates a parser for a parameter or result object.
- * @param pConfig The request configuration.
- * @param pContext A namespace context, for looking up prefix mappings.
- * @param pURI The namespace URI of the element containing the parameter or result.
- * @param pLocalName The local name of the element containing the parameter or result.
- * @return The created parser.
- */
- TypeParser getParser(XmlRpcStreamConfig pConfig, NamespaceContextImpl pContext, String pURI, String pLocalName);
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/TypeFactoryImpl.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/TypeFactoryImpl.java
deleted file mode 100644
index 5ed32a8..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/TypeFactoryImpl.java
+++ /dev/null
@@ -1,220 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.TimeZone;
-
-import org.xbib.netty.http.xmlrpc.common.parser.BigDecimalParser;
-import org.xbib.netty.http.xmlrpc.common.parser.BigIntegerParser;
-import org.xbib.netty.http.xmlrpc.common.parser.BooleanParser;
-import org.xbib.netty.http.xmlrpc.common.parser.ByteArrayParser;
-import org.xbib.netty.http.xmlrpc.common.parser.CalendarParser;
-import org.xbib.netty.http.xmlrpc.common.parser.DateParser;
-import org.xbib.netty.http.xmlrpc.common.parser.DoubleParser;
-import org.xbib.netty.http.xmlrpc.common.parser.FloatParser;
-import org.xbib.netty.http.xmlrpc.common.parser.I1Parser;
-import org.xbib.netty.http.xmlrpc.common.parser.I2Parser;
-import org.xbib.netty.http.xmlrpc.common.parser.I4Parser;
-import org.xbib.netty.http.xmlrpc.common.parser.I8Parser;
-import org.xbib.netty.http.xmlrpc.common.parser.MapParser;
-import org.xbib.netty.http.xmlrpc.common.parser.NullParser;
-import org.xbib.netty.http.xmlrpc.common.parser.ObjectArrayParser;
-import org.xbib.netty.http.xmlrpc.common.parser.StringParser;
-import org.xbib.netty.http.xmlrpc.common.parser.TypeParser;
-import org.xbib.netty.http.xmlrpc.common.serializer.BigDecimalSerializer;
-import org.xbib.netty.http.xmlrpc.common.serializer.BigIntegerSerializer;
-import org.xbib.netty.http.xmlrpc.common.serializer.BooleanSerializer;
-import org.xbib.netty.http.xmlrpc.common.serializer.ByteArraySerializer;
-import org.xbib.netty.http.xmlrpc.common.serializer.CalendarSerializer;
-import org.xbib.netty.http.xmlrpc.common.serializer.DateSerializer;
-import org.xbib.netty.http.xmlrpc.common.serializer.DoubleSerializer;
-import org.xbib.netty.http.xmlrpc.common.serializer.FloatSerializer;
-import org.xbib.netty.http.xmlrpc.common.serializer.I1Serializer;
-import org.xbib.netty.http.xmlrpc.common.serializer.I2Serializer;
-import org.xbib.netty.http.xmlrpc.common.serializer.I4Serializer;
-import org.xbib.netty.http.xmlrpc.common.serializer.I8Serializer;
-import org.xbib.netty.http.xmlrpc.common.serializer.ListSerializer;
-import org.xbib.netty.http.xmlrpc.common.serializer.MapSerializer;
-import org.xbib.netty.http.xmlrpc.common.serializer.NullSerializer;
-import org.xbib.netty.http.xmlrpc.common.serializer.ObjectArraySerializer;
-import org.xbib.netty.http.xmlrpc.common.serializer.StringSerializer;
-import org.xbib.netty.http.xmlrpc.common.serializer.TypeSerializer;
-import org.xbib.netty.http.xmlrpc.common.serializer.XmlRpcWriter;
-import org.w3c.dom.Node;
-import org.xbib.netty.http.xmlrpc.common.util.NamespaceContextImpl;
-import org.xbib.netty.http.xmlrpc.common.util.XmlRpcDateTimeDateFormat;
-import org.xml.sax.SAXException;
-
-
-/**
- * Default implementation of a type factory.
- */
-public class TypeFactoryImpl implements TypeFactory {
- private static final TypeSerializer NULL_SERIALIZER = new NullSerializer();
- private static final TypeSerializer STRING_SERIALIZER = new StringSerializer();
- private static final TypeSerializer I4_SERIALIZER = new I4Serializer();
- private static final TypeSerializer BOOLEAN_SERIALIZER = new BooleanSerializer();
- private static final TypeSerializer DOUBLE_SERIALIZER = new DoubleSerializer();
- private static final TypeSerializer BYTE_SERIALIZER = new I1Serializer();
- private static final TypeSerializer SHORT_SERIALIZER = new I2Serializer();
- private static final TypeSerializer LONG_SERIALIZER = new I8Serializer();
- private static final TypeSerializer FLOAT_SERIALIZER = new FloatSerializer();
- private static final TypeSerializer BIGDECIMAL_SERIALIZER = new BigDecimalSerializer();
- private static final TypeSerializer BIGINTEGER_SERIALIZER = new BigIntegerSerializer();
- private static final TypeSerializer CALENDAR_SERIALIZER = new CalendarSerializer();
-
- private final XmlRpcController controller;
- private DateSerializer dateSerializer;
-
- /** Creates a new instance.
- * @param pController The controller, which operates the type factory.
- */
- public TypeFactoryImpl(XmlRpcController pController) {
- controller = pController;
- }
-
- /** Returns the controller, which operates the type factory.
- * @return The controller
- */
- public XmlRpcController getController() {
- return controller;
- }
-
- public TypeSerializer getSerializer(XmlRpcStreamConfig pConfig, Object pObject) throws SAXException {
- if (pObject == null) {
- if (pConfig.isEnabledForExtensions()) {
- return NULL_SERIALIZER;
- } else {
- throw new SAXException(new XmlRpcExtensionException("Null values aren't supported, if isEnabledForExtensions() == false"));
- }
- } else if (pObject instanceof String) {
- return STRING_SERIALIZER;
- } else if (pObject instanceof Byte) {
- if (pConfig.isEnabledForExtensions()) {
- return BYTE_SERIALIZER;
- } else {
- throw new SAXException(new XmlRpcExtensionException("Byte values aren't supported, if isEnabledForExtensions() == false"));
- }
- } else if (pObject instanceof Short) {
- if (pConfig.isEnabledForExtensions()) {
- return SHORT_SERIALIZER;
- } else {
- throw new SAXException(new XmlRpcExtensionException("Short values aren't supported, if isEnabledForExtensions() == false"));
- }
- } else if (pObject instanceof Integer) {
- return I4_SERIALIZER;
- } else if (pObject instanceof Long) {
- if (pConfig.isEnabledForExtensions()) {
- return LONG_SERIALIZER;
- } else {
- throw new SAXException(new XmlRpcExtensionException("Long values aren't supported, if isEnabledForExtensions() == false"));
- }
- } else if (pObject instanceof Boolean) {
- return BOOLEAN_SERIALIZER;
- } else if (pObject instanceof Float) {
- if (pConfig.isEnabledForExtensions()) {
- return FLOAT_SERIALIZER;
- } else {
- throw new SAXException(new XmlRpcExtensionException("Float values aren't supported, if isEnabledForExtensions() == false"));
- }
- } else if (pObject instanceof Double) {
- return DOUBLE_SERIALIZER;
- } else if (pObject instanceof Calendar) {
- if (pConfig.isEnabledForExtensions()) {
- return CALENDAR_SERIALIZER;
- } else {
- throw new SAXException(new XmlRpcExtensionException("Calendar values aren't supported, if isEnabledForExtensions() == false"));
- }
- } else if (pObject instanceof Date) {
- if (dateSerializer == null) {
- dateSerializer = new DateSerializer(new XmlRpcDateTimeDateFormat(){
- private static final long serialVersionUID = 24345909123324234L;
- protected TimeZone getTimeZone() {
- return controller.getConfig().getTimeZone();
- }
- });
- }
- return dateSerializer;
- } else if (pObject instanceof byte[]) {
- return new ByteArraySerializer();
- } else if (pObject instanceof Object[]) {
- return new ObjectArraySerializer(this, pConfig);
- } else if (pObject instanceof List) {
- return new ListSerializer(this, pConfig);
- } else if (pObject instanceof Map) {
- return new MapSerializer(this, pConfig);
- } else if (pObject instanceof Node) {
- throw new SAXException(new XmlRpcExtensionException("DOM nodes aren't supported"));
- } else if (pObject instanceof BigInteger) {
- if (pConfig.isEnabledForExtensions()) {
- return BIGINTEGER_SERIALIZER;
- } else {
- throw new SAXException(new XmlRpcExtensionException("BigInteger values aren't supported, if isEnabledForExtensions() == false"));
- }
- } else if (pObject instanceof BigDecimal) {
- if (pConfig.isEnabledForExtensions()) {
- return BIGDECIMAL_SERIALIZER;
- } else {
- throw new SAXException(new XmlRpcExtensionException("BigDecimal values aren't supported, if isEnabledForExtensions() == false"));
- }
- } else if (pObject instanceof Serializable) {
- throw new SAXException(new XmlRpcExtensionException("Serializable objects aren't supported"));
- } else {
- return null;
- }
- }
-
- public TypeParser getParser(XmlRpcStreamConfig pConfig, NamespaceContextImpl pContext, String pURI, String pLocalName) {
- if (XmlRpcWriter.EXTENSIONS_URI.equals(pURI)) {
- if (!pConfig.isEnabledForExtensions()) {
- return null;
- }
- if (NullSerializer.NIL_TAG.equals(pLocalName)) {
- return new NullParser();
- } else if (I1Serializer.I1_TAG.equals(pLocalName)) {
- return new I1Parser();
- } else if (I2Serializer.I2_TAG.equals(pLocalName)) {
- return new I2Parser();
- } else if (I8Serializer.I8_TAG.equals(pLocalName)) {
- return new I8Parser();
- } else if (FloatSerializer.FLOAT_TAG.equals(pLocalName)) {
- return new FloatParser();
- } else if (BigDecimalSerializer.BIGDECIMAL_TAG.equals(pLocalName)) {
- return new BigDecimalParser();
- } else if (BigIntegerSerializer.BIGINTEGER_TAG.equals(pLocalName)) {
- return new BigIntegerParser();
- } else if (CalendarSerializer.CALENDAR_TAG.equals(pLocalName)) {
- return new CalendarParser();
- }
- } else if ("".equals(pURI)) {
- if (I4Serializer.INT_TAG.equals(pLocalName) || I4Serializer.I4_TAG.equals(pLocalName)) {
- return new I4Parser();
- } else if (BooleanSerializer.BOOLEAN_TAG.equals(pLocalName)) {
- return new BooleanParser();
- } else if (DoubleSerializer.DOUBLE_TAG.equals(pLocalName)) {
- return new DoubleParser();
- } else if (DateSerializer.DATE_TAG.equals(pLocalName)) {
- return new DateParser(new XmlRpcDateTimeDateFormat(){
- private static final long serialVersionUID = 7585237706442299067L;
- protected TimeZone getTimeZone() {
- return controller.getConfig().getTimeZone();
- }
- });
- } else if (ObjectArraySerializer.ARRAY_TAG.equals(pLocalName)) {
- return new ObjectArrayParser(pConfig, pContext, this);
- } else if (MapSerializer.STRUCT_TAG.equals(pLocalName)) {
- return new MapParser(pConfig, pContext, this);
- } else if (ByteArraySerializer.BASE_64_TAG.equals(pLocalName)) {
- return new ByteArrayParser();
- } else if (StringSerializer.STRING_TAG.equals(pLocalName)) {
- return new StringParser();
- }
- }
- return null;
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcConfig.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcConfig.java
deleted file mode 100644
index f197fb8..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcConfig.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-import java.util.TimeZone;
-
-public interface XmlRpcConfig {
-
- /**
- * Returns, whether support for extensions are enabled.
- * By default, extensions are disabled and your client is
- * interoperable with other XML-RPC implementations.
- * Interoperable XML-RPC implementations are those, which
- * are compliant to the
- * XML-RPC Specification .
- * @return Whether extensions are enabled or not.
- */
- boolean isEnabledForExtensions();
-
- /** Returns the timezone, which is used to interpret date/time
- * values. Defaults to {@link TimeZone#getDefault()}.
- * @return time zone
- */
- TimeZone getTimeZone();
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcConfigImpl.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcConfigImpl.java
deleted file mode 100644
index 26e9917..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcConfigImpl.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-import java.util.TimeZone;
-
-/**
- * Default implementation of {@link XmlRpcConfig}.
- */
-public abstract class XmlRpcConfigImpl implements XmlRpcConfig, XmlRpcHttpConfig {
-
- private boolean enabledForExtensions;
-
- private boolean contentLengthOptional;
-
- private String basicEncoding;
-
- private String encoding;
-
- private TimeZone timeZone = TimeZone.getDefault();
-
- public boolean isEnabledForExtensions() { return enabledForExtensions; }
-
- /** Sets, whether extensions are enabled. By default, the
- * client or server is strictly compliant to the XML-RPC
- * specification and extensions are disabled.
- * @param pExtensions True to enable extensions, false otherwise.
- */
- public void setEnabledForExtensions(boolean pExtensions) {
- enabledForExtensions = pExtensions;
- }
-
- /** Sets the encoding for basic authentication.
- * @param pEncoding The encoding; may be null, in which case
- * UTF-8 is choosen.
- */
- public void setBasicEncoding(String pEncoding) {
- basicEncoding = pEncoding;
- }
-
- public String getBasicEncoding() { return basicEncoding; }
-
- /** Sets the requests encoding.
- * @param pEncoding The requests encoding or null (default
- * UTF-8).
- */
- public void setEncoding(String pEncoding) {
- encoding = pEncoding;
- }
-
- public String getEncoding() { return encoding; }
-
- public boolean isContentLengthOptional() {
- return contentLengthOptional;
- }
-
- /** Sets, whether a "Content-Length" header may be
- * omitted. The XML-RPC specification demands, that such
- * a header be present.
- * @param pContentLengthOptional True, if the content length may be omitted.
- */
- public void setContentLengthOptional(boolean pContentLengthOptional) {
- contentLengthOptional = pContentLengthOptional;
- }
-
- public TimeZone getTimeZone() {
- return timeZone;
- }
-
- /** Returns the timezone, which is used to interpret date/time
- * values. Defaults to {@link TimeZone#getDefault()}.
- * @param pTimeZone time zone
- */
- public void setTimeZone(TimeZone pTimeZone) {
- timeZone = pTimeZone;
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcController.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcController.java
deleted file mode 100644
index 1ce823b..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcController.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-
-public abstract class XmlRpcController {
-
- private XmlRpcWorkerFactory workerFactory = getDefaultXmlRpcWorkerFactory();
-
- private int maxThreads;
-
- private TypeFactory typeFactory = new TypeFactoryImpl(this);
-
- /** Creates the controllers default worker factory.
- * @return The default factory for workers.
- */
- protected abstract XmlRpcWorkerFactory getDefaultXmlRpcWorkerFactory();
-
- /** Sets the maximum number of concurrent requests. This includes
- * both synchronous and asynchronous requests.
- * @param pMaxThreads Maximum number of threads or 0 to disable
- * the limit.
- */
- public void setMaxThreads(int pMaxThreads) {
- maxThreads = pMaxThreads;
- }
-
- /** Returns the maximum number of concurrent requests. This includes
- * both synchronous and asynchronous requests.
- * @return Maximum number of threads or 0 to disable
- * the limit.
- */
- public int getMaxThreads() {
- return maxThreads;
- }
-
- /** Sets the clients worker factory.
- * @param pFactory The factory being used to create workers.
- */
- public void setWorkerFactory(XmlRpcWorkerFactory pFactory) {
- workerFactory = pFactory;
- }
-
- /** Returns the clients worker factory.
- * @return The factory being used to create workers.
- */
- public XmlRpcWorkerFactory getWorkerFactory() {
- return workerFactory;
- }
-
- /** Returns the controllers default configuration.
- * @return The default configuration.
- */
- public abstract XmlRpcConfig getConfig();
-
- /** Sets the type factory.
- * @param pTypeFactory The type factory.
- */
- public void setTypeFactory(TypeFactory pTypeFactory) {
- typeFactory = pTypeFactory;
- }
-
- /** Returns the type factory.
- * @return The type factory.
- */
- public TypeFactory getTypeFactory() {
- return typeFactory;
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcException.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcException.java
deleted file mode 100644
index 7a03acd..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcException.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-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.
- */
-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;
-
- /** 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 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 message
- * and error code 0.
- * @param pMessage Detail message.
- */
- public XmlRpcException(String pMessage) {
- this(0, pMessage, null);
- }
-
- /** 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;
- }
-
- @Override
- public void printStackTrace(PrintStream pStream) {
- super.printStackTrace(pStream);
- if (linkedException != null) {
- pStream.println("Caused by:");
- linkedException.printStackTrace(pStream);
- }
- }
-
- @Override
- public void printStackTrace(PrintWriter pWriter) {
- super.printStackTrace(pWriter);
- if (linkedException != null) {
- pWriter.println("Caused by:");
- linkedException.printStackTrace(pWriter);
- }
- }
-
- @Override
- public Throwable getCause() {
- return linkedException;
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcExtensionException.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcExtensionException.java
deleted file mode 100644
index 0debdde..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcExtensionException.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-/**
- * This exception is thrown, if an attempt to use extensions
- * is made, but extensions aren't explicitly enabled.
- */
-public class XmlRpcExtensionException extends XmlRpcException {
-
- private static final long serialVersionUID = 3617014169594311221L;
-
- /** Creates a new instance with the given error message.
- * @param pMessage The error message.
- */
- public XmlRpcExtensionException(String pMessage) {
- super(0, pMessage);
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcHandler.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcHandler.java
deleted file mode 100644
index f3522a9..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcHandler.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-/**
- * The XML-RPC server uses this interface to call a method of an RPC handler.
- */
-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.
- */
- Object execute(XmlRpcRequest pRequest) throws XmlRpcException;
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcHttpConfig.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcHttpConfig.java
deleted file mode 100644
index 4d578dc..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcHttpConfig.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-/**
- * Interface of a configuration for HTTP requests.
- */
-public interface XmlRpcHttpConfig extends XmlRpcStreamConfig {
-
- /**
- * Returns the encoding being used to convert the String "username:password"
- * into bytes.
- * @return Encoding being used for basic HTTP authentication credentials,
- * or null, if the default encoding
- * ({@link XmlRpcStreamRequestConfig#UTF8_ENCODING})
- * is being used.
- */
- String getBasicEncoding();
-
- /** Returns, whether a "Content-Length" header may be
- * omitted. The XML-RPC specification demands, that such
- * a header be present.
- * @return True, if the content length may be omitted.
- */
- boolean isContentLengthOptional();
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcHttpRequestConfig.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcHttpRequestConfig.java
deleted file mode 100644
index 10d36fe..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcHttpRequestConfig.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-/**
- * Extension for HTTP based transport. Provides details like server URL,
- * user credentials, and so on.
- */
-public interface XmlRpcHttpRequestConfig extends XmlRpcStreamRequestConfig, XmlRpcHttpConfig {
-
- /** Returns the user name being used for basic HTTP authentication.
- * @return User name or null, if no basic HTTP authentication is being used.
- */
- String getBasicUserName();
-
- /** Returns the password being used for basic HTTP authentication.
- * @return Password or null, if no basic HTTP authentication is beind used.
- * @throws IllegalStateException A user name is configured, but no password.
- */
- String getBasicPassword();
-
- /** Return the connection timeout in milliseconds
- * @return connection timeout in milliseconds or 0 if no set
- */
- int getConnectionTimeout();
-
- /** Return the reply timeout in milliseconds
- * @return reply timeout in milliseconds or 0 if no set
- */
- int getReplyTimeout();
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcHttpRequestConfigImpl.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcHttpRequestConfigImpl.java
deleted file mode 100644
index f2e534f..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcHttpRequestConfigImpl.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-/**
- * Default implementation of a request configuration.
- */
-public class XmlRpcHttpRequestConfigImpl extends XmlRpcConfigImpl implements
- XmlRpcHttpRequestConfig {
-
- private boolean gzipCompressing;
-
- private boolean gzipRequesting;
-
- private String basicUserName;
-
- private String basicPassword;
-
- private int connectionTimeout = 0;
-
- private int replyTimeout = 0;
-
- private boolean enabledForExceptions;
-
- /** Sets, whether gzip compression is being used for
- * transmitting the request.
- * @param pCompressing True for enabling gzip compression,
- * false otherwise.
- * @see #setGzipRequesting(boolean)
- */
- public void setGzipCompressing(boolean pCompressing) {
- gzipCompressing = pCompressing;
- }
-
- public boolean isGzipCompressing() {
- return gzipCompressing;
- }
-
- /** Sets, whether gzip compression is requested for the
- * response.
- * @param pRequesting True for requesting gzip compression,
- * false otherwise.
- * @see #setGzipCompressing(boolean)
- */
- public void setGzipRequesting(boolean pRequesting) {
- gzipRequesting = pRequesting;
- }
-
- public boolean isGzipRequesting() {
- return gzipRequesting;
- }
-
- /** Sets the user name for basic authentication.
- * @param pUser The user name.
- */
- public void setBasicUserName(String pUser) {
- basicUserName = pUser;
- }
-
- public String getBasicUserName() { return basicUserName; }
-
- /** Sets the password for basic authentication.
- * @param pPassword The password.
- */
- public void setBasicPassword(String pPassword) {
- basicPassword = pPassword;
- }
-
- public String getBasicPassword() { return basicPassword; }
-
- /** Set the connection timeout in milliseconds.
- * @param pTimeout connection timeout, 0 to disable it
- */
- public void setConnectionTimeout(int pTimeout) {
- connectionTimeout = pTimeout;
- }
-
- public int getConnectionTimeout() {
- return connectionTimeout;
- }
-
- /** Set the reply timeout in milliseconds.
- * @param pTimeout reply timeout, 0 to disable it
- */
- public void setReplyTimeout(int pTimeout) {
- replyTimeout = pTimeout;
- }
-
- public int getReplyTimeout() {
- return replyTimeout;
- }
-
- /** Sets, whether the response should contain a "faultCause" element
- * in case of errors. The "faultCause" is an exception, which the
- * server has trapped and written into a byte stream as a serializable
- * object.
- * @param pEnabledForExceptions enabled for exceptions
- */
- public void setEnabledForExceptions(boolean pEnabledForExceptions) {
- enabledForExceptions = pEnabledForExceptions;
- }
-
- public boolean isEnabledForExceptions() {
- return enabledForExceptions;
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcInvocationException.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcInvocationException.java
deleted file mode 100644
index 560917b..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcInvocationException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-/**
- * This exception is thrown, if the server catches an exception, which
- * is thrown by the handler.
- */
-public class XmlRpcInvocationException extends XmlRpcException {
-
- private static final long serialVersionUID = 7439737967784966169L;
-
- /**
- * Creates a new instance with the given error code, error message
- * and cause.
- * @param pCode code
- * @param pMessage message
- * @param pLinkedException exception
- */
- public XmlRpcInvocationException(int pCode, String pMessage, Throwable pLinkedException) {
- super(pCode, pMessage, pLinkedException);
- }
-
- /**
- * Creates a new instance with the given error message and cause.
- * @param pMessage message
- * @param pLinkedException exception
- */
- public XmlRpcInvocationException(String pMessage, Throwable pLinkedException) {
- super(pMessage, pLinkedException);
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcLoadException.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcLoadException.java
deleted file mode 100644
index be64ca3..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcLoadException.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-/**
- * This exception is thrown, if the clients or servers maximum
- * number of concurrent threads is exceeded.
- */
-public class XmlRpcLoadException extends XmlRpcException {
-
- private static final long serialVersionUID = 4050760511635272755L;
-
- /** Creates a new instance.
- * @param pMessage Error description.
- */
- public XmlRpcLoadException(String pMessage) {
- super(0, pMessage, null);
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcNotAuthorizedException.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcNotAuthorizedException.java
deleted file mode 100644
index 503de69..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcNotAuthorizedException.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-/**
- * This exception must be thrown, if the user isn't authenticated.
- */
-public class XmlRpcNotAuthorizedException extends XmlRpcException {
-
- private static final long serialVersionUID = 3258410629709574201L;
-
- /** Creates a new instance with the given error message.
- * @param pMessage The error message.
- */
- public XmlRpcNotAuthorizedException(String pMessage) {
- super(0, pMessage);
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcRequest.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcRequest.java
deleted file mode 100644
index 5d63cc6..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcRequest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-/**
- * Interface to an XML-RPC request made by a client.
- */
-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 pIndex
.
- * @param pIndex Number between 0 and {@link #getParameterCount()}-1.
- * @return Parameter being sent to the server.
- */
- public Object getParameter(int pIndex);
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcRequestConfig.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcRequestConfig.java
deleted file mode 100644
index 29807d4..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcRequestConfig.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-/**
- * Interface of a request configuration. Depending on
- * the transport, implementations will also implement
- * additional interfaces like
- * {@link XmlRpcStreamRequestConfig}.
- */
-public interface XmlRpcRequestConfig extends XmlRpcConfig {
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcRequestProcessor.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcRequestProcessor.java
deleted file mode 100644
index 52e6eb0..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcRequestProcessor.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-/**
- * Interface of an object, which is able to process
- * XML-RPC requests.
- */
-public interface XmlRpcRequestProcessor {
-
- /**
- * Processes the given request and returns a
- * result object.
- * @param pRequest request
- * @return result
- * @throws XmlRpcException Processing the request failed.
- */
- Object execute(XmlRpcRequest pRequest) throws XmlRpcException;
-
- /**
- * Returns the request processors {@link TypeConverterFactory}.
- * @return type converter factory
- */
- TypeConverterFactory getTypeConverterFactory();
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcRequestProcessorFactory.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcRequestProcessorFactory.java
deleted file mode 100644
index 89141bb..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcRequestProcessorFactory.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-/**
- * Interface of an object, which may be used
- * to create instances of {@link XmlRpcRequestProcessor}.
- */
-public interface XmlRpcRequestProcessorFactory {
-
- /**
- * Returns the {@link 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();
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcStreamConfig.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcStreamConfig.java
deleted file mode 100644
index 3c48def..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcStreamConfig.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-/**
- * Interface of a configuration for a stream based transport.
- */
-public interface XmlRpcStreamConfig extends XmlRpcConfig {
-
- /**
- * Default encoding (UTF-8).
- */
- String UTF8_ENCODING = "UTF-8";
-
- /**
- * Returns the encoding being used for data encoding, when writing
- * to a stream.
- * @return Suggested encoding, or null, if the {@link #UTF8_ENCODING}
- * is being used.
- */
- String getEncoding();
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcStreamRequestConfig.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcStreamRequestConfig.java
deleted file mode 100644
index 2118ea7..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcStreamRequestConfig.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-/**
- * Interface of a client configuration for a transport, which
- * is implemented by writing to a stream.
- */
-public interface XmlRpcStreamRequestConfig extends XmlRpcStreamConfig, XmlRpcRequestConfig {
-
- /**
- * Returns true if the request stream is being compressed. Note,
- * that the response stream may still be uncompressed.
- * @return Whether to use Gzip compression or not. Defaults to false.
- * @see #isGzipRequesting()
- */
- boolean isGzipCompressing();
-
- /**
- * Returns true if compression is requested for the response stream.
- * Note, that the request is stull uncompressed, unless
- * {@link #isGzipCompressing()} is activated. Also note, that the
- * server may still decide to send uncompressed data.
- * @return Whether to use Gzip compression or not. Defaults to false.
- * @see #isGzipCompressing()
- */
- boolean isGzipRequesting();
-
- /**
- * Returns true if the response should contain a "faultCause" element
- * in case of errors. The "faultCause" is an exception, which the
- * server has trapped and written into a byte stream as a serializable
- * object.
- * @return true if enabled for exceptions
- */
- boolean isEnabledForExceptions();
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcStreamRequestProcessor.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcStreamRequestProcessor.java
deleted file mode 100644
index 39ded20..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcStreamRequestProcessor.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-/**
- * An instance of {@link 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.
- * @param pConfig config
- * @param pConnection connection
- * @throws XmlRpcException Processing the request failed.
- */
- void execute(XmlRpcStreamRequestConfig pConfig, ServerStreamConnection pConnection) throws XmlRpcException;
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcWorker.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcWorker.java
deleted file mode 100644
index 01727ef..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcWorker.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-/**
- * An object, which executes requests on the controllers
- * behalf. These objects are mainly used for controlling the
- * clients or servers load, which is defined in terms of the
- * number of currently active workers.
- */
-public interface XmlRpcWorker {
-
- /**
- * Returns the workers controller.
- * @return The controller
- */
- XmlRpcController getController();
-
- /**
- * Performs a synchronous request. The client worker extends
- * this interface with the ability to perform asynchronous
- * requests.
- * @param pRequest The request being performed.
- * @return The requests result.
- * @throws XmlRpcException Performing the request failed.
- */
- Object execute(XmlRpcRequest pRequest) throws XmlRpcException;
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcWorkerFactory.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcWorkerFactory.java
deleted file mode 100644
index 412d5da..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/XmlRpcWorkerFactory.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * A factory for {@link XmlRpcWorker} instances.
- */
-public abstract class XmlRpcWorkerFactory {
-
- private final XmlRpcWorker singleton = newWorker();
-
- private final XmlRpcController controller;
-
- private final List pool = new ArrayList<>();
-
- private int numThreads;
-
- /**
- * Creates a new instance.
- * @param pController The client controlling the factory.
- */
- public XmlRpcWorkerFactory(XmlRpcController pController) {
- controller = pController;
- }
-
- /**
- * Creates a new worker instance.
- * @return New instance of {@link XmlRpcWorker}.
- */
- protected abstract XmlRpcWorker newWorker();
-
- /**
- * Returns the factory controller.
- * @return The controller
- */
- public XmlRpcController getController() {
- return controller;
- }
-
- /** Returns a worker for synchronous processing.
- * @return An instance of {@link XmlRpcWorker}, which is ready
- * for use.
- * @throws XmlRpcLoadException The clients maximum number of concurrent
- * threads is exceeded.
- */
- public synchronized XmlRpcWorker getWorker() throws XmlRpcLoadException {
- int max = controller.getMaxThreads();
- if (max > 0 && numThreads == max) {
- throw new XmlRpcLoadException("Maximum number of concurrent requests exceeded: " + max);
- }
- if (max == 0) {
- return singleton;
- }
- ++numThreads;
- if (pool.size() == 0) {
- return newWorker();
- } else {
- return pool.remove(pool.size() - 1);
- }
- }
-
- /** Called, when the worker did its job. Frees resources and
- * decrements the number of concurrent requests.
- * @param pWorker The worker being released.
- */
- public synchronized void releaseWorker(XmlRpcWorker pWorker) {
- --numThreads;
- int max = controller.getMaxThreads();
- if (pWorker != singleton) {
- if (pool.size() < max) {
- pool.add(pWorker);
- }
- }
- }
-
- /**
- * Returns the number of currently running requests.
- * @return Current number of concurrent requests.
- */
- public synchronized int getCurrentRequests() {
- return numThreads;
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/AtomicParser.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/AtomicParser.java
deleted file mode 100644
index 54a0491..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/AtomicParser.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.parser;
-
-import javax.xml.namespace.QName;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * Abstract base implementation of {@link TypeParser}
- * for parsing an atomic value.
- */
-public abstract class AtomicParser extends TypeParserImpl {
- private int level;
- protected StringBuffer sb;
-
- /**
- * Creates a new instance.
- */
- protected AtomicParser() {
- }
-
- protected abstract void setResult(String pResult) throws SAXException;
-
- public void startDocument() throws SAXException {
- level = 0;
- }
-
- public void characters(char[] pChars, int pStart, int pLength) throws SAXException {
- if (sb == null) {
- if (!isEmpty(pChars, pStart, pLength)) {
- throw new SAXParseException("Unexpected non-whitespace characters",
- getDocumentLocator());
- }
- } else {
- sb.append(pChars, pStart, pLength);
- }
- }
-
- public void endElement(String pURI, String pLocalName, String pQName) throws SAXException {
- if (--level == 0) {
- setResult(sb.toString());
- } else {
- throw new SAXParseException("Unexpected end tag in atomic element: "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- }
-
- public void startElement(String pURI, String pLocalName, String pQName, Attributes pAttrs) throws SAXException {
- if (level++ == 0) {
- sb = new StringBuffer();
- } else {
- throw new SAXParseException("Unexpected start tag in atomic element: "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/BigDecimalParser.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/BigDecimalParser.java
deleted file mode 100644
index f13b9d2..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/BigDecimalParser.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.parser;
-
-import java.math.BigDecimal;
-
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * Parser for BigDecimal values.
- */
-public class BigDecimalParser extends AtomicParser {
- protected void setResult(String pResult) throws SAXException {
- try {
- super.setResult(new BigDecimal(pResult));
- } catch (NumberFormatException e) {
- throw new SAXParseException("Failed to parse BigDecimal value: " + pResult,
- getDocumentLocator());
- }
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/BigIntegerParser.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/BigIntegerParser.java
deleted file mode 100644
index 24dbd1e..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/BigIntegerParser.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.parser;
-
-import java.math.BigInteger;
-
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * Parser for BigInteger values.
- */
-public class BigIntegerParser extends AtomicParser {
- protected void setResult(String pResult) throws SAXException {
- try {
- super.setResult(new BigInteger(pResult));
- } catch (NumberFormatException e) {
- throw new SAXParseException("Failed to parse BigInteger value: " + pResult,
- getDocumentLocator());
- }
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/BooleanParser.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/BooleanParser.java
deleted file mode 100644
index 84220e1..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/BooleanParser.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.parser;
-
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * Parser for boolean values.
- */
-public class BooleanParser extends AtomicParser {
-
- @Override
- protected void setResult(String pResult) throws SAXException {
- String s = pResult.trim();
- if ("1".equals(s)) {
- super.setResult(Boolean.TRUE);
- } else if ("0".equals(s)) {
- super.setResult(Boolean.FALSE);
- } else {
- throw new SAXParseException("Failed to parse boolean value: " + pResult,
- getDocumentLocator());
- }
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/ByteArrayParser.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/ByteArrayParser.java
deleted file mode 100644
index 8462684..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/ByteArrayParser.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.parser;
-
-import java.util.Base64;
-
-import javax.xml.namespace.QName;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * A parser for base64 elements.
- */
-public class ByteArrayParser extends TypeParserImpl {
- private int level;
- private StringBuilder sb;
-
- @Override
- public void startDocument() throws SAXException {
- level = 0;
- }
-
- @Override
- public void characters(char[] pChars, int pStart, int pLength) throws SAXException {
- sb.append(new String(pChars, pStart, pLength));
- }
-
- @Override
- public void endElement(String pURI, String pLocalName, String pQName) throws SAXException {
- if (--level == 0) {
- setResult(Base64.getDecoder().decode(sb.toString()));
- } else {
- throw new SAXParseException("Unexpected end tag in atomic element: "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- }
-
- @Override
- public void startElement(String pURI, String pLocalName, String pQName, Attributes pAttrs) throws SAXException {
- if (level++ == 0) {
- sb = new StringBuilder();
- } else {
- throw new SAXParseException("Unexpected start tag in atomic element: "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/CalendarParser.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/CalendarParser.java
deleted file mode 100644
index 47d91da..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/CalendarParser.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.parser;
-
-import java.text.ParseException;
-
-import org.xbib.netty.http.xmlrpc.common.util.XsDateTimeFormat;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * Parser for integer values.
- */
-public class CalendarParser extends AtomicParser {
-
- private static final XsDateTimeFormat format = new XsDateTimeFormat();
-
- @Override
- protected void setResult(String pResult) throws SAXException {
- try {
- super.setResult(format.parseObject(pResult.trim()));
- } catch (ParseException e) {
- int offset = e.getErrorOffset();
- final String msg;
- if (offset == -1) {
- msg = "Failed to parse dateTime value: " + pResult;
- } else {
- msg = "Failed to parse dateTime value " + pResult
- + " at position " + e.getErrorOffset();
- }
- throw new SAXParseException(msg, getDocumentLocator(), e);
- }
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/DateParser.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/DateParser.java
deleted file mode 100644
index 05cc087..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/DateParser.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.parser;
-
-import java.text.Format;
-import java.text.ParseException;
-
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * Parser for integer values.
- */
-public class DateParser extends AtomicParser {
- private final Format f;
-
- /**
- * Creates a new instance with the given format.
- * @param pFormat format
- */
- public DateParser(Format pFormat) {
- f = pFormat;
- }
-
- protected void setResult(String pResult) throws SAXException {
- final String s = pResult.trim();
- if (s.length() == 0) {
- return;
- }
- try {
- super.setResult(f.parseObject(s));
- } catch (ParseException e) {
- final String msg;
- int offset = e.getErrorOffset();
- if (e.getErrorOffset() == -1) {
- msg = "Failed to parse date value: " + pResult;
- } else {
- msg = "Failed to parse date value " + pResult
- + " at position " + offset;
- }
- throw new SAXParseException(msg, getDocumentLocator(), e);
- }
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/DoubleParser.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/DoubleParser.java
deleted file mode 100644
index ab7c2c6..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/DoubleParser.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.parser;
-
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * Parser for double values.
- */
-public class DoubleParser extends AtomicParser {
-
- @Override
- protected void setResult(String pResult) throws SAXException {
- try {
- super.setResult(Double.valueOf(pResult));
- } catch (NumberFormatException e) {
- throw new SAXParseException("Failed to parse double value: " + pResult,
- getDocumentLocator());
- }
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/FloatParser.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/FloatParser.java
deleted file mode 100644
index cc7da13..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/FloatParser.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.parser;
-
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * Parser for float values.
- */
-public class FloatParser extends AtomicParser {
-
- @Override
- protected void setResult(String pResult) throws SAXException {
- try {
- super.setResult(Float.valueOf(pResult));
- } catch (NumberFormatException e) {
- throw new SAXParseException("Failed to parse float value: " + pResult,
- getDocumentLocator());
- }
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/I1Parser.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/I1Parser.java
deleted file mode 100644
index f358e97..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/I1Parser.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.parser;
-
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * Parser for byte values.
- */
-public class I1Parser extends AtomicParser {
-
- @Override
- protected void setResult(String pResult) throws SAXException {
- try {
- super.setResult(Byte.valueOf(pResult.trim()));
- } catch (NumberFormatException e) {
- throw new SAXParseException("Failed to parse byte value: " + pResult,
- getDocumentLocator());
- }
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/I2Parser.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/I2Parser.java
deleted file mode 100644
index c0e418a..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/I2Parser.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.parser;
-
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * Parser for short values.
- */
-public class I2Parser extends AtomicParser {
-
- @Override
- protected void setResult(String pResult) throws SAXException {
- try {
- super.setResult(Short.valueOf(pResult.trim()));
- } catch (NumberFormatException e) {
- throw new SAXParseException("Failed to parse short value: " + pResult,
- getDocumentLocator());
- }
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/I4Parser.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/I4Parser.java
deleted file mode 100644
index 5f4ee2c..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/I4Parser.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.parser;
-
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * Parser for integer values.
- */
-public class I4Parser extends AtomicParser {
-
- @Override
- protected void setResult(String pResult) throws SAXException {
- try {
- super.setResult(Integer.valueOf(pResult.trim()));
- } catch (NumberFormatException e) {
- throw new SAXParseException("Failed to parse integer value: " + pResult,
- getDocumentLocator());
- }
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/I8Parser.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/I8Parser.java
deleted file mode 100644
index 6e2dfed..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/I8Parser.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.parser;
-
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * Parser for long values.
- */
-public class I8Parser extends AtomicParser {
-
- @Override
- protected void setResult(String pResult) throws SAXException {
- try {
- super.setResult(Long.valueOf(pResult.trim()));
- } catch (NumberFormatException e) {
- throw new SAXParseException("Failed to parse long value: " + pResult,
- getDocumentLocator());
- }
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/LongParser.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/LongParser.java
deleted file mode 100644
index fd6d81e..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/LongParser.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.parser;
-
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * Parser for long values.
- */
-public class LongParser extends AtomicParser {
-
- @Override
- protected void setResult(String pResult) throws SAXException {
- try {
- super.setResult(Long.valueOf(pResult.trim()));
- } catch (NumberFormatException e) {
- throw new SAXParseException("Failed to parse long value: " + pResult,
- getDocumentLocator());
- }
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/MapParser.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/MapParser.java
deleted file mode 100644
index a836c4f..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/MapParser.java
+++ /dev/null
@@ -1,187 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.parser;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-
-import org.xbib.netty.http.xmlrpc.common.TypeFactory;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamConfig;
-import org.xbib.netty.http.xmlrpc.common.serializer.MapSerializer;
-import org.xbib.netty.http.xmlrpc.common.serializer.TypeSerializerImpl;
-import org.xbib.netty.http.xmlrpc.common.util.NamespaceContextImpl;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * {@link org.xbib.netty.http.xmlrpc.common.parser.TypeParser} implementation
- * for maps.
- */
-public class MapParser extends RecursiveTypeParserImpl {
-
- private int level = 0;
-
- private StringBuffer nameBuffer = new StringBuffer();
-
- private Object nameObject;
-
- private Map map;
-
- private boolean inName, inValue, doneValue;
-
- /** Creates a new instance.
- * @param pConfig The request or response configuration.
- * @param pContext The namespace context.
- * @param pFactory The factory.
- */
- public MapParser(XmlRpcStreamConfig pConfig,
- NamespaceContextImpl pContext,
- TypeFactory pFactory) {
- super(pConfig, pContext, pFactory);
- }
-
- protected void addResult(Object pResult) throws SAXException {
- if (inName) {
- nameObject = pResult;
- } else {
- if (nameObject == null) {
- throw new SAXParseException("Invalid state: Expected name",
- getDocumentLocator());
- } else {
- if (map.containsKey(nameObject)) {
- throw new SAXParseException("Duplicate name: " + nameObject,
- getDocumentLocator());
- } else {
- map.put(nameObject, pResult);
- }
- }
- }
- }
-
- public void startDocument() throws SAXException {
- super.startDocument();
- level = 0;
- map = new HashMap<>();
- inValue = inName = false;
- }
-
- public void characters(char[] pChars, int pOffset, int pLength) throws SAXException {
- if (inName && !inValue) {
- nameBuffer.append(pChars, pOffset, pLength);
- } else {
- super.characters(pChars, pOffset, pLength);
- }
- }
-
- public void ignorableWhitespace(char[] pChars, int pOffset, int pLength) throws SAXException {
- if (inName) {
- characters(pChars, pOffset, pLength);
- } else {
- super.ignorableWhitespace(pChars, pOffset, pLength);
- }
- }
-
- public void startElement(String pURI, String pLocalName, String pQName,
- Attributes pAttrs) throws SAXException {
- switch (level++) {
- case 0:
- if (!"".equals(pURI) || !MapSerializer.STRUCT_TAG.equals(pLocalName)) {
- throw new SAXParseException("Expected " + MapSerializer.STRUCT_TAG + ", got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- break;
- case 1:
- if (!"".equals(pURI) || !MapSerializer.MEMBER_TAG.equals(pLocalName)) {
- throw new SAXParseException("Expected " + MapSerializer.MEMBER_TAG + ", got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- doneValue = inName = inValue = false;
- nameObject = null;
- nameBuffer.setLength(0);
- break;
- case 2:
- if (doneValue) {
- throw new SAXParseException("Expected /" + MapSerializer.MEMBER_TAG
- + ", got " + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- if ("".equals(pURI) && MapSerializer.NAME_TAG.equals(pLocalName)) {
- if (nameObject == null) {
- inName = true;
- } else {
- throw new SAXParseException("Expected " + TypeSerializerImpl.VALUE_TAG
- + ", got " + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- } else if ("".equals(pURI) && TypeSerializerImpl.VALUE_TAG.equals(pLocalName)) {
- if (nameObject == null) {
- throw new SAXParseException("Expected " + MapSerializer.NAME_TAG
- + ", got " + new QName(pURI, pLocalName),
- getDocumentLocator());
- } else {
- inValue = true;
- startValueTag();
- }
-
- }
- break;
- case 3:
- if (inName && "".equals(pURI) && TypeSerializerImpl.VALUE_TAG.equals(pLocalName)) {
- if (cfg.isEnabledForExtensions()) {
- inValue = true;
- startValueTag();
- } else {
- throw new SAXParseException("Expected /" + MapSerializer.NAME_TAG
- + ", got " + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- } else {
- super.startElement(pURI, pLocalName, pQName, pAttrs);
- }
- break;
- default:
- super.startElement(pURI, pLocalName, pQName, pAttrs);
- break;
- }
- }
-
- public void endElement(String pURI, String pLocalName, String pQName) throws SAXException {
- switch (--level) {
- case 0:
- setResult(map);
- break;
- case 1:
- break;
- case 2:
- if (inName) {
- inName = false;
- if (nameObject == null) {
- nameObject = nameBuffer.toString();
- } else {
- for (int i = 0; i < nameBuffer.length(); i++) {
- if (!Character.isWhitespace(nameBuffer.charAt(i))) {
- throw new SAXParseException("Unexpected non-whitespace character in member name",
- getDocumentLocator());
- }
- }
- }
- } else if (inValue) {
- endValueTag();
- doneValue = true;
- }
- break;
- case 3:
- if (inName && inValue && "".equals(pURI) && TypeSerializerImpl.VALUE_TAG.equals(pLocalName)) {
- endValueTag();
- } else {
- super.endElement(pURI, pLocalName, pQName);
- }
- break;
- default:
- super.endElement(pURI, pLocalName, pQName);
- }
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/NullParser.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/NullParser.java
deleted file mode 100644
index 3867e82..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/NullParser.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.parser;
-
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * SAX parser for a nil element (null value).
- */
-public class NullParser extends AtomicParser {
- protected void setResult(String pResult) throws SAXException {
- if (pResult == null || "".equals(pResult.trim())) {
- super.setResult((Object) null);
- } else {
- throw new SAXParseException("Unexpected characters in nil element.",
- getDocumentLocator());
- }
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/ObjectArrayParser.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/ObjectArrayParser.java
deleted file mode 100644
index 761a7f0..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/ObjectArrayParser.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.parser;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.xbib.netty.http.xmlrpc.common.TypeFactory;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamConfig;
-import org.xbib.netty.http.xmlrpc.common.serializer.ObjectArraySerializer;
-import org.xbib.netty.http.xmlrpc.common.serializer.TypeSerializerImpl;
-import org.xbib.netty.http.xmlrpc.common.util.NamespaceContextImpl;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * Parser for an array of objects, as created by
- * {@link ObjectArraySerializer}.
- */
-public class ObjectArrayParser extends RecursiveTypeParserImpl {
-
- private int level = 0;
-
- private List list;
-
- /** Creates a new instance.
- * @param pContext The namespace context.
- * @param pConfig The request or response configuration.
- * @param pFactory The type factory.
- */
- public ObjectArrayParser(XmlRpcStreamConfig pConfig,
- NamespaceContextImpl pContext,
- TypeFactory pFactory) {
- super(pConfig, pContext, pFactory);
- }
-
- public void startDocument() throws SAXException {
- level = 0;
- list = new ArrayList<>();
- super.startDocument();
- }
-
- protected void addResult(Object pValue) {
- list.add(pValue);
- }
-
- public void endElement(String pURI, String pLocalName, String pQName) throws SAXException {
- switch (--level) {
- case 0:
- setResult(list.toArray());
- break;
- case 1:
- break;
- case 2:
- endValueTag();
- break;
- default:
- super.endElement(pURI, pLocalName, pQName);
- }
- }
-
- public void startElement(String pURI, String pLocalName, String pQName, Attributes pAttrs) throws SAXException {
- switch (level++) {
- case 0:
- if (!"".equals(pURI) || !ObjectArraySerializer.ARRAY_TAG.equals(pLocalName)) {
- throw new SAXParseException("Expected array element, got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- break;
- case 1:
- if (!"".equals(pURI) || !ObjectArraySerializer.DATA_TAG.equals(pLocalName)) {
- throw new SAXParseException("Expected data element, got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- break;
- case 2:
- if (!"".equals(pURI) || !TypeSerializerImpl.VALUE_TAG.equals(pLocalName)) {
- throw new SAXParseException("Expected data element, got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- startValueTag();
- break;
- default:
- super.startElement(pURI, pLocalName, pQName, pAttrs);
- break;
- }
- }
-
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/RecursiveTypeParserImpl.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/RecursiveTypeParserImpl.java
deleted file mode 100644
index 441d12a..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/RecursiveTypeParserImpl.java
+++ /dev/null
@@ -1,177 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.parser;
-
-import javax.xml.namespace.QName;
-
-import org.xbib.netty.http.xmlrpc.common.TypeFactory;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcExtensionException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamConfig;
-import org.xbib.netty.http.xmlrpc.common.serializer.XmlRpcWriter;
-import org.xbib.netty.http.xmlrpc.common.util.NamespaceContextImpl;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * Abstract base class of a parser, that invokes other type
- * parsers recursively.
- */
-public abstract class RecursiveTypeParserImpl extends TypeParserImpl {
- private final NamespaceContextImpl context;
- protected final XmlRpcStreamConfig cfg;
- private final TypeFactory factory;
- private boolean inValueTag;
- private TypeParser typeParser;
- private StringBuffer text = new StringBuffer();
-
- /** Creates a new instance.
- * @param pContext The namespace context.
- * @param pConfig The request or response configuration.
- * @param pFactory The type factory.
- */
- protected RecursiveTypeParserImpl(XmlRpcStreamConfig pConfig,
- NamespaceContextImpl pContext,
- TypeFactory pFactory) {
- cfg = pConfig;
- context = pContext;
- factory = pFactory;
- }
-
- /**
- * Called to start a value tag.
- * @throws SAXException if parse fails
- */
- protected void startValueTag() throws SAXException {
- inValueTag = true;
- text.setLength(0);
- typeParser = null;
- }
-
- protected abstract void addResult(Object pResult) throws SAXException;
-
- protected void endValueTag() throws SAXException {
- if (inValueTag) {
- if (typeParser == null) {
- addResult(text.toString());
- text.setLength(0);
- } else {
- typeParser.endDocument();
- try {
- addResult(typeParser.getResult());
- } catch (XmlRpcException e) {
- throw new SAXException(e);
- }
- typeParser = null;
- }
- } else {
- throw new SAXParseException("Invalid state: Not inside value tag.",
- getDocumentLocator());
- }
- }
-
- public void startDocument() throws SAXException {
- inValueTag = false;
- text.setLength(0);
- typeParser = null;
- }
-
- public void endElement(String pURI, String pLocalName, String pQName)
- throws SAXException {
- if (inValueTag) {
- if (typeParser == null) {
- throw new SAXParseException("Invalid state: No type parser configured.",
- getDocumentLocator());
- } else {
- typeParser.endElement(pURI, pLocalName, pQName);
- }
- } else {
- throw new SAXParseException("Invalid state: Not inside value tag.",
- getDocumentLocator());
- }
- }
-
- public void startElement(String pURI, String pLocalName,
- String pQName, Attributes pAttrs) throws SAXException {
- if (inValueTag) {
- if (typeParser == null) {
- typeParser = factory.getParser(cfg, context, pURI, pLocalName);
- if (typeParser == null) {
- if (XmlRpcWriter.EXTENSIONS_URI.equals(pURI) && !cfg.isEnabledForExtensions()) {
- String msg = "The tag " + new QName(pURI, pLocalName) + " is invalid, if isEnabledForExtensions() == false.";
- throw new SAXParseException(msg, getDocumentLocator(),
- new XmlRpcExtensionException(msg));
- } else {
- throw new SAXParseException("Unknown type: " + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- }
- typeParser.setDocumentLocator(getDocumentLocator());
- typeParser.startDocument();
- if (text.length() > 0) {
- typeParser.characters(text.toString().toCharArray(), 0, text.length());
- text.setLength(0);
- }
- }
- typeParser.startElement(pURI, pLocalName, pQName, pAttrs);
- } else {
- throw new SAXParseException("Invalid state: Not inside value tag.",
- getDocumentLocator());
- }
- }
-
- public void characters(char[] pChars, int pOffset, int pLength) throws SAXException {
- if (typeParser == null) {
- if (inValueTag) {
- text.append(pChars, pOffset, pLength);
- } else {
- super.characters(pChars, pOffset, pLength);
- }
- } else {
- typeParser.characters(pChars, pOffset, pLength);
- }
- }
-
- public void ignorableWhitespace(char[] pChars, int pOffset, int pLength) throws SAXException {
- if (typeParser == null) {
- if (inValueTag) {
- text.append(pChars, pOffset, pLength);
- } else {
- super.ignorableWhitespace(pChars, pOffset, pLength);
- }
- } else {
- typeParser.ignorableWhitespace(pChars, pOffset, pLength);
- }
- }
-
- public void processingInstruction(String pTarget, String pData) throws SAXException {
- if (typeParser == null) {
- super.processingInstruction(pTarget, pData);
- } else {
- typeParser.processingInstruction(pTarget, pData);
- }
- }
-
- public void skippedEntity(String pEntity) throws SAXException {
- if (typeParser == null) {
- super.skippedEntity(pEntity);
- } else {
- typeParser.skippedEntity(pEntity);
- }
- }
-
- public void startPrefixMapping(String pPrefix, String pURI) throws SAXException {
- if (typeParser == null) {
- super.startPrefixMapping(pPrefix, pURI);
- } else {
- context.startPrefixMapping(pPrefix, pURI);
- }
- }
-
- public void endPrefixMapping(String pPrefix) throws SAXException {
- if (typeParser == null) {
- super.endPrefixMapping(pPrefix);
- } else {
- context.endPrefixMapping(pPrefix);
- }
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/StringParser.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/StringParser.java
deleted file mode 100644
index fed8077..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/StringParser.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.parser;
-
-import org.xml.sax.SAXException;
-
-/**
- * Parser implementation for parsing a string.
- */
-public class StringParser extends AtomicParser {
-
- @Override
- protected void setResult(String pResult) throws SAXException {
- super.setResult((Object) pResult);
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/TypeParser.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/TypeParser.java
deleted file mode 100644
index 1deae07..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/TypeParser.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.parser;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xml.sax.ContentHandler;
-
-/**
- * Interface of a SAX handler parsing a single parameter or
- * result object.
- */
-public interface TypeParser extends ContentHandler {
-
- /**
- * Returns the parsed object.
- * @return The parameter or result object.
- * @throws XmlRpcException Creating the result object failed.
- * @throws IllegalStateException The method was invoked before
- * {@link ContentHandler#endDocument}.
- */
- Object getResult() throws XmlRpcException;
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/TypeParserImpl.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/TypeParserImpl.java
deleted file mode 100644
index 7c18e49..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/TypeParserImpl.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.parser;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * Abstract base implementation of a {@link TypeParser},
- * for derivation of subclasses.
- */
-public abstract class TypeParserImpl implements TypeParser {
- private Object result;
- private Locator locator;
-
- /** Sets the result object.
- * @param pResult The result object.
- */
- public void setResult(Object pResult) { result = pResult; }
-
- @Override
- public Object getResult() throws XmlRpcException { return result; }
-
- /** Returns the document locator.
- * @return Locator object describing the current location within the
- * document.
- */
- public Locator getDocumentLocator() { return locator; }
- public void setDocumentLocator(Locator pLocator) { locator = pLocator; }
-
- /** PI's are by default ignored.
- */
- public void processingInstruction(String pTarget, String pData) throws SAXException {
- }
-
- /** Skipped entities raise an exception by default.
- */
- public void skippedEntity(String pName) throws SAXException {
- throw new SAXParseException("Don't know how to handle entity " + pName,
- getDocumentLocator());
- }
-
- public void startPrefixMapping(String pPrefix, String pURI) throws SAXException {
- }
-
- public void endPrefixMapping(String pPrefix) throws SAXException {
- }
-
- public void endDocument() throws SAXException {
- }
-
- public void startDocument() throws SAXException {
- }
-
- protected static boolean isEmpty(char[] pChars, int pStart, int pLength) {
- for (int i = 0; i < pLength; i++) {
- if (!Character.isWhitespace(pChars[pStart+i])) {
- return false;
- }
- }
- return true;
- }
-
- public void characters(char[] pChars, int pOffset, int pLength) throws SAXException {
- if (!isEmpty(pChars, pOffset, pLength)) {
- throw new SAXParseException("Unexpected non-whitespace character data",
- getDocumentLocator());
- }
- }
-
- public void ignorableWhitespace(char[] pChars, int pOffset, int pLength) throws SAXException {
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/XmlRpcRequestParser.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/XmlRpcRequestParser.java
deleted file mode 100644
index 6acf063..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/XmlRpcRequestParser.java
+++ /dev/null
@@ -1,167 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.parser;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import org.xbib.netty.http.xmlrpc.common.TypeFactory;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamConfig;
-import org.xbib.netty.http.xmlrpc.common.util.NamespaceContextImpl;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * A SAX parser for an client request.
- */
-public class XmlRpcRequestParser extends RecursiveTypeParserImpl {
-
- private int level;
-
- private boolean inMethodName;
-
- private String methodName;
-
- private List params;
-
- /** Creates a new instance, which parses a clients request.
- * @param pConfig The client configuration.
- * @param pTypeFactory The type factory.
- */
- public XmlRpcRequestParser(XmlRpcStreamConfig pConfig, TypeFactory pTypeFactory) {
- super(pConfig, new NamespaceContextImpl(), pTypeFactory);
- }
-
- protected void addResult(Object pResult) {
- params.add(pResult);
- }
-
- public void startDocument() throws SAXException {
- super.startDocument();
- level = 0;
- inMethodName = false;
- methodName = null;
- params = null;
- }
-
-
- public void characters(char[] pChars, int pOffset, int pLength) throws SAXException {
- if (inMethodName) {
- String s = new String(pChars, pOffset, pLength);
- methodName = methodName == null ? s : methodName + s;
- } else {
- super.characters(pChars, pOffset, pLength);
- }
- }
-
- public void startElement(String pURI, String pLocalName, String pQName,
- Attributes pAttrs) throws SAXException {
- switch (level++) {
- case 0:
- if (!"".equals(pURI) || !"methodCall".equals(pLocalName)) {
- throw new SAXParseException("Expected root element 'methodCall', got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- break;
- case 1:
- if (methodName == null) {
- if ("".equals(pURI) && "methodName".equals(pLocalName)) {
- inMethodName = true;
- } else {
- throw new SAXParseException("Expected methodName element, got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- } else if (params == null) {
- if ("".equals(pURI) && "params".equals(pLocalName)) {
- params = new ArrayList<>();
- } else {
- throw new SAXParseException("Expected params element, got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- } else {
- throw new SAXParseException("Expected /methodCall, got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- break;
- case 2:
- if (!"".equals(pURI) || !"param".equals(pLocalName)) {
- throw new SAXParseException("Expected param element, got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- break;
- case 3:
- if (!"".equals(pURI) || !"value".equals(pLocalName)) {
- throw new SAXParseException("Expected value element, got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- startValueTag();
- break;
- default:
- super.startElement(pURI, pLocalName, pQName, pAttrs);
- break;
- }
- }
-
- public void endElement(String pURI, String pLocalName, String pQName) throws SAXException {
- switch(--level) {
- case 0:
- break;
- case 1:
- if (inMethodName) {
- if ("".equals(pURI) && "methodName".equals(pLocalName)) {
- if (methodName == null) {
- methodName = "";
- }
- } else {
- throw new SAXParseException("Expected /methodName, got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- inMethodName = false;
- } else if (!"".equals(pURI) || !"params".equals(pLocalName)) {
- throw new SAXParseException("Expected /params, got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- break;
- case 2:
- if (!"".equals(pURI) || !"param".equals(pLocalName)) {
- throw new SAXParseException("Expected /param, got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- break;
- case 3:
- if (!"".equals(pURI) || !"value".equals(pLocalName)) {
- throw new SAXParseException("Expected /value, got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- endValueTag();
- break;
- default:
- super.endElement(pURI, pLocalName, pQName);
- break;
- }
- }
-
- /**
- * Returns the method name being invoked.
- * @return Requested method name.
- */
-
- public String getMethodName() { return methodName; }
-
- /**
- * Returns the parameter list.
- * @return Parameter list.
- */
- public List getParams() { return params; }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/XmlRpcResponseParser.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/XmlRpcResponseParser.java
deleted file mode 100644
index ff1fbf8..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/parser/XmlRpcResponseParser.java
+++ /dev/null
@@ -1,224 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.parser;
-
-import java.io.ByteArrayInputStream;
-import java.io.ObjectInputStream;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-
-import org.xbib.netty.http.xmlrpc.common.TypeFactory;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamRequestConfig;
-import org.xbib.netty.http.xmlrpc.common.util.NamespaceContextImpl;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * A SAX parser for an server response.
- */
-public class XmlRpcResponseParser extends RecursiveTypeParserImpl {
-
- private int level;
-
- private boolean isSuccess;
-
- private int errorCode;
-
- private String errorMessage;
-
- private Throwable errorCause;
-
- /** Creates a new instance.
- * @param pConfig The response configuration.
- * @param pTypeFactory The type factory for creating instances of
- * {@link TypeParser}.
- */
- public XmlRpcResponseParser(XmlRpcStreamRequestConfig pConfig,
- TypeFactory pTypeFactory) {
- super(pConfig, new NamespaceContextImpl(), pTypeFactory);
- }
-
- @SuppressWarnings("unchecked")
- protected void addResult(Object pResult) throws SAXException {
- if (isSuccess) {
- super.setResult(pResult);
- } else {
- Map map = (Map) pResult;
- Integer faultCode = (Integer) map.get("faultCode");
- if (faultCode == null) {
- throw new SAXParseException("Missing faultCode", getDocumentLocator());
- }
- try {
- errorCode = faultCode;
- } catch (NumberFormatException e) {
- throw new SAXParseException("Invalid faultCode: " + faultCode,
- getDocumentLocator());
- }
- errorMessage = (String) map.get("faultString");
- Object exception = map.get("faultCause");
- if (exception != null) {
- try {
- byte[] bytes = (byte[]) exception;
- ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
- ObjectInputStream ois = new ObjectInputStream(bais);
- errorCause = (Throwable) ois.readObject();
- ois.close();
- bais.close();
- } catch (Throwable t) {
- // Ignore me
- }
- }
- }
- }
-
- public void startDocument() throws SAXException {
- super.startDocument();
- level = 0;
- isSuccess = false;
- errorCode = 0;
- errorMessage = null;
- }
-
- public void startElement(String pURI, String pLocalName, String pQName,
- Attributes pAttrs) throws SAXException {
- switch (level++) {
- case 0:
- if (!"".equals(pURI) || !"methodResponse".equals(pLocalName)) {
- throw new SAXParseException("Expected methodResponse element, got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- break;
- case 1:
- if ("".equals(pURI) && "params".equals(pLocalName)) {
- isSuccess = true;
- } else if ("".equals(pURI) && "fault".equals(pLocalName)) {
- isSuccess = false;
- } else {
- throw new SAXParseException("Expected params or fault element, got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- break;
- case 2:
- if (isSuccess) {
- if (!"".equals(pURI) || !"param".equals(pLocalName)) {
- throw new SAXParseException("Expected param element, got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- } else {
- if ("".equals(pURI) && "value".equals(pLocalName)) {
- startValueTag();
- } else {
- throw new SAXParseException("Expected value element, got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- }
- break;
- case 3:
- if (isSuccess) {
- if ("".equals(pURI) && "value".equals(pLocalName)) {
- startValueTag();
- } else {
- throw new SAXParseException("Expected value element, got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- } else {
- super.startElement(pURI, pLocalName, pQName, pAttrs);
- }
- break;
- default:
- super.startElement(pURI, pLocalName, pQName, pAttrs);
- break;
- }
- }
-
- public void endElement(String pURI, String pLocalName, String pQName) throws SAXException {
- switch (--level) {
- case 0:
- if (!"".equals(pURI) || !"methodResponse".equals(pLocalName)) {
- throw new SAXParseException("Expected /methodResponse element, got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- break;
- case 1:
- {
- String tag;
- if (isSuccess) {
- tag = "params";
- } else {
- tag = "fault";
- }
- if (!"".equals(pURI) || !tag.equals(pLocalName)) {
- throw new SAXParseException("Expected /" + tag + " element, got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- break;
- }
- case 2:
- if (isSuccess) {
- if (!"".equals(pURI) || !"param".equals(pLocalName)) {
- throw new SAXParseException("Expected /param, got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- } else {
- if ("".equals(pURI) && "value".equals(pLocalName)) {
- endValueTag();
- } else {
- throw new SAXParseException("Expected /value, got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- }
- break;
- case 3:
- if (isSuccess) {
- if ("".equals(pURI) && "value".equals(pLocalName)) {
- endValueTag();
- } else {
- throw new SAXParseException("Expected /value, got "
- + new QName(pURI, pLocalName),
- getDocumentLocator());
- }
- } else {
- super.endElement(pURI, pLocalName, pQName);
- }
- break;
- default:
- super.endElement(pURI, pLocalName, pQName);
- break;
- }
- }
-
- /** Returns whether the response returned success. If so, the
- * result object may be fetched using {@link #getResult()}.
- * Otherwise, you may use the methods
- * {@link #getErrorCode()} and {@link #getErrorMessage()} to
- * check for error reasons.
- * @return True, if the response indicated success, false otherwise.
- */
- public boolean isSuccess() { return isSuccess; }
-
- /** If the response contained a fault, returns the error code.
- * @return The numeric error code.
- */
- public int getErrorCode() { return errorCode; }
-
- /** If the response contained a fault, returns the error message.
- * @return The error message.
- */
- public String getErrorMessage() { return errorMessage; }
-
- /**
- * If the response contained a fault, returns the (optional)
- * exception.
- * @return fault
- */
- public Throwable getErrorCause() { return errorCause; }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/BaseXmlWriterFactory.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/BaseXmlWriterFactory.java
deleted file mode 100644
index 7f1784a..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/BaseXmlWriterFactory.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.serializer;
-
-import java.io.BufferedWriter;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamConfig;
-import org.xbib.netty.http.xmlrpc.common.util.XMLWriter;
-import org.xbib.netty.http.xmlrpc.common.util.XMLWriterImpl;
-import org.xml.sax.ContentHandler;
-
-/**
- * The default instance of {@link XmlWriterFactory} creates
- * instances of {@link XMLWriterImpl}.
- */
-public class BaseXmlWriterFactory implements XmlWriterFactory {
-
- protected XMLWriter newXmlWriter() {
- return new XMLWriterImpl();
- }
-
- @Override
- public ContentHandler getXmlWriter(XmlRpcStreamConfig pConfig, OutputStream pStream)
- throws XmlRpcException {
- XMLWriter xw = newXmlWriter();
- xw.setDeclarating(true);
- String enc = pConfig.getEncoding();
- if (enc == null) {
- enc = XmlRpcStreamConfig.UTF8_ENCODING;
- }
- xw.setEncoding(enc);
- xw.setIndenting(false);
- xw.setFlushing(true);
- try {
- xw.setWriter(new BufferedWriter(new OutputStreamWriter(pStream, enc)));
- } catch (UnsupportedEncodingException e) {
- throw new XmlRpcException("Unsupported encoding: " + enc, e);
- }
- return xw;
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/BigDecimalSerializer.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/BigDecimalSerializer.java
deleted file mode 100644
index 18ca1bd..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/BigDecimalSerializer.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.serializer;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * A {@link TypeSerializer} for BigDecimal.
- */
-public class BigDecimalSerializer extends TypeSerializerImpl {
- /**
- * Tag name of a BigDecimal value.
- */
- public static final String BIGDECIMAL_TAG = "bigdecimal";
-
- private static final String EX_BIGDECIMAL_TAG = "ex:" + BIGDECIMAL_TAG;
-
- @Override
- public void write(ContentHandler pHandler, Object pObject) throws SAXException {
- write(pHandler, BIGDECIMAL_TAG, EX_BIGDECIMAL_TAG, pObject.toString());
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/BigIntegerSerializer.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/BigIntegerSerializer.java
deleted file mode 100644
index a6d932e..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/BigIntegerSerializer.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.serializer;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * A {@link TypeSerializer} for BigInteger.
- */
-public class BigIntegerSerializer extends TypeSerializerImpl {
- /** Tag name of a BigDecimal value.
- */
- public static final String BIGINTEGER_TAG = "biginteger";
-
- private static final String EX_BIGINTEGER_TAG = "ex:" + BIGINTEGER_TAG;
-
- @Override
- public void write(ContentHandler pHandler, Object pObject) throws SAXException {
- write(pHandler, BIGINTEGER_TAG, EX_BIGINTEGER_TAG, pObject.toString());
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/BooleanSerializer.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/BooleanSerializer.java
deleted file mode 100644
index 1bee887..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/BooleanSerializer.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.serializer;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * A {@link TypeSerializer} for booleans.
- */
-public class BooleanSerializer extends TypeSerializerImpl {
-
- /**
- * Tag name of a boolean value.
- */
- public static final String BOOLEAN_TAG = "boolean";
-
- private static final char[] TRUE = new char[]{'1'};
-
- private static final char[] FALSE = new char[]{'0'};
-
- @Override
- public void write(ContentHandler pHandler, Object pObject) throws SAXException {
- write(pHandler, BOOLEAN_TAG, (Boolean) pObject ? TRUE : FALSE);
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/ByteArraySerializer.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/ByteArraySerializer.java
deleted file mode 100644
index f0b0152..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/ByteArraySerializer.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.serializer;
-
-import java.util.Base64;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * A {@link TypeSerializer} for byte arrays.
- */
-public class ByteArraySerializer extends TypeSerializerImpl {
-
- /**
- * Tag name of a base64 value.
- */
- public static final String BASE_64_TAG = "base64";
-
- @Override
- public void write(final ContentHandler pHandler, Object pObject) throws SAXException {
- pHandler.startElement("", VALUE_TAG, VALUE_TAG, ZERO_ATTRIBUTES);
- pHandler.startElement("", BASE_64_TAG, BASE_64_TAG, ZERO_ATTRIBUTES);
- byte[] buffer = (byte[]) pObject;
- if (buffer.length > 0) {
- String encoded = Base64.getEncoder().encodeToString(buffer);
- char[] charBuffer = encoded.toCharArray();
- pHandler.characters(charBuffer, 0, charBuffer.length);
- }
- pHandler.endElement("", BASE_64_TAG, BASE_64_TAG);
- pHandler.endElement("", VALUE_TAG, VALUE_TAG);
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/CalendarSerializer.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/CalendarSerializer.java
deleted file mode 100644
index 2125fdc..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/CalendarSerializer.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.serializer;
-
-import org.xbib.netty.http.xmlrpc.common.util.XsDateTimeFormat;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * A {@link TypeSerializer} for date values.
- */
-public class CalendarSerializer extends TypeSerializerImpl {
-
- private static final XsDateTimeFormat format = new XsDateTimeFormat();
-
- /** Tag name of a BigDecimal value.
- */
- public static final String CALENDAR_TAG = "dateTime";
-
- private static final String EX_CALENDAR_TAG = "ex:" + CALENDAR_TAG;
-
- /** Tag name of a date value.
- */
- public static final String DATE_TAG = "dateTime.iso8601";
-
- @Override
- public void write(ContentHandler pHandler, Object pObject) throws SAXException {
- write(pHandler, CALENDAR_TAG, EX_CALENDAR_TAG, format.format(pObject));
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/CharSetXmlWriterFactory.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/CharSetXmlWriterFactory.java
deleted file mode 100644
index c6c8b54..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/CharSetXmlWriterFactory.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.serializer;
-
-import org.xbib.netty.http.xmlrpc.common.util.CharSetXMLWriter;
-import org.xbib.netty.http.xmlrpc.common.util.XMLWriter;
-
-/**
- * An implementation of {@link XmlWriterFactory},
- * which creates instances of {@link CharSetXMLWriter}.
- */
-public class CharSetXmlWriterFactory extends BaseXmlWriterFactory {
-
- @Override
- protected XMLWriter newXmlWriter() {
- return new CharSetXMLWriter();
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/DateSerializer.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/DateSerializer.java
deleted file mode 100644
index 4db9f19..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/DateSerializer.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.serializer;
-
-import java.text.Format;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * A {@link TypeSerializer} for date values.
- */
-public class DateSerializer extends TypeSerializerImpl {
-
- /** Tag name of a date value.
- */
- public static final String DATE_TAG = "dateTime.iso8601";
-
- private final Format format;
-
- /**
- * Creates a new instance with the given formatter.
- * @param pFormat format
- */
- public DateSerializer(Format pFormat) {
- format = pFormat;
- }
-
- @Override
- public void write(ContentHandler pHandler, Object pObject) throws SAXException {
- write(pHandler, DATE_TAG, format.format(pObject));
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/DefaultXMLWriterFactory.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/DefaultXMLWriterFactory.java
deleted file mode 100644
index 0419e20..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/DefaultXMLWriterFactory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.serializer;
-
-import java.io.OutputStream;
-import java.io.StringWriter;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamConfig;
-import org.xbib.netty.http.xmlrpc.common.util.CharSetXMLWriter;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.helpers.AttributesImpl;
-
-/**
- * The default implementation of {@link XmlWriterFactory}
- * tests, whether the {@link CharSetXmlWriterFactory}
- * is usable.
- */
-public class DefaultXMLWriterFactory implements XmlWriterFactory {
- private final XmlWriterFactory factory;
-
- /**
- * Creates a new instance.
- */
- public DefaultXMLWriterFactory() {
- XmlWriterFactory xwf;
- try {
- CharSetXMLWriter csw = new CharSetXMLWriter();
- StringWriter sw = new StringWriter();
- csw.setWriter(sw);
- csw.startDocument();
- csw.startElement("", "test", "test", new AttributesImpl());
- csw.endElement("", "test", "test");
- csw.endDocument();
- xwf = new CharSetXmlWriterFactory();
- } catch (Throwable t) {
- xwf = new BaseXmlWriterFactory();
- }
- factory = xwf;
- }
-
- public ContentHandler getXmlWriter(XmlRpcStreamConfig pConfig,
- OutputStream pStream) throws XmlRpcException {
- return factory.getXmlWriter(pConfig, pStream);
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/DoubleSerializer.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/DoubleSerializer.java
deleted file mode 100644
index 1ab1f79..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/DoubleSerializer.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.serializer;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * A {@link TypeSerializer} for doubles.
- */
-public class DoubleSerializer extends TypeSerializerImpl {
-
- /**
- * Tag name of a double value.
- */
- public static final String DOUBLE_TAG = "double";
-
- @Override
- public void write(ContentHandler pHandler, Object pObject) throws SAXException {
- write(pHandler, DOUBLE_TAG, pObject.toString());
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/FloatSerializer.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/FloatSerializer.java
deleted file mode 100644
index 131a0e0..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/FloatSerializer.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.serializer;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * A {@link TypeSerializer} for floats.
- */
-public class FloatSerializer extends TypeSerializerImpl {
- /** Tag name of a float value.
- */
- public static final String FLOAT_TAG = "float";
-
- /** Fully qualified name of a float value.
- */
- public static final String EX_FLOAT_TAG = "ex:float";
-
- @Override
- public void write(ContentHandler pHandler, Object pObject) throws SAXException {
- write(pHandler, FLOAT_TAG, EX_FLOAT_TAG, pObject.toString());
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/I1Serializer.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/I1Serializer.java
deleted file mode 100644
index f405cf2..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/I1Serializer.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.serializer;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * A {@link TypeSerializer} for bytes.
- */
-public class I1Serializer extends TypeSerializerImpl {
-
- /**
- * Tag name of an i1 value.
- */
- public static final String I1_TAG = "i1";
-
- /**
- * Fully qualified name of an i1 value.
- */
- public static final String EX_I1_TAG = "ex:i1";
-
- @Override
- public void write(ContentHandler pHandler, Object pObject) throws SAXException {
- write(pHandler, I1_TAG, EX_I1_TAG, pObject.toString());
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/I2Serializer.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/I2Serializer.java
deleted file mode 100644
index 97efd9b..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/I2Serializer.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.serializer;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * A {@link TypeSerializer} for shorts.
- */
-public class I2Serializer extends TypeSerializerImpl {
-
- /**
- * Tag name of an i2 value.
- */
- public static final String I2_TAG = "i2";
-
- /**
- * Fully qualified name of an i2 value.
- */
- public static final String EX_I2_TAG = "ex:i2";
-
- @Override
- public void write(ContentHandler pHandler, Object pObject) throws SAXException {
- write(pHandler, I2_TAG, EX_I2_TAG, pObject.toString());
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/I4Serializer.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/I4Serializer.java
deleted file mode 100644
index 77d15ba..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/I4Serializer.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.serializer;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * A {@link TypeSerializer} for integers.
- */
-public class I4Serializer extends TypeSerializerImpl {
-
- /**
- * Tag name of an int value.
- */
- public static final String INT_TAG = "int";
-
- /**
- * Tag name of an i4 value.
- */
- public static final String I4_TAG = "i4";
-
- @Override
- public void write(ContentHandler pHandler, Object pObject) throws SAXException {
- write(pHandler, I4_TAG, pObject.toString());
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/I8Serializer.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/I8Serializer.java
deleted file mode 100644
index e942a1e..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/I8Serializer.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.serializer;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * A {@link TypeSerializer} for longs.
- */
-public class I8Serializer extends TypeSerializerImpl {
-
- /**
- * Tag name of an i8 value.
- */
- public static final String I8_TAG = "i8";
-
- /**
- * Fully qualified name of an i8 value.
- */
- public static final String EX_I8_TAG = "ex:i8";
-
- @Override
- public void write(ContentHandler pHandler, Object pObject) throws SAXException {
- write(pHandler, I8_TAG, EX_I8_TAG, pObject.toString());
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/ListSerializer.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/ListSerializer.java
deleted file mode 100644
index 8707c25..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/ListSerializer.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.serializer;
-
-import java.util.List;
-
-import org.xbib.netty.http.xmlrpc.common.TypeFactory;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamConfig;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * A {@link TypeSerializer} for lists.
- */
-public class ListSerializer extends ObjectArraySerializer {
-
- /** Creates a new instance.
- * @param pTypeFactory The factory being used for creating serializers.
- * @param pConfig The configuration being used for creating serializers.
- */
- public ListSerializer(TypeFactory pTypeFactory, XmlRpcStreamConfig pConfig) {
- super(pTypeFactory, pConfig);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected void writeData(ContentHandler pHandler, Object pObject) throws SAXException {
- List data = (List) pObject;
- for (Object datum : data) {
- writeObject(pHandler, datum);
- }
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/MapSerializer.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/MapSerializer.java
deleted file mode 100644
index 15f0fe9..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/MapSerializer.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.serializer;
-
-import java.util.Map;
-
-import org.xbib.netty.http.xmlrpc.common.TypeFactory;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamConfig;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * A {@link TypeSerializer} for maps.
- */
-public class MapSerializer extends TypeSerializerImpl {
- /** Tag name of a maps struct tag.
- */
- public static final String STRUCT_TAG = "struct";
-
- /** Tag name of a maps member tag.
- */
- public static final String MEMBER_TAG = "member";
-
- /** Tag name of a maps members name tag.
- */
- public static final String NAME_TAG = "name";
-
- private final XmlRpcStreamConfig config;
- private final TypeFactory typeFactory;
-
- /** Creates a new instance.
- * @param pTypeFactory The factory being used for creating serializers.
- * @param pConfig The configuration being used for creating serializers.
- */
- public MapSerializer(TypeFactory pTypeFactory, XmlRpcStreamConfig pConfig) {
- typeFactory = pTypeFactory;
- config = pConfig;
- }
-
- protected void writeEntry(ContentHandler pHandler, Object pKey, Object pValue) throws SAXException {
- pHandler.startElement("", MEMBER_TAG, MEMBER_TAG, ZERO_ATTRIBUTES);
- pHandler.startElement("", NAME_TAG, NAME_TAG, ZERO_ATTRIBUTES);
- if (config.isEnabledForExtensions() && !(pKey instanceof String)) {
- writeValue(pHandler, pKey);
- } else {
- String key = pKey.toString();
- pHandler.characters(key.toCharArray(), 0, key.length());
- }
- pHandler.endElement("", NAME_TAG, NAME_TAG);
- writeValue(pHandler, pValue);
- pHandler.endElement("", MEMBER_TAG, MEMBER_TAG);
- }
-
- private void writeValue(ContentHandler pHandler, Object pValue)
- throws SAXException {
- TypeSerializer ts = typeFactory.getSerializer(config, pValue);
- if (ts == null) {
- throw new SAXException("Unsupported Java type: " + pValue.getClass().getName());
- }
- ts.write(pHandler, pValue);
- }
-
- @SuppressWarnings("unchecked")
- protected void writeData(ContentHandler pHandler, Object pData) throws SAXException {
- Map map = (Map) pData;
- for (Object o : map.entrySet()) {
- Map.Entry entry = (Map.Entry) o;
- writeEntry(pHandler, entry.getKey(), entry.getValue());
- }
- }
-
- public void write(final ContentHandler pHandler, Object pObject) throws SAXException {
- pHandler.startElement("", VALUE_TAG, VALUE_TAG, ZERO_ATTRIBUTES);
- pHandler.startElement("", STRUCT_TAG, STRUCT_TAG, ZERO_ATTRIBUTES);
- writeData(pHandler, pObject);
- pHandler.endElement("", STRUCT_TAG, STRUCT_TAG);
- pHandler.endElement("", VALUE_TAG, VALUE_TAG);
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/NullSerializer.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/NullSerializer.java
deleted file mode 100644
index 533e575..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/NullSerializer.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.xbib.netty.http.xmlrpc.common.serializer;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-
-/** A {@link TypeSerializer} for null values.
- */
-public class NullSerializer extends TypeSerializerImpl {
- /** Tag name of a nil value.
- */
- public static final String NIL_TAG = "nil";
- /** Qualified tag name of a nil value.
- */
- public static final String EX_NIL_TAG = "ex:nil";
-
- public void write(ContentHandler pHandler, Object pObject) throws SAXException {
- pHandler.startElement("", VALUE_TAG, VALUE_TAG, ZERO_ATTRIBUTES);
- pHandler.startElement(XmlRpcWriter.EXTENSIONS_URI, NIL_TAG, EX_NIL_TAG, ZERO_ATTRIBUTES);
- pHandler.endElement(XmlRpcWriter.EXTENSIONS_URI, NIL_TAG, EX_NIL_TAG);
- pHandler.endElement("", VALUE_TAG, VALUE_TAG);
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/ObjectArraySerializer.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/ObjectArraySerializer.java
deleted file mode 100644
index a05e15c..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/ObjectArraySerializer.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.serializer;
-
-import org.xbib.netty.http.xmlrpc.common.TypeFactory;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamConfig;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/** A {@link TypeSerializer} for object arrays.
- */
-public class ObjectArraySerializer extends TypeSerializerImpl {
- /** Tag name of an array value.
- */
- public static final String ARRAY_TAG = "array";
- /** Tag name of an arrays data.
- */
- public static final String DATA_TAG = "data";
-
- private final XmlRpcStreamConfig config;
- private final TypeFactory typeFactory;
-
- /** Creates a new instance.
- * @param pTypeFactory The factory being used for creating serializers.
- * @param pConfig The configuration being used for creating serializers.
- */
- public ObjectArraySerializer(TypeFactory pTypeFactory, XmlRpcStreamConfig pConfig) {
- typeFactory = pTypeFactory;
- config = pConfig;
- }
- protected void writeObject(ContentHandler pHandler, Object pObject) throws SAXException {
- TypeSerializer ts = typeFactory.getSerializer(config, pObject);
- if (ts == null) {
- throw new SAXException("Unsupported Java type: " + pObject.getClass().getName());
- }
- ts.write(pHandler, pObject);
- }
- protected void writeData(ContentHandler pHandler, Object pObject) throws SAXException {
- Object[] data = (Object[]) pObject;
- for (int i = 0; i < data.length; i++) {
- writeObject(pHandler, data[i]);
- }
- }
- public void write(final ContentHandler pHandler, Object pObject) throws SAXException {
- pHandler.startElement("", VALUE_TAG, VALUE_TAG, ZERO_ATTRIBUTES);
- pHandler.startElement("", ARRAY_TAG, ARRAY_TAG, ZERO_ATTRIBUTES);
- pHandler.startElement("", DATA_TAG, DATA_TAG, ZERO_ATTRIBUTES);
- writeData(pHandler, pObject);
- pHandler.endElement("", DATA_TAG, DATA_TAG);
- pHandler.endElement("", ARRAY_TAG, ARRAY_TAG);
- pHandler.endElement("", VALUE_TAG, VALUE_TAG);
- }
-}
\ No newline at end of file
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/StringSerializer.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/StringSerializer.java
deleted file mode 100644
index 0b1b7a1..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/StringSerializer.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.serializer;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * A {@link TypeSerializer} for strings.
- */
-public class StringSerializer extends TypeSerializerImpl {
-
- /**
- * (Optional) Tag name of a string value.
- */
- public static final String STRING_TAG = "string";
-
- @Override
- public void write(ContentHandler pHandler, Object pObject) throws SAXException {
- write(pHandler, null, pObject.toString());
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/TypeSerializer.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/TypeSerializer.java
deleted file mode 100644
index 0089d23..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/TypeSerializer.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.serializer;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * A TypeSerializer
is able to write a parameter
- * or result object to the XML RPC request or response.
- */
-public interface TypeSerializer {
-
- /** Writes the object pObject
to the SAX handler
- * pHandler
.
- * @param pHandler The destination handler.
- * @param pObject The object being written.
- * @throws SAXException Writing the object failed.
- */
- void write(ContentHandler pHandler, Object pObject) throws SAXException;
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/TypeSerializerImpl.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/TypeSerializerImpl.java
deleted file mode 100644
index 6342933..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/TypeSerializerImpl.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.serializer;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-/**
- * Abstract base implementation of a type serializer.
- */
-public abstract class TypeSerializerImpl implements TypeSerializer {
- protected static final Attributes ZERO_ATTRIBUTES = new AttributesImpl();
- /** Tag name of a value element.
- */
- public static final String VALUE_TAG = "value";
-
- protected void write(ContentHandler pHandler, String pTagName, String pValue) throws SAXException {
- write(pHandler, pTagName, pValue.toCharArray());
- }
-
- protected void write(ContentHandler pHandler, String pTagName, char[] pValue) throws SAXException {
- pHandler.startElement("", TypeSerializerImpl.VALUE_TAG, TypeSerializerImpl.VALUE_TAG, ZERO_ATTRIBUTES);
- if (pTagName != null) {
- pHandler.startElement("", pTagName, pTagName, ZERO_ATTRIBUTES);
- }
- pHandler.characters(pValue, 0, pValue.length);
- if (pTagName != null) {
- pHandler.endElement("", pTagName, pTagName);
- }
- pHandler.endElement("", TypeSerializerImpl.VALUE_TAG, TypeSerializerImpl.VALUE_TAG);
- }
-
- protected void write(ContentHandler pHandler, String pLocalName, String pQName,
- String pValue) throws SAXException {
- pHandler.startElement("", TypeSerializerImpl.VALUE_TAG, TypeSerializerImpl.VALUE_TAG, ZERO_ATTRIBUTES);
- pHandler.startElement(XmlRpcWriter.EXTENSIONS_URI, pLocalName, pQName, ZERO_ATTRIBUTES);
- char[] value = pValue.toCharArray();
- pHandler.characters(value, 0, value.length);
- pHandler.endElement(XmlRpcWriter.EXTENSIONS_URI, pLocalName, pQName);
- pHandler.endElement("", TypeSerializerImpl.VALUE_TAG, TypeSerializerImpl.VALUE_TAG);
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/XmlRpcWriter.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/XmlRpcWriter.java
deleted file mode 100644
index 9f0b2e4..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/XmlRpcWriter.java
+++ /dev/null
@@ -1,159 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.serializer;
-
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectOutputStream;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.xbib.netty.http.xmlrpc.common.TypeFactory;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequest;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequestConfig;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamConfig;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamRequestConfig;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-/**
- * This class is responsible for writing an XmlRpc request or an
- * XmlRpc response to an output stream.
- */
-public class XmlRpcWriter {
- /** The namespace URI for proprietary XML-RPC extensions.
- */
- public static final String EXTENSIONS_URI = "http://ws.apache.org/xmlrpc/namespaces/extensions";
- private static final Attributes ZERO_ATTRIBUTES = new AttributesImpl();
- private final XmlRpcStreamConfig config;
- private final TypeFactory typeFactory;
- private final ContentHandler handler;
-
- /** Creates a new instance.
- * @param pConfig The clients configuration.
- * @param pHandler The target SAX handler.
- * @param pTypeFactory The type factory being used to create serializers.
- */
- public XmlRpcWriter(XmlRpcStreamConfig pConfig, ContentHandler pHandler,
- TypeFactory pTypeFactory) {
- config = pConfig;
- handler = pHandler;
- typeFactory = pTypeFactory;
- }
-
- /** Writes a clients request to the output stream.
- * @param pRequest The request being written.
- * @throws SAXException Writing the request failed.
- */
- public void write(XmlRpcRequest pRequest) throws SAXException {
- handler.startDocument();
- boolean extensions = pRequest.getConfig().isEnabledForExtensions();
- if (extensions) {
- handler.startPrefixMapping("ex", XmlRpcWriter.EXTENSIONS_URI);
- }
- handler.startElement("", "methodCall", "methodCall", ZERO_ATTRIBUTES);
- handler.startElement("", "methodName", "methodName", ZERO_ATTRIBUTES);
- String s = pRequest.getMethodName();
- handler.characters(s.toCharArray(), 0, s.length());
- handler.endElement("", "methodName", "methodName");
- handler.startElement("", "params", "params", ZERO_ATTRIBUTES);
- int num = pRequest.getParameterCount();
- for (int i = 0; i < num; i++) {
- handler.startElement("", "param", "param", ZERO_ATTRIBUTES);
- writeValue(pRequest.getParameter(i));
- handler.endElement("", "param", "param");
- }
- handler.endElement("", "params", "params");
- handler.endElement("", "methodCall", "methodCall");
- if (extensions) {
- handler.endPrefixMapping("ex");
- }
- handler.endDocument();
- }
-
- /** Writes a servers response to the output stream.
- * @param pConfig The request configuration.
- * @param pResult The result object.
- * @throws SAXException Writing the response failed.
- */
- public void write(XmlRpcRequestConfig pConfig, Object pResult) throws SAXException {
- handler.startDocument();
- boolean extensions = pConfig.isEnabledForExtensions();
- if (extensions) {
- handler.startPrefixMapping("ex", XmlRpcWriter.EXTENSIONS_URI);
- }
- handler.startElement("", "methodResponse", "methodResponse", ZERO_ATTRIBUTES);
- handler.startElement("", "params", "params", ZERO_ATTRIBUTES);
- handler.startElement("", "param", "param", ZERO_ATTRIBUTES);
- writeValue(pResult);
- handler.endElement("", "param", "param");
- handler.endElement("", "params", "params");
- handler.endElement("", "methodResponse", "methodResponse");
- if (extensions) {
- handler.endPrefixMapping("ex");
- }
- handler.endDocument();
- }
-
- /** Writes a servers error message to the output stream.
- * @param pConfig The request configuration.
- * @param pCode The error code
- * @param pMessage The error message
- * @throws SAXException Writing the error message failed.
- */
- public void write(XmlRpcRequestConfig pConfig, int pCode, String pMessage) throws SAXException {
- write(pConfig, pCode, pMessage, null);
- }
-
- /** Writes a servers error message to the output stream.
- * @param pConfig The request configuration.
- * @param pCode The error code
- * @param pMessage The error message
- * @param pThrowable An exception, which is being sent to the client
- * @throws SAXException Writing the error message failed.
- */
- public void write(XmlRpcRequestConfig pConfig, int pCode, String pMessage,
- Throwable pThrowable) throws SAXException {
- handler.startDocument();
- boolean extensions = pConfig.isEnabledForExtensions();
- if (extensions) {
- handler.startPrefixMapping("ex", XmlRpcWriter.EXTENSIONS_URI);
- }
- handler.startElement("", "methodResponse", "methodResponse", ZERO_ATTRIBUTES);
- handler.startElement("", "fault", "fault", ZERO_ATTRIBUTES);
- Map map = new HashMap<>();
- map.put("faultCode", pCode);
- map.put("faultString", pMessage == null ? "" : pMessage);
- if (pThrowable != null && extensions && (pConfig instanceof XmlRpcStreamRequestConfig) &&
- ((XmlRpcStreamRequestConfig) pConfig).isEnabledForExceptions()) {
- try {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(pThrowable);
- oos.close();
- baos.close();
- map.put("faultCause", baos.toByteArray());
- } catch (Throwable t) {
- // Ignore me
- }
- }
- writeValue(map);
- handler.endElement("", "fault", "fault");
- handler.endElement("", "methodResponse", "methodResponse");
- if (extensions) {
- handler.endPrefixMapping("ex");
- }
- handler.endDocument();
- }
-
- /** Writes the XML representation of a Java object.
- * @param pObject The object being written.
- * @throws SAXException Writing the object failed.
- */
- protected void writeValue(Object pObject) throws SAXException {
- TypeSerializer serializer = typeFactory.getSerializer(config, pObject);
- if (serializer == null) {
- throw new SAXException("Unsupported Java type: " + pObject.getClass().getName());
- }
- serializer.write(handler, pObject);
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/XmlWriterFactory.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/XmlWriterFactory.java
deleted file mode 100644
index 3ecb14d..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/serializer/XmlWriterFactory.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.serializer;
-
-import java.io.OutputStream;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamConfig;
-import org.xbib.netty.http.xmlrpc.common.util.XMLWriter;
-import org.xml.sax.ContentHandler;
-
-/** This factory is responsible for creating instances of
- * {@link XMLWriter}.
- */
-public interface XmlWriterFactory {
- /** Creates a new instance of {@link ContentHandler},
- * writing to the given {@link OutputStream}.
- * @return A SAX handler
- * @param pStream The destination stream.
- * @param pConfig The request or response configuration.
- * @throws XmlRpcException Creating the handler failed.
- */
- public ContentHandler getXmlWriter(XmlRpcStreamConfig pConfig,
- OutputStream pStream) throws XmlRpcException;
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/CharSetXMLWriter.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/CharSetXMLWriter.java
deleted file mode 100644
index 2af0f48..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/CharSetXMLWriter.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.util;
-
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetEncoder;
-
-import org.xml.sax.SAXException;
-
-/**
- * An improved version of {@link XMLWriterImpl},
- * using {@link Charset}.
- */
-public class CharSetXMLWriter extends XMLWriterImpl {
-
- private CharsetEncoder charsetEncoder;
-
- @Override
- public void startDocument() throws SAXException {
- Charset charSet = Charset.forName(getEncoding());
- if (charSet.canEncode()) {
- charsetEncoder = charSet.newEncoder();
- }
- }
-
- @Override
- public boolean canEncode(char c) {
- return (charsetEncoder != null) && charsetEncoder.canEncode(c);
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/HttpUtil.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/HttpUtil.java
deleted file mode 100644
index 795b570..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/HttpUtil.java
+++ /dev/null
@@ -1,173 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.util;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcHttpRequestConfigImpl;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamConfig;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.Base64;
-import java.util.Enumeration;
-import java.util.StringTokenizer;
-
-/**
- * Provides utility functions useful in HTTP communications
- */
-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 pEncoding
is invalid.
- */
- public static String encodeBasicAuthentication(String pUser, String pPassword, String pEncoding)
- throws UnsupportedEncodingException {
- if (pUser == null) {
- return null;
- }
- final String s = pUser + ':' + pPassword;
- if (pEncoding == null) {
- pEncoding = XmlRpcStreamConfig.UTF8_ENCODING;
- }
- final byte[] bytes = s.getBytes(pEncoding);
- return Base64.getEncoder().encodeToString(s.getBytes(pEncoding));
- }
-
- /**
- * Returns, whether the HTTP header value pHeaderValue
- * indicates, that GZIP encoding is used or may be used.
- * @param pHeaderValue The HTTP header value being parsed. 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;
- }
- for (StringTokenizer st = new StringTokenizer(pHeaderValue, ","); st.hasMoreTokens(); ) {
- String encoding = st.nextToken();
- int offset = encoding.indexOf(';');
- if (offset >= 0) {
- encoding = encoding.substring(0, offset);
- }
- if ("gzip".equalsIgnoreCase(encoding.trim())) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Returns, whether the HTTP header value pHeaderValue
- * indicates, that another encoding than "identity" is used.
- * This is typically the value of "Transfer-Encoding", or "TE".
- * @return Null, if the transfer encoding in use is "identity".
- * Otherwise, another transfer encoding.
- */
- public static String getNonIdentityTransferEncoding(String pHeaderValue) {
- if (pHeaderValue == null) {
- return null;
- }
- for (StringTokenizer st = new StringTokenizer(pHeaderValue, ","); st.hasMoreTokens(); ) {
- String encoding = st.nextToken();
- int offset = encoding.indexOf(';');
- if (offset >= 0) {
- encoding = encoding.substring(0, offset);
- }
- if (!"identity".equalsIgnoreCase(encoding.trim())) {
- return encoding.trim();
- }
- }
- return null;
- }
-
- /**
- * Returns, whether the HTTP header values in pValues
- * indicate, that GZIP encoding is used or may be used.
- * @param pValues The HTTP header values being parsed. These are typically
- * the values of "Content-Encoding", or "Accept-Encoding".
- * @return True, if the header values suggests that GZIP encoding is or may
- * be used.
- */
- public static boolean isUsingGzipEncoding(Enumeration pValues) {
- if (pValues != null) {
- while (pValues.hasMoreElements()) {
- if (isUsingGzipEncoding(pValues.nextElement())) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Reads a header line from the input stream pIn
- * and converts it into a string.
- * @param pIn The input stream being read.
- * @param pBuffer A buffer being used for temporary storage.
- * The buffers length is a limit of the header lines length.
- * @return Next header line or null, if no more header lines
- * are available.
- * @throws IOException Reading the header line failed.
- */
- public static String readLine(InputStream pIn, byte[] pBuffer) throws IOException {
- int next;
- int count = 0;
- while (true) {
- next = pIn.read();
- if (next < 0 || next == '\n') {
- break;
- }
- if (next != '\r') {
- pBuffer[count++] = (byte) next;
- }
- if (count >= pBuffer.length) {
- throw new IOException ("HTTP Header too long");
- }
- }
- return new String(pBuffer, 0, count, "US-ASCII");
- }
-
- /**
- * Parses an "Authorization" header and adds the username and password
- * to pConfig
.
- * @param pConfig The request configuration being created.
- * @param pLine The header being parsed, including the "basic" part.
- */
- public static void parseAuthorization(XmlRpcHttpRequestConfigImpl pConfig, String pLine) {
- if (pLine == null) {
- return;
- }
- pLine = pLine.trim();
- StringTokenizer st = new StringTokenizer(pLine);
- if (!st.hasMoreTokens()) {
- return;
- }
- String type = st.nextToken();
- if (!"basic".equalsIgnoreCase(type)) {
- return;
- }
- if (!st.hasMoreTokens()) {
- return;
- }
- String auth = st.nextToken();
- try {
- byte[] c = Base64.getDecoder().decode(auth);
- String enc = pConfig.getBasicEncoding();
- if (enc == null) {
- enc = XmlRpcStreamConfig.UTF8_ENCODING;
- }
- String str = new String(c, enc);
- int col = str.indexOf(':');
- if (col >= 0) {
- pConfig.setBasicUserName(str.substring(0, col));
- pConfig.setBasicPassword(str.substring(col+1));
- }
- } catch (Throwable ignore) {
- }
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/LimitedInputStream.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/LimitedInputStream.java
deleted file mode 100644
index 9d42ea2..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/LimitedInputStream.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.util;
-
-import java.io.InputStream;
-import java.io.IOException;
-
-/** A filtering {@link InputStream} for proper handling of
- * the Content-Length
header: It guarantees to return
- * at most a given number of bytes.
- */
-public class LimitedInputStream extends InputStream {
- // bytes remaining to be read from the input stream. This is
- // initialized from CONTENT_LENGTH (or getContentLength()).
- // This is used in order to correctly return a -1 when all the
- // data POSTed was read. If this is left to -1, content length is
- // assumed as unknown and the standard InputStream methods will be used
- private long available;
- private long markedAvailable;
- private InputStream in;
-
- /** Creates a new instance, reading from the given input stream
- * and returning at most the given number of bytes.
- * @param pIn Input stream being read.
- * @param pAvailable Number of bytes available in pIn
.
- */
- public LimitedInputStream(InputStream pIn, int pAvailable) {
- in = pIn;
- available = pAvailable;
- }
-
- public int read() throws IOException {
- if (available > 0) {
- available--;
- return in.read();
- }
- return -1;
- }
-
- public int read(byte b[], int off, int len) throws IOException {
- if (available > 0) {
- if (len > available) {
- // shrink len
- len = (int) available;
- }
- int read = in.read(b, off, len);
- if (read == -1) {
- available = 0;
- } else {
- available -= read;
- }
- return read;
- }
- return -1;
- }
-
- public long skip(long n) throws IOException {
- long skip = in.skip(n);
- if (available > 0) {
- available -= skip;
- }
- return skip;
- }
-
- public void mark(int readlimit) {
- in.mark(readlimit);
- markedAvailable = available;
- }
-
- public void reset() throws IOException {
- in.reset();
- available = markedAvailable;
- }
-
- public boolean markSupported() {
- return true;
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/NamespaceContextImpl.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/NamespaceContextImpl.java
deleted file mode 100644
index 2b926e9..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/NamespaceContextImpl.java
+++ /dev/null
@@ -1,315 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.util;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.xml.XMLConstants;
-import javax.xml.namespace.NamespaceContext;
-
-/**
- * Default implementation of {@link NamespaceContext}.
- */
-public class NamespaceContextImpl implements NamespaceContext {
-
- /*
- * List of currently defined prefixes (even indexes, 0, 2, 4, ...)
- * and namespace URI's (odd indexes, 1, 3, 5, ...)
- */
- private List prefixList;
-
- /*
- * The prefix and namespace URI, which have been defined
- * last. It is assumed, that these are looked up the most.
- * Thus we keep them in separate variables, for reasons
- * of speed.
- */
- private String cachedPrefix, cachedURI;
-
- /** Resets the NamespaceSupport's state. Allows reusing the
- * object.
- */
- public void reset() {
- cachedURI = cachedPrefix = null;
- if (prefixList != null) {
- prefixList.clear();
- }
- }
-
- /**
- * Declares a new prefix.
- * @param pPrefix prefix
- * @param pURI uri
- * @throws IllegalArgumentException Prefix or URI are null.
- */
- public void startPrefixMapping(String pPrefix, String pURI) {
- if (pPrefix == null) {
- throw new IllegalArgumentException("The namespace prefix must not be null.");
- }
- if (pURI == null) {
- throw new IllegalArgumentException("The namespace prefix must not be null.");
- }
- if (cachedURI != null) {
- if (prefixList == null) { prefixList = new ArrayList<>(); }
- prefixList.add(cachedPrefix);
- prefixList.add(cachedURI);
- }
- cachedURI = pURI;
- cachedPrefix = pPrefix;
- }
-
- /** Removes the declaration of the prefix, which has been defined
- * last.
- * @param pPrefix prefix
- * @throws IllegalArgumentException The prefix is null.
- * @throws IllegalStateException The prefix is not the prefix, which
- * has been defined last. In other words, the calls to
- * {@link #startPrefixMapping(String, String)}, and
- * {@link #endPrefixMapping(String)} aren't in LIFO order.
- */
- public void endPrefixMapping(String pPrefix) {
- if (pPrefix == null) {
- throw new IllegalArgumentException("The namespace prefix must not be null.");
- }
- if (pPrefix.equals(cachedPrefix)) {
- if (prefixList != null && prefixList.size() > 0) {
- cachedURI = prefixList.remove(prefixList.size()-1).toString();
- cachedPrefix = prefixList.remove(prefixList.size()-1).toString();
- } else {
- cachedPrefix = cachedURI = null;
- }
- } else {
- throw new IllegalStateException("The prefix " + pPrefix
- + " isn't the prefix, which has been defined last.");
- }
- }
-
- /**
- * Given a prefix, returns the URI to which the prefix is
- * currently mapped or null, if there is no such mapping.
- * Note: This methods behaviour is precisely
- * defined by {@link NamespaceContext#getNamespaceURI(String)}.
- * @param pPrefix The prefix in question
- */
- public String getNamespaceURI(String pPrefix) {
- if (pPrefix == null) {
- throw new IllegalArgumentException("The namespace prefix must not be null.");
- }
- if (cachedURI != null) {
- if (cachedPrefix.equals(pPrefix)) { return cachedURI; }
- if (prefixList != null) {
- for (int i = prefixList.size(); i > 0; i -= 2) {
- if (pPrefix.equals(prefixList.get(i-2))) {
- return prefixList.get(i-1);
- }
- }
- }
- }
- if (XMLConstants.XML_NS_PREFIX.equals(pPrefix)) {
- return XMLConstants.XML_NS_URI;
- } else if (XMLConstants.XMLNS_ATTRIBUTE.equals(pPrefix)) {
- return XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
- }
- return null;
- }
-
- /** Returns a prefix currently mapped to the given URI or
- * null, if there is no such mapping. This method may be used
- * to find a possible prefix for an elements namespace URI. For
- * attributes you should use {@link #getAttributePrefix(String)}.
- * Note : This methods behaviour is precisely
- * defined by {@link NamespaceContext#getPrefix(String)}.
- * @param pURI The namespace URI in question
- * @throws IllegalArgumentException The namespace URI is null.
- */
- @Override
- public String getPrefix(String pURI) {
- if (pURI == null) {
- throw new IllegalArgumentException("The namespace URI must not be null.");
- }
- if (cachedURI != null) {
- if (cachedURI.equals(pURI)) { return cachedPrefix; }
- if (prefixList != null) {
- for (int i = prefixList.size(); i > 0; i -= 2) {
- if (pURI.equals(prefixList.get(i-1))) {
- return prefixList.get(i-2);
- }
- }
- }
- }
- if (XMLConstants.XML_NS_URI.equals(pURI)) {
- return XMLConstants.XML_NS_PREFIX;
- } else if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(pURI)) {
- return XMLConstants.XMLNS_ATTRIBUTE;
- }
- return null;
- }
-
- /**
- * Returns a non-empty prefix currently mapped to the given
- * URL or null, if there is no such mapping. This method may be
- * used to find a possible prefix for an attributes namespace
- * URI. For elements you should use {@link #getPrefix(String)}.
- * @param pURI Thhe namespace URI in question
- * @return prefix
- * @throws IllegalArgumentException The namespace URI is null.
- */
- public String getAttributePrefix(String pURI) {
- if (pURI == null) {
- throw new IllegalArgumentException("The namespace URI must not be null.");
- }
- if (pURI.length() == 0) {
- return "";
- }
- if (cachedURI != null) {
- if (cachedURI.equals(pURI) && cachedPrefix.length() > 0) {
- return cachedPrefix;
- }
- if (prefixList != null) {
- for (int i = prefixList.size(); i > 0; i -= 2) {
- if (pURI.equals(prefixList.get(i-1))) {
- String prefix = prefixList.get(i-2);
- if (prefix.length() > 0) {
- return prefix;
- }
- }
- }
- }
- }
- if (XMLConstants.XML_NS_URI.equals(pURI)) {
- return XMLConstants.XML_NS_PREFIX;
- } else if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(pURI)) {
- return XMLConstants.XMLNS_ATTRIBUTE;
- }
- return null;
- }
-
- /**
- * Returns a collection to all prefixes bound to the given
- * namespace URI.
- * Note : This methods behaviour is precisely
- * defined by {@link NamespaceContext#getPrefixes(String)}.
- * @param pURI The namespace prefix in question
- */
- @Override
- public Iterator getPrefixes(String pURI) {
- if (pURI == null) {
- throw new IllegalArgumentException("The namespace URI must not be null.");
- }
- List list = new ArrayList<>();
- if (cachedURI != null) {
- if (cachedURI.equals(pURI)) { list.add(cachedPrefix); }
- if (prefixList != null) {
- for (int i = prefixList.size(); i > 0; i -= 2) {
- if (pURI.equals(prefixList.get(i-1))) {
- list.add(prefixList.get(i-2).toString());
- }
- }
- }
- }
- if (pURI.equals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI)) {
- list.add(XMLConstants.XMLNS_ATTRIBUTE);
- } else if (pURI.equals(XMLConstants.XML_NS_URI)) {
- list.add(XMLConstants.XML_NS_PREFIX);
- }
- return list.iterator();
- }
-
- /**
- * Returns whether a given prefix is currently declared.
- * @param pPrefix prefix
- * @return true if prefix is declared
- */
- public boolean isPrefixDeclared(String pPrefix) {
- if (cachedURI != null) {
- if (cachedPrefix != null && cachedPrefix.equals(pPrefix)) { return true; }
- if (prefixList != null) {
- for (int i = prefixList.size(); i > 0; i -= 2) {
- if (prefixList.get(i-2).equals(pPrefix)) {
- return true;
- }
- }
- }
- }
- return "xml".equals(pPrefix);
- }
-
- /** Returns the current number of assigned prefixes.
- * Note, that a prefix may be assigned in several nested
- * elements, in which case every assignment is counted.
- * This method is typically called before invoking the
- * method
- * {@link org.xml.sax.ContentHandler#startElement(String, String, String, org.xml.sax.Attributes)}.
- * The return value is used as a saveable state. After
- * invoking
- * {@link org.xml.sax.ContentHandler#endElement(String, String, String)},
- * the state is restored by calling {@link #checkContext(int)}.
- * @return number of assigned prefixes
- */
- public int getContext() {
- return (prefixList == null ? 0 : prefixList.size()) +
- (cachedURI == null ? 0 : 2);
- }
-
- /** This method is used to restore the namespace state
- * after an element is created. It takes as input a state,
- * as returned by {@link #getContext()}.
- * For any prefix, which was since saving the state,
- * the prefix is returned and deleted from the internal
- * list. In other words, a typical use looks like this:
- *
- * NamespaceSupport nss;
- * ContentHandler h;
- * int context = nss.getContext();
- * h.startElement("foo", "bar", "f:bar", new AttributesImpl());
- * ...
- * h.endElement("foo", "bar", "f:bar");
- * for (;;) {
- * String prefix = nss.checkContext(context);
- * if (prefix == null) {
- * break;
- * }
- * h.endPrefixMapping(prefix);
- * }
- *
- * @param i context number
- * @return prefix
- */
- public String checkContext(int i) {
- if (getContext() == i) {
- return null;
- }
- String result = cachedPrefix;
- if (prefixList != null && prefixList.size() > 0) {
- cachedURI = prefixList.remove(prefixList.size()-1).toString();
- cachedPrefix = prefixList.remove(prefixList.size()-1).toString();
- } else {
- cachedURI = null;
- cachedPrefix = null;
- }
- return result;
- }
-
- /**
- * Returns a list of all prefixes, which are currently declared,
- * in the order of declaration. Duplicates are possible, if a
- * prefix has been assigned to more than one URI, or repeatedly to
- * the same URI.
- * @return prefixes
- */
- public List getPrefixes() {
- if (cachedPrefix == null) {
- return Collections.emptyList();
- } else if (prefixList == null) {
- return Collections.singletonList(cachedPrefix);
- } else {
- List result = new ArrayList<>(prefixList.size() + 1);
- for (int i = 0; i < prefixList.size(); i += 2) {
- result.add(prefixList.get(i));
- }
- result.add(cachedPrefix);
- return result;
- }
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/SAXParsers.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/SAXParsers.java
deleted file mode 100644
index b765f53..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/SAXParsers.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.util;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-
-/**
- * Utility class for working with SAX parsers.
- */
-public class SAXParsers {
- private static SAXParserFactory spf;
- static {
- spf = SAXParserFactory.newInstance();
- spf.setNamespaceAware(true);
- spf.setValidating(false);
- try {
- spf.setFeature("http://xml.org/sax/features/external-general-entities", false);
- } catch (ParserConfigurationException | SAXException e) {
- // Ignore it
- }
- try {
- spf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
- } catch (ParserConfigurationException | SAXException e) {
- // Ignore it
- }
- }
-
- /** Creates a new instance of {@link XMLReader}.
- */
- public static XMLReader newXMLReader() throws XmlRpcException {
- try {
- return spf.newSAXParser().getXMLReader();
- } catch (ParserConfigurationException | SAXException e) {
- throw new XmlRpcException("Unable to create XML parser: " + e.getMessage(), e);
- }
- }
-
- /**
- * Returns the SAX parser factory, which is used by Apache XML-RPC. You may
- * use this to configure the factory.
- */
- public static SAXParserFactory getSAXParserFactory() {
- return spf;
- }
-
- /**
- * Sets the SAX parser factory, which is used by Apache XML-RPC. You may use
- * this to configure another instance than the default.
- */
- public static void setSAXParserFactory(SAXParserFactory pFactory) {
- spf = pFactory;
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/XMLWriter.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/XMLWriter.java
deleted file mode 100644
index ca96702..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/XMLWriter.java
+++ /dev/null
@@ -1,118 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.util;
-
-import org.xml.sax.ContentHandler;
-import java.io.Writer;
-
-/**
- * A simple serializer for XML documents, which is writing to
- * an instance of {@link Writer}.
- */
-public interface XMLWriter extends ContentHandler {
- /** Sets the writers encoding.
- * @param pEncoding Writers encoding, by default null, in
- * which case UTF-8 is being used.
- */
- void setEncoding(String pEncoding);
-
- /** Returns the writers encoding.
- * @return Writers encoding, by default null, in
- * which case UTF-8 is being used.
- */
- String getEncoding();
-
- /** Sets, whether an XML declaration is being generated.
- * @param pDeclarating Whether an XML declaration is generated. Defaults
- * to false.
- */
- void setDeclarating(boolean pDeclarating);
-
- /** Returns, whether an XML declaration is being generated.
- * @return Whether an XML declaration is generated. Defaults
- * to false.
- */
- boolean isDeclarating();
-
- /** Sets the target {@link Writer}. This is typically an instance
- * of {@link java.io.BufferedWriter}, which is connected to an
- * instance of {@link java.io.OutputStreamWriter} with an encoding
- * matching the XML documents encoding.
- * @param pWriter The target writer.
- */
- void setWriter(Writer pWriter);
-
- /** Returns the target {@link Writer}. This is typically an instance
- * of {@link java.io.BufferedWriter}, which is connected to an
- * instance of {@link java.io.OutputStreamWriter} with an encoding
- * matching the XML documents encoding.
- * @return The target writer.
- */
- Writer getWriter();
-
- /** Returns whether the XMLWriter can encode the character
- * c
without an escape sequence like &#ddd;.
- * @param pChar The character being checked for escaping.
- * @return Whether to encode the character.
- */
- boolean canEncode(char pChar);
-
- /** Returns, whether the XMLWriter
is indenting
- * (pretty printing). If you want indenting,
- * you should consider to invoke the methods
- * {@link #setIndentString(String)} and
- * {@link #setLineFeed(String)} as well.
- * @param pIndenting Whether indentation is enabled. Defaults to false.
- */
- void setIndenting(boolean pIndenting);
-
- /** Returns, whether the XMLWriter
is indenting
- * (pretty printing). If you want indenting,
- * you should consider to invoke the methods
- * {@link #setIndentString(String)} and
- * {@link #setLineFeed(String)} as well.
- * @return Whether indentation is enabled. Defaults to false.
- */
- boolean isIndenting();
-
- /** Sets the string being used to indent an XML element
- * by one level. Ignored, if indentation is disabled.
- * @param pIndentString The indentation string, by default " " (two blanks).
- */
- void setIndentString(String pIndentString);
-
- /** Returns the string being used to indent an XML element
- * by one level. Ignored, if indentation is disabled.
- * @return The indentation string, by default " " (two blanks).
- */
- String getIndentString();
-
- /** Sets the line terminator. Ignored, if indentation is
- * disabled.
- * @param pLineFeed The line terminator, by default "\n"
- * (Line Feed). You might prefer "\r\n" (Carriage Return,
- * Line Feed), which is the default on Windows and related
- * operating systems.
- */
- void setLineFeed(String pLineFeed);
-
- /** Returns the line terminator. Ignored, if indentation is
- * disabled.
- * @return The line terminator, by default "\n"
- * (Line Feed). You might prefer "\r\n" (Carriage Return,
- * Line Feed), which is the default on Windows and related
- * operating systems.
- */
- String getLineFeed();
-
- /** Sets, whether the method {@link org.xml.sax.ContentHandler#endDocument}
- * should do a flush on the target stream.
- * @param pFlushing True, if a flush should be done. Defaults to
- * false.
- */
- void setFlushing(boolean pFlushing);
-
- /** Returns, whether the method {@link org.xml.sax.ContentHandler#endDocument}
- * should do a flush on the target stream.
- * @return True, if a flush should be done. Defaults to false.
- */
- boolean isFlushing();
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/XMLWriterImpl.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/XMLWriterImpl.java
deleted file mode 100644
index 9e57d7c..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/XMLWriterImpl.java
+++ /dev/null
@@ -1,401 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.util;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.XMLConstants;
-
-/**
- * Default implementation of {@link XMLWriter}.
- */
-public class XMLWriterImpl implements XMLWriter {
-
- private static final int STATE_OUTSIDE = 0;
-
- private static final int STATE_IN_START_ELEMENT = 1;
-
- private static final int STATE_IN_ELEMENT = 2;
-
- private String encoding, indentString, lineFeed;
-
- private Writer w;
-
- private Locator l;
-
- private Map delayedPrefixes;
-
- private int curIndent = 0;
-
- private int state;
-
- private boolean declarating, indenting, flushing;
-
- @Override
- public void setEncoding(String pEncoding) { encoding = pEncoding; }
-
- @Override
- public String getEncoding() { return encoding; }
-
- @Override
- public void setDeclarating(boolean pDeclarating) { declarating = pDeclarating; }
-
- @Override
- public boolean isDeclarating() { return declarating; }
-
- @Override
- public void setIndenting(boolean pIndenting) { indenting = pIndenting; }
-
- @Override
- public boolean isIndenting() { return indenting; }
-
- @Override
- public void setIndentString(String pIndentString) { indentString = pIndentString; }
-
- @Override
- public String getIndentString() { return indentString; }
-
- @Override
- public void setLineFeed(String pLineFeed) { lineFeed = pLineFeed; }
-
- @Override
- public String getLineFeed() { return lineFeed; }
-
- @Override
- public void setFlushing(boolean pFlushing) { flushing = pFlushing; }
-
- @Override
- public boolean isFlushing() { return flushing; }
-
- /** Sets the JaxbXMLSerializers Writer.
- */
- public void setWriter(Writer pWriter) {
- w = pWriter;
- }
-
- /** Returns the JaxbXMLSerializers Writer.
- */
- public Writer getWriter() {
- return w;
- }
-
- /** Sets the locator.
- *
- * @param pLocator A locator for use in case of errors
- * @see #getDocumentLocator
- */
- public void setDocumentLocator(Locator pLocator) { l = pLocator; }
-
- /** Returns the locator
- * @return A locator previously set with setDocumentLocator or null.
- * @see #setDocumentLocator
- */
- public Locator getDocumentLocator() { return l; }
-
- /**
- * Starts use of a namespace prefix.
- *
- * @param namespaceURI The namespace URI
- * @param prefix The prefix
- * @throws SAXException Not actually thrown, just for compliance to the interface specification.
- */
- public void startPrefixMapping(String prefix, String namespaceURI) throws SAXException {
- if (delayedPrefixes == null) {
- delayedPrefixes = new HashMap<>();
- }
- if ("".equals(prefix)) {
- if (namespaceURI.equals(prefix)) {
- return;
- }
- prefix = XMLConstants.XMLNS_ATTRIBUTE;
- } else {
- prefix = XMLConstants.XMLNS_ATTRIBUTE + ":" + prefix;
- }
- delayedPrefixes.put(prefix, namespaceURI);
- }
-
- /** Terminates use of a namespace prefix.
- *
- * @param prefix The prefix being abandoned.
- * @throws SAXException Not actually thrown, just for compliance to the interface specification.
- */
- public void endPrefixMapping(String prefix) throws SAXException {
- if (delayedPrefixes != null) {
- if ("".equals(prefix)) {
- prefix = XMLConstants.XMLNS_ATTRIBUTE;
- } else {
- prefix = XMLConstants.XMLNS_ATTRIBUTE + ":" + prefix;
- }
- delayedPrefixes.remove(prefix);
- }
- }
-
- /** Starts a document.
- * @throws SAXException Not actually thrown, just for compliance to the interface specification.
- */
- public void startDocument() throws SAXException {
- if (delayedPrefixes != null) {
- delayedPrefixes.clear();
- }
- state = STATE_OUTSIDE;
- curIndent = 0;
- if (isDeclarating() && w != null) {
- try {
- w.write("");
- if (isIndenting()) {
- String lf = getLineFeed();
- if (lf != null) {
- w.write(lf);
- }
- }
- } catch (IOException e) {
- throw new SAXException("Failed to write XML declaration: " + e.getMessage(), e);
- }
- }
- }
-
- /** This method finishs the handlers action. After calling endDocument you
- * may start a new action by calling startDocument again.
- *
- * @throws SAXException Not actually thrown, just for compliance to the
- * interface specification.
- */
- public void endDocument() throws SAXException {
- if (isFlushing() && w != null) {
- try {
- w.flush();
- } catch (IOException e) {
- throw new SAXException("Failed to flush target writer: " + e.getMessage(), e);
- }
- }
- }
-
- /** Calls the character method with the same arguments.
- * @param ch A string of whitespace characters being inserted into the document.
- * @param start The index of the first character.
- * @param length The number of characters.
- * @throws SAXException Thrown in case of an IOException.
- */
- public void ignorableWhitespace(char[] ch, int start, int length)
- throws SAXException {
- characters(ch, start, length);
- }
-
- private void stopTerminator() throws IOException {
- if (state == STATE_IN_START_ELEMENT) {
- if (w != null) {
- w.write('>');
- }
- state = STATE_IN_ELEMENT;
- }
- }
-
- /** Inserts a string of characters into the document.
- * @param ch The characters being inserted. A substring, to be precise.
- * @param start Index of the first character
- * @param length Number of characters being inserted
- * @throws SAXException Thrown in case of an IOException
- */
- public void characters(char[] ch, int start, int length) throws SAXException {
- try {
- stopTerminator();
- if (w == null) return;
- int end = start+length;
- for (int i = start; i < end; i++) {
- char c = ch[i];
- switch (c) {
- case '&': w.write("&"); break;
- case '<': w.write("<"); break;
- case '>': w.write(">"); break;
- case '\n':
- case '\r':
- case '\t':
- w.write(c); break;
- default:
- if (canEncode(c)) {
- w.write(c);
- } else {
- w.write("");
- w.write(Integer.toString(c));
- w.write(";");
- }
- break;
- }
- }
- } catch (IOException e) {
- throw new SAXException(e);
- }
- }
-
- public boolean canEncode(char c) {
- return c == '\n' || (c >= ' ' && c < 0x7f);
- }
-
-
- /** Terminates an element.
- *
- * @param namespaceURI The namespace URI, if any, or null
- * @param localName The local name, without prefix, or null
- * @param qName The qualified name, including a prefix, or null
- * @throws SAXException Thrown in case of an IOException.
- */
- public void endElement(String namespaceURI, String localName, String qName)
- throws SAXException {
- if (isIndenting()) {
- --curIndent;
- }
- if (w != null) {
- try {
- if (state == STATE_IN_START_ELEMENT) {
- w.write("/>");
- state = STATE_OUTSIDE;
- } else {
- if (state == STATE_OUTSIDE) {
- indentMe();
- }
- w.write("");
- w.write(qName);
- w.write('>');
- }
- state = STATE_OUTSIDE;
- } catch (IOException e) {
- throw new SAXException(e);
- }
- }
- }
-
- private void indentMe() throws IOException {
- if (w != null) {
- if (isIndenting()) {
- String s = getLineFeed();
- if (s != null) {
- w.write(s);
- }
- s = getIndentString();
- if (s != null) {
- for (int i = 0; i < curIndent; i++) {
- w.write(s);
- }
- }
- }
- }
- }
-
- private void writeCData(String v) throws IOException {
- int len = v.length();
- for (int j = 0; j < len; j++) {
- char c = v.charAt(j);
- switch (c) {
- case '&': w.write("&"); break;
- case '<': w.write("<"); break;
- case '>': w.write(">"); break;
- case '\'': w.write("'"); break;
- case '"': w.write("""); break;
- default:
- if (canEncode(c)) {
- w.write(c);
- } else {
- w.write("");
- w.write(Integer.toString(c));
- w.write(';');
- }
- break;
- }
- }
- }
-
- /** Starts a new element.
- *
- * @param namespaceURI The namespace URI, if any, or null
- * @param localName The local name, without prefix, or null
- * @param qName The qualified name, including a prefix, or null
- * @param attr The element attributes
- * @throws SAXException Thrown in case of an IOException.
- */
- public void startElement(String namespaceURI, String localName, String qName,
- Attributes attr) throws SAXException {
- try {
- stopTerminator();
- if (isIndenting()) {
- if (curIndent > 0) {
- indentMe();
- }
- curIndent++;
- }
-
- if (w != null) {
- w.write('<');
- w.write(qName);
- if (attr != null) {
- for (int i = attr.getLength(); i > 0;) {
- w.write(' ');
- String name = attr.getQName(--i);
- w.write(name);
- if (delayedPrefixes != null) {
- delayedPrefixes.remove(name);
- }
- w.write("=\"");
- writeCData(attr.getValue(i));
- w.write('"');
- }
- }
- if (delayedPrefixes != null && delayedPrefixes.size() > 0) {
- for (Map.Entry entry : delayedPrefixes.entrySet()) {
- w.write(' ');
- w.write(entry.getKey());
- w.write("=\"");
- w.write(entry.getValue());
- w.write('"');
- }
- delayedPrefixes.clear();
- }
- }
- state = STATE_IN_START_ELEMENT;
- } catch (IOException e) {
- throw new SAXException(e);
- }
- }
-
- /** Not actually implemented, because I don't know how to skip entities.
- *
- * @param ent The entity being skipped.
- * @throws SAXException Not actually thrown, just for compliance to the interface specification.
- */
- public void skippedEntity(String ent) throws SAXException {
- throw new SAXException("Don't know how to skip entities");
- }
-
- /** Inserts a processing instruction.
- *
- * @param target The PI target
- * @param data The PI data
- * @throws SAXException Thrown in case of an IOException
- */
- public void processingInstruction(String target, String data)
- throws SAXException {
- try {
- stopTerminator();
- if (w != null) {
- w.write("");
- w.write(target);
- w.write(' ');
- w.write(data);
- w.write("?>");
- }
- } catch (IOException e) {
- throw new SAXException(e);
- }
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/XmlRpcDateTimeDateFormat.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/XmlRpcDateTimeDateFormat.java
deleted file mode 100644
index 72e0cac..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/XmlRpcDateTimeDateFormat.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.util;
-
-import java.text.FieldPosition;
-import java.text.ParsePosition;
-import java.util.Calendar;
-import java.util.Date;
-
-/** An extension of {@link XmlRpcDateTimeFormat}, which accepts
- * and/or creates instances of {@link Date}.
- */
-public abstract class XmlRpcDateTimeDateFormat extends XmlRpcDateTimeFormat {
- private static final long serialVersionUID = -5107387618606150784L;
-
- public StringBuffer format(Object pCalendar, StringBuffer pBuffer, FieldPosition pPos) {
- final Object cal;
- if (pCalendar != null && pCalendar instanceof Date) {
- Calendar calendar = Calendar.getInstance(getTimeZone());
- calendar.setTime((Date) pCalendar);
- cal = calendar;
- } else {
- cal = pCalendar;
- }
- return super.format(cal, pBuffer, pPos);
- }
-
- public Object parseObject(String pString, ParsePosition pParsePosition) {
- Calendar cal = (Calendar) super.parseObject(pString, pParsePosition);
- return cal == null ? null : cal.getTime();
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/XmlRpcDateTimeFormat.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/XmlRpcDateTimeFormat.java
deleted file mode 100644
index 5f2cf8f..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/XmlRpcDateTimeFormat.java
+++ /dev/null
@@ -1,159 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.util;
-
-import java.text.FieldPosition;
-import java.text.Format;
-import java.text.ParsePosition;
-import java.util.Calendar;
-import java.util.TimeZone;
-
-/** An instance of {@link Format}, which may be used
- * to parse and format dateTime
values, as specified
- * by the XML-RPC specification. The specification doesn't precisely
- * describe the format, it only gives an example:
- *
- * 19980717T14:08:55
- *
- * This class accepts and creates instances of {@link Calendar}.
- */
-public abstract class XmlRpcDateTimeFormat extends Format {
- private static final long serialVersionUID = -8008230377361175138L;
-
- /**
- * Returns the time zone, which is used to interpret date/time
- * values.
- * @return time zone
- */
- protected abstract TimeZone getTimeZone();
-
- private int parseInt(String pString, int pOffset, StringBuffer pDigits, int pMaxDigits) {
- int length = pString.length();
- pDigits.setLength(0);
- while (pMaxDigits-- > 0 && pOffset < length) {
- char c = pString.charAt(pOffset);
- if (Character.isDigit(c)) {
- pDigits.append(c);
- ++pOffset;
- } else {
- break;
- }
- }
- return pOffset;
- }
-
- public Object parseObject(String pString, ParsePosition pParsePosition) {
- if (pString == null) {
- throw new NullPointerException("The String argument must not be null.");
- }
- if (pParsePosition == null) {
- throw new NullPointerException("The ParsePosition argument must not be null.");
- }
- int offset = pParsePosition.getIndex();
- int length = pString.length();
-
- StringBuffer digits = new StringBuffer();
- int year, month, mday;
-
- offset = parseInt(pString, offset, digits, 4);
- if (digits.length() < 4) {
- pParsePosition.setErrorIndex(offset);
- return null;
- }
- year = Integer.parseInt(digits.toString());
-
- offset = parseInt(pString, offset, digits, 2);
- if (digits.length() != 2) {
- pParsePosition.setErrorIndex(offset);
- return null;
- }
- month = Integer.parseInt(digits.toString());
-
- offset = parseInt(pString, offset, digits, 2);
- if (digits.length() != 2) {
- pParsePosition.setErrorIndex(offset);
- return null;
- }
- mday = Integer.parseInt(digits.toString());
-
- if (offset < length && pString.charAt(offset) == 'T') {
- ++offset;
- } else {
- pParsePosition.setErrorIndex(offset);
- return null;
- }
-
- int hour, minute, second;
- offset = parseInt(pString, offset, digits, 2);
- if (digits.length() != 2) {
- pParsePosition.setErrorIndex(offset);
- return null;
- }
- hour = Integer.parseInt(digits.toString());
-
- if (offset < length && pString.charAt(offset) == ':') {
- ++offset;
- } else {
- pParsePosition.setErrorIndex(offset);
- return null;
- }
-
- offset = parseInt(pString, offset, digits, 2);
- if (digits.length() != 2) {
- pParsePosition.setErrorIndex(offset);
- return null;
- }
- minute = Integer.parseInt(digits.toString());
-
- if (offset < length && pString.charAt(offset) == ':') {
- ++offset;
- } else {
- pParsePosition.setErrorIndex(offset);
- return null;
- }
-
- offset = parseInt(pString, offset, digits, 2);
- if (digits.length() != 2) {
- pParsePosition.setErrorIndex(offset);
- return null;
- }
- second = Integer.parseInt(digits.toString());
-
- Calendar cal = Calendar.getInstance(getTimeZone());
- cal.set(year, month-1, mday, hour, minute, second);
- cal.set(Calendar.MILLISECOND, 0);
- pParsePosition.setIndex(offset);
- return cal;
- }
-
- private void append(StringBuffer pBuffer, int pNum, int pMinLen) {
- String s = Integer.toString(pNum);
- for (int i = s.length(); i < pMinLen; i++) {
- pBuffer.append('0');
- }
- pBuffer.append(s);
- }
-
- public StringBuffer format(Object pCalendar, StringBuffer pBuffer, FieldPosition pPos) {
- if (pCalendar == null) {
- throw new NullPointerException("The Calendar argument must not be null.");
- }
- if (pBuffer == null) {
- throw new NullPointerException("The StringBuffer argument must not be null.");
- }
- if (pPos == null) {
- throw new NullPointerException("The FieldPosition argument must not be null.");
- }
-
- Calendar cal = (Calendar) pCalendar;
- int year = cal.get(Calendar.YEAR);
- append(pBuffer, year, 4);
- append(pBuffer, cal.get(Calendar.MONTH)+1, 2);
- append(pBuffer, cal.get(Calendar.DAY_OF_MONTH), 2);
- pBuffer.append('T');
- append(pBuffer, cal.get(Calendar.HOUR_OF_DAY), 2);
- pBuffer.append(':');
- append(pBuffer, cal.get(Calendar.MINUTE), 2);
- pBuffer.append(':');
- append(pBuffer, cal.get(Calendar.SECOND), 2);
- return pBuffer;
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/XsDateFormat.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/XsDateFormat.java
deleted file mode 100644
index 557c24d..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/XsDateFormat.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.util;
-
-/**
- * An instance of {@link java.text.Format}, which may be used to parse
- * and format xs:date
values.
- */
-public class XsDateFormat extends XsDateTimeFormat {
- private static final long serialVersionUID = 3832621764093030707L;
-
- /** Creates a new instance.
- */
- public XsDateFormat() {
- super(true, false);
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/XsDateTimeFormat.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/XsDateTimeFormat.java
deleted file mode 100644
index 1e8395a..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/XsDateTimeFormat.java
+++ /dev/null
@@ -1,279 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.util;
-
-import java.text.FieldPosition;
-import java.text.Format;
-import java.text.ParsePosition;
-import java.util.Calendar;
-import java.util.TimeZone;
-
-/** An instance of {@link Format}, which may be used
- * to parse and format xs:dateTime
values.
- */
-public class XsDateTimeFormat extends Format {
- private static final long serialVersionUID = 3258131340871479609L;
- final boolean parseDate;
- final boolean parseTime;
-
- XsDateTimeFormat(boolean pParseDate, boolean pParseTime) {
- parseDate = pParseDate;
- parseTime = pParseTime;
- }
-
- /** Creates a new instance.
- */
- public XsDateTimeFormat() {
- this(true, true);
- }
-
- private int parseInt(String pString, int pOffset, StringBuffer pDigits) {
- int length = pString.length();
- pDigits.setLength(0);
- while (pOffset < length) {
- char c = pString.charAt(pOffset);
- if (Character.isDigit(c)) {
- pDigits.append(c);
- ++pOffset;
- } else {
- break;
- }
- }
- return pOffset;
- }
-
- public Object parseObject(String pString, ParsePosition pParsePosition) {
- if (pString == null) {
- throw new NullPointerException("The String argument must not be null.");
- }
- if (pParsePosition == null) {
- throw new NullPointerException("The ParsePosition argument must not be null.");
- }
- int offset = pParsePosition.getIndex();
- int length = pString.length();
-
- boolean isMinus = false;
- StringBuffer digits = new StringBuffer();
- int year, month, mday;
- if (parseDate) {
- // Sign
- if (offset < length) {
- char c = pString.charAt(offset);
- if (c == '+') {
- ++offset;
- } else if (c == '-') {
- ++offset;
- isMinus = true;
- }
- }
-
- offset = parseInt(pString, offset, digits);
- if (digits.length() < 4) {
- pParsePosition.setErrorIndex(offset);
- return null;
- }
- year = Integer.parseInt(digits.toString());
-
- if (offset < length && pString.charAt(offset) == '-') {
- ++offset;
- } else {
- pParsePosition.setErrorIndex(offset);
- return null;
- }
-
- offset = parseInt(pString, offset, digits);
- if (digits.length() != 2) {
- pParsePosition.setErrorIndex(offset);
- return null;
- }
- month = Integer.parseInt(digits.toString());
-
- if (offset < length && pString.charAt(offset) == '-') {
- ++offset;
- } else {
- pParsePosition.setErrorIndex(offset);
- return null;
- }
-
- offset = parseInt(pString, offset, digits);
- if (digits.length() != 2) {
- pParsePosition.setErrorIndex(offset);
- return null;
- }
- mday = Integer.parseInt(digits.toString());
-
- if (parseTime) {
- if (offset < length && pString.charAt(offset) == 'T') {
- ++offset;
- } else {
- pParsePosition.setErrorIndex(offset);
- return null;
- }
- }
- } else {
- year = month = mday = 0;
- }
-
- int hour, minute, second, millis;
- if (parseTime) {
- offset = parseInt(pString, offset, digits);
- if (digits.length() != 2) {
- pParsePosition.setErrorIndex(offset);
- return null;
- }
- hour = Integer.parseInt(digits.toString());
-
- if (offset < length && pString.charAt(offset) == ':') {
- ++offset;
- } else {
- pParsePosition.setErrorIndex(offset);
- return null;
- }
-
- offset = parseInt(pString, offset, digits);
- if (digits.length() != 2) {
- pParsePosition.setErrorIndex(offset);
- return null;
- }
- minute = Integer.parseInt(digits.toString());
-
- if (offset < length && pString.charAt(offset) == ':') {
- ++offset;
- } else {
- pParsePosition.setErrorIndex(offset);
- return null;
- }
-
- offset = parseInt(pString, offset, digits);
- if (digits.length() != 2) {
- pParsePosition.setErrorIndex(offset);
- return null;
- }
- second = Integer.parseInt(digits.toString());
-
- if (offset < length && pString.charAt(offset) == '.') {
- ++offset;
- offset = parseInt(pString, offset, digits);
- if (digits.length() > 0) {
- millis = Integer.parseInt(digits.toString());
- if (millis > 999) {
- pParsePosition.setErrorIndex(offset);
- return null;
- }
- for (int i = digits.length(); i < 3; i++) {
- millis *= 10;
- }
- } else {
- millis = 0;
- }
- } else {
- millis = 0;
- }
- } else {
- hour = minute = second = millis = 0;
- }
-
- digits.setLength(0);
- digits.append("GMT");
- if (offset < length) {
- char c = pString.charAt(offset);
- if (c == 'Z') {
- // Ignore UTC, it is the default
- ++offset;
- } else if (c == '+' || c == '-') {
- digits.append(c);
- ++offset;
- for (int i = 0; i < 5; i++) {
- if (offset >= length) {
- pParsePosition.setErrorIndex(offset);
- return null;
- }
- c = pString.charAt(offset);
- if ((i != 2 && Character.isDigit(c)) ||
- (i == 2 && c == ':')) {
- digits.append(c);
- } else {
- pParsePosition.setErrorIndex(offset);
- return null;
- }
- ++offset;
- }
- }
- }
-
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(digits.toString()));
- cal.set(isMinus ? -year : year, parseDate ? month-1 : month, mday, hour, minute, second);
- cal.set(Calendar.MILLISECOND, millis);
- pParsePosition.setIndex(offset);
- return cal;
- }
-
- private void append(StringBuffer pBuffer, int pNum, int pMinLen) {
- String s = Integer.toString(pNum);
- for (int i = s.length(); i < pMinLen; i++) {
- pBuffer.append('0');
- }
- pBuffer.append(s);
- }
-
- public StringBuffer format(Object pCalendar, StringBuffer pBuffer, FieldPosition pPos) {
- if (pCalendar == null) {
- throw new NullPointerException("The Calendar argument must not be null.");
- }
- if (pBuffer == null) {
- throw new NullPointerException("The StringBuffer argument must not be null.");
- }
- if (pPos == null) {
- throw new NullPointerException("The FieldPosition argument must not be null.");
- }
-
- Calendar cal = (Calendar) pCalendar;
- if (parseDate) {
- int year = cal.get(Calendar.YEAR);
- if (year < 0) {
- pBuffer.append('-');
- year = -year;
- }
- append(pBuffer, year, 4);
- pBuffer.append('-');
- append(pBuffer, cal.get(Calendar.MONTH)+1, 2);
- pBuffer.append('-');
- append(pBuffer, cal.get(Calendar.DAY_OF_MONTH), 2);
- if (parseTime) {
- pBuffer.append('T');
- }
- }
- if (parseTime) {
- append(pBuffer, cal.get(Calendar.HOUR_OF_DAY), 2);
- pBuffer.append(':');
- append(pBuffer, cal.get(Calendar.MINUTE), 2);
- pBuffer.append(':');
- append(pBuffer, cal.get(Calendar.SECOND), 2);
- int millis = cal.get(Calendar.MILLISECOND);
- if (millis > 0) {
- pBuffer.append('.');
- append(pBuffer, millis, 3);
- }
- }
- TimeZone tz = cal.getTimeZone();
- int offset = cal.get(Calendar.ZONE_OFFSET);
- if (tz.inDaylightTime(cal.getTime())) {
- offset += cal.get(Calendar.DST_OFFSET);
- }
- if (offset == 0) {
- pBuffer.append('Z');
- } else {
- if (offset < 0) {
- pBuffer.append('-');
- offset = -offset;
- } else {
- pBuffer.append('+');
- }
- int minutes = offset / (60*1000);
- int hours = minutes / 60;
- minutes -= hours * 60;
- append(pBuffer, hours, 2);
- pBuffer.append(':');
- append(pBuffer, minutes, 2);
- }
- return pBuffer;
- }
-}
diff --git a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/XsTimeFormat.java b/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/XsTimeFormat.java
deleted file mode 100644
index 256096b..0000000
--- a/netty-http-xmlrpc-common/src/main/java/org/xbib/netty/http/xmlrpc/common/util/XsTimeFormat.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.xbib.netty.http.xmlrpc.common.util;
-
-/**
- * An instance of {@link java.text.Format}, which may be used to parse
- * and format xs:time
values.
- */
-public class XsTimeFormat extends XsDateTimeFormat {
-
- private static final long serialVersionUID = 3906931187925727282L;
-
- /** Creates a new instance.
- */
- public XsTimeFormat() {
- super(false, true);
- }
-}
diff --git a/netty-http-xmlrpc-server/build.gradle b/netty-http-xmlrpc-server/build.gradle
deleted file mode 100644
index d7d26a4..0000000
--- a/netty-http-xmlrpc-server/build.gradle
+++ /dev/null
@@ -1,3 +0,0 @@
-dependencies {
- compile project(":netty-http-xmlrpc-common")
-}
\ No newline at end of file
diff --git a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/AbstractReflectiveHandlerMapping.java b/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/AbstractReflectiveHandlerMapping.java
deleted file mode 100644
index b210384..0000000
--- a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/AbstractReflectiveHandlerMapping.java
+++ /dev/null
@@ -1,236 +0,0 @@
-package org.xbib.netty.http.xmlrpc.server;
-
-import org.xbib.netty.http.xmlrpc.common.TypeConverterFactory;
-import org.xbib.netty.http.xmlrpc.common.TypeConverterFactoryImpl;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcHandler;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequest;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/** Abstract base class of handler mappings, which are
- * using reflection.
- */
-public abstract class AbstractReflectiveHandlerMapping
- implements XmlRpcListableHandlerMapping {
- /** An object implementing this interface may be used
- * to validate user names and passwords.
- */
- public interface AuthenticationHandler {
- /** Returns, whether the user is authenticated and
- * authorized to perform the request.
- */
- boolean isAuthorized(XmlRpcRequest pRequest)
- throws XmlRpcException;
- }
-
- private TypeConverterFactory typeConverterFactory = new TypeConverterFactoryImpl();
-
- protected Map handlerMap = new HashMap<>();
-
- private AuthenticationHandler authenticationHandler;
-
- private RequestProcessorFactoryFactory requestProcessorFactoryFactory = new RequestProcessorFactoryFactory.RequestSpecificProcessorFactoryFactory();
-
- private boolean voidMethodEnabled;
-
- /**
- * Sets the mappings {@link TypeConverterFactory}.
- */
- public void setTypeConverterFactory(TypeConverterFactory pFactory) {
- typeConverterFactory = pFactory;
- }
-
- /**
- * Returns the mappings {@link TypeConverterFactory}.
- */
- public TypeConverterFactory getTypeConverterFactory() {
- return typeConverterFactory;
- }
-
- /** Sets the mappings {@link RequestProcessorFactoryFactory}. Note, that this doesn't
- * affect already registered handlers.
- */
- public void setRequestProcessorFactoryFactory(RequestProcessorFactoryFactory pFactory) {
- requestProcessorFactoryFactory = pFactory;
- }
-
- /** Returns the mappings {@link RequestProcessorFactoryFactory}.
- */
- public RequestProcessorFactoryFactory getRequestProcessorFactoryFactory() {
- return requestProcessorFactoryFactory;
- }
-
- /** Returns the authentication handler, if any, or null.
- */
- public AuthenticationHandler getAuthenticationHandler() {
- return authenticationHandler;
- }
-
- /** Sets the authentication handler, if any, or null.
- */
- public void setAuthenticationHandler(AuthenticationHandler pAuthenticationHandler) {
- authenticationHandler = pAuthenticationHandler;
- }
-
- protected boolean isHandlerMethod(Method pMethod) {
- if (!Modifier.isPublic(pMethod.getModifiers())) {
- return false; // Ignore methods, which aren't public
- }
- if (Modifier.isStatic(pMethod.getModifiers())) {
- return false; // Ignore methods, which are static
- }
- if (!isVoidMethodEnabled() && pMethod.getReturnType() == void.class) {
- return false; // Ignore void methods.
- }
- return pMethod.getDeclaringClass() != Object.class;
- }
-
- /** Searches for methods in the given class. For any valid
- * method, it creates an instance of {@link XmlRpcHandler}.
- * Valid methods are defined as follows:
- *
- * They must be public.
- * They must not be static.
- * The return type must not be void.
- * The declaring class must not be
- * {@link Object}.
- * If multiple methods with the same name exist,
- * which meet the above conditins, then an attempt is
- * made to identify a method with a matching signature.
- * If such a method is found, then this method is
- * invoked. If multiple such methods are found, then
- * the first one is choosen. (This may be the case,
- * for example, if there are methods with a similar
- * signature, but varying subclasses.) Note, that
- * there is no concept of the "most matching" method.
- * If no matching method is found at all, then an
- * exception is thrown.
- *
- * @param pKey Suffix for building handler names. A dot and
- * the method name are being added.
- * @param pType The class being inspected.
- */
- protected void registerPublicMethods(String pKey, Class> pType) throws XmlRpcException {
- Map map = new HashMap<>();
- Method[] methods = pType.getMethods();
- for (final Method method : methods) {
- if (!isHandlerMethod(method)) {
- continue;
- }
- String name = pKey + "." + method.getName();
- Method[] mArray;
- Method[] oldMArray = map.get(name);
- if (oldMArray == null) {
- mArray = new Method[]{method};
- } else {
- mArray = new Method[oldMArray.length + 1];
- System.arraycopy(oldMArray, 0, mArray, 0, oldMArray.length);
- mArray[oldMArray.length] = method;
- }
- map.put(name, mArray);
- }
-
- for (Map.Entry entry : map.entrySet()) {
- String name = entry.getKey();
- Method[] mArray = entry.getValue();
- handlerMap.put(name, newXmlRpcHandler(pType, mArray));
- }
- }
-
- /** Creates a new instance of {@link XmlRpcHandler}.
- * @param pClass The class, which was inspected for handler
- * methods. This is used for error messages only. Typically,
- * it is the same than pInstance.getClass() .
- * @param pMethods The method being invoked.
- */
- protected XmlRpcHandler newXmlRpcHandler(final Class> pClass,
- final Method[] pMethods) throws XmlRpcException {
- String[][] sig = getSignature(pMethods);
- String help = getMethodHelp(pClass, pMethods);
- RequestProcessorFactoryFactory.RequestProcessorFactory factory = requestProcessorFactoryFactory.getRequestProcessorFactory(pClass);
- if (sig == null || help == null) {
- return new ReflectiveXmlRpcHandler(this, typeConverterFactory,
- pClass, factory, pMethods);
- }
- return new ReflectiveXmlRpcMetaDataHandler(this, typeConverterFactory,
- pClass, factory, pMethods, sig, help);
- }
-
- /** Creates a signature for the given method.
- */
- protected String[][] getSignature(Method[] pMethods) {
- return Util.getSignature(pMethods);
- }
-
- /** Creates a help string for the given method, when applied
- * to the given class.
- */
- protected String getMethodHelp(Class> pClass, Method[] pMethods) {
- return Util.getMethodHelp(pClass, pMethods);
- }
-
- /** Returns the {@link XmlRpcHandler} with the given name.
- * @param pHandlerName The handlers name
- * @throws XmlRpcNoSuchHandlerException A handler with the given
- * name is unknown.
- */
- public XmlRpcHandler getHandler(String pHandlerName)
- throws XmlRpcException {
- XmlRpcHandler result = handlerMap.get(pHandlerName);
- if (result == null) {
- throw new XmlRpcNoSuchHandlerException("No such handler: " + pHandlerName);
- }
- return result;
- }
-
- public String[] getListMethods() {
- List list = new ArrayList<>();
- for (Map.Entry entry : handlerMap.entrySet()) {
- if (entry.getValue() instanceof XmlRpcMetaDataHandler) {
- list.add(entry.getKey());
- }
- }
- return list.toArray(new String[0]);
- }
-
- public String getMethodHelp(String pHandlerName) throws XmlRpcException {
- XmlRpcHandler h = getHandler(pHandlerName);
- if (h instanceof XmlRpcMetaDataHandler)
- return ((XmlRpcMetaDataHandler)h).getMethodHelp();
- throw new XmlRpcNoSuchHandlerException("No help available for method: "
- + pHandlerName);
- }
-
- public String[][] getMethodSignature(String pHandlerName) throws XmlRpcException {
- XmlRpcHandler h = getHandler(pHandlerName);
- if (h instanceof XmlRpcMetaDataHandler)
- return ((XmlRpcMetaDataHandler)h).getSignatures();
- throw new XmlRpcNoSuchHandlerException("No metadata available for method: "
- + pHandlerName);
- }
-
- /**
- * Returns, whether void methods are enabled. By default, null values
- * aren't supported by XML-RPC and void methods are in fact returning
- * null (at least from the perspective of reflection).
- */
- public boolean isVoidMethodEnabled() {
- return voidMethodEnabled;
- }
-
- /**
- * Sets, whether void methods are enabled. By default, null values
- * aren't supported by XML-RPC and void methods are in fact returning
- * null (at least from the perspective of reflection).
- */
- public void setVoidMethodEnabled(boolean pVoidMethodEnabled) {
- voidMethodEnabled = pVoidMethodEnabled;
- }
-}
diff --git a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/PropertyHandlerMapping.java b/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/PropertyHandlerMapping.java
deleted file mode 100644
index f31ae09..0000000
--- a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/PropertyHandlerMapping.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package org.xbib.netty.http.xmlrpc.server;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * A handler mapping based on a property file. The property file
- * contains a set of properties. The property key is taken as the
- * handler name. The property value is taken as the name of a
- * class being instantiated. For any non-void, non-static, and
- * public method in the class, an entry in the handler map is
- * generated. A typical use would be, to specify interface names
- * as the property keys and implementations as the values.
- */
-public class PropertyHandlerMapping extends AbstractReflectiveHandlerMapping {
- /**
- * Reads handler definitions from a resource file.
- * @param pClassLoader The class loader being used to load
- * handler classes.
- * @param pResource The resource being used, for example
- * "org/apache/xmlrpc/webserver/XmlRpcServlet.properties"
- * @throws IOException Loading the property file failed.
- * @throws XmlRpcException Initializing the handlers failed.
- */
- public void load(ClassLoader pClassLoader, String pResource)
- throws IOException, XmlRpcException {
- URL url = pClassLoader.getResource(pResource);
- if (url == null) {
- throw new IOException("Unable to locate resource " + pResource);
- }
- load(pClassLoader, url);
- }
-
- /**
- * Reads handler definitions from a property file.
- * @param pClassLoader The class loader being used to load
- * handler classes.
- * @param pURL The URL from which to load the property file
- * @throws IOException Loading the property file failed.
- * @throws XmlRpcException Initializing the handlers failed.
- */
- public void load(ClassLoader pClassLoader, URL pURL) throws IOException, XmlRpcException {
- Properties props = new Properties();
- props.load(pURL.openStream());
- load(pClassLoader, props);
- }
-
- /**
- * Reads handler definitions from an existing Map.
- * @param pClassLoader The class loader being used to load
- * handler classes.
- * @param pMap The existing Map to read from
- * @throws XmlRpcException Initializing the handlers failed.
- */
- public void load(ClassLoader pClassLoader, Map pMap) throws XmlRpcException {
- for (Map.Entry entry : pMap.entrySet()) {
- String key = entry.getKey().toString();
- String value = entry.getValue().toString();
- Class> c = newHandlerClass(pClassLoader, value);
- registerPublicMethods(key, c);
- }
- }
-
- protected Class> newHandlerClass(ClassLoader pClassLoader, String pClassName)
- throws XmlRpcException {
- final Class> c;
- try {
- c = pClassLoader.loadClass(pClassName);
- } catch (ClassNotFoundException e) {
- throw new XmlRpcException("Unable to load class: " + pClassName, e);
- }
- if (c == null) {
- throw new XmlRpcException(0, "Loading class " + pClassName + " returned null.");
- }
- return c;
- }
-
- /**
- * Adds handlers for the given object to the mapping.
- * The handlers are build by invoking
- * {@link #registerPublicMethods(String, Class)}.
- * @param pKey The class key, which is passed
- * to {@link #registerPublicMethods(String, Class)}.
- * @param pClass Class, which is responsible for handling the request.
- */
- public void addHandler(String pKey, Class> pClass) throws XmlRpcException {
- registerPublicMethods(pKey, pClass);
- }
-
- /**
- * Removes all handlers with the given class key.
- */
- public void removeHandler(String pKey) {
- handlerMap.keySet().removeIf(k -> k.startsWith(pKey));
- }
-}
diff --git a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/ReflectiveXmlRpcHandler.java b/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/ReflectiveXmlRpcHandler.java
deleted file mode 100644
index 183a578..0000000
--- a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/ReflectiveXmlRpcHandler.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package org.xbib.netty.http.xmlrpc.server;
-
-import org.xbib.netty.http.xmlrpc.common.TypeConverter;
-import org.xbib.netty.http.xmlrpc.common.TypeConverterFactory;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcHandler;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcInvocationException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcNotAuthorizedException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequest;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-/**
- * Default implementation of {@link XmlRpcHandler}.
- */
-public class ReflectiveXmlRpcHandler implements XmlRpcHandler {
-
- private static class MethodData {
-
- final Method method;
-
- final TypeConverter[] typeConverters;
-
- MethodData(Method pMethod, TypeConverterFactory pTypeConverterFactory) {
- method = pMethod;
- Class>[] paramClasses = method.getParameterTypes();
- typeConverters = new TypeConverter[paramClasses.length];
- for (int i = 0; i < paramClasses.length; i++) {
- typeConverters[i] = pTypeConverterFactory.getTypeConverter(paramClasses[i]);
- }
- }
- }
-
- private final AbstractReflectiveHandlerMapping mapping;
-
- private final MethodData[] methods;
-
- private final Class> clazz;
-
- private final RequestProcessorFactoryFactory.RequestProcessorFactory requestProcessorFactory;
-
- /** Creates a new instance.
- * @param pMapping The mapping, which creates this handler.
- * @param pClass The class, which has been inspected to create
- * this handler. Typically, this will be the same as
- * pInstance.getClass() . It is used for diagnostic
- * messages only.
- * @param pMethods The method, which will be invoked for
- * executing the handler.
- */
- public ReflectiveXmlRpcHandler(AbstractReflectiveHandlerMapping pMapping,
- TypeConverterFactory pTypeConverterFactory,
- Class> pClass, RequestProcessorFactoryFactory.RequestProcessorFactory pFactory, Method[] pMethods) {
- mapping = pMapping;
- clazz = pClass;
- methods = new MethodData[pMethods.length];
- requestProcessorFactory = pFactory;
- for (int i = 0; i < methods.length; i++) {
- methods[i] = new MethodData(pMethods[i], pTypeConverterFactory);
- }
- }
-
- private Object getInstance(XmlRpcRequest pRequest) throws XmlRpcException {
- return requestProcessorFactory.getRequestProcessor(pRequest);
- }
-
- public Object execute(XmlRpcRequest pRequest) throws XmlRpcException {
- AbstractReflectiveHandlerMapping.AuthenticationHandler authHandler = mapping.getAuthenticationHandler();
- if (authHandler != null && !authHandler.isAuthorized(pRequest)) {
- throw new XmlRpcNotAuthorizedException("Not authorized");
- }
- Object[] args = new Object[pRequest.getParameterCount()];
- for (int j = 0; j < args.length; j++) {
- args[j] = pRequest.getParameter(j);
- }
- Object instance = getInstance(pRequest);
- for (MethodData methodData : methods) {
- TypeConverter[] converters = methodData.typeConverters;
- if (args.length == converters.length) {
- boolean matching = true;
- for (int j = 0; j < args.length; j++) {
- if (!converters[j].isConvertable(args[j])) {
- matching = false;
- break;
- }
- }
- if (matching) {
- for (int j = 0; j < args.length; j++) {
- args[j] = converters[j].convert(args[j]);
- }
- return invoke(instance, methodData.method, args);
- }
- }
- }
- throw new XmlRpcException("No method matching arguments: " + Util.getSignature(args));
- }
-
- private Object invoke(Object pInstance, Method pMethod, Object[] pArgs) throws XmlRpcException {
- try {
- return pMethod.invoke(pInstance, pArgs);
- } catch (IllegalAccessException e) {
- throw new XmlRpcException("Illegal access to method "
- + pMethod.getName() + " in class "
- + clazz.getName(), e);
- } catch (IllegalArgumentException e) {
- throw new XmlRpcException("Illegal argument for method "
- + pMethod.getName() + " in class "
- + clazz.getName(), e);
- } catch (InvocationTargetException e) {
- Throwable t = e.getTargetException();
- if (t instanceof XmlRpcException) {
- throw (XmlRpcException) t;
- }
- throw new XmlRpcInvocationException("Failed to invoke method "
- + pMethod.getName() + " in class "
- + clazz.getName() + ": "
- + t.getMessage(), t);
- }
- }
-}
diff --git a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/ReflectiveXmlRpcMetaDataHandler.java b/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/ReflectiveXmlRpcMetaDataHandler.java
deleted file mode 100644
index 75c622b..0000000
--- a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/ReflectiveXmlRpcMetaDataHandler.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package org.xbib.netty.http.xmlrpc.server;
-
-import org.xbib.netty.http.xmlrpc.common.TypeConverterFactory;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-
-import java.lang.reflect.Method;
-
-/** Default implementation of {@link XmlRpcMetaDataHandler}.
- */
-public class ReflectiveXmlRpcMetaDataHandler extends ReflectiveXmlRpcHandler
- implements XmlRpcMetaDataHandler {
- private final String[][] signatures;
- private final String methodHelp;
-
- /** Creates a new instance.
- * @param pMapping The mapping, which creates this handler.
- * @param pClass The class, which has been inspected to create
- * this handler. Typically, this will be the same as
- * pInstance.getClass() . It is used for diagnostic
- * messages only.
- * @param pMethods The method, which will be invoked for
- * executing the handler.
- * @param pSignatures The signature, which will be returned by
- * {@link #getSignatures()}.
- * @param pMethodHelp The help string, which will be returned
- * by {@link #getMethodHelp()}.
- */
- public ReflectiveXmlRpcMetaDataHandler(AbstractReflectiveHandlerMapping pMapping,
- TypeConverterFactory pTypeConverterFactory,
- Class> pClass, RequestProcessorFactoryFactory.RequestProcessorFactory pFactory,
- Method[] pMethods,
- String[][] pSignatures, String pMethodHelp) {
- super(pMapping, pTypeConverterFactory, pClass, pFactory, pMethods);
- signatures = pSignatures;
- methodHelp = pMethodHelp;
- }
-
- public String[][] getSignatures() throws XmlRpcException {
- return signatures;
- }
-
- public String getMethodHelp() throws XmlRpcException {
- return methodHelp;
- }
-}
diff --git a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/RequestProcessorFactoryFactory.java b/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/RequestProcessorFactoryFactory.java
deleted file mode 100644
index 2103ba4..0000000
--- a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/RequestProcessorFactoryFactory.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package org.xbib.netty.http.xmlrpc.server;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequest;
-
-/**
- * The request processor is the object which is actually performing
- * the request. There is nothing magic about the request processor:
- * It may very well be a POJO. The {@link RequestProcessorFactoryFactory}
- * is passed to the {@link AbstractReflectiveHandlerMapping} at startup.
- * The mapping uses this factory to create instances of
- * {@link RequestProcessorFactory}, which are used to initialize
- * the {@link ReflectiveXmlRpcHandler}. The handler in turn uses its
- * factory to create the actual request processor when a request comes
- * in.
- * However, the question arises, when and how the request processor
- * is created and whether it needs request specific initialization?
- * The {@link RequestProcessorFactoryFactory} is an object, which makes
- * that logic pluggable. Unfortunately, we aren't done with a single
- * factory: We even need a factory for factories. The rationale is
- * best explained by looking at the different use cases and how to
- * implement them.
- * The default {@link RequestProcessorFactoryFactory} is the
- * {@link RequestSpecificProcessorFactoryFactory}. It creates a new
- * processor instance for any request. In other words, it allows the
- * request processor to have some state. This is fine, if the request
- * processor is a lightweight object or needs request specific
- * initialization. In this case, the actual request processor is
- * created and invoked when
- * calling {@link RequestProcessorFactory#getRequestProcessor(XmlRpcRequest)}.
- * An alternative implementation is the
- * {@link StatelessProcessorFactoryFactory}, which may be used to
- * create stateless request processors. Stateless request processors
- * are typically heavyweight objects, which have an expensive
- * initialization phase. The processor factory, which is created by
- * {@link #getRequestProcessorFactory(Class pClass)} contains an
- * initialized singleton, which is returned by
- * {@link RequestProcessorFactory#getRequestProcessor(XmlRpcRequest)}.
- * Other alternatives might be a
- * {@link RequestProcessorFactoryFactory}, which maintains a pool
- * of {@link RequestProcessorFactory} instances. The instances are
- * configured by calling
- * {@link RequestProcessorFactory#getRequestProcessor(XmlRpcRequest)}.
- */
-public interface RequestProcessorFactoryFactory {
- /**
- * This is the factory for request processors. This factory is itself
- * created by a call to
- * {@link RequestProcessorFactoryFactory#getRequestProcessorFactory(Class)}.
- */
- interface RequestProcessorFactory {
- /**
- * This method is invoked for any request in order to create and
- * configure the request processor. The returned object is an
- * instance of the class parameter in
- * {@link RequestProcessorFactoryFactory#getRequestProcessorFactory(Class)}.
- */
- Object getRequestProcessor(XmlRpcRequest pRequest) throws XmlRpcException;
- }
-
- /**
- * This method is invoked at startup. It creates a factory for instances of
- * pClass
.
- */
- RequestProcessorFactory getRequestProcessorFactory(Class> pClass) throws XmlRpcException;
-
- /**
- * This is the default implementation of {@link RequestProcessorFactoryFactory}.
- * A new instance is created and initialized for any request. The instance may
- * be configured by overwriting {@link #getRequestProcessor(Class, XmlRpcRequest)}.
- */
- class RequestSpecificProcessorFactoryFactory
- implements RequestProcessorFactoryFactory {
- /**
- * Subclasses may override this method for request specific configuration.
- * A typical subclass will look like this:
- *
- * public class MyRequestProcessorFactoryFactory
- * extends RequestProcessorFactoryFactory {
- * protected Object getRequestProcessor(Class pClass, XmlRpcRequest pRequest) {
- * Object result = super.getRequestProcessor(pClass, pRequest);
- * // Configure the object here
- * ...
- * return result;
- * }
- * }
- *
- * @param pRequest The request object.
- */
- protected Object getRequestProcessor(Class> pClass, XmlRpcRequest pRequest) throws XmlRpcException {
- return Util.newInstance(pClass);
- }
- public RequestProcessorFactory getRequestProcessorFactory(final Class> pClass) {
- return pRequest -> RequestSpecificProcessorFactoryFactory.this.getRequestProcessor(pClass, pRequest);
- }
- }
-
- /**
- * This is an alternative implementation of {@link RequestProcessorFactoryFactory}.
- * It creates stateless request processors, which are able to process concurrent
- * requests without request specific initialization.
- */
- class StatelessProcessorFactoryFactory
- implements RequestProcessorFactoryFactory {
- /**
- * Subclasses may override this method for class specific configuration. Note,
- * that this method will be called at startup only! A typical subclass will
- * look like this:
- *
- * public class MyRequestProcessorFactoryFactory
- * extends StatelessProcessorFactoryFactory {
- * protected Object getRequestProcessor(Class pClass) {
- * Object result = super.getRequestProcessor(pClass);
- * // Configure the object here
- * ...
- * return result;
- * }
- * }
- *
- */
- protected Object getRequestProcessor(Class> pClass) throws XmlRpcException {
- return Util.newInstance(pClass);
- }
-
- @Override
- public RequestProcessorFactory getRequestProcessorFactory(Class> pClass) {
- return pRequest -> getRequestProcessor(pClass);
- }
- }
-}
diff --git a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/ServerHttpConnection.java b/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/ServerHttpConnection.java
deleted file mode 100644
index c191e5c..0000000
--- a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/ServerHttpConnection.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.xbib.netty.http.xmlrpc.server;
-
-import org.xbib.netty.http.xmlrpc.common.ServerStreamConnection;
-
-/** Interface of a {@link ServerStreamConnection} for HTTP
- * response transport.
- */
-public interface ServerHttpConnection extends ServerStreamConnection {
- /** Sets a response header.
- */
- void setResponseHeader(String pKey, String pValue);
- /** Sets the content length.
- */
- void setContentLength(int pContentLength);
-}
diff --git a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/Util.java b/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/Util.java
deleted file mode 100644
index bc6ee05..0000000
--- a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/Util.java
+++ /dev/null
@@ -1,200 +0,0 @@
-package org.xbib.netty.http.xmlrpc.server;
-
-import java.io.Serializable;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import org.w3c.dom.Node;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-
-/** Utility class, which provides services to meta data
- * handlers and handler mappings.
- */
-public class Util {
- /** This field should solve the problem, that we do not
- * want to depend on the presence of JAXB. However, if
- * it is available, we want to support it.
- */
- private static final Class> jaxbElementClass;
- static {
- Class> c;
- try {
- c = Class.forName("javax.xml.bind.Element");
- } catch (ClassNotFoundException e) {
- c = null;
- }
- jaxbElementClass = c;
- }
-
- /** Returns a signature for the given return type or
- * parameter class.
- * @param pType The class for which a signature is being
- * queried.
- * @return Signature, if known, or null.
- */
- public static String getSignatureType(Class> pType) {
- if (pType == Integer.TYPE || pType == Integer.class)
- return "int";
- if (pType == Double.TYPE || pType == Double.class)
- return "double";
- if (pType == Boolean.TYPE || pType == Boolean.class)
- return "boolean";
- if (pType == String.class)
- return "string";
- if (Object[].class.isAssignableFrom(pType)
- || List.class.isAssignableFrom(pType))
- return "array";
- if (Map.class.isAssignableFrom(pType))
- return "struct";
- if (Date.class.isAssignableFrom(pType)
- || Calendar.class.isAssignableFrom(pType))
- return "dateTime.iso8601";
- if (pType == byte[].class)
- return "base64";
-
- // extension types
- if (pType == void.class)
- return "ex:nil";
- if (pType == Byte.TYPE || pType == Byte.class)
- return "ex:i1";
- if (pType == Short.TYPE || pType == Short.class)
- return "ex:i2";
- if (pType == Long.TYPE || pType == Long.class)
- return "ex:i8";
- if (pType == Float.TYPE || pType == Float.class)
- return "ex:float";
- if (Node.class.isAssignableFrom(pType))
- return "ex:node";
- if (jaxbElementClass != null
- && jaxbElementClass.isAssignableFrom(pType)) {
- return "ex:jaxbElement";
- }
- if (Serializable.class.isAssignableFrom(pType))
- return "base64";
-
- // give up
- return null;
- }
-
- /** Returns a signature for the given methods.
- * @param pMethods Methods, for which a signature is
- * being queried.
- * @return Signature string, or null, if no signature
- * is available.
- */
- public static String[][] getSignature(Method[] pMethods) {
- final List result = new ArrayList<>();
- for (Method pMethod : pMethods) {
- String[] sig = getSignature(pMethod);
- if (sig != null) {
- result.add(sig);
- }
- }
- return result.toArray(new String[result.size()][]);
- }
-
- /** Returns a signature for the given methods.
- * @param pMethod Method, for which a signature is
- * being queried.
- * @return Signature string, or null, if no signature
- * is available.
- */
- public static String[] getSignature(Method pMethod) {
- Class>[] paramClasses = pMethod.getParameterTypes();
- String[] sig = new String[paramClasses.length + 1];
- String s = getSignatureType(pMethod.getReturnType());
- if (s == null) {
- return null;
- }
- sig[0] = s;
- for (int i = 0; i < paramClasses.length; i++) {
- s = getSignatureType(paramClasses[i]);
- if (s == null) {
- return null;
- }
- sig[i+1] = s;
- }
- return sig;
- }
-
- /** Returns a help string for the given method, which
- * is applied to the given class.
- */
- public static String getMethodHelp(Class> pClass, Method[] pMethods) {
- final List result = new ArrayList<>();
- for (Method pMethod : pMethods) {
- String help = getMethodHelp(pClass, pMethod);
- result.add(help);
- }
- switch (result.size()) {
- case 0:
- return null;
- case 1:
- return result.get(0);
- default:
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < result.size(); i++) {
- sb.append(i+1);
- sb.append(": ");
- sb.append(result.get(i));
- sb.append("\n");
- }
- return sb.toString();
- }
- }
-
- /** Returns a help string for the given method, which
- * is applied to the given class.
- */
- public static String getMethodHelp(Class> pClass, Method pMethod) {
- StringBuilder sb = new StringBuilder();
- sb.append("Invokes the method ");
- sb.append(pClass.getName());
- sb.append(".");
- sb.append(pMethod.getName());
- sb.append("(");
- Class>[] paramClasses = pMethod.getParameterTypes();
- for (int i = 0; i < paramClasses.length; i++) {
- if (i > 0) {
- sb.append(", ");
- }
- sb.append(paramClasses[i].getName());
- }
- sb.append(").");
- return sb.toString();
- }
-
- /** Returns a signature for the given parameter set. This is used
- * in error messages.
- */
- public static String getSignature(Object[] args) {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < args.length; i++) {
- if (i > 0) {
- sb.append(", ");
- }
- if (args[i] == null) {
- sb.append("null");
- } else {
- sb.append(args[i].getClass().getName());
- }
- }
- return sb.toString();
- }
-
- /**
- * Creates a new instance of pClass
.
- */
- public static Object newInstance(Class> pClass) throws XmlRpcException {
- try {
- return pClass.getConstructor().newInstance();
- } catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
- throw new XmlRpcException("Failed to instantiate class " + pClass.getName(), e);
- }
- }
-}
diff --git a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcErrorLogger.java b/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcErrorLogger.java
deleted file mode 100644
index e9ca631..0000000
--- a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcErrorLogger.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.xbib.netty.http.xmlrpc.server;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Instances of this class can be used to customize the servers
- * error logging.
- */
-public class XmlRpcErrorLogger {
-
- private static final Logger log = Logger.getLogger(XmlRpcErrorLogger.class.getName());
-
- /**
- * Called to log the given error.
- */
- public void log(String pMessage, Throwable pThrowable) {
- log.log(Level.INFO, pMessage, pThrowable);
- }
-
- /**
- * Called to log the given error message.
- */
- public void log(String pMessage) {
- log.log(Level.INFO, pMessage);
- }
-}
diff --git a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcHandlerMapping.java b/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcHandlerMapping.java
deleted file mode 100644
index e3a5002..0000000
--- a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcHandlerMapping.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.xbib.netty.http.xmlrpc.server;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcHandler;
-
-/** Maps from a handler name to a handler object.
- */
-public interface XmlRpcHandlerMapping {
- /**
- * Return the handler for the specified handler name.
- * @param handlerName The name of the handler to retrieve.
- * @return Object The desired handler. Never null, an exception
- * is thrown if no such handler is available.
- * @throws XmlRpcNoSuchHandlerException The handler is not available.
- * @throws XmlRpcException An internal error occurred.
- */
- XmlRpcHandler getHandler(String handlerName)
- throws XmlRpcNoSuchHandlerException, XmlRpcException;
-}
diff --git a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcHttpServer.java b/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcHttpServer.java
deleted file mode 100644
index 87e5e61..0000000
--- a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcHttpServer.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.xbib.netty.http.xmlrpc.server;
-
-import org.xbib.netty.http.xmlrpc.common.ServerStreamConnection;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamRequestConfig;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * Abstract extension of {@link XmlRpcStreamServer} for deriving
- * HTTP servers.
- */
-public abstract class XmlRpcHttpServer extends XmlRpcStreamServer {
- protected abstract void setResponseHeader(ServerStreamConnection pConnection, String pHeader, String pValue);
-
- protected OutputStream getOutputStream(ServerStreamConnection pConnection, XmlRpcStreamRequestConfig pConfig, OutputStream pStream) throws IOException {
- if (pConfig.isEnabledForExtensions() && pConfig.isGzipRequesting()) {
- setResponseHeader(pConnection, "Content-Encoding", "gzip");
- }
- return super.getOutputStream(pConnection, pConfig, pStream);
- }
-}
diff --git a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcHttpServerConfig.java b/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcHttpServerConfig.java
deleted file mode 100644
index 1b62e7d..0000000
--- a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcHttpServerConfig.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.xbib.netty.http.xmlrpc.server;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcHttpConfig;
-
-/**
- * HTTP servers configuration.
- */
-public interface XmlRpcHttpServerConfig extends XmlRpcServerConfig, XmlRpcHttpConfig {
- /** Returns, whether HTTP keepalive is being enabled.
- * @return True, if keepalive is enabled, false otherwise.
- */
- boolean isKeepAliveEnabled();
-
- /** Returns, whether the server may create a "faultCause" element in an error
- * response. Note, that this may be a security issue!
- */
- boolean isEnabledForExceptions();
-}
diff --git a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcListableHandlerMapping.java b/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcListableHandlerMapping.java
deleted file mode 100644
index caa5032..0000000
--- a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcListableHandlerMapping.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package org.xbib.netty.http.xmlrpc.server;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcHandler;
-
-/**
- * A listable handler mapping is able to provide support for
- * XML-RPC meta data, as specified
- *
- * here .
- *
- * @see
- * Specification of XML-RPC introspection
- */
-public interface XmlRpcListableHandlerMapping extends XmlRpcHandlerMapping {
- /** This method implements the introspection method
- * system.listMethods
, which is specified
- * as follows:
- *
- * This method may be used to enumerate the methods implemented
- * by the XML-RPC server.
- * The system.listMethods
method requires no
- * parameters. It returns an array of strings, each of which is
- * the name of a method implemented by the server.
- *
- * Note, that the specification doesn't require that the list
- * must be exhaustive. We conclude, that a valid method
- * "handlerName" doesn't need to be in the list. For example,
- * a handler, which implements {@link XmlRpcHandler}, but not
- * {@link XmlRpcMetaDataHandler}, should possibly excluded:
- * Otherwise, the listable handler mapping could not provide
- * meaningful replies to system.methodSignature
,
- * and system.methodHelp
.
- *
- * @throws XmlRpcException An internal error occurred.
- */
- String[] getListMethods() throws XmlRpcException;
-
- /** This method implements the introspection method
- * system.methodSignature
, which is specified
- * as follows:
- *
- * This method takes one parameter, the name of a method
- * implemented by the XML-RPC server. It returns an array
- * of possible signatures for this method. A signature is
- * an array of types. The first of these types is the return
- * type of the method, the rest are parameters.
- * Multiple signatures (ie. overloading) are permitted:
- * this is the reason that an array of signatures are returned
- * by this method.
- * Signatures themselves are restricted to the top level
- * parameters expected by a method. For instance if a method
- * expects one array of structs as a parameter, and it returns
- * a string, its signature is simply "string, array". If it
- * expects three integers, its signature is
- * "string, int, int, int".
- * If no signature is defined for the method, a none-array
- * value is returned. Therefore this is the way to test for a
- * non-signature, if $resp below is the response object from
- * a method call to system.methodSignature:
- *
- * $v=$resp->value();
- * if ($v->kindOf()!="array") {
- * // then the method did not have a signature defined
- * }
- *
- * See the introspect.php demo included in this distribution
- * for an example of using this method.
- *
- * @see XmlRpcMetaDataHandler#getSignatures()
- */
- String[][] getMethodSignature(String pHandlerName) throws XmlRpcException;
-
- /** This method implements the introspection method
- * system.methodSignature
, which is specified
- * as follows:
- *
- * This method takes one parameter, the name of a
- * method implemented by the XML-RPC server. It
- * returns a documentation string describing the
- * use of that method. If no such string is available,
- * an empty string is returned.
- * The documentation string may contain HTML markup.
- *
- */
- String getMethodHelp(String pHandlerName) throws XmlRpcException;
-}
diff --git a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcLocalStreamServer.java b/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcLocalStreamServer.java
deleted file mode 100644
index 6072e2e..0000000
--- a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcLocalStreamServer.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.xbib.netty.http.xmlrpc.server;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequest;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequestProcessor;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequestProcessorFactory;
-
-/**
- * Server part of a local stream transport.
- */
-public class XmlRpcLocalStreamServer extends XmlRpcStreamServer {
- @Override
- public Object execute(XmlRpcRequest pRequest) throws XmlRpcException {
- XmlRpcRequestProcessor server = ((XmlRpcRequestProcessorFactory) pRequest.getConfig()).getXmlRpcServer();
- return server.execute(pRequest);
- }
-}
\ No newline at end of file
diff --git a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcMetaDataHandler.java b/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcMetaDataHandler.java
deleted file mode 100644
index ba8505d..0000000
--- a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcMetaDataHandler.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.xbib.netty.http.xmlrpc.server;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcHandler;
-
-/** A metadata handler is able to provide metadata about
- * itself, as specified
- *
- * here .
- *
- * @see
- * Specification of XML-RPC introspection
- */
-public interface XmlRpcMetaDataHandler extends XmlRpcHandler {
- /** This method may be used to implement
- * {@link XmlRpcListableHandlerMapping#getMethodSignature(String)}.
- * Typically, the handler mapping will pick up the
- * matching handler, invoke its method
- * {@link #getSignatures()}, and return the result.
- * Method handlers, which are created by the
- * {@link AbstractReflectiveHandlerMapping}, will typically
- * return a single signature only.
- * @return An array of arrays. Any element in the outer
- * array is a signature. The elements in the inner array
- * are being concatenated with commas. The inner arrays
- * first element is the return type, followed by the
- * parameter types.
- */
- String[][] getSignatures() throws XmlRpcException;
-
- /** This method may be used to implement
- * {@link XmlRpcListableHandlerMapping#getMethodHelp(String)}.
- * Typically, the handler mapping will pick up the
- * matching handler, invoke its method
- * {@link #getMethodHelp()}, and return the result.
- */
- String getMethodHelp() throws XmlRpcException;
-}
diff --git a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcNoSuchHandlerException.java b/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcNoSuchHandlerException.java
deleted file mode 100644
index 4677454..0000000
--- a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcNoSuchHandlerException.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.xbib.netty.http.xmlrpc.server;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-
-/**
- * This exception is thrown, if an unknown handler is called.
- */
-public class XmlRpcNoSuchHandlerException extends XmlRpcException {
- private static final long serialVersionUID = 3257002138218344501L;
-
- /** Creates a new instance with the given message.
- * @param pMessage The error details.
- */
- public XmlRpcNoSuchHandlerException(String pMessage) {
- super(0, pMessage);
- }
-}
diff --git a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcServer.java b/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcServer.java
deleted file mode 100644
index d270062..0000000
--- a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcServer.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.xbib.netty.http.xmlrpc.server;
-
-import org.xbib.netty.http.xmlrpc.common.TypeConverterFactory;
-import org.xbib.netty.http.xmlrpc.common.TypeConverterFactoryImpl;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcConfig;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcController;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequest;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequestProcessor;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcWorker;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcWorkerFactory;
-
-/** A multithreaded, reusable XML-RPC server object. The name may
- * be misleading because this does not open any server sockets.
- * Instead it is fed by passing instances of
- * {@link XmlRpcRequest} from
- * a transport.
- */
-public class XmlRpcServer extends XmlRpcController
- implements XmlRpcRequestProcessor {
- private XmlRpcHandlerMapping handlerMapping;
- private TypeConverterFactory typeConverterFactory = new TypeConverterFactoryImpl();
- private XmlRpcServerConfig config = new XmlRpcServerConfigImpl();
-
- protected XmlRpcWorkerFactory getDefaultXmlRpcWorkerFactory() {
- return new XmlRpcServerWorkerFactory(this);
- }
-
- /** Sets the servers {@link TypeConverterFactory}.
- */
- public void setTypeConverterFactory(TypeConverterFactory pFactory) {
- typeConverterFactory = pFactory;
- }
- public TypeConverterFactory getTypeConverterFactory() {
- return typeConverterFactory;
- }
-
- /** Sets the servers configuration.
- * @param pConfig The new server configuration.
- */
- public void setConfig(XmlRpcServerConfig pConfig) { config = pConfig; }
- public XmlRpcConfig getConfig() { return config; }
-
- /** Sets the servers handler mapping.
- * @param pMapping The servers handler mapping.
- */
- public void setHandlerMapping(XmlRpcHandlerMapping pMapping) {
- handlerMapping = pMapping;
- }
-
- /** Returns the servers handler mapping.
- * @return The servers handler mapping.
- */
- public XmlRpcHandlerMapping getHandlerMapping() {
- return handlerMapping;
- }
-
- /** Performs the given request.
- * @param pRequest The request being executed.
- * @return The result object.
- * @throws XmlRpcException The request failed.
- */
- public Object execute(XmlRpcRequest pRequest) throws XmlRpcException {
- final XmlRpcWorkerFactory factory = getWorkerFactory();
- final XmlRpcWorker worker = factory.getWorker();
- try {
- return worker.execute(pRequest);
- } finally {
- factory.releaseWorker(worker);
- }
- }
-}
diff --git a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcServerConfig.java b/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcServerConfig.java
deleted file mode 100644
index 61d10bf..0000000
--- a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcServerConfig.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package org.xbib.netty.http.xmlrpc.server;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcConfig;
-
-/**
- * Server specific extension of {@link XmlRpcConfig}.
- */
-public interface XmlRpcServerConfig extends XmlRpcConfig {
-}
diff --git a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcServerConfigImpl.java b/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcServerConfigImpl.java
deleted file mode 100644
index a86bbcb..0000000
--- a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcServerConfigImpl.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.xbib.netty.http.xmlrpc.server;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcConfigImpl;
-
-/**
- * Default implementation of {@link XmlRpcServerConfig}.
- */
-public class XmlRpcServerConfigImpl extends XmlRpcConfigImpl
- implements XmlRpcServerConfig, XmlRpcHttpServerConfig {
- private boolean isKeepAliveEnabled;
- private boolean isEnabledForExceptions;
-
- /** Sets, whether HTTP keepalive is enabled for this server.
- * @param pKeepAliveEnabled True, if keepalive is enabled. False otherwise.
- */
- public void setKeepAliveEnabled(boolean pKeepAliveEnabled) {
- isKeepAliveEnabled = pKeepAliveEnabled;
- }
-
- public boolean isKeepAliveEnabled() { return isKeepAliveEnabled; }
-
- /** Sets, whether the server may create a "faultCause" element in an error
- * response. Note, that this may be a security issue!
- */
- public void setEnabledForExceptions(boolean pEnabledForExceptions) {
- isEnabledForExceptions = pEnabledForExceptions;
- }
-
- public boolean isEnabledForExceptions() { return isEnabledForExceptions; }
-}
diff --git a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcServerWorker.java b/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcServerWorker.java
deleted file mode 100644
index dde2065..0000000
--- a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcServerWorker.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.xbib.netty.http.xmlrpc.server;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcController;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcHandler;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequest;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcWorker;
-
-/** Server specific implementation of {@link XmlRpcWorker}.
- */
-public class XmlRpcServerWorker implements XmlRpcWorker {
- private final XmlRpcServerWorkerFactory factory;
-
- /** Creates a new instance.
- * @param pFactory The factory creating the worker.
- */
- public XmlRpcServerWorker(XmlRpcServerWorkerFactory pFactory) {
- factory = pFactory;
- }
-
- public XmlRpcController getController() { return factory.getController(); }
-
- public Object execute(XmlRpcRequest pRequest) throws XmlRpcException {
- XmlRpcServer server = (XmlRpcServer) getController();
- XmlRpcHandlerMapping mapping = server.getHandlerMapping();
- XmlRpcHandler handler = mapping.getHandler(pRequest.getMethodName());
- return handler.execute(pRequest);
- }
-}
diff --git a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcServerWorkerFactory.java b/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcServerWorkerFactory.java
deleted file mode 100644
index b1dfda5..0000000
--- a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcServerWorkerFactory.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.xbib.netty.http.xmlrpc.server;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcWorker;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcWorkerFactory;
-
-/** Server specific worker factory.
- */
-public class XmlRpcServerWorkerFactory extends XmlRpcWorkerFactory {
- /** Creates a new factory with the given controller.
- * @param pServer The factory controller.
- */
- public XmlRpcServerWorkerFactory(XmlRpcServer pServer) {
- super(pServer);
- }
-
- protected XmlRpcWorker newWorker() {
- return new XmlRpcServerWorker(this);
- }
-}
diff --git a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcStreamServer.java b/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcStreamServer.java
deleted file mode 100644
index 433080e..0000000
--- a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcStreamServer.java
+++ /dev/null
@@ -1,282 +0,0 @@
-package org.xbib.netty.http.xmlrpc.server;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.List;
-import java.util.zip.GZIPInputStream;
-import java.util.zip.GZIPOutputStream;
-
-import org.xbib.netty.http.xmlrpc.common.ServerStreamConnection;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequest;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcRequestConfig;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamRequestConfig;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamRequestProcessor;
-import org.xbib.netty.http.xmlrpc.common.parser.XmlRpcRequestParser;
-import org.xbib.netty.http.xmlrpc.common.serializer.DefaultXMLWriterFactory;
-import org.xbib.netty.http.xmlrpc.common.serializer.XmlRpcWriter;
-import org.xbib.netty.http.xmlrpc.common.serializer.XmlWriterFactory;
-import org.xbib.netty.http.xmlrpc.common.util.SAXParsers;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-
-
-/** Extension of {@link XmlRpcServer} with support for reading
- * requests from a stream and writing the response to another
- * stream.
- */
-public abstract class XmlRpcStreamServer extends XmlRpcServer
- implements XmlRpcStreamRequestProcessor {
-
- private XmlWriterFactory writerFactory = new DefaultXMLWriterFactory();
-
- private static final XmlRpcErrorLogger theErrorLogger = new XmlRpcErrorLogger();
-
- private XmlRpcErrorLogger errorLogger = theErrorLogger;
-
- protected XmlRpcRequest getRequest(final XmlRpcStreamRequestConfig pConfig,
- InputStream pStream) throws XmlRpcException {
- final XmlRpcRequestParser parser = new XmlRpcRequestParser(pConfig, getTypeFactory());
- final XMLReader xr = SAXParsers.newXMLReader();
- xr.setContentHandler(parser);
- try {
- xr.parse(new InputSource(pStream));
- } catch (SAXException e) {
- Exception ex = e.getException();
- if (ex instanceof XmlRpcException) {
- throw (XmlRpcException) ex;
- }
- throw new XmlRpcException("Failed to parse XML-RPC request: " + e.getMessage(), e);
- } catch (IOException e) {
- throw new XmlRpcException("Failed to read XML-RPC request: " + e.getMessage(), e);
- }
- final List params = parser.getParams();
- return new XmlRpcRequest(){
-
- @Override
- public XmlRpcRequestConfig getConfig() { return pConfig; }
-
- @Override
- public String getMethodName() { return parser.getMethodName(); }
-
- @Override
- public int getParameterCount() { return params == null ? 0 : params.size(); }
-
- @Override
- public Object getParameter(int pIndex) { return params.get(pIndex); }
- };
- }
-
- protected XmlRpcWriter getXmlRpcWriter(XmlRpcStreamRequestConfig pConfig,
- OutputStream pStream)
- throws XmlRpcException {
- ContentHandler w = getXMLWriterFactory().getXmlWriter(pConfig, pStream);
- return new XmlRpcWriter(pConfig, w, getTypeFactory());
- }
-
- protected void writeResponse(XmlRpcStreamRequestConfig pConfig, OutputStream pStream,
- Object pResult) throws XmlRpcException {
- try {
- getXmlRpcWriter(pConfig, pStream).write(pConfig, pResult);
- } catch (SAXException e) {
- throw new XmlRpcException("Failed to write XML-RPC response: " + e.getMessage(), e);
- }
- }
-
- /**
- * This method allows to convert the error into another error. For example, this
- * may be an error, which could be deserialized by the client.
- */
- protected Throwable convertThrowable(Throwable pError) {
- return pError;
- }
-
- protected void writeError(XmlRpcStreamRequestConfig pConfig, OutputStream pStream,
- Throwable pError)
- throws XmlRpcException {
- final Throwable error = convertThrowable(pError);
- final int code;
- final String message;
- if (error instanceof XmlRpcException) {
- XmlRpcException ex = (XmlRpcException) error;
- code = ex.code;
- } else {
- code = 0;
- }
- message = error.getMessage();
- try {
- getXmlRpcWriter(pConfig, pStream).write(pConfig, code, message, error);
- } catch (SAXException e) {
- throw new XmlRpcException("Failed to write XML-RPC response: " + e.getMessage(), e);
- }
- }
-
- /** Sets the XML Writer factory.
- * @param pFactory The XML Writer factory.
- */
- public void setXMLWriterFactory(XmlWriterFactory pFactory) {
- writerFactory = pFactory;
- }
-
- /** Returns the XML Writer factory.
- * @return The XML Writer factory.
- */
- public XmlWriterFactory getXMLWriterFactory() {
- return writerFactory;
- }
-
- protected InputStream getInputStream(XmlRpcStreamRequestConfig pConfig,
- ServerStreamConnection pConnection) throws IOException {
- InputStream istream = pConnection.newInputStream();
- if (pConfig.isEnabledForExtensions() && pConfig.isGzipCompressing()) {
- istream = new GZIPInputStream(istream);
- }
- return istream;
- }
-
- /** Called to prepare the output stream. Typically used for enabling
- * compression, or similar filters.
- * @param pConnection The connection object.
- */
- protected OutputStream getOutputStream(ServerStreamConnection pConnection,
- XmlRpcStreamRequestConfig pConfig, OutputStream pStream) throws IOException {
- if (pConfig.isEnabledForExtensions() && pConfig.isGzipRequesting()) {
- return new GZIPOutputStream(pStream);
- } else {
- return pStream;
- }
- }
-
- /** Called to prepare the output stream, if content length is
- * required.
- * @param pConfig The configuration object.
- * @param pSize The requests size.
- */
- protected OutputStream getOutputStream(XmlRpcStreamRequestConfig pConfig,
- ServerStreamConnection pConnection,
- int pSize) throws IOException {
- return pConnection.newOutputStream();
- }
-
- /** Returns, whether the requests content length is required.
- * @param pConfig The configuration object.
- */
- protected boolean isContentLengthRequired(XmlRpcStreamRequestConfig pConfig) {
- return false;
- }
-
- /**
- * Processes a "connection". The "connection" is an opaque object, which is
- * being handled by the subclasses.
- * @param pConfig The request configuration.
- * @param pConnection The "connection" being processed.
- * @throws XmlRpcException Processing the request failed.
- */
- @Override
- public void execute(XmlRpcStreamRequestConfig pConfig, ServerStreamConnection pConnection)
- throws XmlRpcException {
- try {
- Object result;
- Throwable error;
- InputStream istream = null;
- try {
- istream = getInputStream(pConfig, pConnection);
- XmlRpcRequest request = getRequest(pConfig, istream);
- result = execute(request);
- istream.close();
- istream = null;
- error = null;
- } catch (Throwable t) {
- logError(t);
- result = null;
- error = t;
- } finally {
- if (istream != null) {
- try {
- istream.close();
- } catch (Throwable ignore) {
- //
- }
- }
- }
- boolean contentLengthRequired = isContentLengthRequired(pConfig);
- ByteArrayOutputStream baos;
- OutputStream ostream;
- if (contentLengthRequired) {
- baos = new ByteArrayOutputStream();
- ostream = baos;
- } else {
- baos = null;
- ostream = pConnection.newOutputStream();
- }
- ostream = getOutputStream(pConnection, pConfig, ostream);
- try {
- if (error == null) {
- writeResponse(pConfig, ostream, result);
- } else {
- writeError(pConfig, ostream, error);
- }
- ostream.close();
- ostream = null;
- } finally {
- if (ostream != null) {
- try {
- ostream.close();
- } catch (Throwable ignore) {
-
- }
- }
- }
- if (baos != null) {
- OutputStream dest = getOutputStream(pConfig, pConnection, baos.size());
- try {
- baos.writeTo(dest);
- dest.close();
- dest = null;
- } finally {
- if (dest != null) {
- try {
- dest.close();
- } catch (Throwable ignore) {
-
- }
- }
- }
- }
- pConnection.close();
- pConnection = null;
- } catch (IOException e) {
- throw new XmlRpcException("I/O error while processing request: " + e.getMessage(), e);
- } finally {
- if (pConnection != null) {
- try {
- pConnection.close(); } catch (Throwable ignore) {
-
- }
- }
- }
- }
-
- protected void logError(Throwable t) {
- final String msg = t.getMessage() == null ? t.getClass().getName() : t.getMessage();
- errorLogger.log(msg, t);
- }
-
- /**
- * Returns the error logger.
- */
- public XmlRpcErrorLogger getErrorLogger() {
- return errorLogger;
- }
-
- /**
- * Sets the error logger.
- */
- public void setErrorLogger(XmlRpcErrorLogger pErrorLogger) {
- errorLogger = pErrorLogger;
- }
-}
diff --git a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcSystemImpl.java b/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcSystemImpl.java
deleted file mode 100644
index 9805406..0000000
--- a/netty-http-xmlrpc-server/src/main/java/org/xbib/netty/http/xmlrpc/server/XmlRpcSystemImpl.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package org.xbib.netty.http.xmlrpc.server;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-
-/**
- * This class implements the various "system" calls,
- * as specifies by {@link XmlRpcListableHandlerMapping}.
- * Suggested use is to create an instance and add it to
- * the handler mapping with the "system" prefix.
- */
-public class XmlRpcSystemImpl {
- private XmlRpcListableHandlerMapping mapping;
-
- /** Creates a new instance, which provides meta data
- * for the given handler mappings methods.
- */
- public XmlRpcSystemImpl(XmlRpcListableHandlerMapping pMapping) {
- mapping = pMapping;
- }
-
- /** Implements the "system.methodSignature" call.
- * @see XmlRpcListableHandlerMapping#getMethodSignature(String)
- */
- public String[][] methodSignature(String methodName) throws XmlRpcException {
- return mapping.getMethodSignature(methodName);
- }
-
- /** Implements the "system.methodHelp" call.
- * @see XmlRpcListableHandlerMapping#getMethodHelp(String)
- */
- public String methodHelp(String methodName) throws XmlRpcException {
- return mapping.getMethodHelp(methodName);
- }
-
- /** Implements the "system.listMethods" call.
- * @see XmlRpcListableHandlerMapping#getListMethods()
- */
- public String[] listMethods() throws XmlRpcException {
- return mapping.getListMethods();
- }
-
- /**
- * Adds an instance of this class to the given handler
- * mapping.
- */
- public static void addSystemHandler(final PropertyHandlerMapping pMapping)
- throws XmlRpcException {
- final RequestProcessorFactoryFactory factory = pMapping.getRequestProcessorFactoryFactory();
- final XmlRpcSystemImpl systemHandler = new XmlRpcSystemImpl(pMapping);
- pMapping.setRequestProcessorFactoryFactory(pClass -> {
- if (XmlRpcSystemImpl.class.equals(pClass)) {
- return request -> systemHandler;
- } else {
- return factory.getRequestProcessorFactory(pClass);
- }
- });
- pMapping.addHandler("system", XmlRpcSystemImpl.class);
- }
-}
diff --git a/netty-http-xmlrpc-servlet/build.gradle b/netty-http-xmlrpc-servlet/build.gradle
deleted file mode 100644
index f941b7f..0000000
--- a/netty-http-xmlrpc-servlet/build.gradle
+++ /dev/null
@@ -1,4 +0,0 @@
-dependencies {
- compile project(":netty-http-xmlrpc-server")
- compileOnly group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
-}
\ No newline at end of file
diff --git a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/Connection.java b/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/Connection.java
deleted file mode 100644
index 0e7023a..0000000
--- a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/Connection.java
+++ /dev/null
@@ -1,422 +0,0 @@
-package org.xbib.netty.http.xmlrpc.servlet;
-
-import org.xbib.netty.http.xmlrpc.common.ServerStreamConnection;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcHttpRequestConfig;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcNotAuthorizedException;
-import org.xbib.netty.http.xmlrpc.common.util.HttpUtil;
-import org.xbib.netty.http.xmlrpc.common.util.LimitedInputStream;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcHttpServerConfig;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcStreamServer;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.Socket;
-import java.net.SocketException;
-import java.nio.charset.StandardCharsets;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Handler for a single clients connection. This implementation
- * is able to do HTTP keepalive. In other words, it can serve
- * multiple requests via a single, physical connection.
- */
-public class Connection implements ThreadPool.InterruptableTask, ServerStreamConnection {
-
- private static final Logger logger = Logger.getLogger(Connection.class.getName());
-
- private static final byte[] ctype = toHTTPBytes("Content-Type: text/xml\r\n");
-
- private static final byte[] clength = toHTTPBytes("Content-Length: ");
-
- private static final byte[] newline = toHTTPBytes("\r\n");
-
- private static final byte[] doubleNewline = toHTTPBytes("\r\n\r\n");
-
- private static final byte[] conkeep = toHTTPBytes("Connection: Keep-Alive\r\n");
-
- private static final byte[] conclose = toHTTPBytes("Connection: close\r\n");
-
- private static final byte[] ok = toHTTPBytes(" 200 OK\r\n");
-
- private static final byte[] serverName = toHTTPBytes("Server: Apache XML-RPC 1.0\r\n");
-
- private static final byte[] wwwAuthenticate = toHTTPBytes("WWW-Authenticate: Basic realm=XML-RPC\r\n");
-
- private static abstract class RequestException extends IOException {
- private static final long serialVersionUID = 2113732921468653309L;
- private final RequestData requestData;
-
- RequestException(RequestData pData, String pMessage) {
- super(pMessage);
- requestData = pData;
- }
-
- RequestData getRequestData() { return requestData; }
- }
-
- private static class BadEncodingException extends RequestException {
- private static final long serialVersionUID = -2674424938251521248L;
- BadEncodingException(RequestData pData, String pTransferEncoding) {
- super(pData, pTransferEncoding);
- }
- }
-
- private static class BadRequestException extends RequestException {
- private static final long serialVersionUID = 3257848779234554934L;
- BadRequestException(RequestData pData, String pTransferEncoding) {
- super(pData, pTransferEncoding);
- }
- }
-
- /** Returns the US-ASCII encoded byte representation of text for
- * HTTP use (as per section 2.2 of RFC 2068).
- */
- private static byte[] toHTTPBytes(String text) {
- return text.getBytes(StandardCharsets.US_ASCII);
- }
-
- private final WebServer webServer;
-
- private final Socket socket;
-
- private final InputStream input;
-
- private final OutputStream output;
-
- private final XmlRpcStreamServer server;
-
- private byte[] buffer;
-
- private Map headers;
-
- private RequestData requestData;
-
- private boolean shuttingDown;
-
- private boolean firstByte;
-
- /** Creates a new webserver connection on the given socket.
- * @param pWebServer The webserver maintaining this connection.
- * @param pServer The server being used to execute requests.
- * @param pSocket The server socket to handle; the Connection
- * is responsible for closing this socket.
- * @throws IOException
- */
- public Connection(WebServer pWebServer, XmlRpcStreamServer pServer, Socket pSocket)
- throws IOException {
- webServer = pWebServer;
- server = pServer;
- socket = pSocket;
- input = new BufferedInputStream(socket.getInputStream()){
- /** It may happen, that the XML parser invokes close().
- * Closing the input stream must not occur, because
- * that would close the whole socket. So we suppress it.
- */
- @Override
- public void close() {
- }
- };
- output = new BufferedOutputStream(socket.getOutputStream());
- headers = new LinkedHashMap<>();
- }
-
- /** Returns the connections request configuration by
- * merging the HTTP request headers and the servers configuration.
- * @return The connections request configuration.
- * @throws IOException Reading the request headers failed.
- */
- private RequestData getRequestConfig() throws IOException {
- requestData = new RequestData(this);
- headers.clear();
- firstByte = true;
- XmlRpcHttpServerConfig serverConfig = (XmlRpcHttpServerConfig) server.getConfig();
- requestData.setBasicEncoding(serverConfig.getBasicEncoding());
- requestData.setContentLengthOptional(serverConfig.isContentLengthOptional());
- requestData.setEnabledForExtensions(serverConfig.isEnabledForExtensions());
- requestData.setEnabledForExceptions(serverConfig.isEnabledForExceptions());
- String line = readLine();
- if (line == null && firstByte) {
- return null;
- }
- if (line != null && line.length() == 0) {
- line = readLine();
- if (line == null || line.length() == 0) {
- return null;
- }
- }
- if (line != null) {
- StringTokenizer tokens = new StringTokenizer(line);
- String method = tokens.nextToken();
- if (!"POST".equalsIgnoreCase(method)) {
- throw new BadRequestException(requestData, method);
- }
- requestData.setMethod(method);
- tokens.nextToken(); // Skip URI
- String httpVersion = tokens.nextToken();
- requestData.setHttpVersion(httpVersion);
- requestData.setKeepAlive(serverConfig.isKeepAliveEnabled()
- && WebServer.HTTP_11.equals(httpVersion));
- }
- do {
- line = readLine();
- if (line != null) {
- String lineLower = line.toLowerCase();
- if (lineLower.startsWith("content-length:")) {
- String cLength = line.substring("content-length:".length());
- requestData.setContentLength(Integer.parseInt(cLength.trim()));
- } else if (lineLower.startsWith("connection:")) {
- requestData.setKeepAlive(serverConfig.isKeepAliveEnabled()
- && lineLower.contains("keep-alive"));
- } else if (lineLower.startsWith("authorization:")) {
- String credentials = line.substring("authorization:".length());
- HttpUtil.parseAuthorization(requestData, credentials);
- } else if (lineLower.startsWith("transfer-encoding:")) {
- String transferEncoding = line.substring("transfer-encoding:".length());
- String nonIdentityEncoding = HttpUtil.getNonIdentityTransferEncoding(transferEncoding);
- if (nonIdentityEncoding != null) {
- throw new BadEncodingException(requestData, nonIdentityEncoding);
- }
- }
- }
- }
- while (line != null && line.length() != 0);
- return requestData;
- }
-
- @Override
- public void run() {
- try {
- while (true) {
- RequestData data = getRequestConfig();
- if (data == null) {
- break;
- }
- server.execute(data, this);
- output.flush();
- if (!data.isKeepAlive() || !data.isSuccess()) {
- break;
- }
- }
- } catch (RequestException e) {
- webServer.log(e.getClass().getName() + ": " + e.getMessage());
- try {
- writeErrorHeader(e.requestData, e, -1);
- output.flush();
- } catch (IOException e1) {
- logger.log(Level.WARNING, e1.getMessage(), e1);
- }
- } catch (Throwable t) {
- if (!shuttingDown) {
- webServer.log(t);
- }
- } finally {
- try {
- output.close();
- } catch (Throwable ignore) {
- //
- }
- try {
- input.close();
- } catch (Throwable ignore) {
- //
- }
- try {
- socket.close();
- } catch (Throwable ignore) {
- //
- }
- }
- }
-
- private String readLine() throws IOException {
- if (buffer == null) {
- buffer = new byte[2048];
- }
- int next;
- int count = 0;
- for (;;) {
- try {
- next = input.read();
- firstByte = false;
- } catch (SocketException e) {
- if (firstByte) {
- return null;
- } else {
- throw e;
- }
- }
- if (next < 0 || next == '\n') {
- break;
- }
- if (next != '\r') {
- buffer[count++] = (byte) next;
- }
- if (count >= buffer.length) {
- throw new IOException("HTTP Header too long");
- }
- }
- return new String(buffer, 0, count, StandardCharsets.US_ASCII);
- }
-
- /** Writes the response header and the response to the
- * output stream.
- * @param pData The request data.
- * @param pBuffer The {@link ByteArrayOutputStream} holding the response.
- * @throws IOException Writing the response failed.
- */
- public void writeResponse(RequestData pData, OutputStream pBuffer)
- throws IOException {
- ByteArrayOutputStream response = (ByteArrayOutputStream) pBuffer;
- writeResponseHeader(pData, response.size());
- response.writeTo(output);
- }
-
- /** Writes the response header to the output stream. *
- * @param pData The request data
- * @param pContentLength The content length, if known, or -1.
- * @throws IOException Writing the response failed.
- */
- public void writeResponseHeader(RequestData pData, int pContentLength)
- throws IOException {
- output.write(toHTTPBytes(pData.getHttpVersion()));
- output.write(ok);
- output.write(serverName);
- output.write(pData.isKeepAlive() ? conkeep : conclose);
- output.write(ctype);
- if (headers != null) {
- for (Map.Entry entry : headers.entrySet()) {
- String header = entry.getKey();
- for (String string : entry.getValue()) {
- output.write(toHTTPBytes(header + ": " + string + "\r\n"));
- }
- }
- }
- if (pContentLength != -1) {
- output.write(clength);
- output.write(toHTTPBytes(Integer.toString(pContentLength)));
- output.write(doubleNewline);
- } else {
- output.write(newline);
- }
- pData.setSuccess(true);
- }
-
- /** Writes an error response to the output stream.
- * @param pData The request data.
- * @param pError The error being reported.
- * @param pStream The {@link ByteArrayOutputStream} with the error response.
- * @throws IOException Writing the response failed.
- */
- public void writeError(RequestData pData, Throwable pError, ByteArrayOutputStream pStream)
- throws IOException {
- writeErrorHeader(pData, pError, pStream.size());
- pStream.writeTo(output);
- output.flush();
- }
-
- /** Writes an error responses headers to the output stream.
- * @param pData The request data.
- * @param pError The error being reported.
- * @param pContentLength The response length, if known, or -1.
- * @throws IOException Writing the response failed.
- */
- public void writeErrorHeader(RequestData pData, Throwable pError, int pContentLength)
- throws IOException {
- if (pError instanceof BadRequestException) {
- final byte[] content = toHTTPBytes("Method " + pData.getMethod()
- + " not implemented (try POST)\r\n");
- output.write(toHTTPBytes(pData.getHttpVersion()));
- output.write(toHTTPBytes(" 400 Bad Request"));
- output.write(newline);
- output.write(serverName);
- writeContentLengthHeader(content.length);
- output.write(newline);
- output.write(content);
- } else if (pError instanceof BadEncodingException) {
- final byte[] content = toHTTPBytes("The Transfer-Encoding " + pError.getMessage()
- + " is not implemented.\r\n");
- output.write(toHTTPBytes(pData.getHttpVersion()));
- output.write(toHTTPBytes(" 501 Not Implemented"));
- output.write(newline);
- output.write(serverName);
- writeContentLengthHeader(content.length);
- output.write(newline);
- output.write(content);
- } else if (pError instanceof XmlRpcNotAuthorizedException) {
- final byte[] content = toHTTPBytes("Method " + pData.getMethod()
- + " requires a " + "valid user name and password.\r\n");
- output.write(toHTTPBytes(pData.getHttpVersion()));
- output.write(toHTTPBytes(" 401 Unauthorized"));
- output.write(newline);
- output.write(serverName);
- writeContentLengthHeader(content.length);
- output.write(wwwAuthenticate);
- output.write(newline);
- output.write(content);
- } else {
- output.write(toHTTPBytes(pData.getHttpVersion()));
- output.write(ok);
- output.write(serverName);
- output.write(conclose);
- output.write(ctype);
- writeContentLengthHeader(pContentLength);
- output.write(newline);
- }
- }
-
- private void writeContentLengthHeader(int pContentLength) throws IOException {
- if (pContentLength == -1) {
- return;
- }
- output.write(clength);
- output.write(toHTTPBytes(Integer.toString(pContentLength)));
- output.write(newline);
- }
-
- /**
- * Sets a response header value.
- */
- public void setResponseHeader(String pHeader, String[] pValue) {
- headers.put(pHeader, pValue);
- }
-
- @Override
- public OutputStream newOutputStream() {
- boolean useContentLength;
- useContentLength = !requestData.isEnabledForExtensions()
- || !((XmlRpcHttpRequestConfig) requestData).isContentLengthOptional();
- if (useContentLength) {
- return new ByteArrayOutputStream();
- } else {
- return output;
- }
- }
-
- @Override
- public InputStream newInputStream() {
- int contentLength = requestData.getContentLength();
- if (contentLength == -1) {
- return input;
- } else {
- return new LimitedInputStream(input, contentLength);
- }
- }
-
- @Override
- public void close() {
- }
-
- @Override
- public void shutdown() throws Throwable {
- shuttingDown = true;
- socket.close();
- }
-}
diff --git a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/ConnectionServer.java b/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/ConnectionServer.java
deleted file mode 100644
index 7e237d5..0000000
--- a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/ConnectionServer.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.xbib.netty.http.xmlrpc.servlet;
-
-import org.xbib.netty.http.xmlrpc.common.ServerStreamConnection;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamRequestConfig;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcHttpServer;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-class ConnectionServer extends XmlRpcHttpServer {
- protected void writeError(XmlRpcStreamRequestConfig pConfig, OutputStream pStream,
- Throwable pError) throws XmlRpcException {
- RequestData data = (RequestData) pConfig;
- try {
- if (data.isByteArrayRequired()) {
- super.writeError(pConfig, pStream, pError);
- data.getConnection().writeError(data, pError, (ByteArrayOutputStream) pStream);
- } else {
- data.getConnection().writeErrorHeader(data, pError, -1);
- super.writeError(pConfig, pStream, pError);
- pStream.flush();
- }
- } catch (IOException e) {
- throw new XmlRpcException(e.getMessage(), e);
- }
- }
-
- protected void writeResponse(XmlRpcStreamRequestConfig pConfig, OutputStream pStream, Object pResult) throws XmlRpcException {
- RequestData data = (RequestData) pConfig;
- try {
- if (data.isByteArrayRequired()) {
- super.writeResponse(pConfig, pStream, pResult);
- data.getConnection().writeResponse(data, pStream);
- } else {
- data.getConnection().writeResponseHeader(data, -1);
- super.writeResponse(pConfig, pStream, pResult);
- pStream.flush();
- }
- } catch (IOException e) {
- throw new XmlRpcException(e.getMessage(), e);
- }
- }
-
- protected void setResponseHeader(ServerStreamConnection pConnection, String pHeader, String pValue) {
- ((Connection) pConnection).setResponseHeader(pHeader, new String[] { pValue });
- }
-}
\ No newline at end of file
diff --git a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/HttpServletRequestImpl.java b/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/HttpServletRequestImpl.java
deleted file mode 100644
index be66bba..0000000
--- a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/HttpServletRequestImpl.java
+++ /dev/null
@@ -1,653 +0,0 @@
-package org.xbib.netty.http.xmlrpc.servlet;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamConfig;
-import org.xbib.netty.http.xmlrpc.common.util.HttpUtil;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.net.Socket;
-import java.net.URLDecoder;
-import java.nio.charset.StandardCharsets;
-import java.security.Principal;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import javax.servlet.AsyncContext;
-import javax.servlet.DispatcherType;
-import javax.servlet.ReadListener;
-import javax.servlet.RequestDispatcher;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletInputStream;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-import javax.servlet.http.HttpUpgradeHandler;
-import javax.servlet.http.Part;
-
-/**
- * Stub implementation of a {@link javax.servlet.http.HttpServletRequest}
- * with lots of unimplemented methods. I implemented only those, which
- * are required for testing the {@link XmlRpcServlet}.
- * Perhaps someone else is adding more at a later time?
- */
-public class HttpServletRequestImpl implements HttpServletRequest {
-
- private final Socket socket;
-
- private final ServletInputStream istream;
-
- private ServletInputStream sistream;
-
- private BufferedReader reader;
-
- private boolean postParametersParsed;
-
- private String method;
-
- private String protocol;
-
- private String uri;
-
- private String queryString;
-
- private final Map headers = new HashMap<>();
-
- private final Map attributes = new HashMap<>();
-
- private Map parameters;
-
- private String characterEncoding;
-
- private int contentBytesRemaining = -1;
-
- /** Creates a new instance, which reads input from the given
- * socket.
- * @param pSocket The socket, to which the client is connected.
- * @throws IOException Accessing the sockets input stream failed.
- */
- public HttpServletRequestImpl(Socket pSocket) throws IOException {
- socket = pSocket;
- final InputStream bis = new BufferedInputStream(socket.getInputStream()){
- /** It may happen, that the XML parser invokes close().
- * Closing the input stream must not occur, because
- * that would close the whole socket. So we suppress it.
- */
- @Override
- public void close(){
- }
- };
- istream = new ServletInputStream(){
-
- @Override
- public boolean isFinished() {
- return contentBytesRemaining == 0;
- }
-
- @Override
- public boolean isReady() {
- return true;
- }
-
- @Override
- public void setReadListener(ReadListener readListener) {
- // do nothing
- }
-
- @Override
- public int read() throws IOException {
- if (contentBytesRemaining == 0) {
- return -1;
- }
- int c = bis.read();
- if (c != -1 && contentBytesRemaining > 0) {
- --contentBytesRemaining;
- }
- return c;
- }
- };
- }
-
- /**
- * Read the header lines, one by one. Note, that the size of
- * the buffer is a limitation of the maximum header length!
- */
- void readHttpHeaders() throws IOException {
- byte[] buffer = new byte[2048];
- String line = readLine(buffer);
- StringTokenizer tokens = line != null ? new StringTokenizer(line) : null;
- if (tokens == null || !tokens.hasMoreTokens()) {
- throw new ServletWebServer.ServletWebServerException(400, "Bad Request", "Unable to parse requests first line (should" +
- " be 'METHOD uri HTTP/version', was empty.");
- }
- method = tokens.nextToken();
- if (!"POST".equalsIgnoreCase(method)) {
- throw new ServletWebServer.ServletWebServerException(400, "Bad Request", "Expected 'POST' method, got " +
- method);
- }
- if (!tokens.hasMoreTokens()) {
- throw new ServletWebServer.ServletWebServerException(400, "Bad Request", "Unable to parse requests first line (should" +
- " be 'METHOD uri HTTP/version', was: " + line);
- }
- String u = tokens.nextToken();
- int offset = u.indexOf('?');
- if (offset >= 0) {
- uri = u.substring(0, offset);
- queryString = u.substring(offset + 1);
- } else {
- uri = u;
- queryString = null;
- }
- if (tokens.hasMoreTokens()) {
- String v = tokens.nextToken().toUpperCase();
- if (tokens.hasMoreTokens()) {
- throw new ServletWebServer.ServletWebServerException(400, "Bad Request",
- "Unable to parse requests first line (should" + " be 'METHOD uri HTTP/version', was: " + line);
- } else {
- int index = v.indexOf('/');
- if (index == -1) {
- throw new ServletWebServer.ServletWebServerException(400, "Bad Request",
- "Unable to parse requests first line (should" + " be 'METHOD uri HTTP/version', was: " + line);
- }
- protocol = v.substring(0, index).toUpperCase();
- }
- } else {
- protocol = "HTTP";
- }
- while (true) {
- line = HttpUtil.readLine(istream, buffer);
- if (line.length() == 0) {
- break;
- }
- int off = line.indexOf(':');
- if (off > 0) {
- addHeader(line.substring(0, off), line.substring(off + 1).trim());
- } else {
- throw new ServletWebServer.ServletWebServerException(400, "Bad Request",
- "Unable to parse header line: " + line);
- }
- }
- contentBytesRemaining = getIntHeader("content-length");
- }
-
- private String readLine(byte[] pBuffer) throws IOException {
- int res = istream.readLine(pBuffer, 0, pBuffer.length);
- if (res == -1) {
- return null;
- }
- if (res == pBuffer.length && pBuffer[pBuffer.length - 1] != '\n') {
- throw new ServletWebServer.ServletWebServerException(400, "Bad Request",
- "maximum header size of " + pBuffer.length + " characters exceeded");
- }
- return new String(pBuffer, 0, res, StandardCharsets.US_ASCII);
- }
-
- private void addHeader(String pHeader, String pValue) {
- String key = pHeader.toLowerCase();
- String[] strings = headers.get(key);
- if (strings == null) {
- strings = new String[] { pValue };
- } else {
- List list = new ArrayList<>(Arrays.asList(strings));
- list.add(pValue);
- strings = list.toArray(new String[0]);
- }
- headers.put(key, strings);
- }
-
- @Override
- public String getAuthType() {
- String s = getHeader("Authorization");
- if (s == null) {
- return null;
- }
- StringTokenizer st = new StringTokenizer(s);
- if (st.hasMoreTokens()) {
- return st.nextToken().toUpperCase();
- } else {
- return null;
- }
- }
-
- @Override
- public String getContextPath() { return ""; }
-
- @Override
- public Cookie[] getCookies() { throw new IllegalStateException("Not implemented"); }
-
- @Override
- public long getDateHeader(String arg0) { throw new IllegalStateException("Not implemented"); }
-
- @Override
- public String getHeader(String pHeader) {
- String key = pHeader.toLowerCase();
- String[] strings = headers.get(key);
- return strings != null && strings.length > 0 ? strings[0] : null;
- }
-
- @Override
- public Enumeration getHeaderNames() {
- return Collections.enumeration(headers.keySet());
- }
-
- @Override
- public Enumeration getHeaders(String pHeader) {
- String key = pHeader.toLowerCase();
- String[] values = headers.get(key);
- return values != null && values.length > 0 ?
- Collections.enumeration(Arrays.asList(values)) : Collections.emptyEnumeration();
- }
-
- @Override
- public int getIntHeader(String pHeader) {
- String s = getHeader(pHeader);
- return s == null ? -1 : Integer.parseInt(s);
- }
-
- @Override
- public String getMethod() { return method; }
-
- @Override
- public String getPathInfo() { return null; }
-
- @Override
- public String getPathTranslated() { return null; }
-
- @Override
- public String getQueryString() { return queryString; }
-
- @Override
- public String getRemoteUser() { throw new IllegalStateException("Not implemented"); }
-
- @Override
- public String getRequestURI() { return uri; }
-
- @Override
- public StringBuffer getRequestURL() {
- String scheme = getScheme().toLowerCase();
- StringBuffer sb = new StringBuffer(scheme);
- sb.append("://");
- String host = getHeader("host");
- if (host == null) {
- host = getLocalName();
- if (host == null) {
- host = getLocalAddr();
- }
- }
- int port = getLocalPort();
- int offset = host.indexOf(':');
- if (offset != -1) {
- host = host.substring(0, offset);
- try {
- port = Integer.parseInt(host.substring(offset+1));
- } catch (Exception e) {
- //
- }
- }
- boolean isDefaultPort;
- if ("http".equalsIgnoreCase(scheme)) {
- isDefaultPort = port == 80;
- } else if ("https".equalsIgnoreCase(scheme)) {
- isDefaultPort = port == 443;
- } else {
- isDefaultPort = false;
- }
- if (!isDefaultPort) {
- sb.append(':');
- sb.append(port);
- }
- sb.append(getRequestURI());
- return sb;
- }
-
- @Override
- public String getRequestedSessionId() { throw new IllegalStateException("Not implemented"); }
-
- @Override
- public String getServletPath() { return uri; }
-
- @Override
- public HttpSession getSession() { throw new IllegalStateException("Not implemented"); }
-
- @Override
- public String changeSessionId() {
- throw new IllegalStateException("Not implemented");
- }
-
- @Override
- public HttpSession getSession(boolean pCreate) { throw new IllegalStateException("Not implemented"); }
-
- @Override
- public Principal getUserPrincipal() { throw new IllegalStateException("Not implemented"); }
-
- @Override
- public boolean isRequestedSessionIdFromCookie() { throw new IllegalStateException("Not implemented"); }
-
- @Override
- public boolean isRequestedSessionIdFromURL() { throw new IllegalStateException("Not implemented"); }
-
- @Override
- public boolean isRequestedSessionIdFromUrl() { throw new IllegalStateException("Not implemented"); }
-
- @Override
- public boolean authenticate(HttpServletResponse httpServletResponse) {
- throw new IllegalStateException("Not implemented");
- }
-
- @Override
- public void login(String user, String password) {
- throw new IllegalStateException("Not implemented");
- }
-
- @Override
- public void logout() {
- throw new IllegalStateException("Not implemented");
- }
-
- @Override
- public Collection getParts() {
- throw new IllegalStateException("Not implemented");
- }
-
- @Override
- public Part getPart(String s) {
- throw new IllegalStateException("Not implemented");
- }
-
- @Override
- public T upgrade(Class aClass) {
- throw new IllegalStateException("Not implemented");
- }
-
- @Override
- public boolean isRequestedSessionIdValid() { throw new IllegalStateException("Not implemented"); }
-
- @Override
- public boolean isUserInRole(String pRole) { throw new IllegalStateException("Not implemented"); }
-
- @Override
- public Object getAttribute(String pKey) { return attributes.get(pKey); }
-
- @Override
- public Enumeration getAttributeNames() { return Collections.enumeration(attributes.keySet()); }
-
- @Override
- public String getCharacterEncoding() {
- if (characterEncoding == null) {
- String contentType = getHeader("content-type");
- if (contentType != null) {
- for (StringTokenizer st = new StringTokenizer(contentType, ";"); st.hasMoreTokens(); ) {
- String s = st.nextToken().trim();
- if (s.toLowerCase().startsWith("charset=")) {
- return s.substring("charset=".length()).trim();
- }
- }
- }
- return null;
- } else {
- return characterEncoding;
- }
- }
-
- @Override
- public void setCharacterEncoding(String pEncoding) { characterEncoding = pEncoding; }
-
- @Override
- public int getContentLength() {
- try {
- return getIntHeader("content-length");
- } catch (NumberFormatException e) {
- return -1;
- }
- }
-
- @Override
- public long getContentLengthLong() {
- return 0;
- }
-
- @Override
- public String getContentType() { return getHeader("content-type"); }
-
- @Override
- public ServletInputStream getInputStream() {
- if (reader == null) {
- if (sistream == null) {
- if (postParametersParsed) {
- throw new IllegalStateException("The method getInputStream() must not be called, after POST parameters have been parsed.");
- }
- sistream = istream;
- }
- return sistream;
- } else {
- throw new IllegalStateException("The method getReader() has already been invoked.");
- }
- }
-
- @Override
- public Locale getLocale() { throw new IllegalStateException("Not implemented"); }
-
- @Override
- public Enumeration getLocales() { throw new IllegalStateException("Not implemented"); }
-
- private void parseQueryString(Map pParams, String pQueryString, String pEncoding) throws UnsupportedEncodingException {
- for (StringTokenizer st = new StringTokenizer(pQueryString, "&"); st.hasMoreTokens(); ) {
- String s = st.nextToken();
- parseParameter(pParams, s, pEncoding);
- }
- }
-
- private void parseParameter(Map pParams, String pParam, String pEncoding) throws UnsupportedEncodingException {
- if (pParam.length() == 0) {
- return;
- }
- int offset = pParam.indexOf('=');
- final String name, value;
- if (offset == -1) {
- name = pParam;
- value = "";
- } else {
- name = pParam.substring(0, offset);
- value = pParam.substring(offset+1);
- }
- //addParameter(pParams, URLDecoder.decode(name, pEncoding), URLDecoder.decode(value, pEncoding));
- pParams.put(URLDecoder.decode(name, pEncoding), new String[] { URLDecoder.decode(value, pEncoding)});
- }
-
- private void parsePostData(Map pParams, InputStream pStream, String pEncoding) throws IOException {
- Reader r = new InputStreamReader(pStream, StandardCharsets.US_ASCII);
- StringBuilder sb = new StringBuilder();
- for (;;) {
- int c = r.read();
- if (c == -1 || c == '&') {
- parseParameter(pParams, sb.toString(), pEncoding);
- if (c == -1) {
- break;
- } else {
- sb.setLength(0);
- }
- } else {
- sb.append((char) c);
- }
- }
- }
-
- private void parseParameters() {
- if (parameters != null) {
- return;
- }
- String encoding = getCharacterEncoding();
- if (encoding == null) {
- encoding = XmlRpcStreamConfig.UTF8_ENCODING;
- }
- Map params = new HashMap<>();
- String s = getQueryString();
- if (s != null) {
- try {
- parseQueryString(params, s, encoding);
- } catch (IOException e) {
- throw new UndeclaredThrowableException(e);
- }
- }
- if ("POST".equals(getMethod()) &&
- "application/x-www-form-urlencoded".equals(getContentType())) {
- if (sistream != null || reader != null) {
- throw new IllegalStateException("POST parameters cannot be parsed, after"
- + " getInputStream(), or getReader(),"
- + " have been called.");
- }
- postParametersParsed = true;
- try {
- parsePostData(params, istream, encoding);
- } catch (IOException e) {
- throw new UndeclaredThrowableException(e);
- }
- }
- parameters = params;
- }
-
- @Override
- public String getParameter(String pName) {
- parseParameters();
- String[] strings = parameters.get(pName);
- return strings != null ? strings[0] : null;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Map getParameterMap() {
- parseParameters();
- final Map result = new HashMap<>();
- for (Map.Entry entry : parameters.entrySet()) {
- result.put(entry.getKey(), entry.getValue());
- }
- return Collections.unmodifiableMap(result);
- }
-
- @Override
- public Enumeration getParameterNames() {
- parseParameters();
- return Collections.enumeration(parameters.keySet());
- }
-
- @Override
- public String[] getParameterValues(String pName) {
- parseParameters();
- return parameters.get(pName);
- }
-
- public String getProtocol() { return protocol; }
-
- public BufferedReader getReader() throws IOException {
- if (sistream == null) {
- if (reader == null) {
- if (postParametersParsed) {
- throw new IllegalStateException("The method getReader() must not be called, after POST parameters have been parsed.");
- }
- String encoding = getCharacterEncoding();
- if (encoding == null) {
- encoding = "UTF8";
- }
- reader = new BufferedReader(new InputStreamReader(istream, encoding));
- }
- return reader;
- } else {
- throw new IllegalStateException("The methods getInputStream(), and getReader(), are mutually exclusive.");
- }
- }
-
- public String getRealPath(String pPath) { throw new IllegalStateException("Not implemented."); }
-
- public String getLocalAddr() { return socket.getLocalAddress().getHostAddress(); }
-
- public String getLocalName() { return socket.getLocalAddress().getHostName(); }
-
- public int getLocalPort() { return socket.getLocalPort(); }
-
- @Override
- public ServletContext getServletContext() {
- return null;
- }
-
- @Override
- public AsyncContext startAsync() throws IllegalStateException {
- return null;
- }
-
- @Override
- public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) throws IllegalStateException {
- return null;
- }
-
- @Override
- public boolean isAsyncStarted() {
- return false;
- }
-
- @Override
- public boolean isAsyncSupported() {
- return false;
- }
-
- @Override
- public AsyncContext getAsyncContext() {
- return null;
- }
-
- @Override
- public DispatcherType getDispatcherType() {
- return null;
- }
-
- @Override
- public String getRemoteAddr() { return socket.getInetAddress().getHostAddress(); }
-
- @Override
- public String getRemoteHost() { return socket.getInetAddress().getHostName(); }
-
- @Override
- public int getRemotePort() { return socket.getPort(); }
-
- @Override
- public RequestDispatcher getRequestDispatcher(String pUri) {
- throw new IllegalStateException("Not implemented");
- }
-
- @Override
- public String getScheme() { return "http"; }
-
- @Override
- public String getServerName() { return socket.getLocalAddress().getHostName(); }
-
- @Override
- public int getServerPort() { return socket.getLocalPort(); }
-
- @Override
- public boolean isSecure() { return false; }
-
- @Override
- public void removeAttribute(String pKey) {
- attributes.remove(pKey);
- }
-
- @Override
- public void setAttribute(String pKey, Object pValue) {
- attributes.put(pKey, pValue);
- }
-}
diff --git a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/HttpServletResponseImpl.java b/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/HttpServletResponseImpl.java
deleted file mode 100644
index d09f946..0000000
--- a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/HttpServletResponseImpl.java
+++ /dev/null
@@ -1,489 +0,0 @@
-package org.xbib.netty.http.xmlrpc.servlet;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.net.Socket;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import javax.servlet.ServletOutputStream;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * Stub implementation of a {@link javax.servlet.http.HttpServletResponse}
- * with lots of unimplemented methods. I implemented only those, which
- * are required for testing the {@link XmlRpcServlet}.
- * Perhaps someone else is adding more at a later time?
- */
-public class HttpServletResponseImpl implements HttpServletResponse {
-
- static final int BUFFER_SIZE = 8192;
-
- private final OutputStream ostream;
-
- private final Map headers = new HashMap<>();
-
- private int status = HttpServletResponse.SC_OK;
-
- private String message = getStatusMessage(status);
-
- private Locale locale;
-
- private String charEncoding;
-
- private PrintWriter writer;
-
- private ServletOutputStreamImpl soStream;
-
- /** Creates a new instance.
- * @param pSocket The clients socket.
- * @throws IOException Accessing the sockets output stream failed.
- */
- HttpServletResponseImpl(Socket pSocket) throws IOException {
- ostream = pSocket.getOutputStream();
- }
-
- @Override
- public void addCookie(Cookie pCookie) { throw new IllegalStateException("Not implemented"); }
-
- @Override
- public void addDateHeader(String pHeader, long pDate) { throw new IllegalStateException("Not implemented"); }
-
- @Override
- public void addHeader(String pHeader, String pValue) {
- String key = pHeader.toLowerCase();
- String[] strings = headers.get(key);
- if (strings == null) {
- strings = new String[] { pValue };
- } else {
- List list = new ArrayList<>(Arrays.asList(strings));
- list.add(pValue);
- strings = list.toArray(new String[0]);
- }
- headers.put(key, strings);
- }
-
- @Override
- public String getHeader(String pHeader) {
- String key = pHeader.toLowerCase();
- String[] strings = headers.get(key);
- return strings != null && strings.length > 0 ? strings[0] : null;
- }
-
- @Override
- public Collection getHeaders(String pHeader) {
- String key = pHeader.toLowerCase();
- return Arrays.asList(headers.get(key));
- }
-
- @Override
- public Collection getHeaderNames() {
- return headers.keySet();
- }
-
- @Override
- public void addIntHeader(String pHeader, int pValue) {
- addHeader(pHeader, Integer.toString(pValue));
- }
-
- @Override
- public boolean containsHeader(String pHeader) {
- return headers.containsKey(pHeader.toLowerCase());
- }
-
- @Override
- public String encodeRedirectURL(String pURL) { throw new IllegalStateException("Not implemented"); }
-
- @Override
- public String encodeRedirectUrl(String pURL) { return encodeRedirectURL(pURL); }
-
- @Override
- public String encodeURL(String pURL) { throw new IllegalStateException("Not implemented"); }
-
- @Override
- public String encodeUrl(String pURL) { throw new IllegalStateException("Not implemented"); }
-
- @Override
- public void sendError(int pStatusCode) throws IOException {
- sendError(pStatusCode, getStatusMessage(pStatusCode));
- }
-
- @Override
- public void sendError(int pStatusCode, String pMessage) throws IOException {
- sendError(pStatusCode, pMessage, null);
- }
-
- protected void sendError(int pStatusCode, String pMessage, String pDescription) throws IOException {
- if (isCommitted()) {
- throw new IllegalStateException("Can't send an error message, if the response has already been committed.");
- }
- headers.clear();
- setContentType("text/html");
- setStatus(pStatusCode, pMessage);
- if (soStream == null) {
- soStream = new ServletOutputStreamImpl(ostream, this);
- } else {
- soStream.reset();
- }
- OutputStreamWriter osw = new OutputStreamWriter(soStream, getCharacterEncoding());
- osw.write("" + pStatusCode + " " + pMessage + " \r\n");
- osw.write("" + pStatusCode + " " + pMessage + " \r\n");
- if (pDescription != null) {
- osw.write("" + pDescription + "
\r\n");
- }
- osw.write("\r\n");
- osw.close();
- }
-
- @Override
- public void sendRedirect(String arg0) throws IOException { throw new IllegalStateException("Not implemented"); }
-
- @Override
- public void setDateHeader(String arg0, long arg1) { throw new IllegalStateException("Not implemented"); }
-
- @Override
- public void setHeader(String pHeader, String pValue) {
- headers.remove(pHeader.toLowerCase());
- addHeader(pHeader, pValue);
- }
-
- @Override
- public void setIntHeader(String pHeader, int pValue) {
- setHeader(pHeader, Integer.toString(pValue));
- }
-
- @Override
- public void setStatus(int pStatusCode) {
- setStatus(pStatusCode, getStatusMessage(pStatusCode));
- }
-
- @Override
- public void setStatus(int pStatusCode, String pMessage) {
- status = pStatusCode;
- message = pMessage;
- }
-
- @Override
- public int getStatus() {
- return status;
- }
-
- @Override
- public void flushBuffer() throws IOException {
- ostream.flush();
- }
-
- @Override
- public int getBufferSize() { return BUFFER_SIZE; }
-
- /** Sets the character encoding (MIME charset) of the response being sent
- * to the client, for example, to UTF-8. If the character encoding has
- * already been set by setContentType(java.lang.String) or
- * setLocale(java.util.Locale), this method overrides it.
- * Calling setContentType(java.lang.String) with the String
- * of text/html and calling this method with the String of UTF-8
- * is equivalent with calling setContentType with the String of
- * text/html; charset=UTF-8.
- * This method can be called repeatedly to change the character
- * encoding. This method has no effect if it is called after getWriter
- * has been called or after the response has been committed.
- * Containers must communicate the character encoding used for
- * the servlet response's writer to the client if the protocol
- * provides a way for doing so. In the case of HTTP, the character
- * encoding is communicated as part of the Content-Type header for
- * text media types. Note that the character encoding cannot be
- * communicated via HTTP headers if the servlet does not specify
- * a content type; however, it is still used to encode text written
- * via the servlet response's writer.
- * @param pCharset A String specifying only the character set defined
- * by IANA Character Sets (http://www.iana.org/assignments/character-sets)
- * @since Servlet API 2.4
- * @see #setLocale(Locale)
- */
- @Override
- public void setCharacterEncoding(String pCharset) {
- charEncoding = pCharset;
- }
-
- @Override
- public String getCharacterEncoding() {
- if (charEncoding == null) {
- return "ISO-8859-1";
- } else {
- return charEncoding;
- }
- }
-
- @Override
- public Locale getLocale() { return locale; }
-
- @Override
- public ServletOutputStream getOutputStream() {
- if (writer != null) {
- throw new IllegalStateException("You may call either getWriter() or getOutputStream(), but not both.");
- } else {
- if (soStream == null) {
- soStream = new ServletOutputStreamImpl(ostream, this);
- }
- return soStream;
- }
- }
-
- @Override
- public PrintWriter getWriter() throws IOException {
- if (writer != null) {
- return writer;
- } else if (soStream != null) {
- throw new IllegalStateException("You may call either getWriter() or getOutputStream(), but not both.");
- } else {
- writer = new PrintWriter(new OutputStreamWriter(getOutputStream(), getCharacterEncoding()));
- return writer;
- }
- }
-
- @Override
- public boolean isCommitted() {
- return soStream != null && soStream.isCommitted();
- }
-
- @Override
- public void reset() {
- resetBuffer();
- setStatus(HttpServletResponse.SC_OK);
- headers.clear();
- charEncoding = null;
- locale = null;
- }
-
- @Override
- public void resetBuffer() {
- if (isCommitted()) {
- throw new IllegalStateException("The ServletOutputStream is already committed. A reset is no longer possible.");
- }
- if (soStream != null) {
- soStream.reset();
- }
- }
-
- @Override
- public void setBufferSize(int pBufferSize) { throw new IllegalStateException("Not implemented"); }
-
- @Override
- public void setContentLength(int pContentLength) {
- if (pContentLength == -1) {
- headers.remove("content-length");
- } else {
- setIntHeader("content-length", pContentLength);
- }
- }
-
- @Override
- public void setContentLengthLong(long pContentLength) {
- if (pContentLength == -1) {
- headers.remove("content-length");
- } else {
- setHeader("content-length", Long.toString(pContentLength));
- }
- }
-
- /** Returns the content type used for the MIME body sent in this
- * response. The content type proper must have been specified
- * using setContentType(java.lang.String) before the response is
- * committed. If no content type has been specified, this method
- * returns null. If a content type has been specified and a
- * character encoding has been explicitly or implicitly specified
- * as described in getCharacterEncoding(), the charset parameter
- * is included in the string returned. If no character encoding
- * has been specified, the charset parameter is omitted.
- * @return A String specifying the content type, for example,
- * text/html; charset=UTF-8, or null
- * @since Servlet API 2.4
- * @see #setContentType(String)
- */
- @Override
- public String getContentType() {
- String s = getHeader("content-type");
- if (s != null && s.toLowerCase().startsWith("text/")) {
- String enc = getCharacterEncoding();
- if (enc != null) {
- s += "; charset=" + enc;
- }
- }
- return s;
- }
-
- @Override
- public void setContentType(String pType) {
- if (pType != null) {
- boolean charSetFound = false;
- StringBuilder sb = new StringBuilder();
- for (StringTokenizer st = new StringTokenizer(pType, ";"); st.hasMoreTokens(); ) {
- String t = st.nextToken();
- if (t.toLowerCase().startsWith("charset=")) {
- charSetFound = true;
- setCharacterEncoding(t.substring("charset=".length()).trim());
- } else {
- if (sb.length() > 0) {
- sb.append("; ");
- }
- sb.append(t);
- }
- }
- if (charSetFound) {
- pType = sb.toString();
- }
- }
- setHeader("content-type", pType);
- }
-
- @Override
- public void setLocale(Locale pLocale) { locale = pLocale; }
-
- /** Returns a default message for a given HTTP status code.
- * @param pStatusCode The status code being queried.
- * @return The default message.
- */
- public static String getStatusMessage(int pStatusCode) {
- switch (pStatusCode) {
- case HttpServletResponse.SC_OK:
- return ("OK");
- case HttpServletResponse.SC_ACCEPTED:
- return ("Accepted");
- case HttpServletResponse.SC_BAD_GATEWAY:
- return ("Bad Gateway");
- case HttpServletResponse.SC_BAD_REQUEST:
- return ("Bad Request");
- case HttpServletResponse.SC_CONFLICT:
- return ("Conflict");
- case HttpServletResponse.SC_CONTINUE:
- return ("Continue");
- case HttpServletResponse.SC_CREATED:
- return ("Created");
- case HttpServletResponse.SC_EXPECTATION_FAILED:
- return ("Expectation Failed");
- case HttpServletResponse.SC_FORBIDDEN:
- return ("Forbidden");
- case HttpServletResponse.SC_GATEWAY_TIMEOUT:
- return ("Gateway Timeout");
- case HttpServletResponse.SC_GONE:
- return ("Gone");
- case HttpServletResponse.SC_HTTP_VERSION_NOT_SUPPORTED:
- return ("HTTP Version Not Supported");
- case HttpServletResponse.SC_INTERNAL_SERVER_ERROR:
- return ("Internal Server Error");
- case HttpServletResponse.SC_LENGTH_REQUIRED:
- return ("Length Required");
- case HttpServletResponse.SC_METHOD_NOT_ALLOWED:
- return ("Method Not Allowed");
- case HttpServletResponse.SC_MOVED_PERMANENTLY:
- return ("Moved Permanently");
- case HttpServletResponse.SC_MOVED_TEMPORARILY:
- return ("Moved Temporarily");
- case HttpServletResponse.SC_MULTIPLE_CHOICES:
- return ("Multiple Choices");
- case HttpServletResponse.SC_NO_CONTENT:
- return ("No Content");
- case HttpServletResponse.SC_NON_AUTHORITATIVE_INFORMATION:
- return ("Non-Authoritative Information");
- case HttpServletResponse.SC_NOT_ACCEPTABLE:
- return ("Not Acceptable");
- case HttpServletResponse.SC_NOT_FOUND:
- return ("Not Found");
- case HttpServletResponse.SC_NOT_IMPLEMENTED:
- return ("Not Implemented");
- case HttpServletResponse.SC_NOT_MODIFIED:
- return ("Not Modified");
- case HttpServletResponse.SC_PARTIAL_CONTENT:
- return ("Partial Content");
- case HttpServletResponse.SC_PAYMENT_REQUIRED:
- return ("Payment Required");
- case HttpServletResponse.SC_PRECONDITION_FAILED:
- return ("Precondition Failed");
- case HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED:
- return ("Proxy Authentication Required");
- case HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE:
- return ("Request Entity Too Large");
- case HttpServletResponse.SC_REQUEST_TIMEOUT:
- return ("Request Timeout");
- case HttpServletResponse.SC_REQUEST_URI_TOO_LONG:
- return ("Request URI Too Long");
- case HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE:
- return ("Requested Range Not Satisfiable");
- case HttpServletResponse.SC_RESET_CONTENT:
- return ("Reset Content");
- case HttpServletResponse.SC_SEE_OTHER:
- return ("See Other");
- case HttpServletResponse.SC_SERVICE_UNAVAILABLE:
- return ("Service Unavailable");
- case HttpServletResponse.SC_SWITCHING_PROTOCOLS:
- return ("Switching Protocols");
- case HttpServletResponse.SC_UNAUTHORIZED:
- return ("Unauthorized");
- case HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE:
- return ("Unsupported Media Type");
- case HttpServletResponse.SC_USE_PROXY:
- return ("Use Proxy");
- case 207: // WebDAV
- return ("Multi-Status");
- case 422: // WebDAV
- return ("Unprocessable Entity");
- case 423: // WebDAV
- return ("Locked");
- case 507: // WebDAV
- return ("Insufficient Storage");
- default:
- return ("HTTP Response Status " + pStatusCode);
- }
- }
-
- String getHttpHeaders(Integer pContentLength) {
- StringBuilder sb = new StringBuilder();
- sb.append("HTTP/1.0 ");
- sb.append(status);
- sb.append(' ');
- sb.append(message);
- sb.append("\r\n");
- String contentType = getContentType();
- if (contentType != null) {
- sb.append("Content-Type: ");
- sb.append(contentType);
- sb.append("\r\n");
- }
- boolean contentLengthSeen = false;
- for (Map.Entry entry : headers.entrySet()) {
- String header = entry.getKey();
- if ("content-type".equalsIgnoreCase(header)) {
- continue;
- }
- String[] strings = entry.getValue();
- if (strings == null) {
- continue;
- }
- if ("content-length".equalsIgnoreCase(header)) {
- contentLengthSeen = true;
- }
- for (String string : strings) {
- sb.append(header);
- sb.append(": ");
- sb.append(string);
- sb.append("\r\n");
- }
- }
- if (pContentLength != null && !contentLengthSeen) {
- sb.append("Content-Length: ");
- sb.append(pContentLength);
- sb.append("\r\n");
- }
- sb.append("\r\n");
- return sb.toString();
- }
-}
diff --git a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/ReflectionUtil.java b/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/ReflectionUtil.java
deleted file mode 100644
index b8ef93c..0000000
--- a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/ReflectionUtil.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.xbib.netty.http.xmlrpc.servlet;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-
-
-/** A utility class for using reflection.
- */
-public class ReflectionUtil {
- /**
- * This method attempts to set a property value on a given object by calling a
- * matching setter.
- * @param pObject The object, on which a property is being set.
- * @param pPropertyName The property name.
- * @param pPropertyValue The property value.
- * @throws IllegalAccessException Setting the property value failed, because invoking
- * the setter raised an {@link IllegalAccessException}.
- * @throws InvocationTargetException Setting the property value failed, because invoking
- * the setter raised another exception.
- * @return Whether a matching setter was found. The value false indicates, that no such
- * setter exists.
- */
- public static boolean setProperty(Object pObject, String pPropertyName, String pPropertyValue)
- throws IllegalAccessException, InvocationTargetException {
- final String methodName = "set" + pPropertyName.substring(0, 1).toUpperCase() + pPropertyName.substring(1);
- // try to find method signature that matches init param
- Method[] methods = pObject.getClass().getMethods();
-
- for (final Method method : methods) {
- if (!method.getName().equals(methodName)) {
- continue; // Ignore methods, which does have the right name
- }
- if (!Modifier.isPublic(method.getModifiers())) {
- continue; // Ignore methods, which aren't public
- }
-
- Class>[] parameterTypes = method.getParameterTypes();
- if (parameterTypes.length != 1) {
- continue; // Ignore methods, which don't not have exactly one parameter
- }
-
- Class> parameterType = parameterTypes[0];
- final Object param;
- try {
- if (parameterType.equals(boolean.class) || parameterType.equals(Boolean.class)) {
- param = Boolean.valueOf(pPropertyValue);
- } else if (parameterType.equals(char.class) || parameterType.equals(Character.class)) {
- if (pPropertyValue.length() != 1) {
- throw new IllegalArgumentException("Invalid value for parameter "
- + pPropertyName + "(length != 1):"
- + pPropertyValue);
- }
- param = pPropertyValue.charAt(0);
- } else if (parameterType.equals(byte.class) || parameterType.equals(Byte.class)) {
- param = Byte.valueOf(pPropertyValue);
- } else if (parameterType.equals(short.class) || parameterType.equals(Short.class)) {
- param = Short.valueOf(pPropertyValue);
- } else if (parameterType.equals(int.class) || parameterType.equals(Integer.class)) {
- param = Integer.valueOf(pPropertyValue);
- } else if (parameterType.equals(long.class) || parameterType.equals(Long.class)) {
- param = Long.valueOf(pPropertyValue);
- } else if (parameterType.equals(float.class) || parameterType.equals(Float.class)) {
- param = Float.valueOf(pPropertyValue);
- } else if (parameterType.equals(double.class) || parameterType.equals(Double.class)) {
- param = Double.valueOf(pPropertyValue);
- } else if (parameterType.equals(String.class)) {
- param = pPropertyValue;
- } else {
- throw new IllegalStateException("The property " + pPropertyName
- + " has an unsupported type of " + parameterType.getName());
- }
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException("Invalid value for property "
- + pPropertyName + ": " + pPropertyValue);
- }
- method.invoke(pObject, param);
- return true;
- }
- return false;
- }
-}
diff --git a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/RequestData.java b/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/RequestData.java
deleted file mode 100644
index 46ae4ad..0000000
--- a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/RequestData.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package org.xbib.netty.http.xmlrpc.servlet;
-
-import org.xbib.netty.http.xmlrpc.common.XmlRpcHttpRequestConfigImpl;
-
-/** Web servers extension of
- * {@link XmlRpcHttpRequestConfig},
- * which allows to store additional per request data.
- */
-public class RequestData extends XmlRpcHttpRequestConfigImpl {
- private final Connection connection;
- private boolean keepAlive;
- private String method, httpVersion;
- private int contentLength = -1;
- private boolean success;
-
- /** Creates a new instance.
- * @param pConnection The connection, which is serving the request.
- */
- public RequestData(Connection pConnection) {
- connection = pConnection;
- }
-
- /** Returns the connection, which is serving the request.
- * @return The request connection.
- */
- public Connection getConnection() { return connection; }
-
- /** Returns, whether HTTP keepAlive is enabled for this
- * connection.
- * @return True, if keepAlive is enabled, false otherwise.
- */
- public boolean isKeepAlive() { return keepAlive; }
-
- /** Sets, whether HTTP keepAlive is enabled for this
- * connection.
- * @param pKeepAlive True, if keepAlive is enabled, false otherwise.
- */
- public void setKeepAlive(boolean pKeepAlive) {
- keepAlive = pKeepAlive;
- }
-
- /** Returns the requests HTTP version.
- * @return HTTP version, for example "1.0"
- */
- public String getHttpVersion() { return httpVersion; }
-
- /** Sets the requests HTTP version.
- * @param pHttpVersion HTTP version, for example "1.0"
- */
- public void setHttpVersion(String pHttpVersion) {
- httpVersion = pHttpVersion;
- }
-
- /** Returns the requests content length.
- * @return Content length, if known, or -1, if unknown.
- */
- public int getContentLength() { return contentLength; }
-
- /** Sets the requests content length.
- * @param pContentLength Content length, if known, or -1, if unknown.
- */
- public void setContentLength(int pContentLength) {
- contentLength = pContentLength;
- }
-
- /** Returns, whether a byte array for buffering the output is
- * required.
- * @return True, if the byte array is required, false otherwise.
- */
- public boolean isByteArrayRequired() {
- return isKeepAlive() || !isEnabledForExtensions() || !isContentLengthOptional();
- }
-
- /** Returns the request method.
- * @return The request method, should be "POST".
- */
- public String getMethod() { return method; }
-
- /** Sets the request method.
- * @param pMethod The request method, should be "POST".
- */
- public void setMethod(String pMethod) {
- method = pMethod;
- }
-
- /** Returns, whether the request was executed successfull.
- * @return True for success, false, if an error occurred.
- */
- public boolean isSuccess() { return success; }
-
- /** Sets, whether the request was executed successfull.
- * @param pSuccess True for success, false, if an error occurred.
- */
- public void setSuccess(boolean pSuccess) {
- success = pSuccess;
- }
-}
diff --git a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/ServletConnection.java b/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/ServletConnection.java
deleted file mode 100644
index f9b16a2..0000000
--- a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/ServletConnection.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package org.xbib.netty.http.xmlrpc.servlet;
-
-import java.io.IOException;
-import java.net.Socket;
-
-import javax.servlet.http.HttpServlet;
-
-/** {@link ServletWebServer ServletWebServer's} {@link Runnable} for handling a single
- * servlet connection.
- */
-public class ServletConnection implements ThreadPool.InterruptableTask {
-
- private final HttpServlet servlet;
-
- private final Socket socket;
-
- private final HttpServletRequestImpl request;
-
- private final HttpServletResponseImpl response;
-
- private boolean shuttingDown;
-
- /** Creates a new instance.
- * @param pServlet The servlet, which ought to handle the request.
- * @param pSocket The socket, to which the client is connected.
- * @throws IOException
- */
- ServletConnection(HttpServlet pServlet, Socket pSocket) throws IOException {
- servlet = pServlet;
- socket = pSocket;
- request = new HttpServletRequestImpl(pSocket);
- response = new HttpServletResponseImpl(pSocket);
- }
-
- @Override
- public void run() {
- try {
- request.readHttpHeaders();
- servlet.service(request, response);
- } catch (Throwable t) {
- if (!shuttingDown) {
- throw new RuntimeException(t);
- }
- }
- }
-
- @Override
- public void shutdown() throws Throwable {
- shuttingDown = true;
- socket.close();
- }
-}
diff --git a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/ServletOutputStreamImpl.java b/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/ServletOutputStreamImpl.java
deleted file mode 100644
index 6da0a96..0000000
--- a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/ServletOutputStreamImpl.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package org.xbib.netty.http.xmlrpc.servlet;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.charset.StandardCharsets;
-
-import javax.servlet.ServletOutputStream;
-import javax.servlet.WriteListener;
-
-/**
- * Default implementation of a servlet output stream.
- * Handles output of HTTP headers.
- */
-class ServletOutputStreamImpl extends ServletOutputStream {
-
- private final OutputStream target;
-
- private final HttpServletResponseImpl res;
-
- private final byte[] buffer = new byte[HttpServletResponseImpl.BUFFER_SIZE];
-
- private int bufferOffset;
-
- private boolean closed;
-
- private boolean committed;
-
- ServletOutputStreamImpl(OutputStream pTarget, HttpServletResponseImpl pResponse) {
- target = pTarget;
- res = pResponse;
- }
-
- public void write(int b) throws IOException {
- if (closed) {
- throw new IOException("This output stream is already closed.");
- }
- if (bufferOffset == buffer.length) {
- flush();
- }
- buffer[bufferOffset++] = (byte) b;
- }
-
- public void write(byte[] pChars, int pOffset, int pLen) throws IOException {
- if (closed) {
- throw new IOException("This output stream is already closed.");
- }
- while (pLen-- > 0) {
- if (bufferOffset == buffer.length) {
- flush();
- }
- buffer[bufferOffset++] = pChars[pOffset++];
- }
- }
-
- private void flush(boolean pClosing) throws IOException {
- if (!committed) {
- committed = true;
- String headers = res.getHttpHeaders(pClosing ? bufferOffset : null);
- target.write(headers.getBytes(StandardCharsets.US_ASCII));
- }
- if (bufferOffset > 0) {
- target.write(buffer, 0, bufferOffset);
- bufferOffset = 0;
- }
- }
-
- @Override
- public void close() throws IOException {
- if (!closed) {
- flush(true);
- closed = true;
- target.close();
- }
- }
-
- @Override
- public void flush() throws IOException {
- if (closed) {
- throw new IOException("This output stream is already closed.");
- }
- flush(false);
- target.flush();
- }
-
- void reset() {
- if (committed) {
- throw new IllegalStateException("The response is already committed. A reset cannot be performed.");
- }
- }
-
- boolean isCommitted() {
- return committed;
- }
-
- @Override
- public boolean isReady() {
- return true;
- }
-
- @Override
- public void setWriteListener(WriteListener writeListener) {
- // no write listeners
- }
-}
diff --git a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/ServletWebServer.java b/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/ServletWebServer.java
deleted file mode 100644
index 0a4e0b6..0000000
--- a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/ServletWebServer.java
+++ /dev/null
@@ -1,141 +0,0 @@
-package org.xbib.netty.http.xmlrpc.servlet;
-
-import org.xbib.netty.http.xmlrpc.server.XmlRpcStreamServer;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.util.Enumeration;
-import java.util.NoSuchElementException;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-
-/**
- * This is a subclass of the {@link WebServer}, which offers a minimal
- * servlet API. It is recommended to use this class, rather than the
- * {@link WebServer}, because it offers you a smooth migration path to
- * a full blown servlet engine.
- * Use of the {@link ServletWebServer} goes like this: First of all,
- * create a servlet. It may be an instance of {@link XmlRpcServlet} or
- * a subclass thereof. Note, that servlets are stateless: One servlet
- * may be used by multiple threads (aka requests) concurrently. In
- * other words, the servlet must not have any instance variables,
- * other than those which are read only after the servlets
- * initialization.
- * The XmlRpcServlet is by default using a property file named
- * org/apache/xmlrpc/server/webserver/XmlRpcServlet.properties
.
- *
- * final int port = 8088;
- * XmlRpcServlet servlet = new XmlRpcServlet();
- * ServletWebServer webServer = new ServletWebServer(servlet, port);
- * webServer.start();
- *
- */
-public class ServletWebServer extends WebServer {
-
- private final HttpServlet servlet;
-
- /** Creates a new instance, which is listening on all
- * local IP addresses and the given port.
- * @param pServlet The servlet, which is handling requests.
- * @param pPort The servers port number; 0 for a random
- * port being choosen.
- * @throws ServletException Initializing the servlet failed.
- */
- public ServletWebServer(HttpServlet pServlet, int pPort) throws ServletException {
- this(pServlet, pPort, null);
- }
-
- /** Creates a new instance, which is listening on the
- * given IP address and the given port.
- * @param pServlet The servlet, which is handling requests.
- * @param pPort The servers port number; 0 for a random
- * port being choosen.
- * @param pAddr The servers IP address.
- * @throws ServletException Initializing the servlet failed.
- */
- public ServletWebServer(HttpServlet pServlet, int pPort, InetAddress pAddr) throws ServletException {
- super(pPort, pAddr);
- servlet = pServlet;
- servlet.init(new ServletConfig() {
-
- @Override
- public String getServletName() { return servlet.getClass().getName(); }
-
- @Override
- public ServletContext getServletContext() {
- throw new IllegalStateException("Context not available");
- }
-
- @Override
- public String getInitParameter(String pArg0) {
- return null;
- }
-
- @Override
- public Enumeration getInitParameterNames() {
- return new Enumeration(){
-
- @Override
- public boolean hasMoreElements() {
- return false;
- }
-
- @Override
- public String nextElement() {
- throw new NoSuchElementException();
- }
- };
- }
-
- });
- }
-
- @Override
- protected Runnable newTask(WebServer pWebServer,
- XmlRpcStreamServer pXmlRpcServer,
- Socket pSocket) throws IOException {
- return new ServletConnection(servlet, pSocket);
- }
-
- /** This exception is thrown by the request handling classes,
- * advising the server, that it should return an error response.
- */
- public static class ServletWebServerException extends IOException {
-
- private static final long serialVersionUID = 49879832748972394L;
-
- private final int statusCode;
-
- private final String description;
-
- /** Creates a new instance.
- * @param pStatusCode The HTTP status code being sent to the client.
- * @param pMessage The HTTP status message being sent to the client.
- * @param pDescription The error description being sent to the client
- * in the response body.
- */
- ServletWebServerException(int pStatusCode, String pMessage, String pDescription) {
- super(pMessage);
- statusCode = pStatusCode;
- description = pDescription;
- }
-
- public String getMessage() { return statusCode + " " + super.getMessage(); }
-
- /** Returns the error description. The server will send the description
- * as plain text in the response body.
- * @return The error description.
- */
- public String getDescription() { return description; }
-
- /** Returns the HTTP status code.
- * @return The status code.
- */
- public int getStatusCode() { return statusCode; }
- }
-
-}
diff --git a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/ThreadPool.java b/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/ThreadPool.java
deleted file mode 100644
index b137e8d..0000000
--- a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/ThreadPool.java
+++ /dev/null
@@ -1,225 +0,0 @@
-package org.xbib.netty.http.xmlrpc.servlet;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/** Simple thread pool. A task is executed by obtaining a thread from
- * the pool
- */
-public class ThreadPool {
-
- /** A task, which may be interrupted, if the pool is shutting down.
- */
- public interface InterruptableTask extends Runnable {
-
- /** Interrupts the task.
- * @throws Throwable Shutting down the task failed.
- */
- void shutdown() throws Throwable;
- }
-
- private class Poolable extends Thread implements Runnable {
-
- private final Logger logger = Logger.getLogger(Poolable.class.getName());
-
- private volatile boolean shuttingDown;
-
- private Runnable task;
-
- Poolable(ThreadGroup pGroup, int pNum) {
- super(pGroup, pGroup.getName() + "-" + pNum);
- super.start();
- }
-
- @Override
- public void run() {
- while (!shuttingDown) {
- final Runnable t = getTask();
- if (t == null) {
- try {
- synchronized (this) {
- if (!shuttingDown && getTask() == null) {
- wait();
- }
- }
- } catch (InterruptedException e) {
- // Do nothing
- }
- } else {
- try {
- t.run();
- resetTask();
- repool(Poolable.this);
- } catch (Throwable e) {
- logger.log(Level.SEVERE, e.getMessage(), e);
- remove(Poolable.this);
- Poolable.this.shutdown();
- resetTask();
- }
- }
- }
- }
-
- synchronized void shutdown() {
- shuttingDown = true;
- final Runnable t = getTask();
- if (t instanceof InterruptableTask) {
- try {
- ((InterruptableTask) t).shutdown();
- } catch (Throwable th) {
- // Ignore me
- }
- }
- task = null;
- synchronized (this) {
- super.notify();
- }
- }
-
- private Runnable getTask() {
- return task;
- }
-
- private void resetTask() {
- task = null;
- }
-
- void start(Runnable pTask) {
- task = pTask;
- synchronized (this) {
- super.notify();
- }
- }
- }
-
- private final ThreadGroup threadGroup;
-
- private final int maxSize;
-
- private final List waitingThreads = new ArrayList<>();
-
- private final List runningThreads = new ArrayList<>();
-
- private final List waitingTasks = new ArrayList<>();
-
- private int num;
-
-
- /** Creates a new instance.
- * @param pMaxSize Maximum number of concurrent threads.
- * @param pName Thread group name.
- */
- public ThreadPool(int pMaxSize, String pName) {
- maxSize = pMaxSize;
- threadGroup = new ThreadGroup(pName);
- }
-
- private synchronized void remove(Poolable pPoolable) {
- runningThreads.remove(pPoolable);
- waitingThreads.remove(pPoolable);
- }
-
- private void repool(Poolable pPoolable) {
- boolean discarding = false;
- Runnable task = null;
- Poolable poolable = null;
- synchronized (this) {
- if (runningThreads.remove(pPoolable)) {
- if (maxSize != 0 && runningThreads.size() + waitingThreads.size() >= maxSize) {
- discarding = true;
- } else {
- waitingThreads.add(pPoolable);
- if (waitingTasks.size() > 0) {
- task = waitingTasks.remove(waitingTasks.size() - 1);
- poolable = getPoolable(task, false);
- }
- }
- } else {
- discarding = true;
- }
- if (discarding) {
- remove(pPoolable);
- }
- }
- if (poolable != null) {
- poolable.start(task);
- }
- if (discarding) {
- pPoolable.shutdown();
- }
- }
-
- /**
- * Starts a task immediately.
- * @param pTask The task being started.
- * @return True, if the task could be started immediately. False, if
- * the maxmimum number of concurrent tasks was exceeded.
- */
- public boolean startTask(Runnable pTask) {
- final Poolable poolable = getPoolable(pTask, false);
- if (poolable == null) {
- return false;
- }
- poolable.start(pTask);
- return true;
- }
-
- private synchronized Poolable getPoolable(Runnable pTask, boolean pQueue) {
- if (maxSize != 0 && runningThreads.size() >= maxSize) {
- if (pQueue) {
- waitingTasks.add(pTask);
- }
- return null;
- }
- Poolable poolable;
- if (waitingThreads.size() > 0) {
- poolable = (Poolable) waitingThreads.remove(waitingThreads.size()-1);
- } else {
- poolable = new Poolable(threadGroup, num++);
- }
- runningThreads.add(poolable);
- return poolable;
- }
-
- /**
- * Adds a task for immediate or deferred execution.
- * @param pTask The task being added.
- * @return True, if the task was started immediately. False, if
- * the task will be executed later.
- * @deprecated No longer in use.
- */
- @Deprecated
- public boolean addTask(Runnable pTask) {
- final Poolable poolable = getPoolable(pTask, true);
- if (poolable != null) {
- poolable.start(pTask);
- return true;
- }
- return false;
- }
-
- /** Closes the pool.
- */
- public synchronized void shutdown() {
- while (!waitingThreads.isEmpty()) {
- Poolable poolable = (Poolable) waitingThreads.remove(waitingThreads.size()-1);
- poolable.shutdown();
- }
- while (!runningThreads.isEmpty()) {
- Poolable poolable = (Poolable) runningThreads.remove(runningThreads.size()-1);
- poolable.shutdown();
- }
- }
-
- /** Returns the maximum number of concurrent threads.
- * @return Maximum number of threads.
- */
- public int getMaxThreads() { return maxSize; }
-
- /** Returns the number of threads, which have actually been created,
- * as opposed to the number of currently running threads.
- */
- public synchronized int getNumThreads() { return num; }
-}
diff --git a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/WebServer.java b/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/WebServer.java
deleted file mode 100644
index 241b26e..0000000
--- a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/WebServer.java
+++ /dev/null
@@ -1,396 +0,0 @@
-package org.xbib.netty.http.xmlrpc.servlet;
-
-import org.xbib.netty.http.xmlrpc.server.XmlRpcServer;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcStreamServer;
-
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-/**
- * The {@link WebServer} is a minimal HTTP server, that might be used
- * as an embedded web server.
- * Use of the {@link WebServer} has grown very popular amongst users
- * of Apache XML-RPC. Why this is the case, can hardly be explained,
- * because the {@link WebServer} is at best a workaround, compared to
- * full blown servlet engines like Tomcat or Jetty. For example, under
- * heavy load it will almost definitely be slower than a real servlet
- * engine, because it does neither support proper keepalive (multiple
- * requests per physical connection) nor chunked mode (in other words,
- * it cannot stream requests).
- * If you still insist in using the {@link WebServer}, it is
- * recommended to use its subclass, the {@link ServletWebServer} instead,
- * which offers a minimal subset of the servlet API. In other words,
- * you keep yourself the option to migrate to a real servlet engine
- * later.
- * Use of the {@link WebServer} goes roughly like this: First of all,
- * create a property file (for example "MyHandlers.properties") and
- * add it to your jar file. The property keys are handler names and
- * the property values are the handler classes. Once that is done,
- * create an instance of WebServer:
- *
- * final int port = 8088;
- * final String propertyFile = "MyHandler.properties";
- *
- * PropertyHandlerMapping mapping = new PropertyHandlerMapping();
- * ClassLoader cl = Thread.currentThread().getContextClassLoader();
- * mapping.load(cl, propertyFile);
- * WebServer webServer = new WebServer(port);
- * XmlRpcServerConfigImpl config = new XmlRpcServerConfigImpl();
- * XmlRpcServer server = webServer.getXmlRpcServer();
- * server.setConfig(config);
- * server.setHandlerMapping(mapping);
- * webServer.start();
- *
- */
-public class WebServer implements Runnable {
-
- protected ServerSocket serverSocket;
-
- private final WebServerThread webServerThread;
-
- private ThreadPool pool;
-
- protected final List accept = new ArrayList<>();
-
- protected final List deny = new ArrayList<>();
-
- protected final XmlRpcStreamServer server = newXmlRpcStreamServer();
-
- protected XmlRpcStreamServer newXmlRpcStreamServer(){
- return new ConnectionServer();
- }
-
- // Inputs to setupServerSocket()
- private InetAddress address;
-
- private int port;
-
- private boolean paranoid;
-
- static final String HTTP_11 = "HTTP/1.1";
- /** Creates a web server at the specified port number.
- * @param pPort Port number; 0 for a random port, choosen by the
- * operating system.
- */
- public WebServer(int pPort) {
- this(pPort, null);
- }
-
- /** Creates a web server at the specified port number and IP address.
- * @param pPort Port number; 0 for a random port, choosen by the
- * operating system.
- * @param pAddr Local IP address; null for all available IP addresses.
- */
- public WebServer(int pPort, InetAddress pAddr) {
- address = pAddr;
- port = pPort;
- webServerThread = new WebServerThread(this, "XML-RPC Weblistener");
- }
-
- /**
- * Factory method to manufacture the server socket. Useful as a
- * hook method for subclasses to override when they desire
- * different flavor of socket (i.e. a SSLServerSocket
).
- *
- * @param pPort Port number; 0 for a random port, choosen by the operating
- * system.
- * @param backlog
- * @param addr If null
, binds to
- * INADDR_ANY
, meaning that all network interfaces on
- * a multi-homed host will be listening.
- * @exception IOException Error creating listener socket.
- */
- protected ServerSocket createServerSocket(int pPort, int backlog, InetAddress addr)
- throws IOException {
- return new ServerSocket(pPort, backlog, addr);
- }
-
- /**
- * Initializes this server's listener socket with the specified
- * attributes, assuring that a socket timeout has been set. The
- * {@link #createServerSocket(int, int, InetAddress)} method can
- * be overridden to change the flavor of socket used.
- *
- * @see #createServerSocket(int, int, InetAddress)
- */
- private synchronized void setupServerSocket(int backlog) throws IOException {
- serverSocket = createServerSocket(port, backlog, address);
- // A socket timeout must be set.
- if (serverSocket.getSoTimeout() <= 0) {
- serverSocket.setSoTimeout(4096);
- }
- }
-
- /**
- * Spawns a new thread which binds this server to the port it's
- * configured to accept connections on.
- *
- * @see #run()
- * @throws IOException Binding the server socket failed.
- */
- public void start() throws IOException {
- setupServerSocket(50);
- // Not marked as daemon thread since run directly via main().
- webServerThread.start();
- }
-
- /**
- * Switch client filtering on/off.
- * @param pParanoid True to enable filtering, false otherwise.
- * @see #acceptClient(String)
- * @see #denyClient(String)
- */
- public void setParanoid(boolean pParanoid) {
- paranoid = pParanoid;
- }
-
- /**
- * Returns the client filtering state.
- * @return True, if client filtering is enabled, false otherwise.
- * @see #acceptClient(String)
- * @see #denyClient(String)
- */
- protected boolean isParanoid() {
- return paranoid;
- }
-
- /** Add an IP address to the list of accepted clients. The parameter can
- * contain '*' as wildcard character, e.g. "192.168.*.*". You must call
- * setParanoid(true) in order for this to have any effect.
- * @param pAddress The IP address being enabled.
- * @see #denyClient(String)
- * @see #setParanoid(boolean)
- * @throws IllegalArgumentException Parsing the address failed.
- */
- public void acceptClient(String pAddress) {
- accept.add(new AddressMatcher(pAddress));
- }
-
- /**
- * Add an IP address to the list of denied clients. The parameter can
- * contain '*' as wildcard character, e.g. "192.168.*.*". You must call
- * setParanoid(true) in order for this to have any effect.
- * @param pAddress The IP address being disabled.
- * @see #acceptClient(String)
- * @see #setParanoid(boolean)
- * @throws IllegalArgumentException Parsing the address failed.
- */
- public void denyClient(String pAddress) {
- deny.add(new AddressMatcher(pAddress));
- }
-
- /**
- * Checks incoming connections to see if they should be allowed.
- * If not in paranoid mode, always returns true.
- *
- * @param s The socket to inspect.
- * @return Whether the connection should be allowed.
- */
- protected boolean allowConnection(Socket s) {
- if (!paranoid) {
- return true;
- }
- int l = deny.size();
- byte[] addr = s.getInetAddress().getAddress();
- for (int i = 0; i < l; i++) {
- AddressMatcher match = deny.get(i);
- if (match.matches(addr)) {
- return false;
- }
- }
- l = accept.size();
- for (int i = 0; i < l; i++) {
- AddressMatcher match = accept.get(i);
- if (match.matches(addr)) {
- return true;
- }
- }
- return false;
- }
-
- protected Runnable newTask(WebServer pServer, XmlRpcStreamServer pXmlRpcServer,
- Socket pSocket) throws IOException {
- return new Connection(pServer, pXmlRpcServer, pSocket);
- }
-
- /**
- * Listens for client requests until stopped. Call {@link
- * #start()} to invoke this method, and {@link #shutdown()} to
- * break out of it.
- *
- * @throws RuntimeException Generally caused by either an
- * UnknownHostException
or BindException
- * with the vanilla web server.
- *
- * @see #start()
- * @see #shutdown()
- */
- @Override
- public void run() {
- pool = newThreadPool();
- try {
- while (!webServerThread.closed) {
- if (serverSocket.isClosed()) {
- break;
- }
- Socket socket = null;
- try {
- socket = serverSocket.accept();
- socket.setTcpNoDelay(true);
- if (allowConnection(socket)) {
- // set read timeout to 1 seconds
- socket.setSoTimeout(1000);
- Runnable task = newTask(this, server, socket);
- if (pool.startTask(task)) {
- socket = null;
- } else {
- log("Maximum load of " + pool.getMaxThreads()
- + " exceeded, rejecting client");
- }
- }
- } catch (InterruptedIOException e) {
- //
- } catch (Throwable t) {
- log(t);
- throw new RuntimeException(t);
- } finally {
- if (socket != null) {
- try {
- log("closing client socket");
- socket.close();
- } catch (Throwable ignore) {
-
- }
- }
- }
- }
- } finally {
- pool.shutdown();
- if (serverSocket != null && !serverSocket.isClosed()) {
- try {
- log("closing server socket");
- serverSocket.close();
- } catch (IOException e) {
- log(e);
- }
- }
- }
- }
-
- protected ThreadPool newThreadPool() {
- return new ThreadPool(server.getMaxThreads(), "XML-RPC");
- }
-
- /**
- * Stop listening on the server port.
- * Shutting down our {@link #webServerThread} effectively breaks it out of its {@link #run()} loop.
- *
- * @see #run()
- */
- public synchronized void shutdown() throws IOException {
- webServerThread.closed = true;
- webServerThread.interrupt();
- // wait for server socket down
- while (serverSocket != null && !serverSocket.isClosed()) {
- try {
- Thread.sleep(25L);
- } catch (InterruptedException e) {
- //
- }
- }
- serverSocket = null;
- try {
- Thread.sleep(25L);
- } catch (InterruptedException e) {
- //
- }
- log("shutdown complete");
- }
-
- public boolean isShutDown() {
- return serverSocket.isClosed();
- }
-
- /** Returns the port, on which the web server is running.
- * This method may be invoked after {@link #start()} only.
- * @return Servers port number
- */
- public int getPort() {
- return serverSocket.getLocalPort();
- }
-
- /** Logs an error.
- * @param pError The error being logged.
- */
- public void log(Throwable pError) {
- String msg = pError.getMessage() == null ? pError.getClass().getName() : pError.getMessage();
- server.getErrorLogger().log(msg, pError);
- }
-
- /** Logs a message.
- * @param pMessage The being logged.
- */
- public void log(String pMessage) {
- server.getErrorLogger().log(pMessage);
- }
-
- /** Returns the {@link XmlRpcServer}.
- * @return The server object.
- */
- public XmlRpcStreamServer getXmlRpcServer() {
- return server;
- }
-
- private class WebServerThread extends Thread {
- volatile boolean closed = false;
-
- WebServerThread(Runnable runnable, String name) {
- super(runnable, name);
- }
- }
-
- private class AddressMatcher {
-
- private final int[] pattern;
-
- AddressMatcher(String pAddress) {
- try {
- pattern = new int[4];
- StringTokenizer st = new StringTokenizer(pAddress, ".");
- if (st.countTokens() != 4) {
- throw new IllegalArgumentException();
- }
- for (int i = 0; i < 4; i++) {
- String next = st.nextToken();
- if ("*".equals(next)) {
- pattern[i] = 256;
- } else {
- pattern[i] = (byte) Integer.parseInt(next);
- }
- }
- } catch (Exception e) {
- throw new IllegalArgumentException("\"" + pAddress
- + "\" does not represent a valid IP address");
- }
- }
-
- boolean matches(byte[] pAddress) {
- for (int i = 0; i < 4; i++) {
- if (pattern[i] > 255) {
- continue; // Wildcard
- }
- if (pattern[i] != pAddress[i]) {
- return false;
- }
- }
- return true;
- }
- }
-
-}
diff --git a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/XmlRpcServlet.java b/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/XmlRpcServlet.java
deleted file mode 100644
index b3bc551..0000000
--- a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/XmlRpcServlet.java
+++ /dev/null
@@ -1,191 +0,0 @@
-package org.xbib.netty.http.xmlrpc.servlet;
-
-import org.xbib.netty.http.xmlrpc.common.TypeConverterFactory;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.server.AbstractReflectiveHandlerMapping;
-import org.xbib.netty.http.xmlrpc.server.PropertyHandlerMapping;
-import org.xbib.netty.http.xmlrpc.server.RequestProcessorFactoryFactory;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcHandlerMapping;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcServer;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.logging.Logger;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/** A default servlet implementation The typical use would
- * be to derive a subclass, which is overwriting at least the
- * method {@link #newXmlRpcHandlerMapping()}.
- * The servlet accepts the following init parameters:
- *
- * Name Description
- * enabledForExtensions Sets the value
- * {@link XmlRpcConfig#isEnabledForExtensions()}
- * to true.
- *
- *
- */
-public class XmlRpcServlet extends HttpServlet {
-
- private static final long serialVersionUID = 2348768267234L;
-
- private static final Logger log = Logger.getLogger(XmlRpcServlet.class.getName());
-
- private XmlRpcServletServer server;
-
-
- private AbstractReflectiveHandlerMapping.AuthenticationHandler authenticationHandler;
-
- private RequestProcessorFactoryFactory requestProcessorFactoryFactory;
-
- private TypeConverterFactory typeConverterFactory;
-
- /** Returns the servlets instance of {@link XmlRpcServletServer}.
- * @return The configurable instance of {@link XmlRpcServletServer}.
- */
- public XmlRpcServletServer getXmlRpcServletServer() {
- return server;
- }
-
- private void handleInitParameters(ServletConfig pConfig) throws ServletException {
- for (Enumeration en = pConfig.getInitParameterNames(); en.hasMoreElements(); ) {
- String name = en.nextElement();
- String value = pConfig.getInitParameter(name);
- try {
- if (!ReflectionUtil.setProperty(this, name, value)
- && !ReflectionUtil.setProperty(server, name, value)
- && !ReflectionUtil.setProperty(server.getConfig(), name, value)) {
- throw new ServletException("Unknown init parameter " + name);
- }
- } catch (IllegalAccessException e) {
- throw new ServletException("Illegal access to instance of " + server.getClass().getName()
- + " while setting property " + name + ": " + e.getMessage(), e);
- } catch (InvocationTargetException e) {
- Throwable t = e.getTargetException();
- throw new ServletException("Failed to invoke setter for property " + name
- + " on instance of " + server.getClass().getName()
- + ": " + t.getMessage(), t);
- }
- }
- }
-
- public void init(ServletConfig pConfig) throws ServletException {
- super.init(pConfig);
- try {
- server = newXmlRpcServer(pConfig);
- handleInitParameters(pConfig);
- server.setHandlerMapping(newXmlRpcHandlerMapping());
- } catch (XmlRpcException e) {
- try {
- log("Failed to create XmlRpcServer: " + e.getMessage(), e);
- } catch (Throwable ignore) {
- }
- throw new ServletException(e);
- }
- }
-
- /** Sets the servlets {@link AbstractReflectiveHandlerMapping.AuthenticationHandler}.
- */
- public void setAuthenticationHandler(AbstractReflectiveHandlerMapping.AuthenticationHandler pHandler) {
- authenticationHandler = pHandler;
- }
-
- /** Returns the servlets {@link AbstractReflectiveHandlerMapping.AuthenticationHandler}.
- */
- public AbstractReflectiveHandlerMapping.AuthenticationHandler getAuthenticationHandler() {
- return authenticationHandler;
- }
-
- /** Sets the servlets {@link RequestProcessorFactoryFactory}.
- */
- public void setRequestProcessorFactoryFactory(RequestProcessorFactoryFactory pFactory) {
- requestProcessorFactoryFactory = pFactory;
- }
-
- /** Returns the servlets {@link RequestProcessorFactoryFactory}.
- */
- public RequestProcessorFactoryFactory getRequestProcessorFactoryFactory() {
- return requestProcessorFactoryFactory;
- }
-
- /** Sets the servlets {@link TypeConverterFactory}.
- */
- public void setTypeConverterFactory(TypeConverterFactory pFactory) {
- typeConverterFactory = pFactory;
- }
-
- /** Returns the servlets {@link TypeConverterFactory}.
- */
- public TypeConverterFactory getTypeConverterFactory() {
- return typeConverterFactory;
- }
-
- /** Creates a new instance of {@link XmlRpcServer},
- * which is being used to process the requests. The default implementation
- * will simply invoke new {@link XmlRpcServer}.
- * @param pConfig The servlets configuration.
- * @throws XmlRpcException
- */
- protected XmlRpcServletServer newXmlRpcServer(ServletConfig pConfig)
- throws XmlRpcException {
- return new XmlRpcServletServer();
- }
-
- /** Creates a new handler mapping. The default implementation loads
- * a property file from the resource
- * org/apache/xmlrpc/webserver/XmlRpcServlet.properties
- */
- protected XmlRpcHandlerMapping newXmlRpcHandlerMapping() throws XmlRpcException {
- URL url = XmlRpcServlet.class.getResource("XmlRpcServlet.properties");
- if (url == null) {
- throw new XmlRpcException("Failed to locate resource XmlRpcServlet.properties");
- }
- try {
- return newPropertyHandlerMapping(url);
- } catch (IOException e) {
- throw new XmlRpcException("Failed to load resource " + url + ": " + e.getMessage(), e);
- }
- }
-
- /** Creates a new instance of {@link PropertyHandlerMapping} by
- * loading the property file from the given URL. Called from
- * {@link #newXmlRpcHandlerMapping()}.
- */
- protected PropertyHandlerMapping newPropertyHandlerMapping(URL url) throws IOException, XmlRpcException {
- PropertyHandlerMapping mapping = new PropertyHandlerMapping();
- mapping.setAuthenticationHandler(authenticationHandler);
- if (requestProcessorFactoryFactory != null) {
- mapping.setRequestProcessorFactoryFactory(requestProcessorFactoryFactory);
- }
- if (typeConverterFactory != null) {
- mapping.setTypeConverterFactory(typeConverterFactory);
- } else {
- mapping.setTypeConverterFactory(server.getTypeConverterFactory());
- }
- mapping.setVoidMethodEnabled(server.getConfig().isEnabledForExtensions());
- mapping.load(Thread.currentThread().getContextClassLoader(), url);
- return mapping;
- }
-
- /** Creates a new instance of {@link RequestData}
- * for the request.
- */
- public void doPost(HttpServletRequest pRequest, HttpServletResponse pResponse) throws IOException, ServletException {
- server.execute(pRequest, pResponse);
- }
-
- public void log(String pMessage, Throwable pThrowable) {
- server.getErrorLogger().log(pMessage, pThrowable);
- }
-
- public void log(String pMessage) {
- log.info(pMessage);
- }
-}
diff --git a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/XmlRpcServletServer.java b/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/XmlRpcServletServer.java
deleted file mode 100644
index 71a71f4..0000000
--- a/netty-http-xmlrpc-servlet/src/main/java/org/xbib/netty/http/xmlrpc/servlet/XmlRpcServletServer.java
+++ /dev/null
@@ -1,126 +0,0 @@
-package org.xbib.netty.http.xmlrpc.servlet;
-
-import org.xbib.netty.http.xmlrpc.common.ServerStreamConnection;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcException;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcHttpRequestConfig;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcHttpRequestConfigImpl;
-import org.xbib.netty.http.xmlrpc.common.XmlRpcStreamRequestConfig;
-import org.xbib.netty.http.xmlrpc.common.util.HttpUtil;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcHttpServer;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcHttpServerConfig;
-import org.xbib.netty.http.xmlrpc.server.XmlRpcServer;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/** An extension of {@link XmlRpcServer},
- * which is suitable for processing servlet requests.
- */
-public class XmlRpcServletServer extends XmlRpcHttpServer {
- protected static class ServletStreamConnection implements ServerStreamConnection {
- private final HttpServletRequest request;
- private final HttpServletResponse response;
-
- protected ServletStreamConnection(HttpServletRequest pRequest,
- HttpServletResponse pResponse) {
- request = pRequest;
- response = pResponse;
- }
-
- /** Returns the servlet request.
- */
- public HttpServletRequest getRequest() { return request; }
- /** Returns the servlet response.
- */
- public HttpServletResponse getResponse() { return response; }
-
- public InputStream newInputStream() throws IOException {
- return request.getInputStream();
- }
-
- public OutputStream newOutputStream() throws IOException {
- response.setContentType("text/xml");
- return response.getOutputStream();
- }
-
- public void close() throws IOException {
- response.getOutputStream().close();
- }
- }
-
- /**
- * @param pRequest The request object.
- */
- protected XmlRpcHttpRequestConfigImpl newConfig(HttpServletRequest pRequest) {
- return new XmlRpcHttpRequestConfigImpl();
- }
-
- protected XmlRpcHttpRequestConfigImpl getConfig(HttpServletRequest pRequest) {
- XmlRpcHttpRequestConfigImpl result = newConfig(pRequest);
- XmlRpcHttpServerConfig serverConfig = (XmlRpcHttpServerConfig) getConfig();
- result.setBasicEncoding(serverConfig.getBasicEncoding());
- result.setContentLengthOptional(serverConfig.isContentLengthOptional()
- && (pRequest.getHeader("Content-Length") == null));
- result.setEnabledForExtensions(serverConfig.isEnabledForExtensions());
- result.setGzipCompressing(HttpUtil.isUsingGzipEncoding(pRequest.getHeader("Content-Encoding")));
- result.setGzipRequesting(HttpUtil.isUsingGzipEncoding(pRequest.getHeaders("Accept-Encoding")));
- result.setEncoding(pRequest.getCharacterEncoding());
- result.setEnabledForExceptions(serverConfig.isEnabledForExceptions());
- HttpUtil.parseAuthorization(result, pRequest.getHeader("Authorization"));
- return result;
- }
-
- protected ServletStreamConnection newStreamConnection(HttpServletRequest pRequest,
- HttpServletResponse pResponse) {
- return new ServletStreamConnection(pRequest, pResponse);
- }
-
- /** Processes the servlet request.
- * @param pRequest The servlet request being read.
- * @param pResponse The servlet response being created.
- * @throws IOException Reading the request or writing the response failed.
- * @throws ServletException Processing the request failed.
- */
- public void execute(HttpServletRequest pRequest, HttpServletResponse pResponse)
- throws ServletException, IOException {
- XmlRpcHttpRequestConfigImpl config = getConfig(pRequest);
- ServletStreamConnection ssc = newStreamConnection(pRequest, pResponse);
- try {
- super.execute(config, ssc);
- } catch (XmlRpcException e) {
- throw new ServletException(e);
- }
- }
-
- /** Returns, whether the requests content length is required.
- */
- protected boolean isContentLengthRequired(XmlRpcStreamRequestConfig pConfig) {
- if (!pConfig.isEnabledForExtensions()) {
- // The spec requires a content-length.
- return true;
- }
- boolean isRequired = !((XmlRpcHttpServerConfig) getConfig()).isContentLengthOptional();
- if(pConfig instanceof XmlRpcHttpRequestConfig) {
- isRequired |= !((XmlRpcHttpRequestConfig)pConfig).isContentLengthOptional();
- }
- return isRequired;
- }
-
- protected OutputStream getOutputStream(XmlRpcStreamRequestConfig pConfig,
- ServerStreamConnection pConnection,
- int pSize) throws IOException {
- if (pSize != -1) {
- ((ServletStreamConnection) pConnection).getResponse().setContentLength(pSize);
- }
- return super.getOutputStream(pConfig, pConnection, pSize);
- }
-
- protected void setResponseHeader(ServerStreamConnection pConnection, String pHeader, String pValue) {
- ((ServletStreamConnection) pConnection).getResponse().setHeader(pHeader, pValue);
- }
-}
diff --git a/settings.gradle b/settings.gradle
index d1add36..1c653e4 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -3,7 +3,3 @@ include 'netty-http-client'
include 'netty-http-server'
include 'netty-http-server-reactive'
include 'netty-http-server-rest'
-include 'netty-http-xmlrpc-common'
-include 'netty-http-xmlrpc-server'
-include 'netty-http-xmlrpc-servlet'
-include 'netty-http-xmlrpc-client'