Class DefaultPayloadEnricher<T>

java.lang.Object
com.societegenerale.failover.core.payload.DefaultPayloadEnricher<T>
Type Parameters:
T - the type of the payload to enrich
All Implemented Interfaces:
PayloadEnricher<T>

public class DefaultPayloadEnricher<T> extends Object implements PayloadEnricher<T>
Default PayloadEnricher that propagates failover metadata (upToDate, asOf, exception info) into payloads that implement Referential or ReferentialAware.
Author:
Anand Manissery
  • Constructor Details

    • DefaultPayloadEnricher

      public DefaultPayloadEnricher()
  • Method Details

    • enrichOnStore

      public ReferentialPayload<T> enrichOnStore(Failover failover, Class<T> clazz, ReferentialPayload<T> referentialPayload)
      Description copied from interface: PayloadEnricher
      Enriches the payload before it is written to the failover store.
      Specified by:
      enrichOnStore in interface PayloadEnricher<T>
      Parameters:
      failover - annotation metadata for the failover point
      clazz - expected payload type
      referentialPayload - the wrapper holding the payload to enrich
      Returns:
      the enriched referential payload
    • enrichOnRecover

      public ReferentialPayload<T> enrichOnRecover(Failover failover, Class<T> clazz, ReferentialPayload<T> referentialPayload, Throwable cause)
      Description copied from interface: PayloadEnricher
      Enriches the payload after it has been recovered from the failover store.
      Specified by:
      enrichOnRecover in interface PayloadEnricher<T>
      Parameters:
      failover - annotation metadata for the failover point
      clazz - expected payload type
      referentialPayload - the wrapper holding the recovered payload; may be null
      cause - the exception that triggered recovery
      Returns:
      the enriched referential payload
    • extractPayload

      protected T extractPayload(Class<T> clazz, ReferentialPayload<T> referentialPayload)
      Extracts the payload from the referential wrapper. Override to supply a non-null fallback when the stored payload is absent (so metadata is still populated in the unrecovered case).
      Parameters:
      clazz - expected payload type
      referentialPayload - the wrapper holding the stored payload
      Returns:
      the extracted payload, possibly null
    • populateAdditionalInfoOnMetadata

      protected void populateAdditionalInfoOnMetadata(Failover failover, Class<T> clazz, ReferentialPayload<T> referentialPayload, T payload, Throwable cause, Metadata metadata)
      Extension point for adding custom entries to the recovery metadata. Called when the payload implements Referential or ReferentialAware and a cause is present.
      Parameters:
      failover - annotation metadata for the failover point
      clazz - expected payload type
      referentialPayload - the referential wrapper
      payload - the extracted payload
      cause - the exception that triggered recovery
      metadata - the metadata map to populate