001: /*
002: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
003: */
004: package com.tc.object.tx;
005:
006: import com.tc.management.beans.tx.ClientTxMonitorMBean;
007: import com.tc.object.ObjectID;
008: import com.tc.object.TCObject;
009: import com.tc.object.dmi.DmiDescriptor;
010: import com.tc.object.lockmanager.api.LockID;
011: import com.tc.object.lockmanager.api.Notify;
012: import com.tc.util.SequenceID;
013:
014: import java.util.Collection;
015: import java.util.List;
016: import java.util.Map;
017:
018: /**
019: * Hangs on to a grouping of changes to be sent as a batch to the server.
020: * Changes are accumulated by the ClientTransactionManager.
021: *
022: * @author steve
023: */
024: public interface ClientTransaction {
025:
026: /**
027: * Set the transaction context (type and related locks)
028: * @param transactionContext Context
029: */
030: public void setTransactionContext(
031: TransactionContext transactionContext);
032:
033: /**
034: * Get all change buffers associated with this transaction
035: * @return Map of TCObject to TCChangeBuffer
036: */
037: public Map getChangeBuffers();
038:
039: /**
040: * Get new roots in this transaction
041: * @return Map of Root name to ObjectID
042: */
043: public Map getNewRoots();
044:
045: /**
046: * Get initial lock identifier
047: * @return Identifier
048: */
049: public LockID getLockID();
050:
051: /**
052: * Get all locks associated with this transaction
053: * @return All locks
054: */
055: public LockID[] getAllLockIDs();
056:
057: /**
058: * Get transaction identifier
059: * @return Identifier
060: */
061: public TransactionID getTransactionID();
062:
063: /**
064: * Record new object creation
065: * @param source TCObject for new object
066: */
067: public void createObject(TCObject source);
068:
069: /**
070: * Record new root
071: * @param name Root name
072: * @param rootID ObjectID for root value
073: */
074: public void createRoot(String name, ObjectID rootID);
075:
076: /**
077: * Record field changed
078: * @param source TCObject for value
079: * @param classname Class name
080: * @param fieldname Field name
081: * @param newValue New field value
082: * @param index Index into array if array field
083: */
084: public void fieldChanged(TCObject source, String classname,
085: String fieldname, Object newValue, int index);
086:
087: /**
088: * Record literal value changed
089: * @param source TCObject for instance
090: * @param newValue New value for instance
091: * @param oldValue Old value for instance
092: */
093: public void literalValueChanged(TCObject source, Object newValue,
094: Object oldValue);
095:
096: /**
097: * Record array change
098: * @param source TCObject for instance
099: * @param startPos Index into array
100: * @param array Partial array or value
101: * @param length Length of array
102: */
103: public void arrayChanged(TCObject source, int startPos,
104: Object array, int length);
105:
106: /**
107: * Record logical invocation
108: * @param source Source of invoke
109: * @param method Method identifier
110: * @param parameters Parameter values
111: * @param methodName Method name
112: */
113: public void logicalInvoke(TCObject source, int method,
114: Object[] parameters, String methodName);
115:
116: /**
117: * Check whether transactoin has changes or notifications
118: * @return True if has changes or notifies
119: */
120: public boolean hasChangesOrNotifies();
121:
122: /**
123: * Check whether this is a null transaction
124: * @return True if null
125: */
126: public boolean isNull();
127:
128: /**
129: * Get transaction type
130: * @return Type
131: */
132: public TxnType getTransactionType();
133:
134: /**
135: * Record Notify's
136: * @param notifies Of Notify's
137: * @return All Notify's
138: */
139: public List addNotifiesTo(List notifies);
140:
141: /**
142: * Add a new Notify
143: * @param notify Notify
144: */
145: public void addNotify(Notify notify);
146:
147: /**
148: * Indicate place in sequence of transactions
149: * @param sequenceID Identifier
150: */
151: public void setSequenceID(SequenceID sequenceID);
152:
153: /**
154: * @return Sequence identifier in transaction stream
155: */
156: public SequenceID getSequenceID();
157:
158: /**
159: * @return True if concurrent transaction
160: */
161: public boolean isConcurrent();
162:
163: /**
164: * Set transaction as already committed
165: */
166: public void setAlreadyCommitted();
167:
168: /**
169: * @return True if has changes in transaction
170: */
171: public boolean hasChanges();
172:
173: /**
174: * @return Count of notify's in transaction
175: */
176: public int getNotifiesCount();
177:
178: /**
179: * Update MBean with state
180: * @param txMBean MBean to update
181: */
182: public void updateMBean(ClientTxMonitorMBean txMBean);
183:
184: /**
185: * Get all references of objects included in the transaction
186: * @return Collection of referenced objects
187: */
188: public Collection getReferencesOfObjectsInTxn();
189:
190: /**
191: * Add a new DMI descriptor
192: * @param dd Descriptor
193: */
194: public void addDmiDescritor(DmiDescriptor dd);
195:
196: /**
197: * Get all DmiDescriptors
198: * @return List of DmiDescriptors in transaction
199: */
200: public List getDmiDescriptors();
201:
202: }
|