类 AbstractMessageChannel
- java.lang.Object
- org.springframework.messaging.support.AbstractMessageChannel
- 所有已实现的接口:
Aware,BeanNameAware,MessageChannel,InterceptableChannel
- 直接已知子类:
AbstractSubscribableChannel
public abstract class AbstractMessageChannel extends Object implements MessageChannel, InterceptableChannel, BeanNameAware
Abstract base class forMessageChannelimplementations.- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev
嵌套类概要
嵌套类 修饰符和类型 类 说明 protected classAbstractMessageChannel.ChannelInterceptorChainAssists with the invocation of the configured channel interceptors.
字段概要
从接口继承的字段 org.springframework.messaging.MessageChannel
INDEFINITE_TIMEOUT
构造器概要
构造器 构造器 说明 AbstractMessageChannel()
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 voidaddInterceptor(int index, ChannelInterceptor interceptor)Add a channel interceptor at the specified index.voidaddInterceptor(ChannelInterceptor interceptor)Add a channel interceptor to the end of the list.StringgetBeanName()Return the bean name for this message channel.List<ChannelInterceptor>getInterceptors()Return the list of configured interceptors.LoggetLogger()Return the currently configured Logger.ChannelInterceptorremoveInterceptor(int index)Remove the interceptor at the given index.booleanremoveInterceptor(ChannelInterceptor interceptor)Remove the given interceptor.booleansend(Message<?> message)Send aMessageto this channel.booleansend(Message<?> message, long timeout)Send a message, blocking until either the message is accepted or the specified timeout period elapses.protected abstract booleansendInternal(Message<?> message, long timeout)voidsetBeanName(String name)A message channel uses the bean name primarily for logging purposes.voidsetInterceptors(List<ChannelInterceptor> interceptors)Set the list of channel interceptors clearing any existing interceptors.voidsetLogger(Log logger)Set an alternative logger to use than the one based on the class name.StringtoString()
构造器详细资料
AbstractMessageChannel
public AbstractMessageChannel()
方法详细资料
setLogger
public void setLogger(Log logger)
Set an alternative logger to use than the one based on the class name.- 参数:
logger- the logger to use- 从以下版本开始:
- 5.1
setBeanName
public void setBeanName(String name)
A message channel uses the bean name primarily for logging purposes.- 指定者:
setBeanName在接口中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 theBeanFactoryUtils.originalBeanName(String)method to extract the original bean name (without suffix), if desired.
getBeanName
public String getBeanName()
Return the bean name for this message channel.
setInterceptors
public void setInterceptors(List<ChannelInterceptor> interceptors)
从接口复制的说明:InterceptableChannelSet the list of channel interceptors clearing any existing interceptors.- 指定者:
setInterceptors在接口中InterceptableChannel
addInterceptor
public void addInterceptor(ChannelInterceptor interceptor)
从接口复制的说明:InterceptableChannelAdd a channel interceptor to the end of the list.- 指定者:
addInterceptor在接口中InterceptableChannel
addInterceptor
public void addInterceptor(int index, ChannelInterceptor interceptor)
从接口复制的说明:InterceptableChannelAdd a channel interceptor at the specified index.- 指定者:
addInterceptor在接口中InterceptableChannel
getInterceptors
public List<ChannelInterceptor> getInterceptors()
从接口复制的说明:InterceptableChannelReturn the list of configured interceptors.- 指定者:
getInterceptors在接口中InterceptableChannel
removeInterceptor
public boolean removeInterceptor(ChannelInterceptor interceptor)
从接口复制的说明:InterceptableChannelRemove the given interceptor.- 指定者:
removeInterceptor在接口中InterceptableChannel
removeInterceptor
public ChannelInterceptor removeInterceptor(int index)
从接口复制的说明:InterceptableChannelRemove the interceptor at the given index.- 指定者:
removeInterceptor在接口中InterceptableChannel
send
public final boolean send(Message<?> message)
从接口复制的说明:MessageChannelSend aMessageto this channel. If the message is sent successfully, the method returnstrue. If the message cannot be sent due to a non-fatal reason, the method returnsfalse. 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在接口中MessageChannel- 参数:
message- the message to send- 返回:
- whether or not the message was sent
send
public final boolean send(Message<?> message, long timeout)
从接口复制的说明:MessageChannelSend a message, blocking until either the message is accepted or the specified timeout period elapses.- 指定者:
send在接口中MessageChannel- 参数:
message- the message to sendtimeout- the timeout in milliseconds orMessageChannel.INDEFINITE_TIMEOUT- 返回:
trueif the message is sent,falseif not including a timeout of an interrupt of the send
sendInternal
protected abstract boolean sendInternal(Message<?> message, long timeout)