anon.infoservice
Class HTTPConnectionFactory

java.lang.Object
  extended by anon.infoservice.HTTPConnectionFactory

public class HTTPConnectionFactory
extends java.lang.Object

This class creates all instances of HTTPConnection for the JAP client and is a singleton.


Field Summary
static int HTTP_ENCODING_GZIP
           
static java.lang.String HTTP_ENCODING_GZIP_STRING
           
static int HTTP_ENCODING_PLAIN
           
static int HTTP_ENCODING_ZLIB
           
static java.lang.String HTTP_ENCODING_ZLIB_STRING
           
private  boolean m_bUseAuth
          Indicates whether to use proxy authentication
private  ImmutableProxyInterface m_proxyInterface
          The listener for the proxy used.
private  int m_timeout
          Stores the communication timeout (sec) for new HTTP connections.
private  java.util.Vector m_vecHTTPConnections
          The HTTPConnections that were recently created by this factory object.
private static java.lang.Class ms_HTTPConnectionClass
          Defines the HTTPConnection class for that this factory constructs instances.
private static HTTPConnectionFactory ms_httpConnectionFactoryInstance
          Stores the instance of HTTPConnectionFactory (Singleton).
 
Constructor Summary
private HTTPConnectionFactory()
          This creates a new instance of HTTPConnectionFactory.
 
Method Summary
 HTTPClient.HTTPConnection createHTTPConnection(ListenerInterface target)
          This method creates a new instance of HTTPConnection.
 HTTPClient.HTTPConnection createHTTPConnection(ListenerInterface target, ImmutableProxyInterface a_proxySettings)
          This method creates a new instance of HTTPConnection using the specified proxy settings (ignoring the default settings).
 HTTPClient.HTTPConnection createHTTPConnection(ListenerInterface target, ImmutableProxyInterface a_proxySettings, int a_encoding, boolean a_bGet)
          This method creates a new instance of HTTPConnection using the specified proxy settings (ignoring the default settings).
 HTTPClient.HTTPConnection createHTTPConnection(ListenerInterface target, int a_encoding, boolean a_bGet)
          This method creates a new instance of HTTPConnection.
private  HTTPClient.HTTPConnection createHTTPConnectionInternal(ListenerInterface target)
          Creates an HTTPConnection with the listener settings.
private  java.util.Vector getCreatedHTTPConnections()
          Returns the recently created HTTPConnections.
static HTTPConnectionFactory getInstance()
          Returns the instance of HTTPConnectionFactory (Singleton).
 int getTimeout()
          Returns the communication timeout (sec) for new HTTP connections.
private static void replaceHeader(HTTPClient.HTTPConnection connection, HTTPClient.NVPair header)
          An internal helper function to set the header information for the HTTP connection.
private static void setHTTPConnectionClass(java.lang.Class a_HTTPConnectionClass)
          This method is used to change the type of the created HTTPConnections.
 void setNewProxySettings(ImmutableProxyInterface a_proxyInterface, boolean a_bUseAuth)
          This method sets new settings for the proxy server.
 void setTimeout(int a_timeout)
          Sets the communication timeout (sec) for new HTTP connections.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HTTP_ENCODING_PLAIN

public static final int HTTP_ENCODING_PLAIN
See Also:
Constant Field Values

HTTP_ENCODING_ZLIB

public static final int HTTP_ENCODING_ZLIB
See Also:
Constant Field Values

HTTP_ENCODING_GZIP

public static final int HTTP_ENCODING_GZIP
See Also:
Constant Field Values

HTTP_ENCODING_ZLIB_STRING

public static final java.lang.String HTTP_ENCODING_ZLIB_STRING
See Also:
Constant Field Values

HTTP_ENCODING_GZIP_STRING

public static final java.lang.String HTTP_ENCODING_GZIP_STRING
See Also:
Constant Field Values

ms_HTTPConnectionClass

private static java.lang.Class ms_HTTPConnectionClass
Defines the HTTPConnection class for that this factory constructs instances.


ms_httpConnectionFactoryInstance

private static HTTPConnectionFactory ms_httpConnectionFactoryInstance
Stores the instance of HTTPConnectionFactory (Singleton).


m_vecHTTPConnections

private java.util.Vector m_vecHTTPConnections
The HTTPConnections that were recently created by this factory object.


m_timeout

private int m_timeout
Stores the communication timeout (sec) for new HTTP connections. If this value is zero, a connection never times out.


m_proxyInterface

private ImmutableProxyInterface m_proxyInterface
The listener for the proxy used.


m_bUseAuth

private boolean m_bUseAuth
Indicates whether to use proxy authentication

Constructor Detail

HTTPConnectionFactory

private HTTPConnectionFactory()
This creates a new instance of HTTPConnectionFactory. This is only used for setting some values. Use HTTPConnectionFactory.getInstance() for getting an instance of this class.

Method Detail

getInstance

public static HTTPConnectionFactory getInstance()
Returns the instance of HTTPConnectionFactory (Singleton). If there is no instance, there is a new one created.

Returns:
The HTTPConnectionFactory instance.

setNewProxySettings

public void setNewProxySettings(ImmutableProxyInterface a_proxyInterface,
                                boolean a_bUseAuth)
This method sets new settings for the proxy server. All HTTPConnection instances created after the call of this method will use them. Instances of HTTPConnection which already exist are not influenced by that call. The default after creating the instance of HTTPConnectionFactory is to use no proxy for all new instances of HTTPConnection.

Parameters:
a_proxyInterface - the listener interface of the proxy server; if it is set to null, no proxy is used
a_bUseAuth - indicates whether proxy authentication should be used

setTimeout

public void setTimeout(int a_timeout)
Sets the communication timeout (sec) for new HTTP connections. If this value is zero or lower, a connection never times out. Instances of HTTPConnection which already exist, are not influenced by this method.

Parameters:
a_timeout - The new communication timeout.

getTimeout

public int getTimeout()
Returns the communication timeout (sec) for new HTTP connections. If this value is zero, a connection never times out.

Returns:
The communication timeout for new connections.

createHTTPConnection

public HTTPClient.HTTPConnection createHTTPConnection(ListenerInterface target)
This method creates a new instance of HTTPConnection. The current proxy settings are used.

Parameters:
target - The ListenerInterface of the connection target.
Returns:
A new instance of HTTPConnection with a connection to the specified target and the current proxy settings.

createHTTPConnection

public HTTPClient.HTTPConnection createHTTPConnection(ListenerInterface target,
                                                      int a_encoding,
                                                      boolean a_bGet)
This method creates a new instance of HTTPConnection. The current proxy settings are used.

Parameters:
target - The ListenerInterface of the connection target.
a_encoding - http encoding used to send the data (e.g. HTTP_ENCODING_ZLIB)
a_bGet - if encoding is set to another value than HTTP_ENCODING_PLAIN, it must be specified if this is a get or a post statement
Returns:
A new instance of HTTPConnection with a connection to the specified target and the current proxy settings.

createHTTPConnection

public HTTPClient.HTTPConnection createHTTPConnection(ListenerInterface target,
                                                      ImmutableProxyInterface a_proxySettings)
This method creates a new instance of HTTPConnection using the specified proxy settings (ignoring the default settings).

Parameters:
target - The ListenerInterface of the connection target.
a_proxySettings - The proxy settings to use for this single connection. If the proxy settings are null, no proxy is used.
Returns:
A new instance of HTTPConnection with a connection to the specified target and the current proxy settings.

createHTTPConnection

public HTTPClient.HTTPConnection createHTTPConnection(ListenerInterface target,
                                                      ImmutableProxyInterface a_proxySettings,
                                                      int a_encoding,
                                                      boolean a_bGet)
This method creates a new instance of HTTPConnection using the specified proxy settings (ignoring the default settings).

Parameters:
target - The ListenerInterface of the connection target.
a_proxySettings - The proxy settings to use for this single connection. If the proxy settings are null, no proxy is used.
a_bGet - if encoding is set to another value than HTTP_ENCODING_PLAIN, it must be specified if this is a get or a post statement
a_encoding - http encoding used to send the data (e.g. HTTP_ENCODING_ZLIB)
Returns:
A new instance of HTTPConnection with a connection to the specified target and the current proxy settings.

replaceHeader

private static void replaceHeader(HTTPClient.HTTPConnection connection,
                                  HTTPClient.NVPair header)
An internal helper function to set the header information for the HTTP connection.

Parameters:
connection - The connection where the new headers are set.
header - The header information to set.

setHTTPConnectionClass

private static void setHTTPConnectionClass(java.lang.Class a_HTTPConnectionClass)
This method is used to change the type of the created HTTPConnections. A call of this method deletes the current factory instance and can be used as a reset operation, too. This method is used for testing purposes. PLEASE DO NOT REMOVE IT!

Parameters:
a_HTTPConnectionClass - the class of generated HTTPConnections

getCreatedHTTPConnections

private java.util.Vector getCreatedHTTPConnections()
Returns the recently created HTTPConnections. This method is used for testing purposes. PLEASE DO NOT REMOVE IT!

Returns:
Vector

createHTTPConnectionInternal

private HTTPClient.HTTPConnection createHTTPConnectionInternal(ListenerInterface target)
Creates an HTTPConnection with the listener settings.

Parameters:
target - the basic listener settings for this connection
Returns:
an HTTPConnection with the listener settings