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 viaStandaloneProducer
orStandaloneRequestor
.Note that this service just wraps a
StandardHttpProducer
instance but doesn't expose all the possible settings available for the normalStandardHttpProducer
. If you need those features, than continue using the producer wrapped as aStandaloneProducer
orStandaloneRequestor
.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 StandardHttpProducer
buildProducer(AdaptrisMessage msg)
protected void
closeService()
HttpAuthenticator
getAuthenticator()
java.lang.String
getContentType()
java.lang.String
getMethod()
RequestHeaderProvider<java.net.HttpURLConnection>
getRequestHeaderProvider()
ResponseHeaderHandler<java.net.HttpURLConnection>
getResponseHeaderHandler()
java.lang.String
getUrl()
protected void
initService()
void
prepare()
Prepare for initialisation.void
setAuthenticator(HttpAuthenticator auth)
void
setContentType(java.lang.String ct)
void
setMethod(java.lang.String m)
void
setRequestHeaderProvider(RequestHeaderProvider<java.net.HttpURLConnection> handler)
Specify how we want to generate the initial set of HTTP Headers.void
setResponseHeaderHandler(ResponseHeaderHandler<java.net.HttpURLConnection> handler)
Specify how we handle headers from the HTTP response.void
setUrl(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 CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Throws:
CoreException
-
initService
protected void initService() throws CoreException
- Specified by:
initService
in classServiceImp
- Throws:
CoreException
-
closeService
protected void closeService()
- Specified by:
closeService
in 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
-
-