1 package org.jboss.cache.marshall; 2 3 import org.jboss.serial.io.JBossObjectInputStreamSharedTree; 4 import org.jboss.serial.io.JBossObjectOutputStreamSharedTree; 5 6 import java.io.ByteArrayInputStream ; 7 import java.io.IOException ; 8 import java.io.InputStream ; 9 import java.io.ObjectInputStream ; 10 import java.io.ObjectOutputStream ; 11 import java.io.OutputStream ; 12 13 17 class JBossObjectStreamFactory implements ObjectStreamFactory 18 { 19 static class JBossObjectInputStreamOverride extends JBossObjectInputStreamSharedTree 20 { 21 22 public JBossObjectInputStreamOverride(InputStream input) throws IOException 23 { 24 super(input); 25 } 26 27 public Object readObjectOverride() throws IOException , ClassNotFoundException 28 { 29 ClassLoader older = this.getClassLoader(); 30 try 31 { 32 this.setClassLoader(Thread.currentThread().getContextClassLoader()); 33 return super.readObjectOverride(); 34 } 35 finally 36 { 37 this.setClassLoader(older); 38 } 39 } 40 41 } 42 43 44 public ObjectInputStream createObjectInputStream(byte[] bytes) throws IOException 45 { 46 ByteArrayInputStream in = new ByteArrayInputStream (bytes); 47 return new JBossObjectInputStreamOverride(in); 48 } 49 50 public ObjectOutputStream createObjectOutputStream(OutputStream out) throws IOException 51 { 52 return new JBossObjectOutputStreamSharedTree(out); 53 } 54 55 } 56 | Popular Tags |