1 5 package com.tc.object.dmi; 6 7 import com.tc.async.api.EventContext; 8 import com.tc.io.TCByteBufferInputStream; 9 import com.tc.io.TCByteBufferOutput; 10 import com.tc.io.TCSerializable; 11 import com.tc.object.ObjectID; 12 import com.tc.util.Assert; 13 14 import java.io.IOException ; 15 16 19 public class DmiDescriptor implements TCSerializable, EventContext { 20 21 public static final DmiDescriptor[] EMPTY_ARRAY = new DmiDescriptor[0]; 22 23 private ObjectID receiverId; 24 private ObjectID dmiCallId; 25 private DmiClassSpec[] classSpecs; 26 private boolean faultReceiver; 27 28 public DmiDescriptor() { 29 receiverId = null; 30 dmiCallId = null; 31 } 32 33 public DmiDescriptor(ObjectID receiverId, ObjectID dmiCallId, DmiClassSpec[] classSpecs, boolean faultReceiver) { 34 Assert.pre(receiverId != null); 35 Assert.pre(dmiCallId != null); 36 Assert.pre(classSpecs != null); 37 38 this.receiverId = receiverId; 39 this.dmiCallId = dmiCallId; 40 this.classSpecs = classSpecs; 41 this.faultReceiver = faultReceiver; 42 } 43 44 public ObjectID getReceiverId() { 45 return receiverId; 46 } 47 48 public ObjectID getDmiCallId() { 49 return dmiCallId; 50 } 51 52 public DmiClassSpec[] getClassSpecs() { 53 return classSpecs; 54 } 55 56 public boolean isFaultReceiver() { 57 return faultReceiver; 58 } 59 60 public String toString() { 61 return "DmiDescriptor{receiverId=" + receiverId + ", dmiCallId=" + dmiCallId + ", ClassSpecs=" 62 + DmiClassSpec.toString(classSpecs) + "}"; 63 } 64 65 public Object deserializeFrom(TCByteBufferInputStream in) throws IOException { 66 receiverId = new ObjectID(in.readLong()); 67 dmiCallId = new ObjectID(in.readLong()); 68 faultReceiver = in.readBoolean(); 69 final int size = in.readInt(); 70 classSpecs = new DmiClassSpec[size]; 71 for (int i = 0; i < classSpecs.length; i++) { 72 final String classLoaderDesc = in.readString(); 73 final String className = in.readString(); 74 classSpecs[i] = new DmiClassSpec(classLoaderDesc, className); 75 } 76 return this; 77 } 78 79 public void serializeTo(TCByteBufferOutput out) { 80 out.writeLong(receiverId.toLong()); 81 out.writeLong(dmiCallId.toLong()); 82 out.writeBoolean(faultReceiver); 83 out.writeInt(classSpecs.length); 84 for (int i = 0; i < classSpecs.length; i++) { 85 out.writeString(classSpecs[i].getClassLoaderDesc()); 86 out.writeString(classSpecs[i].getClassName()); 87 } 88 } 89 } 90 | Popular Tags |