|
Platform SDK Java 8.5 API Reference | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.fasterxml.jackson.databind.Module
com.fasterxml.jackson.databind.module.SimpleModule
com.genesyslab.platform.json.jackson2.PSDKCommonModule
com.genesyslab.platform.json.jackson2.PSDKModule
public class PSDKModule
Jackson module that describes how to serialize Platform SDK messages for all protocols to/from JSON.
NOTE: the module changes ObjectMapper features when it is registering as shown in commented lines:
ObjectMapper mapper = new ObjectMapper(); mapper.registerModule( new PSDKModule() ); // mapper.setSerializationInclusion(Include.NON_NULL); // mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); // mapper.setDateFormat(new ISO8601DateFormatWithMilliseconds());so if you have own vision how it should be configured then configure it after the module will be registered.
Example:
ConfServerProtocol c = new ConfServerProtocol(endpoint); c.open(); // to use specific metadata version use following code // gets server specific version of metadata CfgMetadata metadata = ((ConfServerContext)c.connectionContext().serverContext()).getMetadata(); // create jackson's JSON converter ObjectMapper mapper = new ObjectMapper(); // register our new PSDK module mapper.registerModule( new PSDKModule(metadata) ); // mapper.registerModule( new PSDKModule() ); in this case the latest metadata that PSDK contains will be used. // create PSDK message RequestReadObjects request = RequestReadObjects.create(); // serialize message String json = mapper.writeValueAsString(request); // deserialize message RequestReadObjects msg = mapper.readValue(json, RequestReadObjects.class);
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.Module |
---|
com.fasterxml.jackson.databind.Module.SetupContext |
Field Summary |
---|
Fields inherited from class com.genesyslab.platform.json.jackson2.PSDKCommonModule |
---|
enabledMessageNameSerialization |
Fields inherited from class com.fasterxml.jackson.databind.module.SimpleModule |
---|
_abstractTypes, _deserializerModifier, _deserializers, _keyDeserializers, _keySerializers, _mixins, _name, _namingStrategy, _serializerModifier, _serializers, _subtypes, _valueInstantiators, _version |
Constructor Summary | |
---|---|
PSDKModule()
Create instance of PSDKModule using the latest CfgMetadata that contains in the used PSDK. |
|
PSDKModule(CfgMetadata metadata)
Create instance of PSDKModule using specified CfgMetadata version or the latest CfgMetadata that contains in the used PSDK (if it isn't defined). |
Method Summary | |
---|---|
CfgMetadata |
getMetadata()
Gets current metadata that must be used to deserialize config server protocol messages to/from JSON . |
void |
setupModule(com.fasterxml.jackson.databind.Module.SetupContext context)
|
Methods inherited from class com.genesyslab.platform.json.jackson2.PSDKCommonModule |
---|
createUnknownMessage, getMarkerClass, getMessageClass, isProtocolAvailable |
Methods inherited from class com.fasterxml.jackson.databind.module.SimpleModule |
---|
addAbstractTypeMapping, addDeserializer, addKeyDeserializer, addKeySerializer, addSerializer, addSerializer, addValueInstantiator, getModuleName, registerSubtypes, registerSubtypes, setAbstractTypes, setDeserializerModifier, setDeserializers, setKeyDeserializers, setKeySerializers, setMixInAnnotation, setNamingStrategy, setSerializerModifier, setSerializers, setValueInstantiators, version |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PSDKModule()
MetadataInstantiationException
- if CfgMetadata instantiation failed (see reason in cause).public PSDKModule(CfgMetadata metadata)
Example. How to get a config server's metadata.
ConfServerProtocol c = new ConfServerProtocol(endpoint); c.open(); CfgMetaData metadata = ((ConfServerContext)c.connectionContext().serverContext()).getMetadata(); PSDKModule module = new PSDKModule(metadata); ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(module);
metadata
- used to deserialize ConfServerProtocol messages from JSON
according to the specific metadata version.
MetadataInstantiationException
- if argument metadata
is null and if CfgMetadata instantiation failed (see the cause for details).Method Detail |
---|
public CfgMetadata getMetadata()
MetaDataSupport
getMetadata
in interface MetaDataSupport
public void setupModule(com.fasterxml.jackson.databind.Module.SetupContext context)
setupModule
in class PSDKCommonModule
|
Platform SDK Java 8.5 API Reference | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |