Class ListenerEndpointRegistry<C extends MessageListenerContainer,E extends ListenerEndpoint<C>>
java.lang.Object
org.springframework.pulsar.config.ListenerEndpointRegistry<C,E>
- Type Parameters:
C- listener container type.E- listener endpoint type.
- All Implemented Interfaces:
EventListener,Aware,DisposableBean,ApplicationContextAware,ApplicationListener<ContextRefreshedEvent>,Lifecycle,Phased,SmartLifecycle,ListenerContainerRegistry
- Direct Known Subclasses:
PulsarListenerEndpointRegistry,ReactivePulsarListenerEndpointRegistry
public class ListenerEndpointRegistry<C extends MessageListenerContainer,E extends ListenerEndpoint<C>>
extends Object
implements ListenerContainerRegistry, DisposableBean, SmartLifecycle, ApplicationContextAware, ApplicationListener<ContextRefreshedEvent>
Creates the necessary container instances for the registered
endpoints. Also manages the lifecycle of the listener
containers, in particular within the lifecycle of the application context.
Contrary to containers 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.
- Author:
- Soby Chacko, Christophe Bornet
-
Field Summary
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected CcreateListenerContainer(E endpoint, ListenerContainerFactory<? extends C, E> factory) voiddestroy()Return all listener container instances including those managed by this registry and those declared as beans in the application context.Return the listener container with the specified id ornullif no such container exists.Return the ids of the managed listener container instance(s).Return the managed listener container instance(s).intgetPhase()booleanbooleanvoidvoidregisterListenerContainer(E endpoint, ListenerContainerFactory<? extends C, E> factory) voidregisterListenerContainer(E endpoint, ListenerContainerFactory<? extends C, E> factory, boolean startImmediately) voidsetApplicationContext(ApplicationContext applicationContext) voidstart()voidstop()void
-
Constructor Details
-
ListenerEndpointRegistry
-
-
Method Details
-
setApplicationContext
- Specified by:
setApplicationContextin interfaceApplicationContextAware- Throws:
BeansException
-
getListenerContainer
Description copied from interface:ListenerContainerRegistryReturn the listener container with the specified id ornullif no such container exists.- Specified by:
getListenerContainerin interfaceListenerContainerRegistry- Parameters:
id- the id of the container- Returns:
- the container or
nullif no container with that id exists - See Also:
-
getListenerContainerIds
Description copied from interface:ListenerContainerRegistryReturn the ids of the managed listener container instance(s).- Specified by:
getListenerContainerIdsin interfaceListenerContainerRegistry- Returns:
- the ids.
- See Also:
-
getListenerContainers
Description copied from interface:ListenerContainerRegistryReturn the managed listener container instance(s).- Specified by:
getListenerContainersin interfaceListenerContainerRegistry- Returns:
- the managed listener container instance(s).
- See Also:
-
getAllListenerContainers
Description copied from interface:ListenerContainerRegistryReturn all listener container instances including those managed by this registry and those declared as beans in the application context. Prototype-scoped containers will be included. Lazy beans that have not yet been created will not be initialized by a call to this method.- Specified by:
getAllListenerContainersin interfaceListenerContainerRegistry- Returns:
- the listener container instance(s).
- See Also:
-
registerListenerContainer
-
registerListenerContainer
public void registerListenerContainer(E endpoint, ListenerContainerFactory<? extends C, E> factory, boolean startImmediately) -
createListenerContainer
-
destroy
- Specified by:
destroyin interfaceDisposableBean- Throws:
Exception
-
getPhase
public int getPhase()- Specified by:
getPhasein interfacePhased- Specified by:
getPhasein interfaceSmartLifecycle
-
isAutoStartup
public boolean isAutoStartup()- Specified by:
isAutoStartupin interfaceSmartLifecycle
-
start
public void start() -
stop
public void stop() -
stop
- Specified by:
stopin interfaceSmartLifecycle
-
isRunning
public boolean isRunning() -
onApplicationEvent
- Specified by:
onApplicationEventin interfaceApplicationListener<C extends MessageListenerContainer>
-