1 24 25 package benchmark.ring; 26 27 import java.io.Externalizable ; 28 import java.io.IOException ; 29 import java.io.ObjectInput ; 30 import java.io.ObjectOutput ; 31 32 import org.objectweb.dream.message.AbstractChunk; 33 import org.objectweb.dream.message.Chunk; 34 import org.objectweb.dream.message.ChunkType; 35 import org.objectweb.dream.util.Util; 36 37 40 public class PayLoadChunkImpl extends AbstractChunk 41 implements 42 PayLoadChunk, 43 Externalizable 44 { 45 46 private byte[] payLoad = null; 47 48 51 public void setPayLoadSize(int nbByte) 52 { 53 payLoad = new byte[nbByte]; 54 } 55 56 59 public int getPayLoadSize() 60 { 61 if (payLoad == null) 62 { 63 return 0; 64 } 65 return payLoad.length; 66 } 67 68 71 public ChunkType getType() 72 { 73 return TYPE; 74 } 75 76 79 public void transfertState(Chunk newInstance) 80 { 81 ((PayLoadChunk) newInstance).setPayLoadSize(getPayLoadSize()); 82 } 83 84 87 public void recycle() 88 { 89 payLoad = null; 90 } 91 92 95 public void readExternal(ObjectInput in) throws IOException , 96 ClassNotFoundException 97 { 98 payLoad = Util.readExternalByteArray(in); 99 } 100 101 104 public void writeExternal(ObjectOutput out) throws IOException 105 { 106 Util.writeExternalByteArray(out, payLoad); 107 } 108 109 } | Popular Tags |