Package com.arpnetworking.utility
Class Reconfigurator<T extends Relaunchable<? super S>,S>
java.lang.Object
com.arpnetworking.utility.Reconfigurator<T,S>
- Type Parameters:
T
- TheRelaunchable
type to configure.S
- The type representing the validated configuration.
- All Implemented Interfaces:
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 Summary
ConstructorDescriptionReconfigurator
(Relaunchable<S> relaunchable, Class<? extends S> configurationClass) Public constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Invoked to apply the most recently offered configuration.void
offerConfiguration
(Configuration configuration) Invoked before new configuration is applied.Generate a Steno log compatible representation.toString()
-
Constructor Details
-
Reconfigurator
Public constructor.- Parameters:
relaunchable
- TheRelaunchable
instance.configurationClass
- The configuration class.
-
-
Method Details
-
offerConfiguration
Description copied from interface:Listener
Invoked before new configuration is applied. Any registered listener may reject the configuration by throwing anException
. Any listener rejecting the configuration rejects the entire configuration and the offering instance will log theException
with an error. Once any listener rejects theConfiguration
other listeners may not be offered that instance.- Specified by:
offerConfiguration
in interfaceListener
- Parameters:
configuration
- The newConfiguration
to be validated.- Throws:
Exception
- Thrown if theConfiguration
should be rejected.
-
applyConfiguration
public void applyConfiguration()Description copied from interface:Listener
Invoked to apply the most recently offered configuration. AnyRuntimeException
thrown is logged and ignored. All validation must be performed during offer.- Specified by:
applyConfiguration
in interfaceListener
-
toLogValue
Generate a Steno log compatible representation.- Returns:
- Steno log compatible representation.
-
toString
-