Source Code Cross Referenced for ClientHandshakeMessageImpl.java in  » Net » Terracotta » com » tc » object » msg » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » Terracotta » com.tc.object.msg 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.bytes.TCByteBuffer;
008:        import com.tc.io.TCByteBufferOutput;
009:        import com.tc.io.TCSerializable;
010:        import com.tc.net.protocol.tcm.MessageChannel;
011:        import com.tc.net.protocol.tcm.MessageMonitor;
012:        import com.tc.net.protocol.tcm.TCMessageHeader;
013:        import com.tc.net.protocol.tcm.TCMessageType;
014:        import com.tc.object.ObjectID;
015:        import com.tc.object.lockmanager.api.LockContext;
016:        import com.tc.object.lockmanager.api.TryLockContext;
017:        import com.tc.object.lockmanager.api.WaitContext;
018:        import com.tc.object.session.SessionID;
019:        import com.tc.object.tx.TransactionID;
020:        import com.tc.util.Assert;
021:        import com.tc.util.SequenceID;
022:
023:        import java.io.IOException;
024:        import java.util.Collection;
025:        import java.util.HashSet;
026:        import java.util.Iterator;
027:        import java.util.Set;
028:
029:        public class ClientHandshakeMessageImpl extends DSOMessageBase
030:                implements  ClientHandshakeMessage {
031:
032:            private static final byte MANAGED_OBJECT_ID = 1;
033:            private static final byte WAIT_CONTEXT = 2;
034:            private static final byte LOCK_CONTEXT = 3;
035:            private static final byte TRANSACTION_SEQUENCE_IDS = 4;
036:            private static final byte PENDING_LOCK_CONTEXT = 5;
037:            private static final byte RESENT_TRANSACTION_IDS = 6;
038:            private static final byte REQUEST_OBJECT_IDS = 7;
039:            private static final byte PENDING_TRY_LOCK_CONTEXT = 8;
040:            private static final byte CLIENT_VERSION = 9;
041:
042:            private final Set objectIDs = new HashSet();
043:            private final Set lockContexts = new HashSet();
044:            private final Set waitContexts = new HashSet();
045:            private final Set pendingLockContexts = new HashSet();
046:            private final Set pendingTryLockContexts = new HashSet();
047:            private final Set sequenceIDs = new HashSet();
048:            private final Set txnIDs = new HashSet();
049:            private boolean requestObjectIDs;
050:            private String clientVersion = "UNKNOW";
051:
052:            public ClientHandshakeMessageImpl(SessionID sessionID,
053:                    MessageMonitor monitor, TCByteBufferOutput out,
054:                    MessageChannel channel, TCMessageType messageType) {
055:                super (sessionID, monitor, out, channel, messageType);
056:            }
057:
058:            public ClientHandshakeMessageImpl(SessionID sessionID,
059:                    MessageMonitor monitor, MessageChannel channel,
060:                    TCMessageHeader header, TCByteBuffer[] data) {
061:                super (sessionID, monitor, channel, header, data);
062:            }
063:
064:            public void addObjectID(ObjectID objectID) {
065:                synchronized (objectIDs) {
066:                    objectIDs.add(objectID);
067:                }
068:            }
069:
070:            public void addLockContext(LockContext ctxt) {
071:                synchronized (lockContexts) {
072:                    lockContexts.add(ctxt);
073:                }
074:            }
075:
076:            public Collection getLockContexts() {
077:                synchronized (lockContexts) {
078:                    return new HashSet(lockContexts);
079:                }
080:            }
081:
082:            public void addPendingLockContext(LockContext ctxt) {
083:                synchronized (pendingLockContexts) {
084:                    pendingLockContexts.add(ctxt);
085:                }
086:            }
087:
088:            public void addPendingTryLockContext(LockContext ctxt) {
089:                Assert.eval(ctxt instanceof  TryLockContext);
090:                synchronized (pendingTryLockContexts) {
091:                    pendingTryLockContexts.add(ctxt);
092:                }
093:            }
094:
095:            public Collection getPendingLockContexts() {
096:                synchronized (pendingLockContexts) {
097:                    return new HashSet(pendingLockContexts);
098:                }
099:            }
100:
101:            public Collection getPendingTryLockContexts() {
102:                synchronized (pendingTryLockContexts) {
103:                    return new HashSet(pendingTryLockContexts);
104:                }
105:            }
106:
107:            public void addWaitContext(WaitContext ctxt) {
108:                synchronized (waitContexts) {
109:                    waitContexts.add(ctxt);
110:                }
111:            }
112:
113:            public Collection getWaitContexts() {
114:                synchronized (waitContexts) {
115:                    return new HashSet(waitContexts);
116:                }
117:            }
118:
119:            public Set getObjectIDs() {
120:                synchronized (objectIDs) {
121:                    return new HashSet(objectIDs);
122:                }
123:            }
124:
125:            protected void dehydrateValues() {
126:                for (Iterator i = objectIDs.iterator(); i.hasNext();) {
127:                    putNVPair(MANAGED_OBJECT_ID, ((ObjectID) i.next()).toLong());
128:                }
129:                for (Iterator i = lockContexts.iterator(); i.hasNext();) {
130:                    putNVPair(LOCK_CONTEXT, (TCSerializable) i.next());
131:                }
132:                for (Iterator i = waitContexts.iterator(); i.hasNext();) {
133:                    putNVPair(WAIT_CONTEXT, (TCSerializable) i.next());
134:                }
135:                for (Iterator i = pendingLockContexts.iterator(); i.hasNext();) {
136:                    putNVPair(PENDING_LOCK_CONTEXT, (TCSerializable) i.next());
137:                }
138:                for (Iterator i = pendingTryLockContexts.iterator(); i
139:                        .hasNext();) {
140:                    putNVPair(PENDING_TRY_LOCK_CONTEXT, (TCSerializable) i
141:                            .next());
142:                }
143:                for (Iterator i = sequenceIDs.iterator(); i.hasNext();) {
144:                    putNVPair(TRANSACTION_SEQUENCE_IDS, ((SequenceID) i.next())
145:                            .toLong());
146:                }
147:                for (Iterator i = txnIDs.iterator(); i.hasNext();) {
148:                    putNVPair(RESENT_TRANSACTION_IDS,
149:                            ((TransactionID) i.next()).toLong());
150:                }
151:                putNVPair(REQUEST_OBJECT_IDS, this .requestObjectIDs);
152:                putNVPair(CLIENT_VERSION, this .clientVersion);
153:            }
154:
155:            protected boolean hydrateValue(byte name) throws IOException {
156:                switch (name) {
157:                case MANAGED_OBJECT_ID:
158:                    objectIDs.add(new ObjectID(getLongValue()));
159:                    return true;
160:                case LOCK_CONTEXT:
161:                    lockContexts.add(getObject(new LockContext()));
162:                    return true;
163:                case WAIT_CONTEXT:
164:                    waitContexts.add(getObject(new WaitContext()));
165:                    return true;
166:                case PENDING_LOCK_CONTEXT:
167:                    pendingLockContexts.add(getObject(new LockContext()));
168:                    return true;
169:                case PENDING_TRY_LOCK_CONTEXT:
170:                    pendingTryLockContexts.add(getObject(new TryLockContext()));
171:                    return true;
172:                case TRANSACTION_SEQUENCE_IDS:
173:                    sequenceIDs.add(new SequenceID(getLongValue()));
174:                    return true;
175:                case RESENT_TRANSACTION_IDS:
176:                    txnIDs.add(new TransactionID(getLongValue()));
177:                    return true;
178:                case REQUEST_OBJECT_IDS:
179:                    this .requestObjectIDs = getBooleanValue();
180:                    return true;
181:                case CLIENT_VERSION:
182:                    this .clientVersion = getStringValue();
183:                    return true;
184:                default:
185:                    return false;
186:                }
187:            }
188:
189:            public Collection getTransactionSequenceIDs() {
190:                return sequenceIDs;
191:            }
192:
193:            public Collection getResentTransactionIDs() {
194:                return txnIDs;
195:            }
196:
197:            public void setTransactionSequenceIDs(Collection seqIDs) {
198:                this .sequenceIDs.addAll(seqIDs);
199:            }
200:
201:            public void setResentTransactionIDs(Collection resentTransactionIDs) {
202:                this .txnIDs.addAll(resentTransactionIDs);
203:            }
204:
205:            public void setIsObjectIDsRequested(boolean request) {
206:                this .requestObjectIDs = request;
207:            }
208:
209:            public boolean isObjectIDsRequested() {
210:                return this .requestObjectIDs;
211:            }
212:
213:            public String getClientVersion() {
214:                return clientVersion;
215:            }
216:
217:            public void setClientVersion(String v) {
218:                clientVersion = v;
219:            }
220:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.