This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information

--Serialization of Objects

Documents for the development of and with JVx.

--Serialization of Objects

Postby Development@SIB » Fri Sep 17, 2010 11:28 am



This article is outdated - please use our new system at

https://doc.sibvisions.com




As already mentioned under Connection Klassen objects are serialized during the transmission between client and enterprise tier. However, instead of the standard Java serialization, special technology-independent serialization mechanisms are used.

The so-called serializers have to fulfill the ISerializer interface.


Why specific serializers?

The communication between Java and C#, Flex, etc. would hardly be possible using standard Java serialization or the Java serialization would have to be taken over. The effort would be enormous.

Existing serializing frameworks, such as Hessian, do not support all necessary objects, such as BigDecimal.

For this reason a separate serializer was implemented, the UniversalSerializer.

However, using the definition of ISerializer, frameworks such as Hessian can be integrated in JVx.


Example

We want to implement a serializer that uses the standard Java serialization.

Code: Select all
public class JavaSerializer implements ISerializer
{
   public Object read(DataInputStream in) throws Exception
   {
      ObjectInputStream ois = new ObjectInputStream(in);

      return ois.readObject();
   }
   
   public void write(DataOutputStream out, Object object) throws Exception
   {
      ObjectOutputStream oos = new ObjectOutputStream(out);
      
      oos.writeObject(object);
   }
}
User avatar
Development@SIB
 
Posts: 325
Joined: Mon Sep 28, 2009 1:54 pm

Return to Documentation