Class ReloadingBuilderSupportListener

java.lang.Object
org.apache.commons.configuration2.builder.ReloadingBuilderSupportListener
All Implemented Interfaces:
EventListener<Event>

final class ReloadingBuilderSupportListener extends 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's BasicConfigurationBuilder.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 Details

    • builder

      private final BasicConfigurationBuilder<?> builder
      Stores the associated configuration builder.
    • reloadingController

      private final ReloadingController reloadingController
      Stores the associated reloading controller.
  • Constructor Details

    • ReloadingBuilderSupportListener

      private ReloadingBuilderSupportListener(BasicConfigurationBuilder<?> configBuilder, ReloadingController controller)
      Creates a new instance of ReloadingBuilderSupportListener and initializes it with the associated objects.
      Parameters:
      configBuilder - the configuration builder
      controller - the ReloadingController
  • Method Details

    • connect

      public static ReloadingBuilderSupportListener connect(BasicConfigurationBuilder<?> configBuilder, ReloadingController controller)
      Creates a new instance of ReloadingBuilderSupportListener which connects the specified ConfigurationBuilder with the given ReloadingController. Listeners are registered to react on notifications and implement a reloading protocol as described in the class comment.
      Parameters:
      configBuilder - the ConfigurationBuilder
      controller - the ReloadingController
      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 an EventType. This event type acts as a filter; all events matched by the filter are passed to the listener. The type parameters defined by the EventType class and this interface guarantee that the events delivered to the handler are compatible with the concrete method signature of onEvent(). 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 interface EventListener<Event>
      Parameters:
      event - the event