1 24 package fr.dyade.aaa.jndi2.msg; 25 26 import javax.naming.*; 27 import java.io.*; 28 29 public class ObjectFactory implements javax.naming.spi.ObjectFactory { 30 public final static String ADDRESS_TYPE = ""; 31 32 public Object getObjectInstance(Object obj, Name name, Context ctx, 33 java.util.Hashtable env) throws Exception { 34 if (obj instanceof Reference) { 35 Reference ref = (Reference)obj; 36 RefAddr addr = ref.get(ADDRESS_TYPE); 37 if (addr instanceof BinaryRefAddr) { 38 BinaryRefAddr binRefAddr = (BinaryRefAddr)addr; 39 byte[] bytes = (byte[])binRefAddr.getContent(); 40 ByteArrayInputStream bais = new ByteArrayInputStream(bytes); 41 ObjectInputStream ois = new ObjectInputStream(bais); 42 return ois.readObject(); 43 } else { 44 throw new Exception ("Binary address expected"); 45 } 46 } else { 47 throw new Exception ("Reference expected"); 48 } 49 } 50 } 51 | Popular Tags |