Class StandardHttpProducer
- java.lang.Object
-
- com.adaptris.core.AdaptrisMessageWorkerImp
-
- com.adaptris.core.AdaptrisMessageProducerImp
-
- com.adaptris.core.RequestReplyProducerBase
-
- com.adaptris.core.RequestReplyProducerImp
-
- com.adaptris.core.http.client.net.HttpProducer<java.net.HttpURLConnection,java.net.HttpURLConnection>
-
- com.adaptris.core.http.client.net.StandardHttpProducer
-
- All Implemented Interfaces:
AdaptrisComponent
,AdaptrisMessageProducer
,AdaptrisMessageSender
,AdaptrisMessageWorker
,ComponentLifecycle
,ComponentLifecycleExtension
,MessageEventGenerator
@ComponentProfile(summary="Make a HTTP request to a remote server using standard JRE components", tag="producer,http,https", metadata="adphttpresponse", recommended=NullConnection.class) public class StandardHttpProducer extends HttpProducer<java.net.HttpURLConnection,java.net.HttpURLConnection>
DefaultHttpProducer
implementation that usesHttpURLConnection
available in a standard java runtime.This uses
com.adaptris.core.http.client
interfaces to manage request and response headers and also theDataInputParameter
andDataOutputParameter
interfaces to source the HTTP body and to handle the HTTP response body respectively. Without specific overrides for these new fields then they default to the payload body.Note that configuring a
AdaptrisMessageEncoder
instance will cause theDataInputParameter
andDataOutputParameter
fields to be ignored.When interacting with HTTPS sites, then you may need to configure a truststore / keystore system properties if non-default certificate handling is required. As this uses
HttpsURLConnection
under the covers; then please consult Oracles JSSE documentation for a full discussion of the required system properties.In the adapter configuration file this class is aliased as standard-http-producer which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.http.client.net.HttpProducer
DEFAULT_TIMEOUT
-
Fields inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
log
-
-
Constructor Summary
Constructors Constructor Description StandardHttpProducer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doProduce(AdaptrisMessage msg, java.lang.String dest)
Actually do the produce.protected AdaptrisMessage
doRequest(AdaptrisMessage msg, java.lang.String endpointUrl, long timeout)
Actually do the request.java.lang.Boolean
getAlwaysSendPayload()
Whether or not to always attempt to send the payload as the entity body.@NonNull HttpAuthenticator
getAuthenticator()
TimeInterval
getConnectTimeout()
The connect timeout.TimeInterval
getReadTimeout()
Set the read timeout.DataInputParameter<java.io.InputStream>
getRequestBody()
Set where the HTTP Request body is going to come from.DataOutputParameter<InputStreamWithEncoding>
getResponseBody()
Set where the HTTP Response Body will be written to.void
setAlwaysSendPayload(java.lang.Boolean alwaysSendPayload)
Whether or not to always attempt to send the payload as the entity body.void
setAuthenticator(@NonNull HttpAuthenticator authenticator)
void
setConnectTimeout(TimeInterval connectTimeout)
The connect timeout.void
setReadTimeout(TimeInterval readTimeout)
Set the read timeout.void
setRequestBody(DataInputParameter<java.io.InputStream> requestBody)
Set where the HTTP Request body is going to come from.void
setResponseBody(DataOutputParameter<InputStreamWithEncoding> responseBody)
Set where the HTTP Response Body will be written to.-
Methods inherited from class com.adaptris.core.http.client.net.HttpProducer
defaultTimeout, endpoint, getAllowRedirect, getContentTypeProvider, getIgnoreServerResponseCode, getMethod, getMethodProvider, getRequestHeaderProvider, getResponseHeaderHandler, getUrl, handleRedirection, ignoreServerResponseCode, logHeaders, prepare, setAllowRedirect, setContentTypeProvider, setIgnoreServerResponseCode, setMethodProvider, setRequestHeaderProvider, setResponseHeaderHandler, setUrl, withURL
-
Methods inherited from class com.adaptris.core.RequestReplyProducerImp
produce, request, request
-
Methods inherited from class com.adaptris.core.RequestReplyProducerBase
copyReplyContents, getIgnoreReplyMetadata, mergeReply, setIgnoreReplyMetadata
-
Methods inherited from class com.adaptris.core.AdaptrisMessageProducerImp
createName
-
Methods inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory, withUniqueID
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueId
-
Methods inherited from interface com.adaptris.core.AdaptrisMessageWorker
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactory
-
Methods inherited from interface com.adaptris.core.ComponentLifecycle
close, init, start, stop
-
Methods inherited from interface com.adaptris.core.MessageEventGenerator
createQualifier, isTrackingEndpoint
-
-
-
-
Method Detail
-
doProduce
protected void doProduce(AdaptrisMessage msg, java.lang.String dest) throws ProduceException
Description copied from class:RequestReplyProducerImp
Actually do the produce.- Specified by:
doProduce
in classRequestReplyProducerImp
- Throws:
ProduceException
-
doRequest
protected AdaptrisMessage doRequest(AdaptrisMessage msg, java.lang.String endpointUrl, long timeout) throws ProduceException
Description copied from class:RequestReplyProducerImp
Actually do the request.- Specified by:
doRequest
in classRequestReplyProducerImp
- Throws:
ProduceException
-
getRequestBody
public DataInputParameter<java.io.InputStream> getRequestBody()
Set where the HTTP Request body is going to come from.The default is
PayloadStreamInputParameter
.
-
setRequestBody
public void setRequestBody(DataInputParameter<java.io.InputStream> requestBody)
Set where the HTTP Request body is going to come from.The default is
PayloadStreamInputParameter
.
-
getResponseBody
public DataOutputParameter<InputStreamWithEncoding> getResponseBody()
Set where the HTTP Response Body will be written to.Note that if you have configured an
AdaptrisMessageEncoder
viaAdaptrisMessageWorkerImp.setEncoder(com.adaptris.core.AdaptrisMessageEncoder)
(such as for AS2) then this may have no effect.The default is
PayloadStreamOutputParameter
.
-
setResponseBody
public void setResponseBody(DataOutputParameter<InputStreamWithEncoding> responseBody)
Set where the HTTP Response Body will be written to.Note that if you have configured an
AdaptrisMessageEncoder
viaAdaptrisMessageWorkerImp.setEncoder(com.adaptris.core.AdaptrisMessageEncoder)
(such as for AS2) then this may have no effect.The default is
PayloadStreamOutputParameter
.
-
getAuthenticator
@NonNull public @NonNull HttpAuthenticator getAuthenticator()
-
setAuthenticator
public void setAuthenticator(@NonNull @NonNull HttpAuthenticator authenticator)
-
getAlwaysSendPayload
public java.lang.Boolean getAlwaysSendPayload()
Whether or not to always attempt to send the payload as the entity body.Only the TRACE method explicitly forbids an entity body; other methods are technically unrestricted. However, best practice suggests that entity bodies are only included for the POST/PUT/(PATCH) methods.
The default is fails if not otherwise specified
-
setAlwaysSendPayload
public void setAlwaysSendPayload(java.lang.Boolean alwaysSendPayload)
Whether or not to always attempt to send the payload as the entity body.Only the TRACE method explicitly forbids an entity body; other methods are technically unrestricted. However, best practice suggests that entity bodies are only included for the POST/PUT/(PATCH) methods.
The default is fails if not otherwise specified
-
getConnectTimeout
public TimeInterval getConnectTimeout()
The connect timeout.
-
setConnectTimeout
public void setConnectTimeout(TimeInterval connectTimeout)
The connect timeout.
-
getReadTimeout
public TimeInterval getReadTimeout()
Set the read timeout.Note that any read timeout will be overridden by the timeout value passed in via the {
RequestReplyProducerImp.request(AdaptrisMessage, long)
method; if it is not the same as 60000
-
setReadTimeout
public void setReadTimeout(TimeInterval readTimeout)
Set the read timeout.Note that any read timeout will be overridden by the timeout value passed in via the {
RequestReplyProducerImp.request(AdaptrisMessage, long)
method; if it is not the same as 60000
-
-