Class SerializationServices
- java.lang.Object
-
- jadex.platform.service.serialization.SerializationServices
-
- All Implemented Interfaces:
ISerializationServices
public class SerializationServices extends java.lang.Object implements ISerializationServices
Functionality for managing serialization.
-
-
Field Summary
Fields Modifier and Type Field Description protected ICodec[]codecsAll available codecs.protected ISerializerdefaultsendserializerDefault serializer used for sending.protected ISerializeroptimizedsendserializerOptimized serializer used for sending to platforms with the same version.protected ITraverseProcessor[]postprocessorsPostprocessors for decoding.protected ITraverseProcessor[]preprocessorsPreprocessors for encoding.protected java.util.Map<java.lang.Class<?>,boolean[]>referencesThe reference class cache (clazz->boolean (is reference)).protected RemoteReferenceModulerrmThe remote reference moduleprotected IRwMap<IComponentIdentifier,java.lang.Boolean>sameversioncacheCache for identifying platforms with the same version.protected ISecurityServicesecservThe security service which injects itself once available.protected ICodec[]sendcodecsCodecs used for sending.protected ISerializer[]serializersAll available serializers
-
Constructor Summary
Constructors Constructor Description SerializationServices(IComponentIdentifier comp)Creates the management.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringconvertObjectToString(java.lang.Object val, java.lang.Class<?> type, java.lang.ClassLoader cl, java.lang.String mediatype, java.lang.Object context)Convert object to string.java.lang.ObjectconvertStringToObject(java.lang.String val, java.lang.Class<?> type, java.lang.ClassLoader cl, java.lang.String mediatype, java.lang.Object context)Convert string to object.java.util.List<ITraverseProcessor>createPostprocessors()Create the preprocessors.java.util.List<ITraverseProcessor>createPreprocessors()java.lang.Objectdecode(IMsgHeader header, IInternalAccess component, byte[] enc)Decodes/deserializes an object.byte[]encode(IMsgHeader header, IInternalAccess component, java.lang.Object obj)Encodes/serializes an object for a particular receiver.java.util.List<ITraverseProcessor>getCloneProcessors()Get the clone processors.ICodec[]getCodecs()Returns all codecs.ITraverseProcessor[]getPostprocessors()Gets the post-processors for decoding a received message.protected static intgetPrefixSize(int codeccount)ITraverseProcessor[]getPreprocessors()Gets the pre-processors for encoding a received message.RemoteReferenceModulegetRemoteReferenceModule()Get the remote reference module.ICodec[]getSendCodecs(IComponentIdentifier receiver)Returns the codecs for sending.ISerializergetSendSerializer(IComponentIdentifier receiverplatform)Returns the serializer for sending.static ISerializationServicesgetSerializationServices(IComponentIdentifier platform)Gets the serialization services.ISerializergetSerializer(int id)Returns a serializer per id.ISerializer[]getSerializers()Returns all serializers.java.util.Map<java.lang.String,IStringConverter>getStringConverters()Get the string converters (can convert to and from string, possibly only for some types).booleanisLocalReference(java.lang.Object object)Test if an object has reference semantics.booleanisRemoteObject(java.lang.Object target)Test if an object is a remote object.voidsetSecurityService(ISecurityService secserv)Injects the security service.
-
-
-
Field Detail
-
rrm
protected RemoteReferenceModule rrm
The remote reference module
-
defaultsendserializer
protected ISerializer defaultsendserializer
Default serializer used for sending.
-
optimizedsendserializer
protected ISerializer optimizedsendserializer
Optimized serializer used for sending to platforms with the same version.
-
serializers
protected ISerializer[] serializers
All available serializers
-
sendcodecs
protected ICodec[] sendcodecs
Codecs used for sending.
-
codecs
protected ICodec[] codecs
All available codecs.
-
preprocessors
protected ITraverseProcessor[] preprocessors
Preprocessors for encoding.
-
postprocessors
protected ITraverseProcessor[] postprocessors
Postprocessors for decoding.
-
references
protected java.util.Map<java.lang.Class<?>,boolean[]> references
The reference class cache (clazz->boolean (is reference)).
-
secserv
protected ISecurityService secserv
The security service which injects itself once available.
-
sameversioncache
protected IRwMap<IComponentIdentifier,java.lang.Boolean> sameversioncache
Cache for identifying platforms with the same version.
-
-
Constructor Detail
-
SerializationServices
public SerializationServices(IComponentIdentifier comp)
Creates the management.
-
-
Method Detail
-
encode
public byte[] encode(IMsgHeader header, IInternalAccess component, java.lang.Object obj)
Encodes/serializes an object for a particular receiver.- Specified by:
encodein interfaceISerializationServices- Parameters:
receiver- The receiver.cl- The classloader used for encoding.obj- Object to be encoded.- Returns:
- Encoded object.
-
decode
public java.lang.Object decode(IMsgHeader header, IInternalAccess component, byte[] enc)
Decodes/deserializes an object.- Specified by:
decodein interfaceISerializationServices- Parameters:
cl- The classloader used for decoding.enc- Encoded object.header- The header object if available, null otherwise.- Returns:
- Object to be encoded.
-
getSendSerializer
public ISerializer getSendSerializer(IComponentIdentifier receiverplatform)
Returns the serializer for sending.- Parameters:
receiver- Receiving platform.- Returns:
- Serializer.
-
getSerializers
public ISerializer[] getSerializers()
Returns all serializers.- Specified by:
getSerializersin interfaceISerializationServices- Parameters:
platform- Sending platform.- Returns:
- Serializers.
-
getSerializer
public ISerializer getSerializer(int id)
Returns a serializer per id.- Specified by:
getSerializerin interfaceISerializationServices- Parameters:
id- The id.- Returns:
- The serializer.
-
getSendCodecs
public ICodec[] getSendCodecs(IComponentIdentifier receiver)
Returns the codecs for sending.- Parameters:
receiver- Receiving platform.- Returns:
- Codecs.
-
getCodecs
public ICodec[] getCodecs()
Returns all codecs.- Returns:
- Codecs.
-
getPostprocessors
public ITraverseProcessor[] getPostprocessors()
Gets the post-processors for decoding a received message.
-
getPreprocessors
public ITraverseProcessor[] getPreprocessors()
Gets the pre-processors for encoding a received message.
-
createPostprocessors
public java.util.List<ITraverseProcessor> createPostprocessors()
Create the preprocessors.
-
createPreprocessors
public java.util.List<ITraverseProcessor> createPreprocessors()
-
getPrefixSize
protected static final int getPrefixSize(int codeccount)
-
isLocalReference
public boolean isLocalReference(java.lang.Object object)
Test if an object has reference semantics. It is a reference when: - it implements IRemotable - it is an IService, IExternalAccess or IFuture - if the object has used an @Reference annotation at type level - has been explicitly set to be reference- Specified by:
isLocalReferencein interfaceISerializationServices
-
isRemoteObject
public boolean isRemoteObject(java.lang.Object target)
Test if an object is a remote object.- Specified by:
isRemoteObjectin interfaceISerializationServices
-
getCloneProcessors
public java.util.List<ITraverseProcessor> getCloneProcessors()
Get the clone processors.- Specified by:
getCloneProcessorsin interfaceISerializationServices- Returns:
- The clone processors.
-
setSecurityService
public void setSecurityService(ISecurityService secserv)
Injects the security service.- Parameters:
secserv- The security service.
-
getSerializationServices
public static final ISerializationServices getSerializationServices(IComponentIdentifier platform)
Gets the serialization services.- Parameters:
platform- The platform ID.- Returns:
- The serialization services.
-
getRemoteReferenceModule
public RemoteReferenceModule getRemoteReferenceModule()
Get the remote reference module.- Returns:
- the remote reference module.
-
getStringConverters
public java.util.Map<java.lang.String,IStringConverter> getStringConverters()
Get the string converters (can convert to and from string, possibly only for some types).- Specified by:
getStringConvertersin interfaceISerializationServices- Returns:
- The converters.
-
convertObjectToString
public java.lang.String convertObjectToString(java.lang.Object val, java.lang.Class<?> type, java.lang.ClassLoader cl, java.lang.String mediatype, java.lang.Object context)Convert object to string.- Specified by:
convertObjectToStringin interfaceISerializationServices- Parameters:
val- The value.- Returns:
- The string value.
-
convertStringToObject
public java.lang.Object convertStringToObject(java.lang.String val, java.lang.Class<?> type, java.lang.ClassLoader cl, java.lang.String mediatype, java.lang.Object context)Convert string to object.- Specified by:
convertStringToObjectin interfaceISerializationServices- Parameters:
val- The value.- Returns:
- The object.
-
-