Serializable Check

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.

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); } } }

Resources