public class JmsListenerEndpointRegistry extends java.lang.Object implements DisposableBean, SmartLifecycle, ApplicationContextAware, ApplicationListener<ContextRefreshedEvent>
MessageListenerContainer 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. Use getListenerContainers() if
you need to access this registry's listener containers for management purposes.
If you need to access to a specific message listener container, use
getListenerContainer(String) with the id of the endpoint.
JmsListenerEndpoint,
MessageListenerContainer,
JmsListenerContainerFactory| Constructor and Description |
|---|
JmsListenerEndpointRegistry() |
| Modifier and Type | Method and Description |
|---|---|
protected MessageListenerContainer |
createListenerContainer(JmsListenerEndpoint endpoint,
JmsListenerContainerFactory<?> factory)
Create and start a new container using the specified factory.
|
void |
destroy()
Invoked by a BeanFactory on destruction of a singleton.
|
MessageListenerContainer |
getListenerContainer(java.lang.String id)
Return the
MessageListenerContainer with the specified id or
null if no such container exists. |
java.util.Set<java.lang.String> |
getListenerContainerIds()
Return the ids of the managed
MessageListenerContainer instance(s). |
java.util.Collection<MessageListenerContainer> |
getListenerContainers()
Return the managed
MessageListenerContainer instance(s). |
int |
getPhase()
Return the phase value of this object.
|
boolean |
isAutoStartup()
Returns
true if this Lifecycle component should get
started automatically by the container at the time that the containing
ApplicationContext gets refreshed. |
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 given
JmsListenerEndpoint. |
void |
registerListenerContainer(JmsListenerEndpoint endpoint,
JmsListenerContainerFactory<?> factory,
boolean startImmediately)
Create a message listener container for the given
JmsListenerEndpoint. |
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(java.lang.Runnable callback)
Indicates that a Lifecycle component must stop if it is currently running.
|
protected final Log logger
public void setApplicationContext(ApplicationContext applicationContext)
ApplicationContextAwareInvoked after population of normal bean properties but before an init callback such
as InitializingBean.afterPropertiesSet()
or a custom init-method. Invoked after ResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader),
ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) and
MessageSourceAware, if applicable.
setApplicationContext in interface ApplicationContextAwareapplicationContext - the ApplicationContext object to be used by this objectBeanInitializationExceptionpublic void onApplicationEvent(ContextRefreshedEvent event)
ApplicationListeneronApplicationEvent in interface ApplicationListener<ContextRefreshedEvent>event - the event to respond to@Nullable public MessageListenerContainer getListenerContainer(java.lang.String id)
MessageListenerContainer with the specified id or
null if no such container exists.id - the id of the containernull if no container with that id existsJmsListenerEndpoint.getId(),
getListenerContainerIds()public java.util.Set<java.lang.String> getListenerContainerIds()
MessageListenerContainer instance(s).getListenerContainer(String)public java.util.Collection<MessageListenerContainer> getListenerContainers()
MessageListenerContainer instance(s).public void registerListenerContainer(JmsListenerEndpoint endpoint, JmsListenerContainerFactory<?> factory, boolean startImmediately)
JmsListenerEndpoint.
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 necessarygetListenerContainers(),
getListenerContainer(String)public void registerListenerContainer(JmsListenerEndpoint endpoint, JmsListenerContainerFactory<?> factory)
JmsListenerEndpoint.
This create the necessary infrastructure to honor that endpoint with regards to its configuration.
endpoint - the endpoint to addfactory - the listener factory to useregisterListenerContainer(JmsListenerEndpoint, JmsListenerContainerFactory, boolean)protected MessageListenerContainer createListenerContainer(JmsListenerEndpoint endpoint, JmsListenerContainerFactory<?> factory)
public int getPhase()
Phasedpublic boolean isAutoStartup()
SmartLifecycletrue if this Lifecycle component should get
started automatically by the container at the time that the containing
ApplicationContext gets refreshed.
A value of false indicates that the component is intended to
be started through an explicit Lifecycle.start() call instead, analogous
to a plain Lifecycle implementation.
isAutoStartup in interface SmartLifecycleLifecycle.start(),
Phased.getPhase(),
LifecycleProcessor.onRefresh(),
ConfigurableApplicationContext.refresh()public void start()
LifecycleShould 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 in interface LifecycleSmartLifecycle.isAutoStartup()public void stop()
LifecycleSmartLifecycle
and its stop(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, only destroy methods will be called.
Should not throw an exception if the component isn't started yet.
In the case of a container, this will propagate the stop signal to all components that apply.
stop in interface LifecycleSmartLifecycle.stop(Runnable),
DisposableBean.destroy()public void stop(java.lang.Runnable callback)
SmartLifecycleThe 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
the SmartLifecycle component does indeed stop.
The LifecycleProcessor will call only this variant of the
stop method; i.e. Lifecycle.stop() will not be called for
SmartLifecycle implementations unless explicitly delegated to within
the implementation of this method.
stop in interface SmartLifecycleLifecycle.stop(),
Phased.getPhase()public boolean isRunning()
LifecycleIn the case of a container, this will return true only if all
components that apply are currently running.
public void destroy()
DisposableBeandestroy in interface DisposableBean