Source Code Cross Referenced for LockResponseMessage.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.net.protocol.tcm.MessageChannel;
010:        import com.tc.net.protocol.tcm.MessageMonitor;
011:        import com.tc.net.protocol.tcm.TCMessageHeader;
012:        import com.tc.net.protocol.tcm.TCMessageType;
013:        import com.tc.object.lockmanager.api.LockID;
014:        import com.tc.object.lockmanager.api.LockLevel;
015:        import com.tc.object.lockmanager.api.ThreadID;
016:        import com.tc.object.lockmanager.impl.GlobalLockInfo;
017:        import com.tc.object.session.SessionID;
018:
019:        import java.io.IOException;
020:
021:        public class LockResponseMessage extends DSOMessageBase {
022:            private static final byte TYPE = 1;
023:            private static final byte THREAD_ID = 2;
024:            private static final byte LOCK_ID = 3;
025:            private static final byte LOCK_LEVEL = 7;
026:            private static final byte GLOBAL_LOCK_INFO = 8;
027:            private static final byte LOCK_STACK_TRACE_DEPTH = 9;
028:            private static final byte LOCK_STAT_COLLECT_FREQUENCY = 10;
029:
030:            public static final int LOCK_AWARD = 1;
031:            public static final int LOCK_RECALL = 2;
032:            public static final int LOCK_WAIT_TIMEOUT = 3;
033:            public static final int LOCK_INFO = 4;
034:            public static final int LOCK_NOT_AWARDED = 5;
035:            public static final int LOCK_STAT_ENABLED = 6;
036:            public static final int LOCK_STAT_DISABLED = 7;
037:
038:            private int type;
039:            private ThreadID threadID;
040:            private LockID lockID;
041:            private int lockLevel;
042:            private GlobalLockInfo globalLockInfo;
043:            private int stackTraceDepth;
044:            private int statCollectFrequency;
045:
046:            public LockResponseMessage(SessionID sessionID,
047:                    MessageMonitor monitor, TCByteBufferOutput out,
048:                    MessageChannel channel, TCMessageType type) {
049:                super (sessionID, monitor, out, channel, type);
050:            }
051:
052:            public LockResponseMessage(SessionID sessionID,
053:                    MessageMonitor monitor, MessageChannel channel,
054:                    TCMessageHeader header, TCByteBuffer[] data) {
055:                super (sessionID, monitor, channel, header, data);
056:            }
057:
058:            protected void dehydrateValues() {
059:                putNVPair(TYPE, this .type);
060:                putNVPair(LOCK_ID, this .lockID.asString());
061:                putNVPair(THREAD_ID, this .threadID.toLong());
062:                putNVPair(LOCK_LEVEL, this .lockLevel);
063:                if (globalLockInfo != null) {
064:                    putNVPair(GLOBAL_LOCK_INFO, globalLockInfo);
065:                }
066:                if (isLockStatEnabled()) {
067:                    putNVPair(LOCK_STACK_TRACE_DEPTH, this .stackTraceDepth);
068:                    putNVPair(LOCK_STAT_COLLECT_FREQUENCY,
069:                            this .statCollectFrequency);
070:                }
071:            }
072:
073:            protected String describePayload() {
074:                StringBuffer rv = new StringBuffer();
075:                rv.append("Type : ");
076:
077:                if (isLockAward()) {
078:                    rv.append("LOCK AWARD \n");
079:                } else if (isLockRecall()) {
080:                    rv.append("LOCK RECALL \n");
081:                } else if (isLockWaitTimeout()) {
082:                    rv.append("LOCK WAIT TIMEOUT \n");
083:                } else if (isLockInfo()) {
084:                    rv.append("LOCK INFO");
085:                } else if (isLockNotAwarded()) {
086:                    rv.append("LOCK NOT AWARDED");
087:                } else if (isLockStatEnabled()) {
088:                    rv.append("ENABLE LOCK STATISTICS");
089:                } else if (isLockStatDisabled()) {
090:                    rv.append("DISABLE LOCK STATISTICS");
091:                } else {
092:                    rv.append("UNKNOWN \n");
093:                }
094:
095:                rv.append(lockID).append(' ').append(threadID).append(' ')
096:                        .append("Lock Type: ").append(
097:                                LockLevel.toString(lockLevel)).append('\n');
098:
099:                return rv.toString();
100:            }
101:
102:            protected boolean hydrateValue(byte name) throws IOException {
103:                switch (name) {
104:                case TYPE:
105:                    this .type = getIntValue();
106:                    return true;
107:                case THREAD_ID:
108:                    // TODO: Make this use a transactionID factory so that we can avoid dups
109:                    this .threadID = new ThreadID(getLongValue());
110:                    return true;
111:                case LOCK_ID:
112:                    // TODO: Make this use a lockID factory so that we can avoid dups
113:                    lockID = new LockID(getStringValue());
114:                    return true;
115:                case LOCK_LEVEL:
116:                    this .lockLevel = getIntValue();
117:                    return true;
118:                case GLOBAL_LOCK_INFO:
119:                    globalLockInfo = new GlobalLockInfo();
120:                    getObject(globalLockInfo);
121:                    return true;
122:                case LOCK_STACK_TRACE_DEPTH:
123:                    this .stackTraceDepth = getIntValue();
124:                    return true;
125:                case LOCK_STAT_COLLECT_FREQUENCY:
126:                    this .statCollectFrequency = getIntValue();
127:                    return true;
128:                default:
129:                    return false;
130:                }
131:            }
132:
133:            public boolean isLockAward() {
134:                return (this .type == LOCK_AWARD);
135:            }
136:
137:            public boolean isLockRecall() {
138:                return (this .type == LOCK_RECALL);
139:            }
140:
141:            public boolean isLockWaitTimeout() {
142:                return (this .type == LOCK_WAIT_TIMEOUT);
143:            }
144:
145:            public boolean isLockInfo() {
146:                return (this .type == LOCK_INFO);
147:            }
148:
149:            public boolean isLockNotAwarded() {
150:                return (this .type == LOCK_NOT_AWARDED);
151:            }
152:
153:            public boolean isLockStatEnabled() {
154:                return (this .type == LOCK_STAT_ENABLED);
155:            }
156:
157:            public boolean isLockStatDisabled() {
158:                return (this .type == LOCK_STAT_DISABLED);
159:            }
160:
161:            public LockID getLockID() {
162:                return this .lockID;
163:            }
164:
165:            public ThreadID getThreadID() {
166:                return this .threadID;
167:            }
168:
169:            public int getLockLevel() {
170:                return this .lockLevel;
171:            }
172:
173:            public int getStackTraceDepth() {
174:                return stackTraceDepth;
175:            }
176:
177:            public int getStatCollectFrequency() {
178:                return statCollectFrequency;
179:            }
180:
181:            public GlobalLockInfo getGlobalLockInfo() {
182:                return globalLockInfo;
183:            }
184:
185:            public void initializeLockAward(LockID lid, ThreadID sid, int level) {
186:                this .type = LOCK_AWARD;
187:                initialize(lid, sid, level, null);
188:            }
189:
190:            public void initializeLockNotAwarded(LockID lid, ThreadID sid,
191:                    int level) {
192:                this .type = LOCK_NOT_AWARDED;
193:                initialize(lid, sid, level);
194:            }
195:
196:            public void initializeLockRecall(LockID lid, ThreadID sid, int level) {
197:                this .type = LOCK_RECALL;
198:                initialize(lid, sid, level);
199:            }
200:
201:            public void initializeLockWaitTimeout(LockID lid, ThreadID sid,
202:                    int level) {
203:                this .type = LOCK_WAIT_TIMEOUT;
204:                initialize(lid, sid, level);
205:            }
206:
207:            public void initializeLockInfo(LockID lid, ThreadID sid, int level,
208:                    GlobalLockInfo info) {
209:                this .type = LOCK_INFO;
210:                initialize(lid, sid, level, info);
211:            }
212:
213:            public void initializeLockStatEnable(LockID lid, ThreadID sid,
214:                    int level, int stackTraceDepth, int statCollectFrequency) {
215:                this .type = LOCK_STAT_ENABLED;
216:                initialize(lid, sid, level);
217:                this .stackTraceDepth = stackTraceDepth;
218:                this .statCollectFrequency = statCollectFrequency;
219:            }
220:
221:            public void initializeLockStatDisable(LockID lid, ThreadID sid,
222:                    int level) {
223:                this .type = LOCK_STAT_DISABLED;
224:                initialize(lid, sid, level);
225:            }
226:
227:            private void initialize(LockID lid, ThreadID sid, int level) {
228:                initialize(lid, sid, level, null);
229:            }
230:
231:            private void initialize(LockID lid, ThreadID sid, int level,
232:                    GlobalLockInfo info) {
233:                this.threadID = sid;
234:                this.lockID = lid;
235:                this.lockLevel = level;
236:                this.globalLockInfo = info;
237:            }
238:
239:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.