public Serializable getObject() throws Exception {
// TODO (AF): May be, we should verify that it is an Object message!!
if (body == null) return null;
ByteArrayInputStream bais = null;
ObjectInputStream ois = null;
Object obj = null;
try {
try {
bais = new ByteArrayInputStream(body);
ois = new ObjectInputStream(bais);
obj = ois.readObject();
} catch (ClassNotFoundException cnfexc) {
// Could not build serialized object: reason could be linked to
// class loaders hierarchy in an application server.
class Specialized_OIS extends ObjectInputStream {
Specialized_OIS(InputStream is) throws IOException {
super(is);
}
protected Class resolveClass(ObjectStreamClass osc) throws IOException, ClassNotFoundException {
String n = osc.getName();
return Class.forName(n, false, Thread.currentThread().getContextClassLoader());
}
}
bais = new ByteArrayInputStream(body);
ois = new Specialized_OIS(bais);
obj = ois.readObject();
}
} catch (Exception exc) {
if (logger.isLoggable(BasicLevel.ERROR))
logger.log(BasicLevel.ERROR, "ERROR: getObject()", exc);
// Don't forget to rethrow the Exception
throw exc;
} finally {
try {
ois.close();
} catch (Exception e) {}
try {
bais.close();
} catch (Exception e) {}
}