org.axonframework.upcasting
Class AbstractUpcasterChain

java.lang.Object
  extended by org.axonframework.upcasting.AbstractUpcasterChain
All Implemented Interfaces:
UpcasterChain
Direct Known Subclasses:
LazyUpcasterChain, SimpleUpcasterChain

public abstract class AbstractUpcasterChain
extends Object
implements UpcasterChain

Abstract implementation of the UpcasterChain interface. This implementation takes care of the iterative process and provides utility functions to convert content types.

Since:
2.0
Author:
Allard Buijze

Constructor Summary
protected AbstractUpcasterChain(ConverterFactory converterFactory, List<Upcaster> upcasters)
          Initializes the UpcasterChain with given converterFactory and upcasters.
protected AbstractUpcasterChain(List<Upcaster> upcasters)
          Initializes the UpcasterChain with given upcasters and a ChainingConverterFactory to convert between content types.
 
Method Summary
protected abstract
<T> List<SerializedObject<?>>
doUpcast(Upcaster<T> upcaster, SerializedObject<?> sourceObject, List<SerializedType> targetTypes, UpcastingContext context)
          Performs the actual upcasting by the given upcaster on the given sourceObject.
protected
<S,T> SerializedObject<T>
ensureCorrectContentType(SerializedObject<S> serializedObject, Class<T> expectedContentType)
          Converts, if necessary, the given serializedObject, and returns a SerializedObject with given expectedContentType.
 List<SerializedObject> upcast(SerializedObject serializedObject, UpcastingContext upcastingContext)
          Pass the given serializedObject through the chain of upcasters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractUpcasterChain

protected AbstractUpcasterChain(List<Upcaster> upcasters)
Initializes the UpcasterChain with given upcasters and a ChainingConverterFactory to convert between content types.

Parameters:
upcasters - the upcasters to form the chain

AbstractUpcasterChain

protected AbstractUpcasterChain(ConverterFactory converterFactory,
                                List<Upcaster> upcasters)
Initializes the UpcasterChain with given converterFactory and upcasters.

Parameters:
converterFactory - The factory providing the converters to convert between content types
upcasters - The upcasters to form this chain
Method Detail

upcast

public List<SerializedObject> upcast(SerializedObject serializedObject,
                                     UpcastingContext upcastingContext)
Description copied from interface: UpcasterChain
Pass the given serializedObject through the chain of upcasters. The result is a list of zero or more serializedObjects representing the latest revision of the payload object.

Specified by:
upcast in interface UpcasterChain
Parameters:
serializedObject - the serialized object to upcast
upcastingContext - the container of properties of the Message transporting the object being upcast
Returns:
the upcast SerializedObjects

ensureCorrectContentType

protected <S,T> SerializedObject<T> ensureCorrectContentType(SerializedObject<S> serializedObject,
                                                             Class<T> expectedContentType)
Converts, if necessary, the given serializedObject, and returns a SerializedObject with given expectedContentType. If the serializedObject already contains the given expectedContentType, it is returned as-is.

Type Parameters:
S - The content type of the provided SerializedObject
T - The content type of the SerializedObject to return
Parameters:
serializedObject - The object to convert
expectedContentType - The content type of the SerializedObject to return
Returns:
a SerializedObject containing data in the expected content type

doUpcast

protected abstract <T> List<SerializedObject<?>> doUpcast(Upcaster<T> upcaster,
                                                          SerializedObject<?> sourceObject,
                                                          List<SerializedType> targetTypes,
                                                          UpcastingContext context)
Performs the actual upcasting by the given upcaster on the given sourceObject. The returned list of serialized object must represent the upcast version of the given sourceObject.

Each item in the returned List of SerializedObject must match the given list of targetTypes. These types are returned by the invocation of Upcaster.upcast(org.axonframework.serializer.SerializedType).

Type Parameters:
T - The representation type expected by the upcaster
Parameters:
upcaster - The upcaster to perform the upcasting with
sourceObject - The SerializedObject to upcast
targetTypes - The types expected in the returned List of SerializedObject
context - The container of properties of the Domain Event Message being upcast
Returns:
The List of SerializedObject representing the upcast sourceObject


Copyright © 2010-2016. All Rights Reserved.