org.springframework.integration.endpoint
Class DefaultEndpoint<T extends MessageHandler>
java.lang.Object
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.endpoint.AbstractRequestReplyEndpoint
org.springframework.integration.endpoint.DefaultEndpoint<T>
- All Implemented Interfaces:
- org.springframework.beans.factory.BeanNameAware, ChannelRegistryAware, MessageEndpoint, MessageTarget
public class DefaultEndpoint<T extends MessageHandler>
- extends AbstractRequestReplyEndpoint
- implements ChannelRegistryAware
The default Message Endpoint implementation. Serves as a "host" for any
MessageHandler
and resolves the target for any reply Message(s)
returned by that handler. If the handler returns a non-empty
CompositeMessage
, each Message in its list will be sent
as a separate reply Message.
The reply target is resolved according to the following order:
- the 'nextTarget' header value of the reply Message
- the 'outputChannel' of this Message Endpoint
- the 'returnAddress' header value of the request Message
For the 'nextTarget' and 'returnAddress' values, either a
MessageTarget
instance or String is accepted. If the
value is a String, then the endpoint will consult its
ChannelRegistry
(typically provided by the MessageBus).
If no reply target can be determined for a non-null reply Message,
a MessageEndpointReplyException
will be thrown.
- Author:
- Mark Fisher
Constructor Summary |
DefaultEndpoint(T handler)
Create an endpoint for the given handler. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
handler
private final T extends MessageHandler handler
channelRegistry
private volatile ChannelRegistry channelRegistry
selector
private volatile MessageSelector selector
interceptors
private final java.util.List<EndpointInterceptor> interceptors
DefaultEndpoint
public DefaultEndpoint(T handler)
- Create an endpoint for the given handler.
getHandler
protected T getHandler()
setSelector
public void setSelector(MessageSelector selector)
addInterceptor
public void addInterceptor(EndpointInterceptor interceptor)
setInterceptors
public void setInterceptors(java.util.List<EndpointInterceptor> interceptors)
setChannelRegistry
public void setChannelRegistry(ChannelRegistry channelRegistry)
- Specified by:
setChannelRegistry
in interface ChannelRegistryAware
getChannelRegistry
protected ChannelRegistry getChannelRegistry()
setReplyTimeout
public void setReplyTimeout(long replyTimeout)
- Specify the timeout for sending reply Messages to the reply
target. The default value indicates an indefinite timeout.
handleRequestMessage
public final Message<?> handleRequestMessage(Message<?> requestMessage)
- Specified by:
handleRequestMessage
in class AbstractRequestReplyEndpoint
isValidReplyMessage
protected boolean isValidReplyMessage(Message<?> replyMessage)
- The reply Message is considered invalid if it is null, has a null payload,
or has an empty Array or Collection as its payload.
- Specified by:
isValidReplyMessage
in class AbstractRequestReplyEndpoint
sendReplyMessage
protected void sendReplyMessage(Message<?> replyMessage,
Message<?> requestMessage)
- Specified by:
sendReplyMessage
in class AbstractRequestReplyEndpoint
doHandleRequestMessage
private Message<?> doHandleRequestMessage(Message<?> requestMessage,
int index)
supports
protected boolean supports(Message<?> message)
resolveReplyTarget
private MessageTarget resolveReplyTarget(Message<?> replyMessage,
MessageHeaders requestHeaders)
resolveTargetAttribute
private MessageTarget resolveTargetAttribute(java.lang.Object targetAttribute)
setReturnAddressOverrides
public void setReturnAddressOverrides(boolean returnAddressOverrides)
setOutputChannel
public void setOutputChannel(MessageChannel outputChannel)
- Specify the channel where reply Messages should be sent if
no 'nextTarget' header value is available on the reply Message.