org.apache.xmlrpc_3.0.0.v20100427-1100

16:41:18.907 INFO  jd.cli.Main - Decompiling org.apache.xmlrpc_3.0.0.v20100427-1100.jar
package org.apache.xmlrpc;

import java.util.TimeZone;

public abstract interface XmlRpcConfig
{
  public abstract boolean isEnabledForExtensions();
  
  public abstract TimeZone getTimeZone();
}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.XmlRpcConfig
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc;

import java.util.TimeZone;
import org.apache.xmlrpc.common.XmlRpcHttpConfig;

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;
  }
  
  public void setEnabledForExtensions(boolean pExtensions)
  {
    enabledForExtensions = pExtensions;
  }
  
  public void setBasicEncoding(String pEncoding)
  {
    basicEncoding = pEncoding;
  }
  
  public String getBasicEncoding()
  {
    return basicEncoding;
  }
  
  public void setEncoding(String pEncoding)
  {
    encoding = pEncoding;
  }
  
  public String getEncoding()
  {
    return encoding;
  }
  
  public boolean isContentLengthOptional()
  {
    return contentLengthOptional;
  }
  
  public void setContentLengthOptional(boolean pContentLengthOptional)
  {
    contentLengthOptional = pContentLengthOptional;
  }
  
  public TimeZone getTimeZone()
  {
    return timeZone;
  }
  
  public void setTimeZone(TimeZone pTimeZone)
  {
    timeZone = pTimeZone;
  }
}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.XmlRpcConfigImpl
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc;

import java.io.PrintStream;
import java.io.PrintWriter;

public class XmlRpcException
  extends Exception
{
  private static final long serialVersionUID = 3258693217049325618L;
  public final int code;
  public final Throwable linkedException;
  
  public XmlRpcException(int pCode, String pMessage)
  {
    this(pCode, pMessage, null);
  }
  
  public XmlRpcException(String pMessage, Throwable pLinkedException)
  {
    this(0, pMessage, pLinkedException);
  }
  
  public XmlRpcException(String pMessage)
  {
    this(0, pMessage, null);
  }
  
  public XmlRpcException(int pCode, String pMessage, Throwable pLinkedException)
  {
    super(pMessage);
    code = pCode;
    linkedException = pLinkedException;
  }
  
  public void printStackTrace(PrintStream pStream)
  {
    super.printStackTrace(pStream);
    if (linkedException != null)
    {
      pStream.println("Caused by:");
      linkedException.printStackTrace(pStream);
    }
  }
  
  public void printStackTrace(PrintWriter pWriter)
  {
    super.printStackTrace(pWriter);
    if (linkedException != null)
    {
      pWriter.println("Caused by:");
      linkedException.printStackTrace(pWriter);
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.XmlRpcException
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc;

public abstract interface XmlRpcHandler
{
  public abstract Object execute(XmlRpcRequest paramXmlRpcRequest)
    throws XmlRpcException;
}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.XmlRpcHandler
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc;

public abstract interface XmlRpcRequest
{
  public abstract XmlRpcRequestConfig getConfig();
  
  public abstract String getMethodName();
  
  public abstract int getParameterCount();
  
  public abstract Object getParameter(int paramInt);
}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.XmlRpcRequest
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc;

public abstract interface XmlRpcRequestConfig
  extends XmlRpcConfig
{}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.XmlRpcRequestConfig
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc.client;

import org.apache.xmlrpc.XmlRpcRequest;

public abstract interface AsyncCallback
{
  public abstract void handleResult(XmlRpcRequest paramXmlRpcRequest, Object paramObject);
  
  public abstract void handleError(XmlRpcRequest paramXmlRpcRequest, Throwable paramThrowable);
}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.client.AsyncCallback
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc.client;

import org.apache.xmlrpc.XmlRpcException;

public class TimingOutCallback$TimeoutException
  extends XmlRpcException
{
  private static final long serialVersionUID = 4875266372372105081L;
  
  public TimingOutCallback$TimeoutException(int pCode, String message)
  {
    super(pCode, message);
  }
}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.client.TimingOutCallback.TimeoutException
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc.client;

import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.XmlRpcRequest;

public class TimingOutCallback
  implements AsyncCallback
{
  private final long timeout;
  private Object result;
  private Throwable error;
  private boolean responseSeen;
  
  public static class TimeoutException
    extends XmlRpcException
  {
    private static final long serialVersionUID = 4875266372372105081L;
    
    public TimeoutException(int pCode, String message)
    {
      super(message);
    }
  }
  
  public TimingOutCallback(long pTimeout)
  {
    timeout = pTimeout;
  }
  
  public synchronized Object waitForResponse()
    throws Throwable
  {
    wait(timeout);
    if (!responseSeen) {
      throw new TimeoutException(0, "No response after waiting for " + timeout + " milliseconds.");
    }
    if (error != null) {
      throw error;
    }
    return result;
  }
  
  public synchronized void handleError(XmlRpcRequest pRequest, Throwable pError)
  {
    responseSeen = true;
    error = pError;
    notify();
  }
  
  public synchronized void handleResult(XmlRpcRequest pRequest, Object pResult)
  {
    responseSeen = true;
    result = pResult;
    notify();
  }
}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.client.TimingOutCallback
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc.client;

import java.util.List;
import org.apache.xmlrpc.XmlRpcConfig;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.XmlRpcRequest;
import org.apache.xmlrpc.common.XmlRpcController;
import org.apache.xmlrpc.common.XmlRpcWorker;
import org.apache.xmlrpc.common.XmlRpcWorkerFactory;
import org.apache.xmlrpc.serializer.DefaultXMLWriterFactory;
import org.apache.xmlrpc.serializer.XmlWriterFactory;

public class XmlRpcClient
  extends XmlRpcController
{
  private XmlRpcTransportFactory transportFactory = new XmlRpcSunHttpTransportFactory(this);
  private XmlRpcClientConfig config = new XmlRpcClientConfigImpl();
  private XmlWriterFactory xmlWriterFactory = new DefaultXMLWriterFactory();
  
  protected XmlRpcWorkerFactory getDefaultXmlRpcWorkerFactory()
  {
    return new XmlRpcClientWorkerFactory(this);
  }
  
  public void setConfig(XmlRpcClientConfig pConfig)
  {
    config = pConfig;
  }
  
  public XmlRpcConfig getConfig()
  {
    return config;
  }
  
  public XmlRpcClientConfig getClientConfig()
  {
    return config;
  }
  
  public void setTransportFactory(XmlRpcTransportFactory pFactory)
  {
    transportFactory = pFactory;
  }
  
  public XmlRpcTransportFactory getTransportFactory()
  {
    return transportFactory;
  }
  
  public Object execute(String pMethodName, Object[] pParams)
    throws XmlRpcException
  {
    return execute(getClientConfig(), pMethodName, pParams);
  }
  
  public Object execute(XmlRpcClientConfig pConfig, String pMethodName, Object[] pParams)
    throws XmlRpcException
  {
    return execute(new XmlRpcClientRequestImpl(pConfig, pMethodName, pParams));
  }
  
  public Object execute(String pMethodName, List pParams)
    throws XmlRpcException
  {
    return execute(getClientConfig(), pMethodName, pParams);
  }
  
  public Object execute(XmlRpcClientConfig pConfig, String pMethodName, List pParams)
    throws XmlRpcException
  {
    return execute(new XmlRpcClientRequestImpl(pConfig, pMethodName, pParams));
  }
  
  public Object execute(XmlRpcRequest pRequest)
    throws XmlRpcException
  {
    return getWorkerFactory().getWorker().execute(pRequest);
  }
  
  public void executeAsync(String pMethodName, Object[] pParams, AsyncCallback pCallback)
    throws XmlRpcException
  {
    executeAsync(getClientConfig(), pMethodName, pParams, pCallback);
  }
  
  public void executeAsync(XmlRpcClientConfig pConfig, String pMethodName, Object[] pParams, AsyncCallback pCallback)
    throws XmlRpcException
  {
    executeAsync(new XmlRpcClientRequestImpl(pConfig, pMethodName, pParams), pCallback);
  }
  
  public void executeAsync(String pMethodName, List pParams, AsyncCallback pCallback)
    throws XmlRpcException
  {
    executeAsync(getClientConfig(), pMethodName, pParams, pCallback);
  }
  
  public void executeAsync(XmlRpcClientConfig pConfig, String pMethodName, List pParams, AsyncCallback pCallback)
    throws XmlRpcException
  {
    executeAsync(new XmlRpcClientRequestImpl(pConfig, pMethodName, pParams), pCallback);
  }
  
  public void executeAsync(XmlRpcRequest pRequest, AsyncCallback pCallback)
    throws XmlRpcException
  {
    XmlRpcClientWorker w = (XmlRpcClientWorker)getWorkerFactory().getWorker();
    w.execute(pRequest, pCallback);
  }
  
  public XmlWriterFactory getXmlWriterFactory()
  {
    return xmlWriterFactory;
  }
  
  public void setXmlWriterFactory(XmlWriterFactory pFactory)
  {
    xmlWriterFactory = pFactory;
  }
}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.client.XmlRpcClient
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc.client;

import org.apache.xmlrpc.XmlRpcRequestConfig;

public abstract interface XmlRpcClientConfig
  extends XmlRpcRequestConfig
{}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.client.XmlRpcClientConfig
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc.client;

import java.io.Serializable;
import java.net.URL;
import org.apache.xmlrpc.common.XmlRpcHttpRequestConfigImpl;
import org.apache.xmlrpc.common.XmlRpcRequestProcessor;

public class XmlRpcClientConfigImpl
  extends XmlRpcHttpRequestConfigImpl
  implements XmlRpcHttpClientConfig, XmlRpcLocalClientConfig, Cloneable, Serializable
{
  private static final long serialVersionUID = 4121131450507800889L;
  private URL serverURL;
  private XmlRpcRequestProcessor xmlRpcServer;
  
  public XmlRpcClientConfigImpl cloneMe()
  {
    try
    {
      return (XmlRpcClientConfigImpl)clone();
    }
    catch (CloneNotSupportedException e)
    {
      throw new IllegalStateException("Unable to create my clone");
    }
  }
  
  public void setServerURL(URL pURL)
  {
    serverURL = pURL;
  }
  
  public URL getServerURL()
  {
    return serverURL;
  }
  
  public void setXmlRpcServer(XmlRpcRequestProcessor pServer)
  {
    xmlRpcServer = pServer;
  }
  
  public XmlRpcRequestProcessor getXmlRpcServer()
  {
    return xmlRpcServer;
  }
}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.client.XmlRpcClientConfigImpl
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc.client;

import org.apache.xmlrpc.XmlRpcException;

public class XmlRpcClientException
  extends XmlRpcException
{
  private static final long serialVersionUID = 3545798797134608691L;
  
  public XmlRpcClientException(String pMessage, Throwable pCause)
  {
    super(0, pMessage, pCause);
  }
}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.client.XmlRpcClientException
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc.client;

import java.util.List;
import org.apache.xmlrpc.XmlRpcRequest;
import org.apache.xmlrpc.XmlRpcRequestConfig;

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;
  
  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);
  }
  
  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;
  }
}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.client.XmlRpcClientRequestImpl
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc.client;

import org.apache.xmlrpc.XmlRpcRequest;
import org.apache.xmlrpc.common.XmlRpcWorkerFactory;

final class XmlRpcClientWorker$1
  implements Runnable
{
  private final XmlRpcRequest val$pRequest;
  private final AsyncCallback val$pCallback;
  private final XmlRpcClientWorker this$0;
  
  XmlRpcClientWorker$1(XmlRpcClientWorker paramXmlRpcClientWorker, XmlRpcRequest paramXmlRpcRequest, AsyncCallback paramAsyncCallback)
  {
    this$0 = paramXmlRpcClientWorker;val$pRequest = paramXmlRpcRequest;val$pCallback = paramAsyncCallback;
  }
  
  public void run()
  {
    Object result = null;
    Throwable th = null;
    try
    {
      XmlRpcClient client = (XmlRpcClient)this$0.getController();
      result = client.getTransportFactory().getTransport().sendRequest(val$pRequest);
    }
    catch (Throwable t)
    {
      th = t;
    }
    XmlRpcClientWorker.access$000(this$0).releaseWorker(this$0);
    if (th == null) {
      val$pCallback.handleResult(val$pRequest, result);
    } else {
      val$pCallback.handleError(val$pRequest, th);
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.client.XmlRpcClientWorker.1
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc.client;

import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.XmlRpcRequest;
import org.apache.xmlrpc.common.XmlRpcController;
import org.apache.xmlrpc.common.XmlRpcWorker;
import org.apache.xmlrpc.common.XmlRpcWorkerFactory;

public class XmlRpcClientWorker
  implements XmlRpcWorker
{
  private final XmlRpcClientWorkerFactory factory;
  
  public XmlRpcClientWorker(XmlRpcClientWorkerFactory pFactory)
  {
    factory = pFactory;
  }
  
  public XmlRpcController getController()
  {
    return factory.getController();
  }
  
  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;
  }
  
  public void execute(XmlRpcRequest pRequest, AsyncCallback pCallback)
  {
    Runnable runnable = new Runnable()
    {
      private final XmlRpcRequest val$pRequest;
      private final AsyncCallback val$pCallback;
      
      public void run()
      {
        Object result = null;
        Throwable th = null;
        try
        {
          XmlRpcClient client = (XmlRpcClient)getController();
          result = client.getTransportFactory().getTransport().sendRequest(val$pRequest);
        }
        catch (Throwable t)
        {
          th = t;
        }
        factory.releaseWorker(XmlRpcClientWorker.this);
        if (th == null) {
          val$pCallback.handleResult(val$pRequest, result);
        } else {
          val$pCallback.handleError(val$pRequest, th);
        }
      }
    };
    newThread(runnable).start();
  }
}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.client.XmlRpcClientWorker
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc.client;

import org.apache.xmlrpc.common.XmlRpcWorker;
import org.apache.xmlrpc.common.XmlRpcWorkerFactory;

public class XmlRpcClientWorkerFactory
  extends XmlRpcWorkerFactory
{
  public XmlRpcClientWorkerFactory(XmlRpcClient pClient)
  {
    super(pClient);
  }
  
  protected XmlRpcWorker newWorker()
  {
    return new XmlRpcClientWorker(this);
  }
}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.client.XmlRpcClientWorkerFactory
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc.client;

import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;

final class XmlRpcCommonsTransport$1$1
  extends FilterOutputStream
{
  private final XmlRpcCommonsTransport.1 this$1;
  
  XmlRpcCommonsTransport$1$1(XmlRpcCommonsTransport.1 param1, OutputStream x0)
    throws IOException
  {
    super(x0);this$1 = param1;
  }
  
  public void close()
    throws IOException
  {
    flush();
  }
}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.client.XmlRpcCommonsTransport.1.1
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc.client;

import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStream;

final class XmlRpcCommonsTransport$1$2
  extends BufferedOutputStream
{
  private final XmlRpcCommonsTransport.1 this$1;
  
  XmlRpcCommonsTransport$1$2(XmlRpcCommonsTransport.1 param1, OutputStream x0)
    throws IOException
  {
    super(x0);this$1 = param1;
  }
  
  public void close()
    throws IOException
  {
    flush();
  }
}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.client.XmlRpcCommonsTransport.1.2
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc.client;

import java.io.BufferedOutputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.commons.httpclient.methods.RequestEntity;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.util.XmlRpcIOException;
import org.xml.sax.SAXException;

final class XmlRpcCommonsTransport$1
  implements RequestEntity
{
  private final XmlRpcStreamTransport.ReqWriter val$pWriter;
  private final XmlRpcCommonsTransport this$0;
  
  XmlRpcCommonsTransport$1(XmlRpcCommonsTransport paramXmlRpcCommonsTransport, XmlRpcStreamTransport.ReqWriter paramReqWriter)
    throws IOException
  {
    this$0 = paramXmlRpcCommonsTransport;val$pWriter = paramReqWriter;
  }
  
  public boolean isRepeatable()
  {
    return XmlRpcCommonsTransport.access$000(this$0) != -1;
  }
  
  public void writeRequest(OutputStream pOut)
    throws IOException
  {
    try
    {
      OutputStream ostream;
      OutputStream ostream;
      if (this$0.isUsingByteArrayOutput(XmlRpcCommonsTransport.access$100(this$0))) {
        ostream = new FilterOutputStream(pOut)
        {
          public void close()
            throws IOException
          {
            flush();
          }
        };
      } else {
        ostream = new BufferedOutputStream(pOut)
        {
          public void close()
            throws IOException
          {
            flush();
          }
        };
      }
      val$pWriter.write(ostream);
    }
    catch (XmlRpcException e)
    {
      throw new XmlRpcIOException(e);
    }
    catch (SAXException e)
    {
      throw new XmlRpcIOException(e);
    }
  }
  
  public long getContentLength()
  {
    return XmlRpcCommonsTransport.access$000(this$0);
  }
  
  public String getContentType()
  {
    return "text/xml";
  }
}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.client.XmlRpcCommonsTransport.1
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc.client;

import java.io.BufferedOutputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpConnectionManager;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpMethodBase;
import org.apache.commons.httpclient.HttpState;
import org.apache.commons.httpclient.HttpVersion;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.RequestEntity;
import org.apache.commons.httpclient.params.DefaultHttpParams;
import org.apache.commons.httpclient.params.HttpClientParams;
import org.apache.commons.httpclient.params.HttpConnectionParams;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.XmlRpcRequest;
import org.apache.xmlrpc.common.XmlRpcHttpConfig;
import org.apache.xmlrpc.common.XmlRpcHttpRequestConfig;
import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig;
import org.apache.xmlrpc.util.HttpUtil;
import org.apache.xmlrpc.util.XmlRpcIOException;
import org.xml.sax.SAXException;

public class XmlRpcCommonsTransport
  extends XmlRpcHttpTransport
{
  private final HttpClient client = new HttpClient();
  private static final String userAgent = "Apache XML RPC 3.0 (Jakarta Commons httpclient Transport)";
  private PostMethod method;
  private int contentLength = -1;
  private XmlRpcHttpClientConfig config;
  
  public XmlRpcCommonsTransport(XmlRpcClient pClient)
  {
    super(pClient, "Apache XML RPC 3.0 (Jakarta Commons httpclient Transport)");
  }
  
  protected void setContentLength(int pLength)
  {
    contentLength = pLength;
  }
  
  protected void initHttpHeaders(XmlRpcRequest pRequest)
    throws XmlRpcClientException
  {
    config = ((XmlRpcHttpClientConfig)pRequest.getConfig());
    method = new PostMethod(config.getServerURL().toString());
    super.initHttpHeaders(pRequest);
    if (config.getConnectionTimeout() != 0) {
      client.getHttpConnectionManager().getParams().setConnectionTimeout(config.getConnectionTimeout());
    }
    if (config.getReplyTimeout() != 0) {
      client.getHttpConnectionManager().getParams().setSoTimeout(config.getConnectionTimeout());
    }
    method.getParams().setVersion(HttpVersion.HTTP_1_1);
  }
  
  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;
    }
    return HttpUtil.isUsingGzipEncoding(h.getValue());
  }
  
  protected InputStream getInputStream()
    throws XmlRpcException
  {
    try
    {
      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 = "UTF-8";
      }
      client.getParams().setParameter("http.protocol.credential-charset", enc);
      Credentials creds = new UsernamePasswordCredentials(userName, pConfig.getBasicPassword());
      AuthScope scope = new AuthScope(null, -1, 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;
    }
    return HttpUtil.isUsingGzipEncoding(h.getValue());
  }
  
  protected void writeRequest(XmlRpcStreamTransport.ReqWriter pWriter)
    throws XmlRpcException
  {
    method.setRequestEntity(new RequestEntity()
    {
      private final XmlRpcStreamTransport.ReqWriter val$pWriter;
      
      public boolean isRepeatable()
      {
        return contentLength != -1;
      }
      
      public void writeRequest(OutputStream pOut)
        throws IOException
      {
        try
        {
          OutputStream ostream;
          OutputStream ostream;
          if (isUsingByteArrayOutput(config)) {
            ostream = new FilterOutputStream(pOut)
            {
              public void close()
                throws IOException
              {
                flush();
              }
            };
          } else {
            ostream = new BufferedOutputStream(pOut)
            {
              public void close()
                throws IOException
              {
                flush();
              }
            };
          }
          val$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
    {
      client.executeMethod(method);
    }
    catch (XmlRpcIOException e)
    {
      Throwable t = e.getLinkedException();
      if ((t instanceof XmlRpcException)) {
        throw ((XmlRpcException)t);
      }
      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);
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.client.XmlRpcCommonsTransport
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc.client;

public class XmlRpcCommonsTransportFactory
  extends XmlRpcTransportFactoryImpl
{
  public XmlRpcCommonsTransportFactory(XmlRpcClient pClient)
  {
    super(pClient);
  }
  
  public XmlRpcTransport getTransport()
  {
    return new XmlRpcCommonsTransport(getClient());
  }
}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.client.XmlRpcCommonsTransportFactory
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc.client;

import java.net.URL;
import org.apache.xmlrpc.common.XmlRpcHttpRequestConfig;

public abstract interface XmlRpcHttpClientConfig
  extends XmlRpcHttpRequestConfig
{
  public abstract URL getServerURL();
}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.client.XmlRpcHttpClientConfig
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc.client;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.XmlRpcRequest;
import org.xml.sax.SAXException;

public class XmlRpcHttpTransport$ByteArrayReqWriter
  implements XmlRpcStreamTransport.ReqWriter
{
  private final ByteArrayOutputStream baos;
  private final XmlRpcHttpTransport this$0;
  
  XmlRpcHttpTransport$ByteArrayReqWriter(XmlRpcHttpTransport paramXmlRpcHttpTransport, XmlRpcRequest pRequest)
    throws XmlRpcException, IOException, SAXException
  {
    this$0 = paramXmlRpcHttpTransport;baos = new ByteArrayOutputStream();
    new XmlRpcStreamTransport.ReqWriterImpl(paramXmlRpcHttpTransport, pRequest).write(baos);
  }
  
  protected int getContentLength()
  {
    return baos.size();
  }
  
  public void write(OutputStream pStream)
    throws IOException
  {
    try
    {
      baos.writeTo(pStream);
      pStream.close();
      pStream = null; return;
    }
    finally
    {
      if (pStream != null) {
        try
        {
          pStream.close();
        }
        catch (Throwable ignore) {}
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.client.XmlRpcHttpTransport.ByteArrayReqWriter
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc.client;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import org.apache.xmlrpc.XmlRpcConfig;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.XmlRpcRequest;
import org.apache.xmlrpc.common.XmlRpcHttpConfig;
import org.apache.xmlrpc.common.XmlRpcHttpRequestConfig;
import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig;
import org.apache.xmlrpc.util.HttpUtil;
import org.xml.sax.SAXException;

public abstract class XmlRpcHttpTransport
  extends XmlRpcStreamTransport
{
  private String userAgent;
  public static final String USER_AGENT = "Apache XML RPC 3.0";
  
  protected class ByteArrayReqWriter
    implements XmlRpcStreamTransport.ReqWriter
  {
    private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    
    ByteArrayReqWriter(XmlRpcRequest pRequest)
      throws XmlRpcException, IOException, SAXException
    {
      new XmlRpcStreamTransport.ReqWriterImpl(XmlRpcHttpTransport.this, pRequest).write(baos);
    }
    
    protected int getContentLength()
    {
      return baos.size();
    }
    
    public void write(OutputStream pStream)
      throws IOException
    {
      try
      {
        baos.writeTo(pStream);
        pStream.close();
        pStream = null; return;
      }
      finally
      {
        if (pStream != null) {
          try
          {
            pStream.close();
          }
          catch (Throwable ignore) {}
        }
      }
    }
  }
  
  protected XmlRpcHttpTransport(XmlRpcClient pClient, String pUserAgent)
  {
    super(pClient);
    userAgent = pUserAgent;
  }
  
  protected String getUserAgent()
  {
    return userAgent;
  }
  
  protected abstract void setRequestHeader(String paramString1, String paramString2);
  
  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");
    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 XmlRpcStreamTransport.ReqWriter newReqWriter(XmlRpcRequest pRequest)
    throws XmlRpcException, IOException, SAXException
  {
    XmlRpcHttpClientConfig config = (XmlRpcHttpClientConfig)pRequest.getConfig();
    if (isUsingByteArrayOutput(config))
    {
      ByteArrayReqWriter reqWriter = new ByteArrayReqWriter(pRequest);
      setContentLength(reqWriter.getContentLength());
      if (isCompressingRequest(config)) {
        return new XmlRpcStreamTransport.GzipReqWriter(this, reqWriter);
      }
      return reqWriter;
    }
    return super.newReqWriter(pRequest);
  }
}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.client.XmlRpcHttpTransport
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.xmlrpc.client;

import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

final class XmlRpcLiteHttpTransport$1
  extends BufferedOutputStream
{
  private final XmlRpcLiteHttpTransport this$0;
  
  XmlRpcLiteHttpTransport$1(XmlRpcLiteHttpTransport paramXmlRpcLiteHttpTransport, OutputStream x0)
    throws IOException
  {
    super(x0);this$0 = paramXmlRpcLiteHttpTransport;
  }
  
  public void close()
    throws IOException
  {
    flush();
    XmlRpcLiteHttpTransport.access$000(this$0).shutdownOutput();
  }
}

/* Location:
 * Qualified Name:     org.apache.xmlrpc.client.XmlRpcLiteHttpTransport.1
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.apache.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.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.StringTokenizer;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.XmlRpcRequest;
import org.apache.xmlrpc.common.XmlRpcHttpRequestConfig;
import org.apache.xmlrpc.common.XmlRpcStreamRequestConfig;
import org.apache.xmlrpc.util.HttpUtil;
import org.apache.xmlrpc.util.LimitedInputStream;
import org.xml.sax.SAXException;

public class XmlRpcLiteHttpTransport
  extends XmlRpcHttpTransport
{
  private static final String userAgent = "Apache XML RPC 3.0 (Lite HTTP Transport)";
  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;
  
  public XmlRpcLiteHttpTransport(XmlRpcClient pClient)
  {
    super(pClient, "Apache XML RPC 3.0 (Lite HTTP Transport)");
  }
  
  public Object sendRequest(XmlRpcRequest pRequest)
    throws XmlRpcException
  {
    config = ((XmlRpcHttpClientConfig)pRequest.getConfig());
    URL url = config.getServerURL();
    hostname = url.getHost();
    int p = url.getPort();
    port = (p < 1 ? 80 : p);
    String u = url.getFile();
    uri = ((u == null) || ("".equals(u)) ? "/" : u);
    host = (hostname + ":" + port);
    headers.put("Host", host);
    return super.sendRequest(pRequest);
  }
  
  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 list = new ArrayList();
        list.add(value);
        headers.put(pHeader, list);
      }
      else
      {
        list = (List)value;
      }
      list.add(pValue);
    }
  }
  
  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
    {
      int retries = 3;
      int delayMillis = 100;
      for (int tries = 0;; tries++) {
        try
        {
          socket = newSocket(hostname, port);
          output = new BufferedOutputStream(socket.getOutputStream())
          {
            public void close()
              throws IOException
            {
              flush();
              socket.shutdownOutput();
            }
          };
        }
        catch (ConnectException e)
        {
          if (tries >= 3) {
            throw new XmlRpcException("Failed to connect to " + hostname + ":" + port + ": " + e.getMessage(), e);
          }
          try
          {
            Thread.sleep(100L);
          }
          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(String pHostName, int pPort)
    throws UnknownHostException, IOException
  {
    return new Socket(pHostName, pPort);
  }
  
  private byte[] toHTTPBytes(String pValue)
    throws UnsupportedEncodingException
  {
    return pValue.getBytes("US-ASCII");
  }
  
  private void sendHeader(OutputStream pOut, String pKey, String pValue)
    throws IOException
  {
    pOut.write(toHTTPBytes(pKey + ": " + pValue + "\r\n"));
  }
  
  private void sendRequestHeaders(OutputStream pOut)
    throws IOException
  {
    pOut.write(("POST " + uri + " HTTP/1.0\r\n").getBytes("US-ASCII"));
    for (Iterator iter = headers.entrySet().iterator(); iter.hasNext();)
    {
      Map.Entry entry = (Map.Entry)iter.next();
      String key = (String)entry.getKey();
      Object value = entry.getValue();
      if ((value instanceof String))
      {
        sendHeader(pOut, key, (String)value);
      }
      else
      {
        List list = (List)value;
        for (int i = 0; i < list.size(); i++) {
          sendHeader(pOut, key, (String)list.get(i));
        }
      }
    }
    pOut.write(toHTTPBytes("\r\n"));
  }
  
  protected boolean isResponseGzipCompressed(XmlRpcStreamRequestConfig pConfig)
  {
    return responseGzipCompressed;
  }
  
  protected InputStream getInputStream()
    throws XmlRpcException
  {
    byte[] buffer = new byte['?'];
    try
    {
      if (config.getReplyTimeout() != 0) {
        socket.setSoTimeout(config.getReplyTimeout());
      }
      input = new BufferedInputStream(socket.getInputSt
1 2 3 4 5 6 7 8 9

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd