Class HttpRequestServiceImpl
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.http.client.net.HttpRequestServiceImpl
-
- All Implemented Interfaces:
AdaptrisComponent,ComponentLifecycle,ComponentLifecycleExtension,MessageEventGenerator,Service,StateManagedComponent
- Direct Known Subclasses:
BranchingHttpRequestService,HttpRequestService
public abstract class HttpRequestServiceImpl extends ServiceImp
Direct HTTP support as a service rather than wrapped viaStandaloneProducerorStandaloneRequestor.Note that this service just wraps a
StandardHttpProducerinstance but doesn't expose all the possible settings available for the normalStandardHttpProducer. If you need those features, than continue using the producer wrapped as aStandaloneProducerorStandaloneRequestor.String parameters in this service will use the
InterlokMessage.resolve(String)which allows you to specify metadata values as part of a constant string e.g.setUrl("%message{http_url}")will use the metadata value associated with the keyhttp_url.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description HttpRequestServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StandardHttpProducerbuildProducer(AdaptrisMessage msg)protected voidcloseService()HttpAuthenticatorgetAuthenticator()java.lang.StringgetContentType()java.lang.StringgetMethod()RequestHeaderProvider<java.net.HttpURLConnection>getRequestHeaderProvider()ResponseHeaderHandler<java.net.HttpURLConnection>getResponseHeaderHandler()java.lang.StringgetUrl()protected voidinitService()voidprepare()Prepare for initialisation.voidsetAuthenticator(HttpAuthenticator auth)voidsetContentType(java.lang.String ct)voidsetMethod(java.lang.String m)voidsetRequestHeaderProvider(RequestHeaderProvider<java.net.HttpURLConnection> handler)Specify how we want to generate the initial set of HTTP Headers.voidsetResponseHeaderHandler(ResponseHeaderHandler<java.net.HttpURLConnection> handler)Specify how we handle headers from the HTTP response.voidsetUrl(java.lang.String s)<T extends HttpRequestServiceImpl>
TwithAuthenticator(HttpAuthenticator auth)<T extends HttpRequestServiceImpl>
TwithContentType(java.lang.String s)<T extends HttpRequestServiceImpl>
TwithMethod(java.lang.String s)<T extends HttpRequestServiceImpl>
TwithRequestHeaderProvider(RequestHeaderProvider<java.net.HttpURLConnection> s)<T extends HttpRequestServiceImpl>
TwithResponseHeaderHandler(ResponseHeaderHandler<java.net.HttpURLConnection> s)<T extends HttpRequestServiceImpl>
TwithUrl(java.lang.String s)-
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId, start, stop
-
-
-
-
Method Detail
-
prepare
public void prepare() throws CoreExceptionDescription copied from interface:ComponentLifecycleExtensionPrepare for initialisation.- Throws:
CoreException
-
initService
protected void initService() throws CoreException- Specified by:
initServicein classServiceImp- Throws:
CoreException
-
closeService
protected void closeService()
- Specified by:
closeServicein classServiceImp
-
buildProducer
protected StandardHttpProducer buildProducer(AdaptrisMessage msg)
-
getResponseHeaderHandler
public ResponseHeaderHandler<java.net.HttpURLConnection> getResponseHeaderHandler()
- Returns:
- the responseHeaderHandler
-
setResponseHeaderHandler
public void setResponseHeaderHandler(ResponseHeaderHandler<java.net.HttpURLConnection> handler)
Specify how we handle headers from the HTTP response.- Parameters:
handler- the handler, default is aDiscardResponseHeaders.
-
withResponseHeaderHandler
public <T extends HttpRequestServiceImpl> T withResponseHeaderHandler(ResponseHeaderHandler<java.net.HttpURLConnection> s)
- Since:
- 3.9.0
-
getRequestHeaderProvider
public RequestHeaderProvider<java.net.HttpURLConnection> getRequestHeaderProvider()
-
setRequestHeaderProvider
public void setRequestHeaderProvider(RequestHeaderProvider<java.net.HttpURLConnection> handler)
Specify how we want to generate the initial set of HTTP Headers.- Parameters:
handler- the handler, default is aNoRequestHeaders
-
withRequestHeaderProvider
public <T extends HttpRequestServiceImpl> T withRequestHeaderProvider(RequestHeaderProvider<java.net.HttpURLConnection> s)
- Since:
- 3.9.0
-
getUrl
public java.lang.String getUrl()
- Returns:
- the url
-
setUrl
public void setUrl(java.lang.String s)
- Parameters:
s- the url to set; can be of the form%message{key1}to use the metadata value associated withkey1
-
withUrl
public <T extends HttpRequestServiceImpl> T withUrl(java.lang.String s)
- Since:
- 3.9.0
-
getContentType
public java.lang.String getContentType()
- Returns:
- the contentType
-
setContentType
public void setContentType(java.lang.String ct)
- Parameters:
ct- the contentType to set; can be of the form%message{key1}to use the metadata value associated withkey1
-
withContentType
public <T extends HttpRequestServiceImpl> T withContentType(java.lang.String s)
- Since:
- 3.9.0
-
getMethod
public java.lang.String getMethod()
- Returns:
- the method
-
setMethod
public void setMethod(java.lang.String m)
- Parameters:
m- the method to set; can be of the form%message{key1}to use the metadata value associated withkey1
-
withMethod
public <T extends HttpRequestServiceImpl> T withMethod(java.lang.String s)
- Since:
- 3.9.0
-
getAuthenticator
public HttpAuthenticator getAuthenticator()
- Returns:
- the authenticator
-
setAuthenticator
public void setAuthenticator(HttpAuthenticator auth)
- Parameters:
auth- the authenticator to set
-
withAuthenticator
public <T extends HttpRequestServiceImpl> T withAuthenticator(HttpAuthenticator auth)
- Since:
- 3.9.0
-
-