com.ibm.di.connector
Class HTTPServerConnector

java.lang.Object
  extended by com.ibm.di.connector.Connector
      extended by com.ibm.di.connector.HTTPServerConnector
All Implemented Interfaces:
ConnectorInterface, VersionInfoInterface

public class HTTPServerConnector
extends Connector
implements ConnectorInterface

This connector provides HTTP server like functionality and ability to receive/handle client requests sent over the HTTP protocol.


Field Summary
static String ATTR_NAME_HTTP_AUTH_ENTRY
          An Entry attribute name: "auth.entry"
static String ATTR_NAME_HTTP_BODY
          An Entry attribute name: "http.body"
static String ATTR_NAME_HTTP_CHARACTER_SET
          An Entry attribute name: "characterSet"
static String ATTR_NAME_HTTP_CONNECTION
          An Entry attribute name: "http.connection"
static String ATTR_NAME_HTTP_CONTENT_TYPE
          An Entry attribute name: "http.Content-Type"
static String ATTR_NAME_HTTP_REMOTE_PASSWORD
          An Entry attribute name: "http.remote_pass"
static String ATTR_NAME_HTTP_REMOTE_USER
          An Entry attribute name: "http.remote_user"
static String HTTP_BAD_REQUEST
          Error String: "400 Bad Request"
static String PARAM_SYSTEM_TCP_BACKLOG
          Parameter Name: "com.ibm.di.tcp.backlog"
static String PARAM_TCP_BACKLOG
          Parameter Name: "backlog"
static String PARAMETER_AUTH_CONN
          Parameter Name: "authConnector"
static String PARAMETER_AUTH_REALM
          Parameter Name: "authRealm"
static String PARAMETER_CONTENT_TYPE
          Parameter Name: "contentType"
static String PARAMETER_HEADERS_AS_PROPS
          Parameter Name: "headersAsProperties"
static String PARAMETER_HTTP_BASIC_AUTH
          Parameter Name: "httpAuth"
static String PARAMETER_IDLE_CONNECTION_TIMEOUT
          Parameter Name: .
static String PARAMETER_REQUIRE_CLIENT_AUTH
          Parameter Name: "needClientAuth"
static String PARAMETER_TCP_DATA_AS_PROPS
          Parameter Name: "tcpDataAsProperties"
static String PARAMETER_TCP_PORT
          Parameter Name: "tcpPort"
static String PARAMETER_USE_CHUNKS
          Parameter Name: "msgChunked"
static String PARAMETER_USE_SSL
          Parameter Name: "useSSL"
 
Fields inherited from class com.ibm.di.connector.Connector
ALL_MODES, myLog, PROPERTY_MESSAGE, PROPERTY_READER, PROPERTY_WRITER
 
Constructor Summary
HTTPServerConnector()
          Constructs this object, sets the supported modes and initializes the internally used HTTPParser.
 
Method Summary
 ConnectorInterface getNextClient()
          This method blocks until a client is connected.
 Entry getNextEntry()
          This method is called when this connector is used in Iterator mode.
 String getPassword()
          Retrieves password.
 HTTPServerConnector getServerConnector()
          Retrieves server connector.
 String getUserName()
          Retrieves username.
 String getVersion()
          Version information.
 void initialize(Object aObject)
          Parsers all the configuration parameters of this connector and prepares for starting the HTTP Server.
 boolean isAccepting()
          Checks whether the connector is waiting for a client connection.
 boolean isAutoChunking()
          Returns whether automatic chunking is enabled or not.
 boolean isChunked()
          Returns true if response is chunked.
 boolean isTerminating()
          Checks whether a termination request is sent.
 void putEntry(Entry aEntry)
          This method provides chunking capabilities to the HTTP server.
 void rejectClientAuthentication()
          Prints the Forbidden page and closes the connection.
 void replyEntry(Entry aEntry)
          This method sends the provided entry to the client as an HTTP response.
 void setAutoChunking(boolean enabled)
          This method lets the user dynamically configure chunked output mode.
 void setProperty(Entry aEntry, String aProperty, Object aValue, boolean aTcpDataAsProps)
          This method adds a property to the provided entry if the aTcpDataAsProps is set to true, if it is set to false then the provided property is added as an attribute.
 void setServerConnector(HTTPServerConnector aServerConnector)
          Sets the server connector for this connector.
 void terminate()
          Terminate the connector.
 void terminateServer()
          This method tries to terminate the server by setting the termination flag for the connector returned by getServerConnector and immediately connecting to its port (which should fail).
 
Methods inherited from class com.ibm.di.connector.Connector
addFindEntry, allModes, clearFindEntries, debug, debugMode, deleteEntry, findEntry, findEntry, getBoolean, getClassInstance, getConfiguration, getContext, getFindEntryCount, getFirstFindEntry, getLog, getMaxDuplicateEntries, getModes, getModes, getName, getNextFindEntry, getParam, getParser, getProperty, getPushbackEntry, getRawConnectorConfiguration, getRSInterface, getUI, hasConfigValue, hasParser, initParser, isDeltaSupported, isExceptionFatal, isIOException, logError, logmsg, modEntry, modEntry, pushback, queryOperations, queryReply, querySchema, queryTables, reconnect, reconnect, registerScriptBeans, selectEntries, setConfiguration, setContext, setCurrent, setDebugMode, setLog, setMaxDuplicateEntries, setModes, setModes, setName, setParam, setParser, setProperty, setRSInterface
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ibm.di.connector.ConnectorInterface
deleteEntry, findEntry, getConfiguration, getContext, getFindEntryCount, getFirstFindEntry, getMaxDuplicateEntries, getName, getNextFindEntry, getParam, getPushbackEntry, getRawConnectorConfiguration, isDeltaSupported, isExceptionFatal, isIOException, modEntry, modEntry, pushback, queryOperations, queryReply, querySchema, reconnect, registerScriptBeans, selectEntries, setConfiguration, setContext, setCurrent, setLog, setMaxDuplicateEntries, setName, setParam, setRSInterface
 

Field Detail

PARAMETER_TCP_PORT

public static final String PARAMETER_TCP_PORT
Parameter Name: "tcpPort"

See Also:
Constant Field Values

PARAM_TCP_BACKLOG

public static final String PARAM_TCP_BACKLOG
Parameter Name: "backlog"

See Also:
Constant Field Values

PARAM_SYSTEM_TCP_BACKLOG

public static final String PARAM_SYSTEM_TCP_BACKLOG
Parameter Name: "com.ibm.di.tcp.backlog"

See Also:
Constant Field Values

PARAMETER_HEADERS_AS_PROPS

public static final String PARAMETER_HEADERS_AS_PROPS
Parameter Name: "headersAsProperties"

See Also:
Constant Field Values

PARAMETER_TCP_DATA_AS_PROPS

public static final String PARAMETER_TCP_DATA_AS_PROPS
Parameter Name: "tcpDataAsProperties"

See Also:
Constant Field Values

PARAMETER_AUTH_CONN

public static final String PARAMETER_AUTH_CONN
Parameter Name: "authConnector"

See Also:
Constant Field Values

PARAMETER_HTTP_BASIC_AUTH

public static final String PARAMETER_HTTP_BASIC_AUTH
Parameter Name: "httpAuth"

See Also:
Constant Field Values

PARAMETER_AUTH_REALM

public static final String PARAMETER_AUTH_REALM
Parameter Name: "authRealm"

See Also:
Constant Field Values

PARAMETER_USE_SSL

public static final String PARAMETER_USE_SSL
Parameter Name: "useSSL"

See Also:
Constant Field Values

PARAMETER_REQUIRE_CLIENT_AUTH

public static final String PARAMETER_REQUIRE_CLIENT_AUTH
Parameter Name: "needClientAuth"

See Also:
Constant Field Values

PARAMETER_CONTENT_TYPE

public static final String PARAMETER_CONTENT_TYPE
Parameter Name: "contentType"

See Also:
Constant Field Values

PARAMETER_USE_CHUNKS

public static final String PARAMETER_USE_CHUNKS
Parameter Name: "msgChunked"

See Also:
Constant Field Values

PARAMETER_IDLE_CONNECTION_TIMEOUT

public static final String PARAMETER_IDLE_CONNECTION_TIMEOUT
Parameter Name: . Connection timeout in seconds.

See Also:
Constant Field Values

ATTR_NAME_HTTP_REMOTE_USER

public static final String ATTR_NAME_HTTP_REMOTE_USER
An Entry attribute name: "http.remote_user"

See Also:
Constant Field Values

ATTR_NAME_HTTP_REMOTE_PASSWORD

public static final String ATTR_NAME_HTTP_REMOTE_PASSWORD
An Entry attribute name: "http.remote_pass"

See Also:
Constant Field Values

ATTR_NAME_HTTP_BODY

public static final String ATTR_NAME_HTTP_BODY
An Entry attribute name: "http.body"

See Also:
Constant Field Values

ATTR_NAME_HTTP_CONTENT_TYPE

public static final String ATTR_NAME_HTTP_CONTENT_TYPE
An Entry attribute name: "http.Content-Type"

See Also:
Constant Field Values

ATTR_NAME_HTTP_CHARACTER_SET

public static final String ATTR_NAME_HTTP_CHARACTER_SET
An Entry attribute name: "characterSet"

See Also:
Constant Field Values

ATTR_NAME_HTTP_CONNECTION

public static final String ATTR_NAME_HTTP_CONNECTION
An Entry attribute name: "http.connection"

See Also:
Constant Field Values

ATTR_NAME_HTTP_AUTH_ENTRY

public static final String ATTR_NAME_HTTP_AUTH_ENTRY
An Entry attribute name: "auth.entry"

See Also:
Constant Field Values

HTTP_BAD_REQUEST

public static final String HTTP_BAD_REQUEST
Error String: "400 Bad Request"

See Also:
Constant Field Values
Constructor Detail

HTTPServerConnector

public HTTPServerConnector()
Constructs this object, sets the supported modes and initializes the internally used HTTPParser.

Method Detail

initialize

public void initialize(Object aObject)
                throws Exception
Parsers all the configuration parameters of this connector and prepares for starting the HTTP Server. If a Socket is provided as a parameter then that socket will be used for communication with the client on the other end of the socket.

Specified by:
initialize in interface ConnectorInterface
Overrides:
initialize in class Connector
Parameters:
aObject - recognizes only an object of type Socket
Throws:
Exception - if an error occurs.

getNextClient

public ConnectorInterface getNextClient()
                                 throws Exception
This method blocks until a client is connected. After a connection is established a new instance of this object is created, initialized and returned.

Specified by:
getNextClient in interface ConnectorInterface
Overrides:
getNextClient in class Connector
Returns:
a new instance of HTTPServerConnector responsible for handling the communication with the new client.
Throws:
Exception - if this connector was not initialized properly or other type of error occurs.

getServerConnector

public HTTPServerConnector getServerConnector()
Retrieves server connector.

Returns:
the server connector if this connector is handling an HTTP client session, or null if a connection has not been established yet.

setServerConnector

public void setServerConnector(HTTPServerConnector aServerConnector)
Sets the server connector for this connector.

Parameters:
aServerConnector - the server connector that created this instance.

isAccepting

public boolean isAccepting()
Checks whether the connector is waiting for a client connection.

Returns:
true if this connector is currently waiting for a client connection.

isTerminating

public boolean isTerminating()
Checks whether a termination request is sent.

Returns:
true if this connector has the termination flag set.

terminateServer

public void terminateServer()
                     throws Exception
This method tries to terminate the server by setting the termination flag for the connector returned by getServerConnector and immediately connecting to its port (which should fail).

Specified by:
terminateServer in interface ConnectorInterface
Overrides:
terminateServer in class Connector
Throws:
Exception - if an error occurs.

terminate

public void terminate()
               throws Exception
Terminate the connector. This function closes all connection and releases all resources used by the connector. This function also calls the parser's closeParser() method if a parser is active.

Specified by:
terminate in interface ConnectorInterface
Overrides:
terminate in class Connector
Throws:
Exception - if an error occurs.

getNextEntry

public Entry getNextEntry()
                   throws Exception
This method is called when this connector is used in Iterator mode. This method will block until a client connects on the opened port. If the authentication fails the method returns null. If authentication is successful the HTTP request is parsed to an Entry object and returned.

Specified by:
getNextEntry in interface ConnectorInterface
Overrides:
getNextEntry in class Connector
Returns:
the parsed HTTP request as an Entry object.
Throws:
Exception - if an error occurs.
See Also:
ConnectorInterface.selectEntries()

putEntry

public void putEntry(Entry aEntry)
              throws Exception
This method provides chunking capabilities to the HTTP server. This method is used from a scripts and is not directly called by the TDI Server. If the chunking is turned off the usage of this method will turn it on.

Specified by:
putEntry in interface ConnectorInterface
Overrides:
putEntry in class Connector
Parameters:
aEntry - the entry to send as a chunk.
Throws:
Exception - if a communication error is raised.

replyEntry

public void replyEntry(Entry aEntry)
                throws Exception
This method sends the provided entry to the client as an HTTP response. If chunking is enabled then the provided entry will be sent as the last chunk.

Specified by:
replyEntry in interface ConnectorInterface
Overrides:
replyEntry in class Connector
Parameters:
aEntry - the entry to send to the client.
Throws:
Exception - if an error occurs.

getUserName

public String getUserName()
Retrieves username.

Returns:
the username used for the authentication.

getPassword

public String getPassword()
Retrieves password.

Returns:
the password the user has authenticated with.

rejectClientAuthentication

public void rejectClientAuthentication()
                                throws Exception
Prints the Forbidden page and closes the connection. This method does not have effect if the basic authentication is not enabled for this connector.

Throws:
Exception - if an error occurs.

setProperty

public void setProperty(Entry aEntry,
                        String aProperty,
                        Object aValue,
                        boolean aTcpDataAsProps)
This method adds a property to the provided entry if the aTcpDataAsProps is set to true, if it is set to false then the provided property is added as an attribute.

Parameters:
aEntry - the entry which the property will be set on.
aProperty - the property name.
aValue - the property value.
aTcpDataAsProps - tells whether the property will be set as an Entry property or as Entry Attribute.

getVersion

public String getVersion()
Version information.

Specified by:
getVersion in interface VersionInfoInterface
Returns:
version information

setAutoChunking

public void setAutoChunking(boolean enabled)
This method lets the user dynamically configure chunked output mode. It has no effect if chunking already is enabled through the configuration. Setting this to "true" will cause the putEntry method to automatically initialize the chunked writer for output.

Parameters:
enabled - The new value for automatic chunking.

isAutoChunking

public boolean isAutoChunking()
Returns whether automatic chunking is enabled or not.

Returns:
True if automatic chunking is enabled.

isChunked

public boolean isChunked()
Returns true if response is chunked.

Returns:
True if response should be chunked.