1 17 package org.apache.geronimo.kernel; 18 19 import java.io.Serializable ; 20 import java.io.IOException ; 21 import java.io.ByteArrayOutputStream ; 22 import java.io.ObjectOutputStream ; 23 import java.io.ByteArrayInputStream ; 24 import java.io.ObjectInputStream ; 25 26 29 public class StoredObject implements Serializable { 30 31 private byte[] content; 32 33 public StoredObject(Serializable object) throws IOException { 34 ByteArrayOutputStream buffer = new ByteArrayOutputStream (); 35 ObjectOutputStream out = new ObjectOutputStream (buffer); 36 out.writeObject(object); 37 out.flush(); 38 out.close(); 39 this.content = buffer.toByteArray(); 40 buffer.close(); 41 } 42 43 public Object getObject(ClassLoader classLoader) throws IOException , ClassNotFoundException { 44 ByteArrayInputStream buffer = new ByteArrayInputStream (this.content); 45 ObjectInputStream in = new ObjectInputStreamExt(buffer, classLoader); 46 Object obj = in.readObject(); 47 buffer.close(); 48 in.close(); 49 return obj; 50 } 51 } 52 | Popular Tags |