Class HttpProducer
- java.lang.Object
-
- com.adaptris.core.AdaptrisMessageWorkerImp
-
- com.adaptris.core.AdaptrisMessageProducerImp
-
- com.adaptris.core.RequestReplyProducerBase
-
- com.adaptris.core.RequestReplyProducerImp
-
- com.adaptris.core.http.apache5.HttpProducer
-
- All Implemented Interfaces:
AdaptrisComponent,AdaptrisMessageProducer,AdaptrisMessageSender,AdaptrisMessageWorker,ComponentLifecycle,ComponentLifecycleExtension,MessageEventGenerator
- Direct Known Subclasses:
ApacheHttpProducer
public abstract class HttpProducer extends RequestReplyProducerImp
Abstract base class for all Apache HTTP producer classes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classHttpProducer.HttpMethodMaps various methods supported by the Apache Http client.
-
Field Summary
Fields Modifier and Type Field Description protected static longDEFAULT_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 HttpAuthenticatorauthenticator()protected longdefaultTimeout()protected voiddoProduce(AdaptrisMessage msg, java.lang.String endpoint)java.lang.Stringendpoint(AdaptrisMessage msg)HttpAuthenticatorgetAuthenticator()Set the authentication method to use for the HTTP requestHttpClientBuilderConfiguratorgetClientConfig()Customise the underlying ApacheHttpClientBuilderbefore the request is made.@NonNull ContentTypeProvidergetContentTypeProvider()The Content-Type header associated with the HTTP operation.java.lang.BooleangetIgnoreServerResponseCode()Control whether or not to ignore the server response code.protected HttpProducer.HttpMethodgetMethod(AdaptrisMessage msg)@NonNull RequestMethodProvidergetMethodProvider()The HTTP method.@NonNull RequestHeaderProvider<org.apache.hc.client5.http.classic.methods.HttpUriRequestBase>getRequestHeaderProvider()Any additional HTTP headers we wish to send with the request.@NonNull ResponseHeaderHandler<org.apache.hc.core5.http.HttpResponse>getResponseHeaderHandler()Specify how we handle headers from the HTTP response.java.lang.StringgetUrl()The URL endpoint to access.protected booleanignoreServerResponseCode()voidprepare()protected voidpreserveRequestPayload(AdaptrisMessage request, AdaptrisMessage response)Ensures that if the reply hasn't got a new payload then we copy the request payload into the response.voidsetAuthenticator(HttpAuthenticator authenticator)Set the authentication method to use for the HTTP requestvoidsetClientConfig(HttpClientBuilderConfigurator clientConfig)Customise the underlying ApacheHttpClientBuilderbefore the request is made.voidsetContentTypeProvider(@NonNull ContentTypeProvider contentTypeProvider)The Content-Type header associated with the HTTP operation.voidsetIgnoreServerResponseCode(java.lang.Boolean ignoreServerResponseCode)Control whether or not to ignore the server response code.voidsetMethodProvider(@NonNull RequestMethodProvider methodProvider)The HTTP method.voidsetRequestHeaderProvider(@NonNull RequestHeaderProvider<org.apache.hc.client5.http.classic.methods.HttpUriRequestBase> requestHeaderProvider)Any additional HTTP headers we wish to send with the request.voidsetResponseHeaderHandler(@NonNull ResponseHeaderHandler<org.apache.hc.core5.http.HttpResponse> responseHeaderHandler)Specify how we handle headers from the HTTP response.voidsetUrl(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
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()
- Specified by:
defaultTimeoutin classRequestReplyProducerBase- See Also:
RequestReplyProducerBase.defaultTimeout()
-
ignoreServerResponseCode
protected boolean ignoreServerResponseCode()
-
getMethod
protected HttpProducer.HttpMethod getMethod(AdaptrisMessage msg)
-
authenticator
protected HttpAuthenticator authenticator()
-
doProduce
protected void doProduce(AdaptrisMessage msg, java.lang.String endpoint) throws ProduceException
- Specified by:
doProducein classRequestReplyProducerImp- Throws:
ProduceException
-
prepare
public void prepare() throws CoreException- Throws:
CoreException
-
endpoint
public java.lang.String endpoint(AdaptrisMessage msg) throws ProduceException
- Specified by:
endpointin classAdaptrisMessageProducerImp- Throws:
ProduceException
-
withURL
public <T extends HttpProducer> T withURL(java.lang.String s)
-
preserveRequestPayload
protected void preserveRequestPayload(AdaptrisMessage request, AdaptrisMessage response) throws java.lang.Exception
Ensures that if the reply hasn't got a new payload then we copy the request payload into the response.- Throws:
java.lang.Exception
-
getMethodProvider
@NonNull public @NonNull RequestMethodProvider getMethodProvider()
The HTTP method.The default is
POST
-
setMethodProvider
public void setMethodProvider(@NonNull @NonNull RequestMethodProvider methodProvider)The HTTP method.The default is
POST
-
getContentTypeProvider
@NonNull public @NonNull ContentTypeProvider getContentTypeProvider()
The Content-Type header associated with the HTTP operation.The default is
text/plainbased on the default fromConfiguredContentTypeProvider.
-
setContentTypeProvider
public void setContentTypeProvider(@NonNull @NonNull ContentTypeProvider contentTypeProvider)The Content-Type header associated with the HTTP operation.The default is
text/plainbased on the default fromConfiguredContentTypeProvider.
-
getResponseHeaderHandler
@NonNull public @NonNull ResponseHeaderHandler<org.apache.hc.core5.http.HttpResponse> getResponseHeaderHandler()
Specify how we handle headers from the HTTP response.If not explicitly configured then the default is
DiscardResponseHeaders
-
setResponseHeaderHandler
public void setResponseHeaderHandler(@NonNull @NonNull ResponseHeaderHandler<org.apache.hc.core5.http.HttpResponse> responseHeaderHandler)Specify how we handle headers from the HTTP response.If not explicitly configured then the default is
DiscardResponseHeaders
-
getRequestHeaderProvider
@NonNull public @NonNull RequestHeaderProvider<org.apache.hc.client5.http.classic.methods.HttpUriRequestBase> getRequestHeaderProvider()
Any additional HTTP headers we wish to send with the request.If not explicitly configured then the default is
NoOpRequestHeaders
-
setRequestHeaderProvider
public void setRequestHeaderProvider(@NonNull @NonNull RequestHeaderProvider<org.apache.hc.client5.http.classic.methods.HttpUriRequestBase> requestHeaderProvider)Any additional HTTP headers we wish to send with the request.If not explicitly configured then the default is
NoOpRequestHeaders
-
getIgnoreServerResponseCode
public java.lang.Boolean getIgnoreServerResponseCode()
Control whether or not 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_CODEis populated with the last server response.
-
setIgnoreServerResponseCode
public void setIgnoreServerResponseCode(java.lang.Boolean ignoreServerResponseCode)
Control whether or not 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_CODEis populated with the last server response.
-
getAuthenticator
public HttpAuthenticator getAuthenticator()
Set the authentication method to use for the HTTP requestIf not explicitly configured then defaults to
NoAuthentication.
-
setAuthenticator
public void setAuthenticator(HttpAuthenticator authenticator)
Set the authentication method to use for the HTTP requestIf not explicitly configured then defaults to
NoAuthentication.
-
getClientConfig
public HttpClientBuilderConfigurator getClientConfig()
Customise the underlying ApacheHttpClientBuilderbefore the request is made.If not explicitly configured will be a
DefaultClientBuilderwith its defaults.
-
setClientConfig
public void setClientConfig(HttpClientBuilderConfigurator clientConfig)
Customise the underlying ApacheHttpClientBuilderbefore the request is made.If not explicitly configured will be a
DefaultClientBuilderwith its defaults.
-
getUrl
public java.lang.String getUrl()
The URL endpoint to access.
-
setUrl
public void setUrl(java.lang.String url)
The URL endpoint to access.
-
-