|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.gateway.AbstractMessagingGateway
org.springframework.integration.gateway.SimpleMessagingGateway
org.springframework.integration.http.HttpInboundEndpoint
public class HttpInboundEndpoint
An inbound endpoint for handling an HTTP request and generating a response.
By default GET and POST requests are accepted, but the 'supportedMethods' property may be set to include others or limit the options (e.g. POST only). By default the request will be converted to a Message payload according to the rules of theDefaultInboundRequestMapper
.
To customize the mapping of the request to the Message payload, provide
a reference to an InboundRequestMapper
implementation to the
setRequestMapper(InboundRequestMapper)
method.
The value for expectReply
is false
by default.
This means that as soon as the Message is created and passed to the
request channel
,
a response will be generated. If a view
has been
provided, it will be invoked to render the response, and it will have
access to the request message in the model map. The corresponding key
in that map is determined by the requestKey
property (with a
default of "requestMessage"). If no view is provided, and the 'expectReply'
value is false
then a simple OK status response will be issued.
To handle request-reply scenarios, set the 'expectReply' flag to
true
. By default, the reply Message's payload will be
extracted prior to generating a response. The payload must be either
a String, a byte array, or a Serializable object. To have the entire
serialized Message written as the response body, switch the
extractReplyPayload
value to false
.
In the request-reply case, if a 'view' is provided, the response will
not be generated directly from the reply Message or its extracted payload.
Instead, the model map will be passed to that view, and it will contain
either the reply Message or payload depending on the value of
extractReplyPayload
. The corresponding key in the map will be
determined by the replyKey
property (with a default of "reply").
The map will also contain the original request Message as described above.
Field Summary |
---|
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport |
---|
logger |
Constructor Summary | |
---|---|
HttpInboundEndpoint()
|
Method Summary | |
---|---|
void |
handleRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
protected void |
onInit()
|
void |
setExpectReply(boolean expectReply)
Specify whether this endpoint should perform a request/reply operation. |
void |
setExtractReplyPayload(boolean extractReplyPayload)
Specify whether the reply Message's payload should be passed in the response. |
void |
setReplyKey(java.lang.String replyKey)
Specify the key to be used when storing the reply Message or payload in the model map. |
void |
setRequestKey(java.lang.String requestKey)
Specify the key to be used when storing the request Message in the model map. |
void |
setRequestMapper(InboundRequestMapper requestMapper)
Specify an InboundRequestMapper implementation to map from the
inbound HttpServletRequest instances to Messages at runtime. |
void |
setSupportedMethods(java.lang.String... supportedMethods)
Specify the supported request methods for this endpoint. |
void |
setView(org.springframework.web.servlet.View view)
Specify a View to be used for rendering the
response. |
Methods inherited from class org.springframework.integration.gateway.SimpleMessagingGateway |
---|
fromMessage, toMessage |
Methods inherited from class org.springframework.integration.gateway.AbstractMessagingGateway |
---|
doStart, doStop, receive, send, sendAndReceive, sendAndReceiveMessage, setReplyChannel, setReplyTimeout, setRequestChannel, setRequestTimeout, setShouldThrowErrors |
Methods inherited from class org.springframework.integration.endpoint.AbstractEndpoint |
---|
afterPropertiesSet, isRunning, setAutoStartup, setTaskScheduler, start, stop |
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport |
---|
getBeanFactory, getBeanName, getChannelResolver, getTaskScheduler, setBeanFactory, setBeanName, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public HttpInboundEndpoint()
Method Detail |
---|
public void setSupportedMethods(java.lang.String... supportedMethods)
public void setExpectReply(boolean expectReply)
public void setRequestMapper(InboundRequestMapper requestMapper)
InboundRequestMapper
implementation to map from the
inbound HttpServletRequest
instances to Messages at runtime.
The default implementation is DefaultInboundRequestMapper
.
public void setExtractReplyPayload(boolean extractReplyPayload)
null
, the String or byte array
will be written directly to the HTTP response.
The default value is 'true'.
setView(View)
public void setView(org.springframework.web.servlet.View view)
View
to be used for rendering the
response. If no View is provided, the reply Message or its
payload will be written directly to the response.
setExtractReplyPayload(boolean)
public void setRequestKey(java.lang.String requestKey)
view
has been
provided for rendering the response. The default key is "requestMessage".
public void setReplyKey(java.lang.String replyKey)
view
has been provided for rendering the response. The default key is "reply".
protected void onInit() throws java.lang.Exception
onInit
in class AbstractMessagingGateway
java.lang.Exception
public void handleRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
handleRequest
in interface org.springframework.web.HttpRequestHandler
javax.servlet.ServletException
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |