001: /*
002: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
003: * notice. All rights reserved.
004: */
005: package com.tc.object.msg;
006:
007: import com.tc.exception.ImplementMe;
008: import com.tc.net.groups.ClientID;
009: import com.tc.net.protocol.tcm.MessageChannel;
010: import com.tc.net.protocol.tcm.TCMessageType;
011: import com.tc.net.protocol.tcm.TestMessageChannel;
012: import com.tc.object.ObjectID;
013: import com.tc.object.lockmanager.api.LockContext;
014: import com.tc.object.lockmanager.api.WaitContext;
015: import com.tc.util.concurrent.NoExceptionLinkedQueue;
016:
017: import java.util.ArrayList;
018: import java.util.Collection;
019: import java.util.Collections;
020: import java.util.HashSet;
021: import java.util.List;
022: import java.util.Set;
023:
024: public class TestClientHandshakeMessage implements
025: ClientHandshakeMessage {
026: public Set clientObjectIds = new HashSet();
027: public Set waitContexts = new HashSet();
028: public NoExceptionLinkedQueue sendCalls = new NoExceptionLinkedQueue();
029: public ClientID clientID;
030: public List lockContexts = new ArrayList();
031: public List pendingLockContexts = new ArrayList();
032: public boolean isChangeListener;
033: public boolean requestedObjectIDs;
034: public NoExceptionLinkedQueue setTransactionSequenceIDsCalls = new NoExceptionLinkedQueue();
035: public NoExceptionLinkedQueue setTransactionIDsCalls = new NoExceptionLinkedQueue();
036: public Collection transactionSequenceIDs = new ArrayList();
037: public Collection transactionIDs = new ArrayList();
038: private TestMessageChannel channel;
039: private String clientVersion;
040:
041: public void addObjectID(ObjectID id) {
042: clientObjectIds.add(id);
043: }
044:
045: public void send() {
046: sendCalls.put(new Object());
047: }
048:
049: public MessageChannel getChannel() {
050: synchronized (this ) {
051: if (channel == null) {
052: channel = new TestMessageChannel();
053: channel.channelID = clientID.getChannelID();
054: }
055:
056: return channel;
057: }
058: }
059:
060: public ClientID getClientID() {
061: return this .clientID;
062: }
063:
064: public Set getObjectIDs() {
065: return clientObjectIds;
066: }
067:
068: public int getCorrelationId(boolean initialize) {
069: throw new ImplementMe();
070: }
071:
072: public void setCorrelationId(int id) {
073: throw new ImplementMe();
074: }
075:
076: public TCMessageType getMessageType() {
077: throw new ImplementMe();
078: }
079:
080: public void hydrate() {
081: //
082: }
083:
084: public void dehydrate() {
085: //
086: }
087:
088: public int getTotalLength() {
089: // TODO Auto-generated method stub
090: return 0;
091: }
092:
093: public void addLockContext(LockContext ctxt) {
094: this .lockContexts.add(ctxt);
095: }
096:
097: public Collection getLockContexts() {
098: return this .lockContexts;
099: }
100:
101: public Collection getWaitContexts() {
102: return this .waitContexts;
103: }
104:
105: public void addWaitContext(WaitContext ctxt) {
106: this .waitContexts.add(ctxt);
107: }
108:
109: public void resend() {
110: throw new ImplementMe();
111:
112: }
113:
114: public void addPendingLockContext(LockContext ctxt) {
115: this .pendingLockContexts.add(ctxt);
116: }
117:
118: public Collection getPendingLockContexts() {
119: return pendingLockContexts;
120: }
121:
122: public Collection getTransactionSequenceIDs() {
123: return this .transactionSequenceIDs;
124: }
125:
126: public void setTransactionSequenceIDs(
127: Collection transactionSequenceIDs) {
128: this .transactionSequenceIDs = transactionSequenceIDs;
129: this .setTransactionSequenceIDsCalls.put(transactionSequenceIDs);
130: }
131:
132: public void setResentTransactionIDs(Collection resentTransactionIDs) {
133: this .transactionIDs = resentTransactionIDs;
134: this .setTransactionIDsCalls.put(resentTransactionIDs);
135:
136: }
137:
138: public Collection getResentTransactionIDs() {
139: return transactionIDs;
140: }
141:
142: public void setIsObjectIDsRequested(boolean request) {
143: this .requestedObjectIDs = request;
144: }
145:
146: public boolean isObjectIDsRequested() {
147: return requestedObjectIDs;
148: }
149:
150: public void addPendingTryLockContext(LockContext ctxt) {
151: throw new ImplementMe();
152:
153: }
154:
155: public Collection getPendingTryLockContexts() {
156: return Collections.EMPTY_LIST;
157: }
158:
159: public String getClientVersion() {
160: return this .clientVersion;
161: }
162:
163: public void setClientVersion(String v) {
164: this.clientVersion = v;
165: }
166: }
|