|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.axonframework.serializer.json.JacksonSerializer
public class JacksonSerializer
Serializer implementation that uses Jackson to serialize objects into a JSON format. Although the Jackson serializer requires classes to be compatible with this specific serializer, it providers much more compact serialization, while still being human readable.
| Constructor Summary | |
|---|---|
JacksonSerializer()
Initialize the serializer with a default ObjectMapper instance. |
|
JacksonSerializer(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
Initialize the serializer with the given objectMapper to serialize and parse the objects to JSON. |
|
JacksonSerializer(com.fasterxml.jackson.databind.ObjectMapper objectMapper,
RevisionResolver revisionResolver)
Initialize the serializer with the given objectMapper to serialize and parse the objects to JSON. |
|
JacksonSerializer(com.fasterxml.jackson.databind.ObjectMapper objectMapper,
RevisionResolver revisionResolver,
ConverterFactory converterFactory)
Initialize the serializer with the given objectMapper to serialize and parse the objects to JSON. |
|
JacksonSerializer(com.fasterxml.jackson.databind.ObjectMapper objectMapper,
RevisionResolver revisionResolver,
ConverterFactory converterFactory,
ClassLoader classLoader)
Initialize the serializer with the given objectMapper to serialize and parse the objects to JSON. |
|
JacksonSerializer(RevisionResolver revisionResolver,
ConverterFactory converterFactory)
Initialize the serializer using a default ObjectMapper instance, using the given revisionResolver
to define revision for each object to serialize, and given converterFactory to be used by
upcasters. |
|
| Method Summary | ||
|---|---|---|
|
canSerializeTo(Class<T> expectedRepresentation)
Indicates whether this Serializer is capable of serializing to the given expectedRepresentation. |
|
Class |
classForType(SerializedType type)
Returns the class for the given type identifier. |
|
|
deserialize(SerializedObject<S> serializedObject)
Deserializes the first object read from the given bytes. |
|
ConverterFactory |
getConverterFactory()
Returns the converter factory used by this Serializer to convert between serialized representations. |
|
com.fasterxml.jackson.databind.ObjectMapper |
getObjectMapper()
Returns the ObjectMapper used by this serializer, allowing for configuration of the serialization settings. |
|
protected com.fasterxml.jackson.databind.ObjectReader |
getReader(Class<?> type)
Provides the ObjectReader, with which objects are read from the JSON form. |
|
protected com.fasterxml.jackson.databind.ObjectWriter |
getWriter()
Provides the ObjectWriter, with which objects are serialized to JSON form. |
|
protected void |
registerConverters(ChainingConverterFactory converterFactory)
Registers converters with the given converterFactory which depend on the actual contents of the
serialized for to represent a JSON format. |
|
protected String |
resolveClassName(SerializedType serializedType)
Resolve the class name from the given serializedType. |
|
|
serialize(Object object,
Class<T> expectedRepresentation)
Serialize the given object into a Serialized Object containing the given
expectedRepresentation. |
|
SerializedType |
typeForClass(Class type)
Returns the type identifier for the given class. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JacksonSerializer()
@Revision annotations on the serialized classes.
public JacksonSerializer(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
objectMapper to serialize and parse the objects to JSON.
This objectMapper allows for customization of the serialized form.
objectMapper - The objectMapper to serialize objects and parse JSON with
public JacksonSerializer(RevisionResolver revisionResolver,
ConverterFactory converterFactory)
revisionResolver
to define revision for each object to serialize, and given converterFactory to be used by
upcasters.
revisionResolver - The strategy to use to resolve the revision of an objectconverterFactory - The factory providing the converter instances for upcasters
public JacksonSerializer(com.fasterxml.jackson.databind.ObjectMapper objectMapper,
RevisionResolver revisionResolver)
objectMapper to serialize and parse the objects to JSON.
This objectMapper allows for customization of the serialized form. The given revisionResolver is
used to resolve the revision from an object to be serialized.
objectMapper - The objectMapper to serialize objects and parse JSON withrevisionResolver - The strategy to use to resolve the revision of an object
public JacksonSerializer(com.fasterxml.jackson.databind.ObjectMapper objectMapper,
RevisionResolver revisionResolver,
ConverterFactory converterFactory)
objectMapper to serialize and parse the objects to JSON.
This objectMapper allows for customization of the serialized form. The given revisionResolver is
used to resolve the revision from an object to be serialized. The given converterFactory is the
converter factory used by upcasters to convert between content types.
objectMapper - The objectMapper to serialize objects and parse JSON withrevisionResolver - The strategy to use to resolve the revision of an objectconverterFactory - The factory providing the converter instances for upcasters
public JacksonSerializer(com.fasterxml.jackson.databind.ObjectMapper objectMapper,
RevisionResolver revisionResolver,
ConverterFactory converterFactory,
ClassLoader classLoader)
objectMapper to serialize and parse the objects to JSON.
This objectMapper allows for customization of the serialized form. The given revisionResolver is
used to resolve the revision from an object to be serialized. The given converterFactory is the
converter factory used by upcasters to convert between content types.
objectMapper - The objectMapper to serialize objects and parse JSON withrevisionResolver - The strategy to use to resolve the revision of an objectconverterFactory - The factory providing the converter instances for upcastersclassLoader - The class loader to load classes with when deserializing| Method Detail |
|---|
protected void registerConverters(ChainingConverterFactory converterFactory)
converterFactory which depend on the actual contents of the
serialized for to represent a JSON format.
converterFactory - The ChainingConverterFactory instance to register the converters with.
public <T> SerializedObject<T> serialize(Object object,
Class<T> expectedRepresentation)
Serializerobject into a Serialized Object containing the given
expectedRepresentation.
Use Serializer.canSerializeTo(Class) to detect whether the expectedRepresentation is supported by
this serializer.
serialize in interface SerializerT - The expected data type representing the serialized objectobject - The object to serializeexpectedRepresentation - The expected data type representing the serialized object
public final com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
protected com.fasterxml.jackson.databind.ObjectWriter getWriter()
protected com.fasterxml.jackson.databind.ObjectReader getReader(Class<?> type)
type - The type of object to create a reader for
public <T> boolean canSerializeTo(Class<T> expectedRepresentation)
SerializerexpectedRepresentation.
When true, this does *not* guarantee that the serialization and (optional) conversion will also
succeed when executed. For example, when a serializer produces a byte[] containing JSON, trying to
convert to a Dom4J Document will fail, even though this serializer has a converter to convert
byte[]
to Dom4J instances.
canSerializeTo in interface SerializerT - The type of data a Serialized Object should containexpectedRepresentation - The type of data a Serialized Object should contain
true if the expectedRepresentation is supported, otherwise false.public <S,T> T deserialize(SerializedObject<S> serializedObject)
Serializerbytes. The bytes are not consumed
from the array or modified in any way. The resulting object instance is cast to the expected type.
deserialize in interface SerializerS - The data type of the serialized objectT - The expected deserialized typeserializedObject - the instance describing the type of object and the bytes providing the serialized data
public Class classForType(SerializedType type)
throws UnknownSerializedTypeException
Serializertype is an instance of the returned Class.
If a class cannot be resolved (i.e. because the class is not available on this JVM's classpath) this method
throws UnknownSerializedTypeException.
classForType in interface Serializertype - The type identifier of the object
UnknownSerializedTypeException - if the type cannot be resolved to a classprotected String resolveClassName(SerializedType serializedType)
serializedType. This method may be overridden to customize
the names used to denote certain classes, for example, by leaving out a certain base package for brevity.
serializedType - The serialized type to resolve the class name for
public SerializedType typeForClass(Class type)
SerializerSerializer.serialize(Object, Class).
typeForClass in interface Serializertype - Class representing the type of the serializable Object.
public ConverterFactory getConverterFactory()
Serializer
getConverterFactory in interface Serializer
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||