1 17 package org.apache.geronimo.naming.reference; 18 19 import java.io.ByteArrayInputStream ; 20 import java.io.IOException ; 21 import java.io.ObjectInputStream ; 22 23 import org.apache.geronimo.kernel.ObjectInputStreamExt; 24 25 28 public class DeserializingReference extends SimpleAwareReference { 29 30 private final byte[] bytes; 31 private transient Object content; 32 33 public DeserializingReference(byte[] bytes) { 34 this.bytes = bytes; 35 } 36 37 public Object getContent() { 38 return content; 39 } 40 41 public void setClassLoader(ClassLoader classLoader) { 42 super.setClassLoader(classLoader); 43 ByteArrayInputStream bais = new ByteArrayInputStream (bytes); 44 try { 45 ObjectInputStream is = new ObjectInputStreamExt(bais, classLoader); 46 try { 47 content = is.readObject(); 48 } finally { 49 is.close(); 50 } 51 } catch (IOException e) { 52 throw new RuntimeException ("Could not deserialize content", e); 53 } catch (ClassNotFoundException e) { 54 throw new RuntimeException ("Could not deserialize content", e); 55 } 56 } 57 58 } 59 | Popular Tags |