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>
Default
PayloadEnricher that propagates failover metadata (upToDate, asOf,
exception info) into payloads that implement Referential
or ReferentialAware.- Author:
- Anand Manissery
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionenrichOnRecover(Failover failover, Class<T> clazz, ReferentialPayload<T> referentialPayload, Throwable cause) Enriches the payload after it has been recovered from the failover store.enrichOnStore(Failover failover, Class<T> clazz, ReferentialPayload<T> referentialPayload) Enriches the payload before it is written to the failover store.protected TextractPayload(Class<T> clazz, ReferentialPayload<T> referentialPayload) Extracts the payload from the referential wrapper.protected voidpopulateAdditionalInfoOnMetadata(Failover failover, Class<T> clazz, ReferentialPayload<T> referentialPayload, T payload, Throwable cause, Metadata metadata) Extension point for adding custom entries to the recovery metadata.
-
Constructor Details
-
DefaultPayloadEnricher
public DefaultPayloadEnricher()
-
-
Method Details
-
enrichOnStore
public ReferentialPayload<T> enrichOnStore(Failover failover, Class<T> clazz, ReferentialPayload<T> referentialPayload) Description copied from interface:PayloadEnricherEnriches the payload before it is written to the failover store.- Specified by:
enrichOnStorein interfacePayloadEnricher<T>- Parameters:
failover- annotation metadata for the failover pointclazz- expected payload typereferentialPayload- 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:PayloadEnricherEnriches the payload after it has been recovered from the failover store.- Specified by:
enrichOnRecoverin interfacePayloadEnricher<T>- Parameters:
failover- annotation metadata for the failover pointclazz- expected payload typereferentialPayload- the wrapper holding the recovered payload; may benullcause- the exception that triggered recovery- Returns:
- the enriched referential payload
-
extractPayload
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 typereferentialPayload- 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 implementsReferentialorReferentialAwareand a cause is present.- Parameters:
failover- annotation metadata for the failover pointclazz- expected payload typereferentialPayload- the referential wrapperpayload- the extracted payloadcause- the exception that triggered recoverymetadata- the metadata map to populate
-