Class JmsListenerEndpointRegistry
- All Implemented Interfaces:
EventListener,Aware,DisposableBean,ApplicationContextAware,ApplicationListener<ContextRefreshedEvent>,Lifecycle,Phased,SmartLifecycle
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.
- Since:
- 4.1
- Author:
- Stephane Nicoll, Juergen Hoeller
- See Also:
-
Field Summary
FieldsFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected MessageListenerContainercreateListenerContainer(JmsListenerEndpoint endpoint, JmsListenerContainerFactory<?> factory) Create and start a new container using the specified factory.voiddestroy()Invoked by the containingBeanFactoryon destruction of a bean.Return theMessageListenerContainerwith the specified id ornullif no such container exists.Return the ids of the managedMessageListenerContainerinstance(s).Return the managedMessageListenerContainerinstance(s).intgetPhase()Return the phase that this lifecycle object is supposed to run in.booleanCheck whether this component is currently running.voidHandle an application event.voidregisterListenerContainer(JmsListenerEndpoint endpoint, JmsListenerContainerFactory<?> factory) Create a message listener container for the givenJmsListenerEndpoint.voidregisterListenerContainer(JmsListenerEndpoint endpoint, JmsListenerContainerFactory<?> factory, boolean startImmediately) Create a message listener container for the givenJmsListenerEndpoint.voidsetApplicationContext(ApplicationContext applicationContext) Set the ApplicationContext that this object runs in.voidstart()Start this component.voidstop()Stop this component, typically in a synchronous fashion, such that the component is fully stopped upon return of this method.voidIndicates that a Lifecycle component must stop if it is currently running.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.SmartLifecycle
isAutoStartup
-
Field Details
-
logger
-
-
Constructor Details
-
JmsListenerEndpointRegistry
public JmsListenerEndpointRegistry()
-
-
Method Details
-
setApplicationContext
Description copied from interface:ApplicationContextAwareSet 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.- Specified by:
setApplicationContextin interfaceApplicationContextAware- Parameters:
applicationContext- the ApplicationContext object to be used by this object- See Also:
-
onApplicationEvent
Description copied from interface:ApplicationListenerHandle an application event.- Specified by:
onApplicationEventin interfaceApplicationListener<ContextRefreshedEvent>- Parameters:
event- the event to respond to
-
getListenerContainer
Return theMessageListenerContainerwith the specified id ornullif no such container exists.- Parameters:
id- the id of the container- Returns:
- the container or
nullif no container with that id exists - See Also:
-
getListenerContainerIds
Return the ids of the managedMessageListenerContainerinstance(s).- Since:
- 4.2.3
- See Also:
-
getListenerContainers
Return the managedMessageListenerContainerinstance(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
startImmediatelyflag determines if the container should be started immediately.- Parameters:
endpoint- the endpoint to addfactory- the listener factory to usestartImmediately- start the container immediately if necessary- See Also:
-
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.
- Parameters:
endpoint- the endpoint to addfactory- the listener factory to use- See Also:
-
createListenerContainer
protected MessageListenerContainer createListenerContainer(JmsListenerEndpoint endpoint, JmsListenerContainerFactory<?> factory) Create and start a new container using the specified factory. -
getPhase
public int getPhase()Description copied from interface:SmartLifecycleReturn the phase that this lifecycle object is supposed to run in.The default implementation returns
SmartLifecycle.DEFAULT_PHASEin order to letstop()callbacks execute after regularLifecycleimplementations.- Specified by:
getPhasein interfacePhased- Specified by:
getPhasein interfaceSmartLifecycle- See Also:
-
start
public void start()Description copied from interface:LifecycleStart 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.
-
stop
public void stop()Description copied from interface:LifecycleStop this component, typically in a synchronous fashion, such that the component is fully stopped upon return of this method. Consider implementingSmartLifecycleand itsstop(Runnable)variant when asynchronous stop behavior is necessary.Note that this stop notification is not guaranteed to come before destruction: On regular shutdown,
Lifecyclebeans 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
Description copied from interface:SmartLifecycleIndicates that a Lifecycle component must stop if it is currently running.The provided callback is used by the
LifecycleProcessorto support an ordered, and potentially concurrent, shutdown of all components having a common shutdown order value. The callback must be executed after theSmartLifecyclecomponent does indeed stop.The
LifecycleProcessorwill call only this variant of thestopmethod; i.e.Lifecycle.stop()will not be called forSmartLifecycleimplementations 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).- Specified by:
stopin interfaceSmartLifecycle- See Also:
-
isRunning
public boolean isRunning()Description copied from interface:LifecycleCheck whether this component is currently running.In the case of a container, this will return
trueonly if all components that apply are currently running. -
destroy
public void destroy()Description copied from interface:DisposableBeanInvoked by the containingBeanFactoryon destruction of a bean.- Specified by:
destroyin interfaceDisposableBean
-