Belongs to following categories: Utility, ULC5.2,
Purpose
Implements a helper class that checks at runtime if the current ULC session is serializable. This information can be useful when an ULC application is or will be deployed in a Servlet or EJB container.
Resources
How to use
We call the
execute() method of the
SerializableCheck class.
SerializableCheck.execute()
How it is implemented
We try to serialize the current ULC session into a byte array using the standard Java Serialization mechanism. An exception will be thrown if the session cannot be serialized.
public class SerializableCheck
{
public static void execute()
{
try
{
ULCSession ulcSession = ULCSession.currentSession(); ObjectOutputStream objectOutputStream = new ObjectOutputStream(new ByteArrayOutputStream());
objectOutputStream.writeObject(ulcSession);
objectOutputStream.flush();
objectOutputStream.close();
}
catch(IOException ioe)
{
System.err.println("Could not serialize session: " + ioe);
}
}
}
Compatibility
The described functionality has been developed and tested using JDK 1.3.1_10 and ULC 5.2.
Author
etienne