org.springframework.jms.config

## Class JmsListenerEndpointRegistry

- java.lang.Object
- - org.springframework.jms.config.JmsListenerEndpointRegistry

All Implemented Interfaces:
  EventListener, org.springframework.beans.factory.Aware, org.springframework.beans.factory.DisposableBean, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle

    public class JmsListenerEndpointRegistry
    extends Object
    implements org.springframework.beans.factory.DisposableBean, org.springframework.context.SmartLifecycle, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>

Creates the necessary `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:
  `JmsListenerEndpoint`, `MessageListenerContainer`, `JmsListenerContainerFactory`

### Field Summary

Fields
`protected Log` `logger`

### Fields inherited from interface org.springframework.context.SmartLifecycle

`DEFAULT_PHASE`

### Constructor Summary

Constructors
Constructor and Description
`JmsListenerEndpointRegistry()`

### Method Summary

All Methods Instance Methods Concrete Methods
`protected MessageListenerContainer` `createListenerContainer(JmsListenerEndpoint endpoint, JmsListenerContainerFactory<?> factory)` Create and start a new container using the specified factory.
`void` `destroy()`
`MessageListenerContainer` `getListenerContainer(String id)` Return the `MessageListenerContainer` with the specified id or `null` if no such container exists.
`Set<String>` `getListenerContainerIds()` Return the ids of the managed `MessageListenerContainer` instance(s).
`Collection<MessageListenerContainer>` `getListenerContainers()` Return the managed `MessageListenerContainer` instance(s).
`int` `getPhase()`
`boolean` `isRunning()`
`void` `onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent 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(org.springframework.context.ApplicationContext applicationContext)`
`void` `start()`
`void` `stop()`
`void` `stop(Runnable callback)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.springframework.context.SmartLifecycle

`isAutoStartup`

### Field Detail

#### logger

    protected final Log logger

### Constructor Detail

#### JmsListenerEndpointRegistry

    public JmsListenerEndpointRegistry()

### Method Detail

#### setApplicationContext

    public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)

Specified by:
  `setApplicationContext` in interface `org.springframework.context.ApplicationContextAware`

#### onApplicationEvent

    public void onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)

Specified by:
  `onApplicationEvent` in interface `org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>`

#### getListenerContainer

    @Nullable
    public MessageListenerContainer getListenerContainer(String id)

Return the `MessageListenerContainer` with the specified id or `null` if no such container exists.

Parameters:
  `id` - the id of the container
Returns:
  the container or `null` if no container with that id exists
See Also:
  `JmsListenerEndpoint.getId()`, `getListenerContainerIds()`

#### getListenerContainerIds

    public Set<String> getListenerContainerIds()

Return the ids of the managed `MessageListenerContainer` instance(s).

Since:
  4.2.3
See Also:
  `getListenerContainer(String)`

#### getListenerContainers

    public Collection<MessageListenerContainer> getListenerContainers()

Return the managed `MessageListenerContainer` instance(s).

#### registerListenerContainer

    public void registerListenerContainer(JmsListenerEndpoint endpoint,
                                          JmsListenerContainerFactory<?> factory,
                                          boolean startImmediately)

Create a message listener container for the given `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.

Parameters:
  `endpoint` - the endpoint to add
  `factory` - the listener factory to use
  `startImmediately` - start the container immediately if necessary
See Also:
  `getListenerContainers()`, `getListenerContainer(String)`

#### registerListenerContainer

    public void registerListenerContainer(JmsListenerEndpoint endpoint,
                                          JmsListenerContainerFactory<?> factory)

Create a message listener container for the given `JmsListenerEndpoint`.

This create the necessary infrastructure to honor that endpoint with regards to its configuration.

Parameters:
  `endpoint` - the endpoint to add
  `factory` - the listener factory to use
See Also:
  `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()

Specified by:
  `getPhase` in interface `org.springframework.context.Phased`
Specified by:
  `getPhase` in interface `org.springframework.context.SmartLifecycle`

#### start

    public void start()

Specified by:
  `start` in interface `org.springframework.context.Lifecycle`

#### stop

    public void stop()

Specified by:
  `stop` in interface `org.springframework.context.Lifecycle`

#### stop

    public void stop(Runnable callback)

Specified by:
  `stop` in interface `org.springframework.context.SmartLifecycle`

#### isRunning

    public boolean isRunning()

Specified by:
  `isRunning` in interface `org.springframework.context.Lifecycle`

#### destroy

    public void destroy()

Specified by:
  `destroy` in interface `org.springframework.beans.factory.DisposableBean`