Class ReloadingBuilderSupportListener
java.lang.Object
org.apache.commons.configuration2.builder.ReloadingBuilderSupportListener
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescriptionprivate final BasicConfigurationBuilder<?>
Stores the associated configuration builder.private final ReloadingController
Stores the associated reloading controller. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
ReloadingBuilderSupportListener
(BasicConfigurationBuilder<?> configBuilder, ReloadingController controller) Creates a new instance ofReloadingBuilderSupportListener
and initializes it with the associated objects. -
Method Summary
Modifier and TypeMethodDescriptionconnect
(BasicConfigurationBuilder<?> configBuilder, ReloadingController controller) Creates a new instance ofReloadingBuilderSupportListener
which connects the specifiedConfigurationBuilder
with the givenReloadingController
.void
Notifies this event listener about the arrival of a new event.
-
Field Details
-
builder
Stores the associated configuration builder. -
reloadingController
Stores the associated reloading controller.
-
-
Constructor Details
-
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 Details
-
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
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
-