Class Reconfigurator<T extends Relaunchable<? super S>,S>

java.lang.Object
com.arpnetworking.utility.Reconfigurator<T,S>
Type Parameters:
T - The Relaunchable type to configure.
S - The type representing the validated configuration.
All Implemented Interfaces:
Listener

public class Reconfigurator<T extends Relaunchable<? super S>,S> extends Object implements Listener
Manages configuration and reconfiguration of a Relaunchable instance using a POJO representation of its configuration. The Relaunchable is updated with each new configuration. The configuration must validate on construction and throw an exception if the configuration is invalid.
Author:
Ville Koskela (ville dot koskela at inscopemetrics dot io)
  • Constructor Details

    • Reconfigurator

      public Reconfigurator(Relaunchable<S> relaunchable, Class<? extends S> configurationClass)
      Public constructor.
      Parameters:
      relaunchable - The Relaunchable instance.
      configurationClass - The configuration class.
  • Method Details

    • offerConfiguration

      public void offerConfiguration(Configuration configuration) throws Exception
      Description copied from interface: Listener
      Invoked before new configuration is applied. Any registered listener may reject the configuration by throwing an Exception. Any listener rejecting the configuration rejects the entire configuration and the offering instance will log the Exception with an error. Once any listener rejects the Configuration other listeners may not be offered that instance.
      Specified by:
      offerConfiguration in interface Listener
      Parameters:
      configuration - The new Configuration to be validated.
      Throws:
      Exception - Thrown if the Configuration should be rejected.
    • applyConfiguration

      public void applyConfiguration()
      Description copied from interface: Listener
      Invoked to apply the most recently offered configuration. Any RuntimeException thrown is logged and ignored. All validation must be performed during offer.
      Specified by:
      applyConfiguration in interface Listener
    • toLogValue

      public Object toLogValue()
      Generate a Steno log compatible representation.
      Returns:
      Steno log compatible representation.
    • toString

      public String toString()
      Overrides:
      toString in class Object