public abstract class AbstractMessageChannel extends java.lang.Object implements MessageChannel, InterceptableChannel, BeanNameAware
MessageChannel
implementations.Modifier and Type | Class and Description |
---|---|
protected class |
AbstractMessageChannel.ChannelInterceptorChain
Assists with the invocation of the configured channel interceptors.
|
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
beanName |
private java.util.List<ChannelInterceptor> |
interceptors |
protected Log |
logger |
INDEFINITE_TIMEOUT
Constructor and Description |
---|
AbstractMessageChannel() |
Modifier and Type | Method and Description |
---|---|
void |
addInterceptor(ChannelInterceptor interceptor)
Add a channel interceptor to the end of the list.
|
void |
addInterceptor(int index,
ChannelInterceptor interceptor)
Add a channel interceptor at the specified index.
|
java.lang.String |
getBeanName()
Return the bean name for this message channel.
|
java.util.List<ChannelInterceptor> |
getInterceptors()
Return the list of configured interceptors.
|
boolean |
removeInterceptor(ChannelInterceptor interceptor)
Remove the given interceptor.
|
ChannelInterceptor |
removeInterceptor(int index)
Remove the interceptor at the given index.
|
boolean |
send(Message<?> message)
Send a
Message to this channel. |
boolean |
send(Message<?> message,
long timeout)
Send a message, blocking until either the message is accepted or the
specified timeout period elapses.
|
protected abstract boolean |
sendInternal(Message<?> message,
long timeout) |
void |
setBeanName(java.lang.String name)
A message channel uses the bean name primarily for logging purposes.
|
void |
setInterceptors(java.util.List<ChannelInterceptor> interceptors)
Set the list of channel interceptors clearing any existing interceptors.
|
java.lang.String |
toString() |
protected final Log logger
private final java.util.List<ChannelInterceptor> interceptors
private java.lang.String beanName
public void setBeanName(java.lang.String name)
setBeanName
in interface BeanNameAware
name
- the name of the bean in the factory.
Note that this name is the actual bean name used in the factory, which may
differ from the originally specified name: in particular for inner bean
names, the actual bean name might have been made unique through appending
"#..." suffixes. Use the BeanFactoryUtils.originalBeanName(String)
method to extract the original bean name (without suffix), if desired.public java.lang.String getBeanName()
public void setInterceptors(java.util.List<ChannelInterceptor> interceptors)
InterceptableChannel
setInterceptors
in interface InterceptableChannel
public void addInterceptor(ChannelInterceptor interceptor)
InterceptableChannel
addInterceptor
in interface InterceptableChannel
public void addInterceptor(int index, ChannelInterceptor interceptor)
InterceptableChannel
addInterceptor
in interface InterceptableChannel
public java.util.List<ChannelInterceptor> getInterceptors()
InterceptableChannel
getInterceptors
in interface InterceptableChannel
public boolean removeInterceptor(ChannelInterceptor interceptor)
InterceptableChannel
removeInterceptor
in interface InterceptableChannel
public ChannelInterceptor removeInterceptor(int index)
InterceptableChannel
removeInterceptor
in interface InterceptableChannel
public final boolean send(Message<?> message)
MessageChannel
Message
to this channel. If the message is sent successfully,
the method returns true
. If the message cannot be sent due to a
non-fatal reason, the method returns false
. The method may also
throw a RuntimeException in case of non-recoverable errors.
This method may block indefinitely, depending on the implementation.
To provide a maximum wait time, use MessageChannel.send(Message, long)
.
send
in interface MessageChannel
message
- the message to sendpublic final boolean send(Message<?> message, long timeout)
MessageChannel
send
in interface MessageChannel
message
- the message to sendtimeout
- the timeout in milliseconds or MessageChannel.INDEFINITE_TIMEOUT
true
if the message is sent, false
if not
including a timeout of an interrupt of the sendprotected abstract boolean sendInternal(Message<?> message, long timeout)
public java.lang.String toString()
toString
in class java.lang.Object