My favorites | Sign in
Project Logo
                
People details
Project owners:
  mario.fusco
Project committers:
luca.marrocco

Just Another Multithread Marshaller Engine

Jamme is a highly customizable multi-thread engine that allows to bidirectionally transform a java object in its XML representation (marshall) and viceversa (unmarshall). It is designed to be easily integrated in a dependency injection framework like Spring.

The main purpose of this library is to allow to serialize and deserialize complex (and even recursive) graphs of java objects in an XML format instead of using the native java serialization mechanism. Indeed XML serialization has the following advantages:

How jamme works

To achieve this results jamme by default introspects the objects to be marshalled not by accessing all their getter methods (as for example betwixt does), but by reading the objects fields skipping the static and the transient ones.

This choice has been made because the actual meaningful state of a java object is in its fields values, while reading and writing those values through the standard java bean accessor methods can easily drive to marshall useless values (for example calculated ones) and ignore the ones that actually represents the object state.

Why jamme is multithreaded

In the last years multithreaded software is gaining more and more importance even because the race toward always higher CPU frequency and number of transistors integrated on a single core is going to finish while CPU makers tend to increase the performances of their devices integrating on them 2 or more cores.

For this reason jamme allows to (optionally) split the potentially time-consuming marshall of huge objects graph and unmarshall of long XML strings on different threads. Jamme achieves this result with a single-producer/multiple-consumers pattern. In more details the producer thread splits the objects graph or the XML string to be processed in more parts pushing each part on a queue while the consumer threads pop these parts from the queue and parse them in parallel.

Start using jamme

To transform an object in its XML representation and vice versa with jamme is as easy as to invoke its Marshaller interface. The default implementation of this interface (that has a very straightforward API) provided by jamme is the MarshallerImpl class. So by instancing this class it is possible to serialize the state of an object in XML format:

Marshaller marshaller = new MarshallerImpl();
String xml = marshaller.marshall(object);

and conversely to do the opposite reconverting the resulting XML string in an object that is a complete deep clone of the former one:

Object object = marshaller.unmarshall(xml);

Jamme configuration and customization

Jamme is highly and easily configurable by replacing its strategy classes that defines its behavior. In other words you can customize how jamme converts objects in XML and vice versa by providing different strategies. For each of these pluggable aspects, jamme comes with a meaningful default strategy that provides a simple, but complete and coherent, behavior that in turn allows to use jamme "as it is" out-of-the-box.

Moreover all of these strategies can be plugged both in the marshaller engine itself (possibly via dependency injection with a framework like Spring or similar) in order to permanently modify its behavior, and in a configuration object that can be passed to a given marshall request to provide a one-shot definition of how that specific request is processed.

It's possible to redefine a given strategy both by providing a new implementation of its specific interface or by extending the jamme default one. Remember that, if you are going to use jamme in a multithreaded environment or even if you want to use its multithreaded marshaller engine, the provided strategy classes need to be thread safe as well. In more detail, the description of all the available strategies through which you can customize jamme follows:

Integrating Jamme with Spring

Jamme has been designed to be easily integrated in a Spring application. Configure and instance Jamme as a normal bean's Spring is straightforward as in the following XML snippet where a class normalizer, a field suppression strategy and an object creator have been added in order to customize the default Jamme behavior.

<bean id="marshaller" class="ch.jamme.impl.MarshallerImpl">
	<property name="classNormalizer"><bean class="mypackage.MyClassNormalizer"/></property>
	<property name="fieldSuppressionStrategy"><bean class="mypackage.MyFieldSuppression"/></property>
	<property name="objectCreator"><bean class="mypackage.MyObjectCreator"/></property>
</bean>

java.net Member Button: 170px wide









Hosted by Google Code