Platform SDK Java 8.5 API Reference

com.genesyslab.platform.json.jackson2
Class PSDKModule

java.lang.Object
  extended by com.fasterxml.jackson.databind.Module
      extended by com.fasterxml.jackson.databind.module.SimpleModule
          extended by com.genesyslab.platform.json.jackson2.PSDKCommonModule
              extended by com.genesyslab.platform.json.jackson2.PSDKModule
All Implemented Interfaces:
com.fasterxml.jackson.core.Versioned, MetaDataSupport, java.io.Serializable

public class PSDKModule
extends PSDKCommonModule
implements MetaDataSupport

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);
 

See Also:
Serialized Form

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

PSDKModule

public PSDKModule()
Create instance of PSDKModule using the latest CfgMetadata that contains in the used PSDK.
The module supports all PSDK protocols.

Throws:
MetadataInstantiationException - if CfgMetadata instantiation failed (see reason in cause).

PSDKModule

public 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).
The module supports all PSDK protocols.

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);
 

Parameters:
metadata - used to deserialize ConfServerProtocol messages from JSON according to the specific metadata version.
Throws:
MetadataInstantiationException - if argument metadata is null and if CfgMetadata instantiation failed (see the cause for details).
Method Detail

getMetadata

public CfgMetadata getMetadata()
Description copied from interface: MetaDataSupport
Gets current metadata that must be used to deserialize config server protocol messages to/from JSON .

Specified by:
getMetadata in interface MetaDataSupport
Returns:
metadata

setupModule

public void setupModule(com.fasterxml.jackson.databind.Module.SetupContext context)
Overrides:
setupModule in class PSDKCommonModule

Platform SDK Java 8.5 API Reference

Send comments on this topicTechpubs.webadmin@genesys.com.
Document version: 8.5.302.00
Copyright © 2006–2017 Genesys Telecommunications Laboratories, Inc. All rights reserved.