SerializeAdapter - Why serialization is that important

Objects, even the simplest objects, are complex structures. In order to transport objects over a medium, these objects must be transformed into a transferable format.

Java already offers two mechanisms for serialization: object serialization and Long Term Persistence for Java Beans. Both make strict demands against the objects which should be transformed. To fulfill these demands is everything but not easy in most cases. Exemplarily it may be stated here that even many classes of the java library do not fulfill the requirements.

Furthermore nearly completely any support for modern forms of data modelling and data binding is missing to the two mechanisms mentioned.

Among other things one goal behind EJOE is to offer as much as possible kinds of serialization mechanisms out of the box. Developers should not have to modify their POJOs, beans or whatever they are using just to be able to transmit their business objects over network!

Here the so-called SerializeAdapter comes into the play:

They are the interface between EJOE and many mechanisms and frameworks for serialization.

Setting the SerializeAdapter yourself

EJClient offers some special constructors for selecting the SerializeAdapter:

public EJClient(String host, int port, final SerializeAdapter adapter) 

public EJClient(String host, int port, final SerializeAdapter adapter, boolean isPersistent,
		boolean isHttp, oolean useCompression, boolean isDirect) 

public EJClient(String host, int port, int classLoaderPort, final SerializeAdapter adapter) 

If no adapter is set, EJClient uses the default adapter automatically:

  • XStreamAdapter, if XStream is available on the classpath
  • otherwise the ObjectStreamAdapter
Only one SerializeAdapter can be used per client, once a SerializeAdapter was set it is not possible to change the SerializeAdapter later.