Class ReloadingBuilderSupportListener
- java.lang.Object
-
- org.apache.commons.configuration2.builder.ReloadingBuilderSupportListener
-
- All Implemented Interfaces:
EventListener<Event>
final class ReloadingBuilderSupportListener extends java.lang.Object implements EventListener<Event>
An internally used helper class for adding reloading support to an arbitrary
ConfigurationBuilder
.This class connects a configuration builder with a
ReloadingController
. This is done in the following way:- An instance is registered as listener at a
ReloadingController
. Whenever the controller indicates that a reload should happen, the associated configuration builder'sBasicConfigurationBuilder.resetResult()
method is called. - When the builder fires a
ConfigurationBuilderResultCreatedEvent
event the reloading controller's reloading state is reset. At that time the reload has actually happened, and the controller is prepared to observe new changes.
- Since:
- 2.0
-
-
Field Summary
Fields Modifier and Type Field Description private BasicConfigurationBuilder<?>
builder
Stores the associated configuration builder.private ReloadingController
reloadingController
Stores the associated reloading controller.
-
Constructor Summary
Constructors Modifier Constructor Description private
ReloadingBuilderSupportListener(BasicConfigurationBuilder<?> configBuilder, ReloadingController controller)
Creates a new instance ofReloadingBuilderSupportListener
and initializes it with the associated objects.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ReloadingBuilderSupportListener
connect(BasicConfigurationBuilder<?> configBuilder, ReloadingController controller)
Creates a new instance ofReloadingBuilderSupportListener
which connects the specifiedConfigurationBuilder
with the givenReloadingController
.void
onEvent(Event event)
Notifies this event listener about the arrival of a new event.
-
-
-
Field Detail
-
builder
private final BasicConfigurationBuilder<?> builder
Stores the associated configuration builder.
-
reloadingController
private final ReloadingController reloadingController
Stores the associated reloading controller.
-
-
Constructor Detail
-
ReloadingBuilderSupportListener
private ReloadingBuilderSupportListener(BasicConfigurationBuilder<?> configBuilder, ReloadingController controller)
Creates a new instance ofReloadingBuilderSupportListener
and initializes it with the associated objects.- Parameters:
configBuilder
- the configuration buildercontroller
- theReloadingController
-
-
Method Detail
-
connect
public static ReloadingBuilderSupportListener connect(BasicConfigurationBuilder<?> configBuilder, ReloadingController controller)
Creates a new instance ofReloadingBuilderSupportListener
which connects the specifiedConfigurationBuilder
with the givenReloadingController
. Listeners are registered to react on notifications and implement a reloading protocol as described in the class comment.- Parameters:
configBuilder
- theConfigurationBuilder
controller
- theReloadingController
- Returns:
- the newly created listener object
-
onEvent
public void onEvent(Event event)
Notifies this event listener about the arrival of a new event. Typically, event listeners are registered at an event source providing anEventType
. This event type acts as a filter; all events matched by the filter are passed to the listener. The type parameters defined by theEventType
class and this interface guarantee that the events delivered to the handler are compatible with the concrete method signature ofonEvent()
. This implementation resets the controller's reloading state if an event about a newly created result was received. Otherwise, in case of a reloading event, the builder's result object is reset.- Specified by:
onEvent
in interfaceEventListener<Event>
- Parameters:
event
- the event
-
-