public class MessageHandlerRegistrar extends Object implements Lifecycle
MessageHandlerRegistrar
manages the lifecycle of a message handling component, by defining a start()
and shutdown()
method and keeping hold of the message handler's Registration
.
Note that this component is not intended for Event Handling Components, as those should be registered through the
EventProcessingConfigurer
.
Lifecycle.LifecycleHandler, Lifecycle.LifecycleRegistry
Constructor and Description |
---|
MessageHandlerRegistrar(Supplier<Configuration> configSupplier,
Function<Configuration,Object> messageHandlerBuilder,
BiFunction<Configuration,Object,Registration> messageHandlerSubscriber)
Instantiate a
MessageHandlerRegistrar , using the provided configSupplier to supply the Configuration needed to build and register the message handler. |
Modifier and Type | Method and Description |
---|---|
void |
registerLifecycleHandlers(Lifecycle.LifecycleRegistry handle)
Registers the activities to be executed in the various phases of an application's lifecycle.
|
void |
shutdown()
Close the message handler registration initialized in phase
Phase.LOCAL_MESSAGE_HANDLER_REGISTRATIONS
through the start() method. |
void |
start()
Start the message handler registration process by building the message handler in the
Phase.LOCAL_MESSAGE_HANDLER_REGISTRATIONS phase. |
public MessageHandlerRegistrar(Supplier<Configuration> configSupplier, Function<Configuration,Object> messageHandlerBuilder, BiFunction<Configuration,Object,Registration> messageHandlerSubscriber)
MessageHandlerRegistrar
, using the provided configSupplier
to supply the Configuration
needed to build and register the message handler. For the latter operations the given messageHandlerBuilder
and messageHandlerSubscriber
will be used respectively.configSupplier
- a Supplier
of the Configuration
to be used by the given messageHandlerBuilder
and messageHandlerSubscriber
messageHandlerBuilder
- a Function
using the configSupplier
's input to create a message
handlermessageHandlerSubscriber
- a BiFunction
using the the configSupplier
and messageHandlerBuilder
their output to register the created message handler with
the Configuration
public void registerLifecycleHandlers(@Nonnull Lifecycle.LifecycleRegistry handle)
Lifecycle
registerLifecycleHandlers
in interface Lifecycle
handle
- the lifecycle instance to register the handlers withLifecycle.LifecycleRegistry.onShutdown(int, Runnable)
,
LifecycleRegistry#onShutdown(int, LifecycleHandler)
,
Lifecycle.LifecycleRegistry.onStart(int, Runnable)
,
LifecycleRegistry#onStart(int, LifecycleHandler)
public void start()
Phase.LOCAL_MESSAGE_HANDLER_REGISTRATIONS
phase. The specified messageHandlerBuilder
is used for
creation and registration is performed through the messageHandlerSubscriber
.public void shutdown()
Phase.LOCAL_MESSAGE_HANDLER_REGISTRATIONS
through the start()
method.Copyright © 2010–2023. All rights reserved.