Class HttpProducer<A,B>
- 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<A,B>
-
- All Implemented Interfaces:
AdaptrisComponent
,AdaptrisMessageProducer
,AdaptrisMessageSender
,AdaptrisMessageWorker
,ComponentLifecycle
,ComponentLifecycleExtension
,MessageEventGenerator
- Direct Known Subclasses:
StandardHttpProducer
public abstract class HttpProducer<A,B> extends RequestReplyProducerImp
-
-
Field Summary
Fields Modifier and Type Field Description protected static long
DEFAULT_TIMEOUT
-
Fields inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
log
-
-
Constructor Summary
Constructors Constructor Description HttpProducer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected long
defaultTimeout()
The default timeout for request messages when not supplied.java.lang.String
endpoint(AdaptrisMessage msg)
Return the endpoint that will be derived from the message.java.lang.Boolean
getAllowRedirect()
Automatically handle redirection.@NonNull ContentTypeProvider
getContentTypeProvider()
Content-Type header associated with the HTTP operationjava.lang.Boolean
getIgnoreServerResponseCode()
Set whether to ignore the server response code.protected RequestMethodProvider.RequestMethod
getMethod(AdaptrisMessage msg)
@NonNull RequestMethodProvider
getMethodProvider()
The request method.@NonNull RequestHeaderProvider<A>
getRequestHeaderProvider()
Specify how we want to generate the initial set of HTTP Headers.@NonNull ResponseHeaderHandler<B>
getResponseHeaderHandler()
Specify how we handle headers from the HTTP response.java.lang.String
getUrl()
The URL endpoint to access.protected boolean
handleRedirection()
protected boolean
ignoreServerResponseCode()
protected void
logHeaders(java.lang.String header, java.lang.String message, java.util.Set headers)
void
prepare()
Prepare for initialisation.void
setAllowRedirect(java.lang.Boolean allowRedirect)
Automatically handle redirection.void
setContentTypeProvider(@NonNull ContentTypeProvider contentTypeProvider)
Content-Type header associated with the HTTP operationvoid
setIgnoreServerResponseCode(java.lang.Boolean ignoreServerResponseCode)
Set whether to ignore the server response code.void
setMethodProvider(@NonNull RequestMethodProvider methodProvider)
The request method.void
setRequestHeaderProvider(@NonNull RequestHeaderProvider<A> requestHeaderProvider)
Specify how we want to generate the initial set of HTTP Headers.void
setResponseHeaderHandler(@NonNull ResponseHeaderHandler<B> responseHeaderHandler)
Specify how we handle headers from the HTTP response.void
setUrl(java.lang.String url)
The URL endpoint to access.<T extends HttpProducer>
TwithURL(java.lang.String s)
-
Methods inherited from class com.adaptris.core.RequestReplyProducerImp
doProduce, doRequest, 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
-
-
-
-
Field Detail
-
DEFAULT_TIMEOUT
protected static final long DEFAULT_TIMEOUT
- See Also:
- Constant Field Values
-
-
Method Detail
-
defaultTimeout
protected long defaultTimeout()
Description copied from class:RequestReplyProducerBase
The default timeout for request messages when not supplied.- Specified by:
defaultTimeout
in classRequestReplyProducerBase
- Returns:
- the default timeout.
- See Also:
RequestReplyProducerBase.defaultTimeout()
-
handleRedirection
protected boolean handleRedirection()
-
ignoreServerResponseCode
protected boolean ignoreServerResponseCode()
-
getMethod
protected RequestMethodProvider.RequestMethod getMethod(AdaptrisMessage msg)
-
logHeaders
protected void logHeaders(java.lang.String header, java.lang.String message, java.util.Set headers)
-
prepare
public void prepare() throws CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Throws:
CoreException
-
endpoint
public java.lang.String endpoint(AdaptrisMessage msg) throws ProduceException
Description copied from class:AdaptrisMessageProducerImp
Return the endpoint that will be derived from the message.The purpose of this method is to mitigate the number of changes that need to happen because
ProduceDestination
is being deprecated; boilerplate code can still be present in the parent super-classes w/o impacting concrete sub-classes "too much".- Specified by:
endpoint
in classAdaptrisMessageProducerImp
- Throws:
ProduceException
- See Also:
AdaptrisMessageSender.produce(AdaptrisMessage)
-
withURL
public <T extends HttpProducer> T withURL(java.lang.String s)
-
getMethodProvider
@NonNull public @NonNull RequestMethodProvider getMethodProvider()
The request method.The default is 'POST'
-
setMethodProvider
public void setMethodProvider(@NonNull @NonNull RequestMethodProvider methodProvider)
The request method.The default is 'POST'
-
getContentTypeProvider
@NonNull public @NonNull ContentTypeProvider getContentTypeProvider()
Content-Type header associated with the HTTP operation
-
setContentTypeProvider
public void setContentTypeProvider(@NonNull @NonNull ContentTypeProvider contentTypeProvider)
Content-Type header associated with the HTTP operation
-
getResponseHeaderHandler
@NonNull public @NonNull ResponseHeaderHandler<B> getResponseHeaderHandler()
Specify how we handle headers from the HTTP response.The default behaviour will be to discard.
-
setResponseHeaderHandler
public void setResponseHeaderHandler(@NonNull @NonNull ResponseHeaderHandler<B> responseHeaderHandler)
Specify how we handle headers from the HTTP response.The default behaviour will be to discard.
-
getRequestHeaderProvider
@NonNull public @NonNull RequestHeaderProvider<A> getRequestHeaderProvider()
Specify how we want to generate the initial set of HTTP Headers.The default behaviour is to not have any additional headers
-
setRequestHeaderProvider
public void setRequestHeaderProvider(@NonNull @NonNull RequestHeaderProvider<A> requestHeaderProvider)
Specify how we want to generate the initial set of HTTP Headers.The default behaviour is to not have any additional headers
-
getIgnoreServerResponseCode
public java.lang.Boolean getIgnoreServerResponseCode()
Set whether to ignore the server response code.In some cases, you may wish to ignore any server response code (such as 500) as this may return meaningful data that you wish to use. If that's the case, make sure this flag is true. It defaults to false.
In all cases the metadata key
CoreConstants.HTTP_PRODUCER_RESPONSE_CODE
is populated with the last server response.
-
setIgnoreServerResponseCode
public void setIgnoreServerResponseCode(java.lang.Boolean ignoreServerResponseCode)
Set whether to ignore the server response code.In some cases, you may wish to ignore any server response code (such as 500) as this may return meaningful data that you wish to use. If that's the case, make sure this flag is true. It defaults to false.
In all cases the metadata key
CoreConstants.HTTP_PRODUCER_RESPONSE_CODE
is populated with the last server response.
-
getAllowRedirect
public java.lang.Boolean getAllowRedirect()
Automatically handle redirection.The default is true if not otherwise specified
-
setAllowRedirect
public void setAllowRedirect(java.lang.Boolean allowRedirect)
Automatically handle redirection.The default is true if not otherwise specified
-
getUrl
public java.lang.String getUrl()
The URL endpoint to access.
-
setUrl
public void setUrl(java.lang.String url)
The URL endpoint to access.
-
-