Class GenericListenerEndpointRegistry<C extends MessageListenerContainer,E extends ListenerEndpoint<C>>
java.lang.Object
org.springframework.pulsar.config.GenericListenerEndpointRegistry<C,E>
- Type Parameters:
C
- listener container type.E
- listener endpoint type.
- All Implemented Interfaces:
EventListener
,Aware
,DisposableBean
,ApplicationContextAware
,ApplicationListener<ContextRefreshedEvent>
,Lifecycle
,Phased
,SmartLifecycle
,PulsarListenerContainerRegistry
- Direct Known Subclasses:
PulsarListenerEndpointRegistry
,ReactivePulsarListenerEndpointRegistry
public class GenericListenerEndpointRegistry<C extends MessageListenerContainer,E extends ListenerEndpoint<C>>
extends Object
implements PulsarListenerContainerRegistry, 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, Chris Bono
-
Field Summary
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected C
createListenerContainer
(E endpoint, ListenerContainerFactory<? extends C, E> factory) void
destroy()
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 ornull
if no such container exists.Return the ids of the managed listener container instance(s).Return the managed listener container instance(s).int
getPhase()
boolean
boolean
void
void
registerListenerContainer
(E endpoint, ListenerContainerFactory<? extends C, E> factory) void
registerListenerContainer
(E endpoint, ListenerContainerFactory<? extends C, E> factory, boolean startImmediately) void
setApplicationContext
(ApplicationContext applicationContext) void
start()
void
stop()
void
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.ApplicationListener
supportsAsyncExecution
-
Constructor Details
-
GenericListenerEndpointRegistry
-
-
Method Details
-
setApplicationContext
- Specified by:
setApplicationContext
in interfaceApplicationContextAware
- Throws:
BeansException
-
getListenerContainer
Description copied from interface:PulsarListenerContainerRegistry
Return the listener container with the specified id ornull
if no such container exists.- Specified by:
getListenerContainer
in interfacePulsarListenerContainerRegistry
- Parameters:
id
- the id of the container- Returns:
- the container or
null
if no container with that id exists - See Also:
-
getListenerContainerIds
Description copied from interface:PulsarListenerContainerRegistry
Return the ids of the managed listener container instance(s).- Specified by:
getListenerContainerIds
in interfacePulsarListenerContainerRegistry
- Returns:
- the ids.
- See Also:
-
getListenerContainers
Description copied from interface:PulsarListenerContainerRegistry
Return the managed listener container instance(s).- Specified by:
getListenerContainers
in interfacePulsarListenerContainerRegistry
- Returns:
- the managed listener container instance(s).
- See Also:
-
getAllListenerContainers
Description copied from interface:PulsarListenerContainerRegistry
Return 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:
getAllListenerContainers
in interfacePulsarListenerContainerRegistry
- 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:
destroy
in interfaceDisposableBean
- Throws:
Exception
-
getPhase
public int getPhase()- Specified by:
getPhase
in interfacePhased
- Specified by:
getPhase
in interfaceSmartLifecycle
-
isAutoStartup
public boolean isAutoStartup()- Specified by:
isAutoStartup
in interfaceSmartLifecycle
-
start
public void start() -
stop
public void stop() -
stop
- Specified by:
stop
in interfaceSmartLifecycle
-
isRunning
public boolean isRunning() -
onApplicationEvent
- Specified by:
onApplicationEvent
in interfaceApplicationListener<C extends MessageListenerContainer>
-