org.axonframework.upcasting
Class SimpleUpcasterChain

java.lang.Object
  extended by org.axonframework.upcasting.AbstractUpcasterChain
      extended by org.axonframework.upcasting.SimpleUpcasterChain
All Implemented Interfaces:
UpcasterChain

public class SimpleUpcasterChain
extends AbstractUpcasterChain

Represents a series of upcasters which are combined to upcast a SerializedObject to the most recent revision of that payload. The intermediate representation required by each of the upcasters is converted using converters provided by a converterFactory.

Upcasters for different object types may be merged into a single chain, as long as the order of related upcasters can be guaranteed.

Since:
2.0
Author:
Allard Buijze, Frank Versnel

Field Summary
static UpcasterChain EMPTY
          Represents an empty UpcasterChain.
 
Constructor Summary
SimpleUpcasterChain(ConverterFactory converterFactory, List<Upcaster> upcasters)
          Initializes the UpcasterChain with given converterFactory and upcasters.
SimpleUpcasterChain(ConverterFactory converterFactory, Upcaster... upcasters)
          Initialize a chain of the given upcasters and using the given converterFactory to create converters for the intermediate representations used by the upcasters.
SimpleUpcasterChain(List<Upcaster> upcasters)
          Initializes the UpcasterChain with given upcasters and a ChainingConverterFactory to convert between content types.
SimpleUpcasterChain(Serializer serializer, List<Upcaster> upcasters)
          Initializes the UpcasterChain with given serializer and upcasters.
 
Method Summary
protected
<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.
 
Methods inherited from class org.axonframework.upcasting.AbstractUpcasterChain
ensureCorrectContentType, upcast
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY

public static final UpcasterChain EMPTY
Represents an empty UpcasterChain.

Constructor Detail

SimpleUpcasterChain

public SimpleUpcasterChain(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

SimpleUpcasterChain

public SimpleUpcasterChain(Serializer serializer,
                           List<Upcaster> upcasters)
Initializes the UpcasterChain with given serializer and upcasters. The serializer is used to fetch the ConverterFactory instance it uses. This ConverterFactory is generally adapted to the exact form of serialization used by the serializer.

Parameters:
serializer - The serializer used to serialize the data
upcasters - The upcasters to form this chain

SimpleUpcasterChain

public SimpleUpcasterChain(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

SimpleUpcasterChain

public SimpleUpcasterChain(ConverterFactory converterFactory,
                           Upcaster... upcasters)
Initialize a chain of the given upcasters and using the given converterFactory to create converters for the intermediate representations used by the upcasters.

Parameters:
converterFactory - The factory providing ContentTypeConverter instances
upcasters - The upcasters forming the chain (in given order)
Method Detail

doUpcast

protected <T> List<SerializedObject<?>> doUpcast(Upcaster<T> upcaster,
                                                 SerializedObject<?> sourceObject,
                                                 List<SerializedType> targetTypes,
                                                 UpcastingContext context)
Description copied from class: AbstractUpcasterChain
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).

Specified by:
doUpcast in class AbstractUpcasterChain
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.