public class JSerializer
extends com.streamscape.sef.dispatcher.AbstractJSerializer
Title: Object Mediation Framework
Description: A serialization mechanism for persisting Java objects as binary data.
This object serialization mechanism provides the ability to serialize/deserialize Java objects
to/from binary representation. It is based on the common Serializer
interface.
This implementation does not use Java native serialization.
It does not require objects to implement the Serializable
interface
or otherwise prepare objects for serialization in any way. Objects are serialized into DataOutputStream
and
can be deserialized from DataInputStream
. Alternatively developers may use methods for working with byte
arrays
which allows users to persist objects into Structured Data Collections
or other data store.
For performance reasons it is recommended to use the stream interface. JSerializer performs byte code inspection of serializable object candidates and compiles dynamic serialization modules on the fly, caching them in the context's environment. Optimized serialization of this type may increase performance by a factor of 6-10 depending on the size of the object. This serializer is intended for use as a high performance serialization mechanism. Unlike other framework serializer mechanisms it's output is not presented in a human-readable format.
The serializer is seamlessly integrated with StreamScape's Structured Data Objects
library. This library provides
a set of pre-packaged, configurable Event Objects and Data Objects that may be used to transmit serialized
data over a variety of messaging transports, including IBM MQSeries, TIBCO Rendezvous, StreamScape's Service
Event Fabric messaging protocol (TLP) or any JMS compliant message broker. Event Objects support serialization
into several popular formats: XML, Binary and JSON (JavaScript Object Notation) which allows the objects to be used
across languages and seamlessly embedded in a variety of technologies. Event Objects support extended system and user-defined
header elements similar to JMS Messages. They also support Content Annotation which allows any object content to
be dynamically extracted from the message and placed into the event's header at message composition time. Any elements
in the event's header may be used for routing and filtering using SQL-like event selector syntax. Combining the serializer's
capabilities with Event Objects allows developers to configure complex Content Based Routing Rules on virtually
any Java Class, XML document or JSON object content using simple, SQL-like syntax.
Event Objects are created and defined by using their appropriate DatagramFactory
. Users can create an
arbitrary Java class and set it as the content of a DataEvent
, then use the serializer to create a transportable
data object. Events may be created as part of a Runtime Context
environment an used in complement with
the Service Event Fabric's
messaging transport: the Structured Data Exchange. In this case the
fabric will use it's internal binary serialization format and the user may use this serializer to build XML content for
the event's data elements. For more information on binary serialization format see JSerializerFactory
.
Alternatively it is possible to make use of the serializers and supporting framework from a Client Context
.
Users may create any object including Event Objects and general Structured Data Objects and serialize
them for transport. Both contexts provide a similar API for dealing with objects and datagram factories.
JSerializer is used internally by the fabric runtime and client to serialize event datagrams that are intended for
transport over the network. Developers that make use of the TLP protocol used by the Service Event Fabric
do not need to use this mechanism directly and may deal exclusively with objects, events and data without concern
for how the object or it's encapsulating event reached the application.
Copyright: Copyright (c) 2009
Company: StreamScape Technologies
DEFAULT_SERIAL_VERSION_ID
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
deserialize(byte[] buffer)
Deserializes instance of a Java object from byte array.
|
java.lang.Object |
deserialize(java.io.DataInputStream buffer)
Deserializes instance of Java object from a
DataOutputStream . |
java.lang.Object |
deserialize(java.lang.String semanticType,
byte[] buffer)
Deserializes instance of a Java object from byte array.
|
java.lang.Object |
deserialize(java.lang.String semanticType,
java.io.DataInputStream buffer)
Deserializes instance of Java object from a
DataOutputStream . |
java.lang.String |
getName()
Returns the name of the serializer.
|
byte[] |
serialize(java.lang.Object object)
Serializes an instance of an arbitrary
Java Object into byte array. |
void |
serialize(java.lang.Object object,
java.io.DataOutputStream buffer)
Serializes instance of a Java object into
DataOutputStream . |
byte[] |
serialize(java.lang.String semanticType,
java.lang.Object object)
Serializes an instance of an arbitrary
Java Object into byte array. |
void |
serialize(java.lang.String semanticType,
java.lang.Object object,
java.io.DataOutputStream buffer)
Serializes instance of a Java object into
DataOutputStream . |
void |
setClassLoader(java.lang.ClassLoader classLoader)
This operation is not supported.
|
destroy, getClassLoader
clone, getSerialVersionUID
public byte[] serialize(java.lang.Object object) throws JSerializerException
Java Object
into byte array. The object may be
a plain Java object or an instance of a StructuredDataObject
.
The object must be defined as a known Semantic Type and all of its elements must be registered
in the Alias Map
.obj
- the object to be serialized.SerializerException
- if an object type or class are not defined in the Alias Map
or
if other errors occur.JSerializerException
public void serialize(java.lang.Object object, java.io.DataOutputStream buffer) throws JSerializerException
Serializer
DataOutputStream
. The object may be an
instance of StructuredDataObject
or a standard Java object. The actual stream format is
implementation specific. The object must be defined as a known Semantic Type and all of its elements
must be registered in the Alias Map
.object
- the object to be serialized.buffer
- the stream containing serialized object.JSerializerException
public byte[] serialize(java.lang.String semanticType, java.lang.Object object) throws SerializerException
Java Object
into byte array. The object may be
a plain Java object or an instance of a StructuredDataObject
.
The object must be defined as a known Semantic Type and all of its elements must be registered
in the Alias Map
.
This method allows for a specific semantic type to be specified, which results in a form of protected casting for
the object based on the Alias Map
. It is therefore possible to serialize varied objects that implement
the same interface.
semanticType
- the semantic type of the specified object.obj
- the object to be serialized.SerializerException
- if an object type or class are not defined in the Alias Map
or
if other errors occur.public void serialize(java.lang.String semanticType, java.lang.Object object, java.io.DataOutputStream buffer) throws SerializerException
Serializer
DataOutputStream
. The object may be an
instance of StructuredDataObject
or a standard Java object. The actual stream format is
implementation specific. The object must be defined as a known Semantic Type and all of its elements
must be registered in the Alias Map
.
This method allows for a specific semantic type to be specified, which results in a form of protected casting for
the object based on the Alias Map
. It is therefore possible to serialize varied objects that implement
the same interface.
semanticType
- the semantic type of the specified object.object
- the object to be serialized.SerializerException
- if an object type or class are not defined in the Alias Map
or
if other errors occur.public java.lang.Object deserialize(byte[] buffer) throws JSerializerException
Serializer
Alias Map
.
The actual instance creation is implementation specific. Framework serializers may not require the presence of a
null constructor.buffer
- the buffer containing serialized object.JSerializerException
public java.lang.Object deserialize(java.io.DataInputStream buffer) throws JSerializerException
Serializer
DataOutputStream
. The stream is a byte representation of an
object in its serialized form. Meaning that the actual format of the object may be binary or text or XML or whatever
format dictated by the serializer. The actual binary format is implementation specific. This method requires that the
object must be defined as a known Semantic Type and all of its elements must be registered in the Alias Map
.
The actual instance creation is implementation specific and may depend on the specific JVM. Framework serializers may
not require the presence of a null constructor.buffer
- the stream containing serialized object.JSerializerException
public java.lang.Object deserialize(java.lang.String semanticType, byte[] buffer) throws SerializerException
Serializer
Alias Map
. The actual instance
creation is implementation specific and may be JVM dependent. Framework serializers may not require the presence of a
null constructor.
The method allows users to specify a particular semantic type, thereby engaging in forced casting of the deserialized object.
semanticType
- the semantic type of the specified object.buffer
- the buffer containing serialized object.SerializerException
- if an object type or class are not defined in the Alias Map
or
if other errors occur.public java.lang.Object deserialize(java.lang.String semanticType, java.io.DataInputStream buffer) throws SerializerException
Serializer
DataOutputStream
. The stream is a byte representation of an
object in its serialized form. Meaning that the actual format of the object may be binary or text or XML or whatever
format dictated by the serializer. The actual binary format is implementation specific. This method requires that the
supplied Semantic Type and all of its elements must be registered in the Alias Map
. The actual
instance creation is implementation specific and may depend on the specific JVM. Framework serializers may not require
the presence of a null constructor.
The method allows users to specify a particular semantic type, thereby engaging in forced casting of the deserialized object.
semanticType
- the semantic type of the specified object.buffer
- the buffer containing serialized object.SerializerException
- if an object type or class are not defined in the Alias Map
or
if other errors occur.public java.lang.String getName()
Serializer
public void setClassLoader(java.lang.ClassLoader classLoader)
setClassLoader
in interface Serializer
setClassLoader
in class com.streamscape.omf.serializer.AbstractSerializer
classLoader
- the loader to be set.Copyright © 2015-2024 StreamScape Technologies. All rights reserved.