1 22 package org.jboss.invocation.iiop; 23 24 import java.io.IOException ; 25 import java.io.Serializable ; 26 import org.jboss.util.Conversion; 27 28 39 public class ReferenceData 40 implements Serializable 41 { 42 private Object servantId; 43 private Object objectId; 44 45 public static byte[] create(Object servantId, Object objectId) 46 { 47 return Conversion.toByteArray(new ReferenceData(servantId, objectId)); 48 } 49 50 public static byte[] create(Object id) 51 { 52 return Conversion.toByteArray(id); 53 } 54 55 public static Object extractServantId(byte[] refData, ClassLoader cl) 56 throws IOException , ClassNotFoundException 57 { 58 Object obj = Conversion.toObject(refData, cl); 59 if (obj != null && obj instanceof ReferenceData) 60 return ((ReferenceData)obj).servantId; 61 else 62 return obj; 63 } 64 65 public static Object extractServantId(byte[] refData) 66 throws IOException , ClassNotFoundException 67 { 68 return extractServantId(refData, 69 Thread.currentThread().getContextClassLoader()); 70 } 71 72 public static Object extractObjectId(byte[] refData, ClassLoader cl) 73 throws IOException , ClassNotFoundException 74 { 75 Object obj = Conversion.toObject(refData, cl); 76 if (obj != null && obj instanceof ReferenceData) 77 return ((ReferenceData)obj).objectId; 78 else 79 return obj; 80 } 81 82 public static Object extractObjectId(byte[] refData) 83 throws IOException , ClassNotFoundException 84 { 85 return extractObjectId(refData, 86 Thread.currentThread().getContextClassLoader()); 87 } 88 89 private ReferenceData(Object servantId, Object objectId) 90 { 91 this.servantId = servantId; 92 this.objectId = objectId; 93 } 94 95 } 96 97 | Popular Tags |