1 49 package org.exolab.jms.tranlog; 50 51 52 import java.io.Externalizable ; 53 import java.io.IOException ; 54 import java.io.ObjectInput ; 55 import java.io.ObjectOutput ; 56 import java.io.Serializable ; 57 58 59 63 public class DataTransactionLogEntry 64 extends BaseTransactionLogEntry 65 implements Externalizable { 66 67 71 static final long serialVersionUID = 2; 72 73 76 private Object _data; 77 78 79 82 public DataTransactionLogEntry() { 83 } 84 85 94 DataTransactionLogEntry(ExternalXid txid, String rid) { 95 this(txid, rid, System.currentTimeMillis()); 96 } 97 98 108 DataTransactionLogEntry(ExternalXid txid, String rid, long created) { 109 super(txid, rid, created); 110 } 111 112 120 public void setData(Object data) 121 throws IllegalArgumentException , IOException { 122 if ((Serializable .class.isAssignableFrom(data.getClass())) || 123 (Externalizable .class.isAssignableFrom(data.getClass()))) { 124 _data = new String (SerializationHelper.serialize(data)); 125 } else { 126 throw new IllegalArgumentException ( 127 "The object to setObject must be serializable"); 128 } 129 } 130 131 136 public Object getData() { 137 return _data; 138 } 139 140 public void writeExternal(ObjectOutput stream) 142 throws IOException { 143 stream.writeLong(serialVersionUID); 144 stream.writeObject(_data); 145 super.writeExternal(stream); 146 } 147 148 public void readExternal(ObjectInput stream) 150 throws IOException , ClassNotFoundException { 151 long version = stream.readLong(); 152 if (version == serialVersionUID) { 153 _data = stream.readObject(); 154 super.readExternal(stream); 155 } else { 156 throw new IOException ("No support for DataTransactionLogEntry " + 157 "with version " + version); 158 } 159 } 160 } 161 | Popular Tags |