1 package org.jgroups.util; 2 3 import org.apache.commons.logging.Log; 4 import org.apache.commons.logging.LogFactory; 5 import org.jgroups.ChannelException; 6 import org.jgroups.conf.ClassConfigurator; 7 8 import java.io.IOException ; 9 import java.io.InputStream ; 10 import java.io.ObjectStreamClass ; 11 12 17 public class MagicObjectInputStream extends ContextObjectInputStream { 18 static ClassConfigurator conf=null; 19 static final Log log=LogFactory.getLog(MagicObjectInputStream.class); 20 21 22 public MagicObjectInputStream(InputStream is) throws IOException { 23 super(is); 24 if(conf == null) { 25 try { 26 conf=ClassConfigurator.getInstance(false); 27 } 28 catch(ChannelException e) { 29 log.error("ClassConfigurator could not be instantiated", e); 30 } 31 } 32 } 33 34 35 protected ObjectStreamClass readClassDescriptor() throws IOException , ClassNotFoundException { 36 ObjectStreamClass retval; 37 int magic_num=super.readInt(); 38 39 if(conf == null || magic_num == -1) { 40 return super.readClassDescriptor(); 41 } 42 43 retval=conf.getObjectStreamClassFromMagicNumber(magic_num); 44 if(retval == null) 45 throw new ClassNotFoundException ("failed fetching class descriptor for magic number " + magic_num); 46 return retval; 49 } 50 } 51 52 | Popular Tags |