org.objectweb.easybeans.util.marshalling
Class Serialization

java.lang.Object
  extended by org.objectweb.easybeans.util.marshalling.Serialization

public final class Serialization
extends java.lang.Object

Allow to get the bytes of an object or to recreate an object from bytes.
It also used a custom reader when recreating object as it uses the context classloader in order to have an object with the right classloader.

Author:
Florent Benoit

Constructor Summary
private Serialization()
          Utility class, no public constructor.
 
Method Summary
static java.lang.Object loadObject(byte[] bytes)
          Transforms the given array of bytes into an object.
static byte[] storeObject(java.io.Serializable object)
          Gets an array of bytes corresponding to the given object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Serialization

private Serialization()
Utility class, no public constructor.

Method Detail

storeObject

public static byte[] storeObject(java.io.Serializable object)
                          throws java.io.IOException
Gets an array of bytes corresponding to the given object.

Parameters:
object - the object to serialize
Returns:
an array of bytes.
Throws:
java.io.IOException - if the object can't be turned into an array of bytes.

loadObject

public static java.lang.Object loadObject(byte[] bytes)
                                   throws java.io.IOException,
                                          java.lang.ClassNotFoundException
Transforms the given array of bytes into an object.

Parameters:
bytes - given array of bytes representing the object
Returns:
object which has been unmarshalled.
Throws:
java.io.IOException - if marshalling fails
java.lang.ClassNotFoundException - if the class required for loading the object is not found.