org.apache.xmlrpc.client
Class XmlRpcStreamTransport

java.lang.Object
  extended by org.apache.xmlrpc.client.XmlRpcTransportImpl
      extended by org.apache.xmlrpc.client.XmlRpcStreamTransport
All Implemented Interfaces:
XmlRpcTransport
Direct Known Subclasses:
XmlRpcHttpTransport, XmlRpcLocalStreamTransport

public abstract class XmlRpcStreamTransport
extends XmlRpcTransportImpl

Implementation of a transport class, which is based on an output stream for sending the request and an input stream for receiving the response,


Constructor Summary
protected XmlRpcStreamTransport(XmlRpcClient pClient)
          Creates a new instance on behalf of the given client.
 
Method Summary
protected abstract  void closeConnection(java.lang.Object pConnection)
          Closes the connection object.
protected  void closeInputStream(java.io.InputStream pStream)
          Closes the opened input stream, indicating that no more data is being read.
protected  void closeOutputStream(java.io.OutputStream pStream)
          Closes the opened output stream, indicating that no more data is being sent.
protected  java.io.InputStream getInputStream(XmlRpcStreamRequestConfig pConfig, java.lang.Object pConnection, byte[] pContent)
           
protected  java.io.OutputStream getOutputStream(XmlRpcStreamRequestConfig pConfig, java.lang.Object pConnection)
           
protected  void initConnection(XmlRpcStreamRequestConfig pConfig, java.lang.Object pConnection)
          Initializes the newly created connection.
protected abstract  boolean isResponseGzipCompressed(XmlRpcStreamRequestConfig pConfig, java.lang.Object pConnection)
          Returns, whether the response is gzip compressed.
protected  boolean isUsingByteArrayOutput(XmlRpcStreamRequestConfig pConfig)
          If this method returns true, then the method newInputStream(XmlRpcStreamRequestConfig, Object, byte[]) will be invoked to create the response.
protected abstract  java.lang.Object newConnection(XmlRpcStreamRequestConfig pConfig)
          Creates the connection object.
protected abstract  java.io.InputStream newInputStream(XmlRpcStreamRequestConfig pConfig, java.lang.Object pConnection)
          Creates a new input stream for reading the response.
protected abstract  java.io.InputStream newInputStream(XmlRpcStreamRequestConfig pConfig, java.lang.Object pConnection, byte[] pContent)
          Creates a new input stream for reading the response.
protected abstract  java.io.OutputStream newOutputStream(XmlRpcStreamRequestConfig pConfig, java.lang.Object pConnection)
          Creates a new output stream, to which the request may be written.
protected  org.xml.sax.XMLReader newXMLReader()
           
protected  java.lang.Object readResponse(XmlRpcStreamRequestConfig pConfig, java.io.InputStream pStream)
           
 java.lang.Object sendRequest(XmlRpcRequest pRequest)
          Send an XML-RPC message.
protected  void writeRequest(XmlRpcStreamRequestConfig pConfig, java.io.OutputStream pStream, XmlRpcRequest pRequest)
           
 
Methods inherited from class org.apache.xmlrpc.client.XmlRpcTransportImpl
getClient
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlRpcStreamTransport

protected XmlRpcStreamTransport(XmlRpcClient pClient)
Creates a new instance on behalf of the given client.

Method Detail

newConnection

protected abstract java.lang.Object newConnection(XmlRpcStreamRequestConfig pConfig)
                                           throws XmlRpcClientException
Creates the connection object. The connection object is a factory for output and input stream.

Throws:
XmlRpcClientException

closeConnection

protected abstract void closeConnection(java.lang.Object pConnection)
                                 throws XmlRpcClientException
Closes the connection object.

Throws:
XmlRpcClientException

initConnection

protected void initConnection(XmlRpcStreamRequestConfig pConfig,
                              java.lang.Object pConnection)
                       throws XmlRpcClientException
Initializes the newly created connection. For example, the HTTP transport will use this to set headers.

Parameters:
pConfig - The clients configuration.
pConnection - The connection being initialized.
Throws:
XmlRpcClientException - A local error on the client occurred.

newOutputStream

protected abstract java.io.OutputStream newOutputStream(XmlRpcStreamRequestConfig pConfig,
                                                        java.lang.Object pConnection)
                                                 throws XmlRpcClientException
Creates a new output stream, to which the request may be written.

Parameters:
pConfig - Client configuration.
pConnection - Connection being used to send request data.
Returns:
Opened output stream.
Throws:
XmlRpcClientException - An error occurred on the client.

closeOutputStream

protected void closeOutputStream(java.io.OutputStream pStream)
                          throws XmlRpcClientException
Closes the opened output stream, indicating that no more data is being sent.

Parameters:
pStream - The stream being closed.
Throws:
XmlRpcClientException - An error occurred on the client.

getOutputStream

protected java.io.OutputStream getOutputStream(XmlRpcStreamRequestConfig pConfig,
                                               java.lang.Object pConnection)
                                        throws XmlRpcClientException
Throws:
XmlRpcClientException

newInputStream

protected abstract java.io.InputStream newInputStream(XmlRpcStreamRequestConfig pConfig,
                                                      java.lang.Object pConnection)
                                               throws XmlRpcException
Creates a new input stream for reading the response.

Parameters:
pConfig - The clients configuration.
pConnection - The connection object.
Returns:
Opened input stream for reading data.
Throws:
XmlRpcException - Creating the input stream failed.

newInputStream

protected abstract java.io.InputStream newInputStream(XmlRpcStreamRequestConfig pConfig,
                                                      java.lang.Object pConnection,
                                                      byte[] pContent)
                                               throws XmlRpcException
Creates a new input stream for reading the response.

Parameters:
pConfig - The clients configuration.
pConnection - The connection object.
pContent - A byte array with the response.
Returns:
Opened input stream for reading data.
Throws:
XmlRpcException - Creating the input stream failed.

closeInputStream

protected void closeInputStream(java.io.InputStream pStream)
                         throws XmlRpcClientException
Closes the opened input stream, indicating that no more data is being read.

Parameters:
pStream - The stream being closed.
Throws:
XmlRpcClientException - An error occurred on the client.

isResponseGzipCompressed

protected abstract boolean isResponseGzipCompressed(XmlRpcStreamRequestConfig pConfig,
                                                    java.lang.Object pConnection)
Returns, whether the response is gzip compressed.

Parameters:
pConfig - The clients configuration.
pConnection - The connection object.
Returns:
Whether the response stream is gzip compressed.

getInputStream

protected java.io.InputStream getInputStream(XmlRpcStreamRequestConfig pConfig,
                                             java.lang.Object pConnection,
                                             byte[] pContent)
                                      throws XmlRpcException
Throws:
XmlRpcException

isUsingByteArrayOutput

protected boolean isUsingByteArrayOutput(XmlRpcStreamRequestConfig pConfig)
If this method returns true, then the method newInputStream(XmlRpcStreamRequestConfig, Object, byte[]) will be invoked to create the response. Otherwise, the methods getOutputStream(XmlRpcStreamRequestConfig, Object), and newInputStream(XmlRpcStreamRequestConfig, Object) will be used.

Returns:
Whether conversion into a byte array is required to create the response.

sendRequest

public java.lang.Object sendRequest(XmlRpcRequest pRequest)
                             throws XmlRpcException
Description copied from interface: XmlRpcTransport
Send an XML-RPC message. This method is called to send a message to the other party.

Parameters:
pRequest - The request being performed.
Returns:
Result object, if invoking the remote method was successfull.
Throws:
XmlRpcException - Performing the request failed.

newXMLReader

protected org.xml.sax.XMLReader newXMLReader()
                                      throws XmlRpcClientException
Throws:
XmlRpcClientException

readResponse

protected java.lang.Object readResponse(XmlRpcStreamRequestConfig pConfig,
                                        java.io.InputStream pStream)
                                 throws XmlRpcException
Throws:
XmlRpcException

writeRequest

protected void writeRequest(XmlRpcStreamRequestConfig pConfig,
                            java.io.OutputStream pStream,
                            XmlRpcRequest pRequest)
                     throws XmlRpcException
Throws:
XmlRpcException


Copyright 2001-2001-2006 Apache Software Foundation. All Rights Reserved.