E- The lifecycle event class to post this hook.
public interface LifecycleHook<E extends LifecycleEvent>
getLifecycleEventClass(), this hook is posted via the
Lifecycle hooks are defined in the experiment schema at the meta, state or variation level. Those hooks, defined
at the meta level are schema-scoped and are applicable to all states and variations in the schema.
Hooks defined at the state level are state-scoped and are only applicable to the state where
they are defined. Finally, hooks defined at the variation level are variation-scoped and are only applicable
to the variation where they are defined. It is an error to define a state-scoped hook which listens to a non-
StateAwareLifecycleEvent. Likewise, is an error to define a variation-scoped hook which listens to a non-
VariationAwareLifecycleEvent. Whenever a lifecycle event of type T is raised, Variant server posts
all hooks whose
getLifecycleEventClass() returns either T or its subclass.
If multiple hooks are to be posted by the same lifecycle event, they form a hook chain, and Variant server will
post them in the order they were defined in the schema. Hooks are posted one after another, until the
post(LifecycleEvent) method returns a non-empty value. If no user defined hook returned a non-empty value,
the default hook is posted, which is guaranteed to return a value.
An implementation must provide at least one public constructor:
Variant creates a new instance of the implementing class for each raised event.
|Modifier and Type||Method and Description|
Implementation must tell the server what life cycle event type(s) it wants to be posted on.
The callback method, called by the server when a life cycle event of type assignable to that returned by
Classobject associated with the life cycle event type(s) of interest.
java.util.Optional<? extends LifecycleEvent.PostResult> post(E event) throws java.lang.Exception
getLifecycleEventClass()is raised. This method may either return a usable result, in the form of a
PostResultobject, or pass the event down the hook chain by returning an empty Optional. An instance of the result object can be obtained by calling the
event- The posting life cycle event. May be further examined for details, e.g. the user session for the runtime event types.
PostResultor empty if this hook wants to delegate down the hook chain.
Variant Experience Server release 0.10.3. Updated 27 Dec 2019.
Copyright © 2019 Variant Inc.