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[]
codecs
All available codecs.protected ISerializer
defaultsendserializer
Default serializer used for sending.protected ISerializer
optimizedsendserializer
Optimized serializer used for sending to platforms with the same version.protected ITraverseProcessor[]
postprocessors
Postprocessors for decoding.protected ITraverseProcessor[]
preprocessors
Preprocessors for encoding.protected java.util.Map<java.lang.Class<?>,boolean[]>
references
The reference class cache (clazz->boolean (is reference)).protected RemoteReferenceModule
rrm
The remote reference moduleprotected IRwMap<IComponentIdentifier,java.lang.Boolean>
sameversioncache
Cache for identifying platforms with the same version.protected ISecurityService
secserv
The security service which injects itself once available.protected ICodec[]
sendcodecs
Codecs used for sending.protected ISerializer[]
serializers
All 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.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.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.java.util.List<ITraverseProcessor>
createPostprocessors()
Create the preprocessors.java.util.List<ITraverseProcessor>
createPreprocessors()
java.lang.Object
decode(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 int
getPrefixSize(int codeccount)
ITraverseProcessor[]
getPreprocessors()
Gets the pre-processors for encoding a received message.RemoteReferenceModule
getRemoteReferenceModule()
Get the remote reference module.ICodec[]
getSendCodecs(IComponentIdentifier receiver)
Returns the codecs for sending.ISerializer
getSendSerializer(IComponentIdentifier receiverplatform)
Returns the serializer for sending.static ISerializationServices
getSerializationServices(IComponentIdentifier platform)
Gets the serialization services.ISerializer
getSerializer(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).boolean
isLocalReference(java.lang.Object object)
Test if an object has reference semantics.boolean
isRemoteObject(java.lang.Object target)
Test if an object is a remote object.void
setSecurityService(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:
encode
in 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:
decode
in 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:
getSerializers
in interfaceISerializationServices
- Parameters:
platform
- Sending platform.- Returns:
- Serializers.
-
getSerializer
public ISerializer getSerializer(int id)
Returns a serializer per id.- Specified by:
getSerializer
in 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:
isLocalReference
in interfaceISerializationServices
-
isRemoteObject
public boolean isRemoteObject(java.lang.Object target)
Test if an object is a remote object.- Specified by:
isRemoteObject
in interfaceISerializationServices
-
getCloneProcessors
public java.util.List<ITraverseProcessor> getCloneProcessors()
Get the clone processors.- Specified by:
getCloneProcessors
in 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:
getStringConverters
in 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:
convertObjectToString
in 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:
convertStringToObject
in interfaceISerializationServices
- Parameters:
val
- The value.- Returns:
- The object.
-
-