Package com.attivio.transport
Class HttpClientTransport
- java.lang.Object
-
- com.attivio.transport.HttpClientTransport
-
- All Implemented Interfaces:
ClientTransport<java.net.URI>
- Direct Known Subclasses:
HttpsClientTransport
public class HttpClientTransport extends java.lang.Object implements ClientTransport<java.net.URI>
Handles sending Messages to Attivio HTTP receivers.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringATTIVIO_AUTHENTICATION_REALMAttivio authentication realmstatic java.lang.StringATTIVIO_SERVERThe Attivio HTTP server type.static java.lang.StringCONTENT_TYPE_XML_UTF8The constant for "text/xml; charset=utf-8".static longDEFAULT_HTTP_IDLE_TIMEOUTDefault setting forHTTP_IDLE_TIMEOUT_PROPERTY.static java.lang.StringHTTP_CONNECTION_TIMEOUT_PROPERTYProperty read to determine the connection timeout(default=0).static java.lang.StringHTTP_CONNECTIONS_PER_HOST_PROPERTYDefault number of http connections to allow to any single host by the commons http client.static java.lang.StringHTTP_IDLE_TIMEOUT_PROPERTYProperty read to determine idle connection timeout (default=30000 (30seconds))static java.lang.StringHTTP_INACTIVITY_VALIDATION_TIMEOUT_PROPERTYProperty read to determine how much inactivity requires re-validation on re-lease of connection (stale check) (default=30000 (30seconds))static java.lang.StringHTTP_MAX_CONNECTIONS_PROPERTYProperty read to determine the maximum number of http connections to a single host (default=1024).static java.lang.StringHTTP_RECEIVER_ADMIN_PASSWORD_PROPERTYHTTP transport admin password propertystatic java.lang.StringHTTP_RECEIVER_ADMIN_USERNAME_PROPERTYHTTP transport admin user name propertystatic java.lang.StringHTTP_SO_TIMEOUT_PROPERTYProperty read to determine the SO TIMEOUT (default=0).static java.lang.StringX_ATTIVIO_ASYNCCustom Attivio HTTP request header, indicates asynchronous message dispatch desired.static java.lang.StringX_ATTIVIO_BASEPORTCustom Attivio HTTP header, contains baseport property.static java.lang.StringX_ATTIVIO_EXCEPTIONCustom Attivio HTTP header, contains remote exception.static java.lang.StringX_ATTIVIO_HOMECustom Attivio HTTP header, contains home directory.static java.lang.StringX_ATTIVIO_ORIG_RESPONSE_CODECustom Attivio HTTP header, contains original response code when response code is converted to SC_OK.static java.lang.StringX_ATTIVIO_PROJECTCustom Attivio HTTP header, contains project directory.static java.lang.StringX_ATTIVIO_VERSIONCustom Attivio HTTP header, contains Attivio version.
-
Constructor Summary
Constructors Constructor Description HttpClientTransport()Creates the http client transport.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.net.URIcreateSender(java.net.URI uri, boolean synchronous)no op.voiddispatchMessage(PlatformMessage msg, java.net.URI sender)Asynchronously send a message via the provided sender with no expected return.static java.lang.StringgetPassword()Returns the password configured via theHTTP_RECEIVER_ADMIN_PASSWORD_PROPERTYproperty.java.lang.StringgetProtocol()Get the String protocol that this transports implements.java.net.URIgetSender(java.net.URI uri)URI's are always validstatic java.lang.StringgetUsername()Returns the username configured via theHTTP_RECEIVER_ADMIN_USERNAME_PROPERTYproperty.static HttpClientTransportinstance()static HttpClientTransportinstance(boolean useSSL)Return a HttpsClientTransport if ssl is used, return HttpClientTransport if notvoidresetClient()Resets the static HttpClient using System properties for username and password.voidresetClient(java.lang.String username, java.lang.String password)Resets the static HttpClientvoidresetConnectionManager()Stop and start the connection manager if there are any live connections in the pool.PlatformMessagesendMessage(PlatformMessage msg, java.net.URI sender)Synchronously send a message via the provided sender.voidshutdown()Closes down any transport related resourcesvoidstartConnectionManager()Setup the connection manager and all default parameters.voidstopSender(java.net.URI sender)no op.<T> Ttransport(java.lang.Class<? extends T> clazz, java.lang.Object o, java.lang.String uri)Sends the object synchronously to the uri via HTTP POST.voidtransportAsync(java.lang.Object o, java.lang.String uri)Sends the object asynchronously to the uri via HTTP POST.
-
-
-
Field Detail
-
CONTENT_TYPE_XML_UTF8
public static final java.lang.String CONTENT_TYPE_XML_UTF8
The constant for "text/xml; charset=utf-8".- See Also:
- Constant Field Values
-
ATTIVIO_SERVER
public static final java.lang.String ATTIVIO_SERVER
The Attivio HTTP server type.- See Also:
- Constant Field Values
-
X_ATTIVIO_BASEPORT
public static final java.lang.String X_ATTIVIO_BASEPORT
Custom Attivio HTTP header, contains baseport property.- See Also:
- Constant Field Values
-
X_ATTIVIO_HOME
public static final java.lang.String X_ATTIVIO_HOME
Custom Attivio HTTP header, contains home directory.- See Also:
- Constant Field Values
-
X_ATTIVIO_PROJECT
public static final java.lang.String X_ATTIVIO_PROJECT
Custom Attivio HTTP header, contains project directory.- See Also:
- Constant Field Values
-
X_ATTIVIO_VERSION
public static final java.lang.String X_ATTIVIO_VERSION
Custom Attivio HTTP header, contains Attivio version.- See Also:
- Constant Field Values
-
X_ATTIVIO_EXCEPTION
public static final java.lang.String X_ATTIVIO_EXCEPTION
Custom Attivio HTTP header, contains remote exception.- See Also:
- Constant Field Values
-
X_ATTIVIO_ASYNC
public static final java.lang.String X_ATTIVIO_ASYNC
Custom Attivio HTTP request header, indicates asynchronous message dispatch desired.- See Also:
- Constant Field Values
-
X_ATTIVIO_ORIG_RESPONSE_CODE
public static final java.lang.String X_ATTIVIO_ORIG_RESPONSE_CODE
Custom Attivio HTTP header, contains original response code when response code is converted to SC_OK.- See Also:
- Constant Field Values
-
HTTP_MAX_CONNECTIONS_PROPERTY
public static final java.lang.String HTTP_MAX_CONNECTIONS_PROPERTY
Property read to determine the maximum number of http connections to a single host (default=1024).- See Also:
- Constant Field Values
-
HTTP_CONNECTIONS_PER_HOST_PROPERTY
public static final java.lang.String HTTP_CONNECTIONS_PER_HOST_PROPERTY
Default number of http connections to allow to any single host by the commons http client.- See Also:
- Constant Field Values
-
HTTP_CONNECTION_TIMEOUT_PROPERTY
public static final java.lang.String HTTP_CONNECTION_TIMEOUT_PROPERTY
Property read to determine the connection timeout(default=0).- See Also:
- Constant Field Values
-
HTTP_SO_TIMEOUT_PROPERTY
public static final java.lang.String HTTP_SO_TIMEOUT_PROPERTY
Property read to determine the SO TIMEOUT (default=0).- See Also:
- Constant Field Values
-
HTTP_IDLE_TIMEOUT_PROPERTY
public static final java.lang.String HTTP_IDLE_TIMEOUT_PROPERTY
Property read to determine idle connection timeout (default=30000 (30seconds))- See Also:
- Constant Field Values
-
DEFAULT_HTTP_IDLE_TIMEOUT
public static final long DEFAULT_HTTP_IDLE_TIMEOUT
Default setting forHTTP_IDLE_TIMEOUT_PROPERTY.- See Also:
- Constant Field Values
-
HTTP_INACTIVITY_VALIDATION_TIMEOUT_PROPERTY
public static final java.lang.String HTTP_INACTIVITY_VALIDATION_TIMEOUT_PROPERTY
Property read to determine how much inactivity requires re-validation on re-lease of connection (stale check) (default=30000 (30seconds))- See Also:
- Constant Field Values
-
ATTIVIO_AUTHENTICATION_REALM
public static final java.lang.String ATTIVIO_AUTHENTICATION_REALM
Attivio authentication realm- See Also:
- Constant Field Values
-
HTTP_RECEIVER_ADMIN_USERNAME_PROPERTY
public static final java.lang.String HTTP_RECEIVER_ADMIN_USERNAME_PROPERTY
HTTP transport admin user name property- See Also:
- Constant Field Values
-
HTTP_RECEIVER_ADMIN_PASSWORD_PROPERTY
public static final java.lang.String HTTP_RECEIVER_ADMIN_PASSWORD_PROPERTY
HTTP transport admin password property- See Also:
- Constant Field Values
-
-
Method Detail
-
startConnectionManager
public void startConnectionManager()
Setup the connection manager and all default parameters.
-
resetConnectionManager
public void resetConnectionManager()
Stop and start the connection manager if there are any live connections in the pool.
-
getUsername
public static java.lang.String getUsername()
Returns the username configured via theHTTP_RECEIVER_ADMIN_USERNAME_PROPERTYproperty.- Returns:
- the configured username or
nullif none defined.
-
getPassword
public static java.lang.String getPassword()
Returns the password configured via theHTTP_RECEIVER_ADMIN_PASSWORD_PROPERTYproperty. The password may be encrypted.- Returns:
- the configured password or
nullif none defined.
-
resetClient
public void resetClient()
Resets the static HttpClient using System properties for username and password.
-
resetClient
public void resetClient(java.lang.String username, java.lang.String password)Resets the static HttpClient
-
sendMessage
public PlatformMessage sendMessage(PlatformMessage msg, java.net.URI sender) throws TransportException
Synchronously send a message via the provided sender.- Specified by:
sendMessagein interfaceClientTransport<java.net.URI>- Parameters:
msg- the message to send.sender- the sender that was chosen based on the URI that the message must be sent toThis method can block as long as is required to send the message including allowing time for the receiver to free up resources.
- Throws:
TransportException
-
dispatchMessage
public void dispatchMessage(PlatformMessage msg, java.net.URI sender) throws TransportException
Asynchronously send a message via the provided sender with no expected return.- Specified by:
dispatchMessagein interfaceClientTransport<java.net.URI>- Parameters:
msg- the message to send.sender- the sender that was chosen based on the URI that the message must be sent to- Throws:
TransportException
-
stopSender
public void stopSender(java.net.URI sender) throws TransportExceptionno op.- Specified by:
stopSenderin interfaceClientTransport<java.net.URI>- Throws:
TransportException
-
getProtocol
public java.lang.String getProtocol()
Description copied from interface:ClientTransportGet the String protocol that this transports implements.This will register this protocol with Attivio for message delivery.
For example if this method returned "foo" then URI's of the form:
foo://someUriSyntax:8000/goes?here
would be processed using this transport. This must return a constant value and must return that value as soon as the object is constructed as the value is registered with the platform and can not be changed once registered.- Specified by:
getProtocolin interfaceClientTransport<java.net.URI>
-
createSender
public java.net.URI createSender(java.net.URI uri, boolean synchronous) throws TransportExceptionno op.- Specified by:
createSenderin interfaceClientTransport<java.net.URI>- Throws:
TransportException
-
transport
public <T> T transport(java.lang.Class<? extends T> clazz, java.lang.Object o, java.lang.String uri) throws AttivioExceptionSends the object synchronously to the uri via HTTP POST.The object will be serialized using the Attivio
XMLSerializer. If a response is returned it will be deserialized and returned.- Parameters:
o- the object to transporturi- the URL to transportoto- Returns:
- the deserialized response
- Throws:
AttivioException
-
transportAsync
public void transportAsync(java.lang.Object o, java.lang.String uri) throws AttivioExceptionSends the object asynchronously to the uri via HTTP POST. The object will be serialized using the AttivioXMLSerializer.- Parameters:
o- the object to transporturi- the URI to transport the object to- Throws:
AttivioException
-
getSender
public java.net.URI getSender(java.net.URI uri)
URI's are always valid- Specified by:
getSenderin interfaceClientTransport<java.net.URI>
-
shutdown
public void shutdown() throws TransportExceptionCloses down any transport related resources- Specified by:
shutdownin interfaceClientTransport<java.net.URI>- Throws:
TransportException
-
instance
public static HttpClientTransport instance()
- Returns:
- an already created transport or creates one
-
instance
public static HttpClientTransport instance(boolean useSSL)
Return a HttpsClientTransport if ssl is used, return HttpClientTransport if not- Parameters:
useSSL-- Returns:
-
-