类 JmsListenerEndpointRegistry
- java.lang.Object
- org.springframework.jms.config.JmsListenerEndpointRegistry
- 所有已实现的接口:
EventListener
,Aware
,DisposableBean
,ApplicationContextAware
,ApplicationListener<ContextRefreshedEvent>
,Lifecycle
,Phased
,SmartLifecycle
public class JmsListenerEndpointRegistry extends Object implements DisposableBean, SmartLifecycle, ApplicationContextAware, ApplicationListener<ContextRefreshedEvent>
Creates the necessaryMessageListenerContainer
instances for the registered endpoints. Also manages the lifecycle of the listener containers, in particular within the lifecycle of the application context.Contrary to
MessageListenerContainers
created manually, listener containers managed by registry are not beans in the application context and are not candidates for autowiring. UsegetListenerContainers()
if you need to access this registry's listener containers for management purposes. If you need to access to a specific message listener container, usegetListenerContainer(String)
with the id of the endpoint.- 从以下版本开始:
- 4.1
- 作者:
- Stephane Nicoll, Juergen Hoeller
- 另请参阅:
JmsListenerEndpoint
,MessageListenerContainer
,JmsListenerContainerFactory
字段概要
从接口继承的字段 org.springframework.context.SmartLifecycle
DEFAULT_PHASE
构造器概要
构造器 构造器 说明 JmsListenerEndpointRegistry()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected MessageListenerContainer
createListenerContainer(JmsListenerEndpoint endpoint, JmsListenerContainerFactory<?> factory)
Create and start a new container using the specified factory.void
destroy()
Invoked by the containingBeanFactory
on destruction of a bean.MessageListenerContainer
getListenerContainer(String id)
Return theMessageListenerContainer
with the specified id ornull
if no such container exists.Set<String>
getListenerContainerIds()
Return the ids of the managedMessageListenerContainer
instance(s).Collection<MessageListenerContainer>
getListenerContainers()
Return the managedMessageListenerContainer
instance(s).int
getPhase()
Return the phase that this lifecycle object is supposed to run in.boolean
isRunning()
Check whether this component is currently running.void
onApplicationEvent(ContextRefreshedEvent event)
Handle an application event.void
registerListenerContainer(JmsListenerEndpoint endpoint, JmsListenerContainerFactory<?> factory)
Create a message listener container for the givenJmsListenerEndpoint
.void
registerListenerContainer(JmsListenerEndpoint endpoint, JmsListenerContainerFactory<?> factory, boolean startImmediately)
Create a message listener container for the givenJmsListenerEndpoint
.void
setApplicationContext(ApplicationContext applicationContext)
Set the ApplicationContext that this object runs in.void
start()
Start this component.void
stop()
Stop this component, typically in a synchronous fashion, such that the component is fully stopped upon return of this method.void
stop(Runnable callback)
Indicates that a Lifecycle component must stop if it is currently running.从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 org.springframework.context.SmartLifecycle
isAutoStartup
构造器详细资料
JmsListenerEndpointRegistry
public JmsListenerEndpointRegistry()
方法详细资料
setApplicationContext
public void setApplicationContext(ApplicationContext applicationContext)
从接口复制的说明:ApplicationContextAware
Set the ApplicationContext that this object runs in. Normally this call will be used to initialize the object.Invoked after population of normal bean properties but before an init callback such as
InitializingBean.afterPropertiesSet()
or a custom init-method. Invoked afterResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader)
,ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)
andMessageSourceAware
, if applicable.- 指定者:
setApplicationContext
在接口中ApplicationContextAware
- 参数:
applicationContext
- the ApplicationContext object to be used by this object- 另请参阅:
BeanInitializationException
onApplicationEvent
public void onApplicationEvent(ContextRefreshedEvent event)
从接口复制的说明:ApplicationListener
Handle an application event.- 指定者:
onApplicationEvent
在接口中ApplicationListener<ContextRefreshedEvent>
- 参数:
event
- the event to respond to
getListenerContainer
@Nullable public MessageListenerContainer getListenerContainer(String id)
Return theMessageListenerContainer
with the specified id ornull
if no such container exists.- 参数:
id
- the id of the container- 返回:
- the container or
null
if no container with that id exists - 另请参阅:
JmsListenerEndpoint.getId()
,getListenerContainerIds()
getListenerContainerIds
public Set<String> getListenerContainerIds()
Return the ids of the managedMessageListenerContainer
instance(s).- 从以下版本开始:
- 4.2.3
- 另请参阅:
getListenerContainer(String)
getListenerContainers
public Collection<MessageListenerContainer> getListenerContainers()
Return the managedMessageListenerContainer
instance(s).
registerListenerContainer
public void registerListenerContainer(JmsListenerEndpoint endpoint, JmsListenerContainerFactory<?> factory, boolean startImmediately)
Create a message listener container for the givenJmsListenerEndpoint
.This create the necessary infrastructure to honor that endpoint with regards to its configuration.
The
startImmediately
flag determines if the container should be started immediately.- 参数:
endpoint
- the endpoint to addfactory
- the listener factory to usestartImmediately
- start the container immediately if necessary- 另请参阅:
getListenerContainers()
,getListenerContainer(String)
registerListenerContainer
public void registerListenerContainer(JmsListenerEndpoint endpoint, JmsListenerContainerFactory<?> factory)
Create a message listener container for the givenJmsListenerEndpoint
.This create the necessary infrastructure to honor that endpoint with regards to its configuration.
- 参数:
endpoint
- the endpoint to addfactory
- the listener factory to use- 另请参阅:
registerListenerContainer(JmsListenerEndpoint, JmsListenerContainerFactory, boolean)
createListenerContainer
protected MessageListenerContainer createListenerContainer(JmsListenerEndpoint endpoint, JmsListenerContainerFactory<?> factory)
Create and start a new container using the specified factory.
getPhase
public int getPhase()
从接口复制的说明:SmartLifecycle
Return the phase that this lifecycle object is supposed to run in.The default implementation returns
SmartLifecycle.DEFAULT_PHASE
in order to letstop()
callbacks execute after regularLifecycle
implementations.
start
public void start()
从接口复制的说明:Lifecycle
Start this component.Should not throw an exception if the component is already running.
In the case of a container, this will propagate the start signal to all components that apply.
- 指定者:
start
在接口中Lifecycle
- 另请参阅:
SmartLifecycle.isAutoStartup()
stop
public void stop()
从接口复制的说明:Lifecycle
Stop this component, typically in a synchronous fashion, such that the component is fully stopped upon return of this method. Consider implementingSmartLifecycle
and itsstop(Runnable)
variant when asynchronous stop behavior is necessary.Note that this stop notification is not guaranteed to come before destruction: On regular shutdown,
Lifecycle
beans will first receive a stop notification before the general destruction callbacks are being propagated; however, on hot refresh during a context's lifetime or on aborted refresh attempts, a given bean's destroy method will be called without any consideration of stop signals upfront.Should not throw an exception if the component is not running (not started yet).
In the case of a container, this will propagate the stop signal to all components that apply.
- 指定者:
stop
在接口中Lifecycle
- 另请参阅:
SmartLifecycle.stop(Runnable)
,DisposableBean.destroy()
stop
public void stop(Runnable callback)
从接口复制的说明:SmartLifecycle
Indicates that a Lifecycle component must stop if it is currently running.The provided callback is used by the
LifecycleProcessor
to support an ordered, and potentially concurrent, shutdown of all components having a common shutdown order value. The callback must be executed after theSmartLifecycle
component does indeed stop.The
LifecycleProcessor
will call only this variant of thestop
method; i.e.Lifecycle.stop()
will not be called forSmartLifecycle
implementations unless explicitly delegated to within the implementation of this method.The default implementation delegates to
Lifecycle.stop()
and immediately triggers the given callback in the calling thread. Note that there is no synchronization between the two, so custom implementations may at least want to put the same steps within their common lifecycle monitor (if any).- 指定者:
stop
在接口中SmartLifecycle
- 另请参阅:
Lifecycle.stop()
,SmartLifecycle.getPhase()
isRunning
public boolean isRunning()
从接口复制的说明:Lifecycle
Check whether this component is currently running.In the case of a container, this will return
true
only if all components that apply are currently running.
destroy
public void destroy()
从接口复制的说明:DisposableBean
Invoked by the containingBeanFactory
on destruction of a bean.- 指定者:
destroy
在接口中DisposableBean