wt.federation
Class FederatedHttpConnection

java.lang.Object
  extended bywt.federation.FederatedHttpConnection
All Implemented Interfaces:
Externalizable, Serializable

public class FederatedHttpConnection
extends Object
implements Externalizable

Creates HTTP connections to remote systems, sends requests, and returns the responses received.

Supported API: true

Extendable: false

See Also:
Serialized Form

Field Summary
private static String CLASSNAME
           
static long EXTERNALIZATION_VERSION_UID
           
private  Hashtable headings
           
private  String hostname
           
private  DataInputStream inputStream
           
private  String method
           
protected static long OLD_FORMAT_VERSION_UID
           
private  DataOutputStream outputStream
           
private  FederatedHttpBodyPart payload
           
private static String RESOURCE
           
(package private) static long serialVersionUID
           
private  Socket socket
           
private  URL url
           
 
Constructor Summary
FederatedHttpConnection()
          Constructor returning an instance initialized with a null URL, method specified as "GET", no payload, and default request headings.
FederatedHttpConnection(String url)
          Constructor returning an instance initialized with the specified URL.
FederatedHttpConnection(String url, String method)
          Constructor returning an instance initialized with the specified URL and method.
FederatedHttpConnection(URL url)
          Constructor returning an instance initialized with the specified URL.
FederatedHttpConnection(URL url, String method)
          Constructor returning an instance initialized with the specified URL and method.
 
Method Summary
 void addHeading(String keyword, String value)
          Adds a specified heading to an HTTP request.
 void addPayload(FederatedHttpBodyPart part)
          Augments the payload of a POST or PUT request with the specified MIME object.
 void addPayload(String contentType, byte[] octets)
          Augments the payload of a POST or PUT request with the specified array of octets of the specified MIME type/subtype.
 void addPayload(String contentType, String text)
          Augments the payload of a POST or PUT request with the specified string of the specified MIME type/subtype.
 void close()
          Closes the HTTP connection and releases resources associated with it.
 FederatedHttpResponse executeRequest()
          Executes an HTTP request using a previously specified URL and method, and returns the MIME object received as a result.
 FederatedHttpResponse executeRequest(URL url)
          Executes an HTTP request using the specified URL and a previously specified method, and returns the MIME object received as a result.
 FederatedHttpResponse executeRequest(URL url, String method)
          Executes an HTTP request using the specified URL and method, and returns the MIME object received as a result.
 String getMethod()
          Gets the value of the attribute: method.
 FederatedHttpBodyPart getPayload()
          Gets the value of the attribute: payload.
 URL getUrl()
          Gets the value of the attribute: url.
 void readExternal(ObjectInput input)
          Reads the non-transient fields of this class from an external source.
private  boolean readOldVersion(ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
          Reads the non-transient fields of this class from an external source, which is not the current version.
protected  boolean readVersion(FederatedHttpConnection thisObject, ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
          Reads the non-transient fields of this class from an external source.
private  void resetPrivateAttributes()
           
 void resetRequest()
          Resets the payload and headings of the HTTP request to default values.
 void setMethod(String a_Method)
          Sets the value of the attribute: method.
 void setPayload(FederatedHttpBodyPart a_Payload)
          Sets the value of the attribute: payload.
 void setUrl(String url)
          Sets the url property to the specified string.
 void setUrl(URL a_Url)
          Sets the value of the attribute: url.
 void writeExternal(ObjectOutput output)
          Writes the non-transient fields of this class to an external source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

url

private URL url

method

private String method

payload

private FederatedHttpBodyPart payload

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

EXTERNALIZATION_VERSION_UID

public static final long EXTERNALIZATION_VERSION_UID
See Also:
Constant Field Values

OLD_FORMAT_VERSION_UID

protected static final long OLD_FORMAT_VERSION_UID
See Also:
Constant Field Values

headings

private Hashtable headings

hostname

private String hostname

inputStream

private DataInputStream inputStream

outputStream

private DataOutputStream outputStream

socket

private Socket socket
Constructor Detail

FederatedHttpConnection

public FederatedHttpConnection()
                        throws WTPropertyVetoException
Constructor returning an instance initialized with a null URL, method specified as "GET", no payload, and default request headings.

Supported API: true

Throws:
WTPropertyVetoException

FederatedHttpConnection

public FederatedHttpConnection(URL url)
                        throws WTPropertyVetoException
Constructor returning an instance initialized with the specified URL.

Supported API: false

Parameters:
url -
Throws:
WTPropertyVetoException

FederatedHttpConnection

public FederatedHttpConnection(String url)
                        throws WTPropertyVetoException
Constructor returning an instance initialized with the specified URL.

Supported API: true

Parameters:
url -
Throws:
WTPropertyVetoException

FederatedHttpConnection

public FederatedHttpConnection(URL url,
                               String method)
                        throws WTPropertyVetoException
Constructor returning an instance initialized with the specified URL and method.

Supported API: true

Parameters:
url -
method -
Throws:
WTPropertyVetoException

FederatedHttpConnection

public FederatedHttpConnection(String url,
                               String method)
                        throws WTPropertyVetoException
Constructor returning an instance initialized with the specified URL and method.

Supported API: false

Parameters:
url -
method -
Throws:
WTPropertyVetoException
Method Detail

writeExternal

public void writeExternal(ObjectOutput output)
                   throws IOException
Writes the non-transient fields of this class to an external source.

Supported API: false

Specified by:
writeExternal in interface Externalizable
Parameters:
output -
Throws:
IOException

readExternal

public void readExternal(ObjectInput input)
                  throws IOException,
                         ClassNotFoundException
Reads the non-transient fields of this class from an external source.

Supported API: false

Specified by:
readExternal in interface Externalizable
Parameters:
input -
Throws:
IOException
ClassNotFoundException

readVersion

protected boolean readVersion(FederatedHttpConnection thisObject,
                              ObjectInput input,
                              long readSerialVersionUID,
                              boolean passThrough,
                              boolean superDone)
                       throws IOException,
                              ClassNotFoundException
Reads the non-transient fields of this class from an external source.

Supported API: false

Parameters:
thisObject -
input -
readSerialVersionUID -
passThrough -
superDone -
Returns:
boolean
Throws:
IOException
ClassNotFoundException

readOldVersion

private boolean readOldVersion(ObjectInput input,
                               long readSerialVersionUID,
                               boolean passThrough,
                               boolean superDone)
                        throws IOException,
                               ClassNotFoundException
Reads the non-transient fields of this class from an external source, which is not the current version.

Parameters:
input -
readSerialVersionUID -
passThrough -
superDone -
Returns:
boolean
Throws:
IOException
ClassNotFoundException

getUrl

public URL getUrl()
Gets the value of the attribute: url.

Supported API: false

Returns:
URL

setUrl

public void setUrl(URL a_Url)
            throws WTPropertyVetoException
Sets the value of the attribute: url.

Supported API: false

Parameters:
a_Url -
Throws:
WTPropertyVetoException

getMethod

public String getMethod()
Gets the value of the attribute: method.

Supported API: false

Returns:
String

setMethod

public void setMethod(String a_Method)
Sets the value of the attribute: method.

Supported API: false

Parameters:
a_Method -

getPayload

public FederatedHttpBodyPart getPayload()
Gets the value of the attribute: payload.

Supported API: false

Returns:
FederatedHttpBodyPart

setPayload

public void setPayload(FederatedHttpBodyPart a_Payload)
                throws WTPropertyVetoException
Sets the value of the attribute: payload.

Supported API: false

Parameters:
a_Payload -
Throws:
WTPropertyVetoException

addPayload

public void addPayload(String contentType,
                       String text)
                throws WTPropertyVetoException
Augments the payload of a POST or PUT request with the specified string of the specified MIME type/subtype.

Supported API: true

Parameters:
contentType -
text -
Throws:
WTPropertyVetoException

addPayload

public void addPayload(String contentType,
                       byte[] octets)
                throws WTPropertyVetoException
Augments the payload of a POST or PUT request with the specified array of octets of the specified MIME type/subtype.

Supported API: true

Parameters:
contentType -
octets -
Throws:
WTPropertyVetoException

addPayload

public void addPayload(FederatedHttpBodyPart part)
                throws WTPropertyVetoException
Augments the payload of a POST or PUT request with the specified MIME object.

Supported API: true

Parameters:
part -
Throws:
WTPropertyVetoException

addHeading

public void addHeading(String keyword,
                       String value)
Adds a specified heading to an HTTP request. If this method is called more than once specifying the same heading keyword, the values are concatenated into an HTTP heading value list.

Supported API: true

Parameters:
keyword -
value -

resetRequest

public void resetRequest()
                  throws WTPropertyVetoException
Resets the payload and headings of the HTTP request to default values.

Supported API: true

Throws:
WTPropertyVetoException

close

public void close()
           throws FederationServicesException
Closes the HTTP connection and releases resources associated with it.

Supported API: true

Throws:
FederationServicesException

executeRequest

public FederatedHttpResponse executeRequest()
                                     throws FederationServicesException
Executes an HTTP request using a previously specified URL and method, and returns the MIME object received as a result.

Supported API: true

Returns:
FederatedHttpResponse
Throws:
FederationServicesException

executeRequest

public FederatedHttpResponse executeRequest(URL url,
                                            String method)
                                     throws FederationServicesException
Executes an HTTP request using the specified URL and method, and returns the MIME object received as a result.

Supported API: true

Parameters:
url -
method -
Returns:
FederatedHttpResponse
Throws:
FederationServicesException

executeRequest

public FederatedHttpResponse executeRequest(URL url)
                                     throws FederationServicesException
Executes an HTTP request using the specified URL and a previously specified method, and returns the MIME object received as a result.

Supported API: true

Parameters:
url -
Returns:
FederatedHttpResponse
Throws:
FederationServicesException

setUrl

public void setUrl(String url)
            throws WTPropertyVetoException
Sets the url property to the specified string.

Supported API: true

Parameters:
url -
Throws:
WTPropertyVetoException

resetPrivateAttributes

private void resetPrivateAttributes()