1 5 package com.tc.objectserver.tx; 6 7 import com.tc.net.protocol.tcm.ChannelID; 8 import com.tc.object.dmi.DmiDescriptor; 9 import com.tc.object.dna.api.DNA; 10 import com.tc.object.dna.impl.ObjectStringSerializer; 11 import com.tc.object.lockmanager.api.LockID; 12 import com.tc.object.tx.ServerTransactionID; 13 import com.tc.object.tx.TransactionID; 14 import com.tc.object.tx.TxnBatchID; 15 import com.tc.object.tx.TxnType; 16 import com.tc.util.SequenceID; 17 18 import java.util.ArrayList ; 19 import java.util.Collection ; 20 import java.util.HashSet ; 21 import java.util.Iterator ; 22 import java.util.List ; 23 import java.util.Map ; 24 import java.util.Set ; 25 26 31 public class ServerTransactionImpl implements ServerTransaction { 32 private final ServerTransactionID serverTxID; 33 private final SequenceID seqID; 34 private final List changes; 35 private final LockID[] lockIDs; 36 private final TransactionID txID; 37 private final Map newRoots; 38 private final ChannelID channelID; 39 private final TxnType transactionType; 40 private final ObjectStringSerializer serializer; 41 private final Collection notifies; 42 private final DmiDescriptor[] dmis; 43 private final Collection objectIDs; 44 private final Set newObjectIDs; 45 private final TxnBatchID batchID; 46 private final boolean passive; 47 48 public ServerTransactionImpl(TxnBatchID batchID, TransactionID txID, SequenceID sequenceID, LockID[] lockIDs, 50 ChannelID channelID, List dnas, ObjectStringSerializer serializer, Map newRoots, 51 TxnType transactionType, Collection notifies, DmiDescriptor[] dmis) { 52 53 this(batchID, txID, sequenceID, lockIDs, channelID, dnas, serializer, newRoots, transactionType, notifies, dmis, 54 false); 55 } 56 57 public ServerTransactionImpl(TxnBatchID batchID, TransactionID txID, SequenceID sequenceID, LockID[] lockIDs, 58 ChannelID channelID, List dnas, ObjectStringSerializer serializer, Map newRoots, 59 TxnType transactionType, Collection notifies, DmiDescriptor[] dmis, boolean passive) { 60 this.batchID = batchID; 61 this.txID = txID; 62 this.seqID = sequenceID; 63 this.lockIDs = lockIDs; 64 this.newRoots = newRoots; 65 this.channelID = channelID; 66 this.passive = passive; 67 this.serverTxID = new ServerTransactionID(channelID, txID); 68 this.transactionType = transactionType; 69 this.notifies = notifies; 70 this.dmis = dmis; 71 this.changes = dnas; 72 this.serializer = serializer; 73 List ids = new ArrayList (changes.size()); 74 HashSet newIDs = new HashSet (changes.size()); 75 for (Iterator i = changes.iterator(); i.hasNext();) { 76 DNA dna = (DNA) i.next(); 77 ids.add(dna.getObjectID()); 78 if (!dna.isDelta()) { 79 newIDs.add(dna.getObjectID()); 80 } 81 } 82 this.objectIDs = ids; 83 this.newObjectIDs = newIDs; 84 } 85 86 public ObjectStringSerializer getSerializer() { 87 return serializer; 88 } 89 90 public LockID[] getLockIDs() { 91 return lockIDs; 92 } 93 94 public ChannelID getChannelID() { 95 return channelID; 96 } 97 98 public TransactionID getTransactionID() { 99 return txID; 100 } 101 102 public SequenceID getClientSequenceID() { 103 return seqID; 104 } 105 106 public List getChanges() { 107 return changes; 108 } 109 110 public Map getNewRoots() { 111 return newRoots; 112 } 113 114 public TxnType getTransactionType() { 115 return transactionType; 116 } 117 118 public Collection getObjectIDs() { 119 return this.objectIDs; 120 } 121 122 public Set getNewObjectIDs() { 123 return this.newObjectIDs; 124 } 125 126 public Collection addNotifiesTo(List list) { 127 list.addAll(notifies); 128 return list; 129 } 130 131 public DmiDescriptor[] getDmiDescriptors() { 132 return dmis; 133 } 134 135 public String toString() { 136 return "ServerTransaction[" + seqID + " , " + txID + "," + channelID + "," + transactionType + "] = { changes = " 137 + changes.size() + ", notifies = " + notifies.size() + ", newRoots = " + newRoots.size() + "}"; 138 } 139 140 public ServerTransactionID getServerTransactionID() { 141 return serverTxID; 142 } 143 144 public TxnBatchID getBatchID() { 145 return batchID; 146 } 147 148 public boolean isPassive() { 149 return passive; 150 } 151 } 152 | Popular Tags |