Source Code Cross Referenced for MockMessageChannel.java in  » Net » Terracotta » com » tc » net » protocol » tcm » 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.net.protocol.tcm 
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 notice.  All rights reserved.
003:         */
004:        package com.tc.net.protocol.tcm;
005:
006:        import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
007:
008:        import com.tc.bytes.TCByteBuffer;
009:        import com.tc.exception.ImplementMe;
010:        import com.tc.io.TCByteBufferOutput;
011:        import com.tc.io.TCByteBufferOutputStream;
012:        import com.tc.net.TCSocketAddress;
013:        import com.tc.net.protocol.NetworkLayer;
014:        import com.tc.net.protocol.NetworkStackID;
015:        import com.tc.net.protocol.TCNetworkMessage;
016:        import com.tc.net.protocol.transport.MessageTransport;
017:
018:        import java.lang.reflect.Constructor;
019:        import java.util.HashMap;
020:        import java.util.Map;
021:
022:        public class MockMessageChannel implements  MessageChannelInternal {
023:
024:            private final ChannelID channelId;
025:            private NetworkLayer sendLayer;
026:
027:            LinkedQueue closedCalls = new LinkedQueue();
028:            private long lastClosedCallTimestamp;
029:
030:            private Map knownMessageTypes;
031:
032:            private int numSends;
033:            private TCNetworkMessage lastSentMessage;
034:
035:            public MockMessageChannel(ChannelID channelId) {
036:                this .channelId = channelId;
037:                this .knownMessageTypes = new HashMap();
038:                reset();
039:            }
040:
041:            public void registerType(TCMessageType messageType, Class theClass) {
042:                this .knownMessageTypes.put(messageType, theClass);
043:            }
044:
045:            public void reset() {
046:                this .numSends = 0;
047:                this .lastSentMessage = null;
048:            }
049:
050:            public TCNetworkMessage getLastSentMessage() {
051:                return lastSentMessage;
052:            }
053:
054:            public int getNumSends() {
055:                return numSends;
056:            }
057:
058:            public void addListener(ChannelEventListener listener) {
059:                throw new ImplementMe();
060:            }
061:
062:            public boolean isConnected() {
063:                throw new ImplementMe();
064:            }
065:
066:            public boolean isOpen() {
067:                throw new ImplementMe();
068:            }
069:
070:            public boolean isClosed() {
071:                throw new ImplementMe();
072:            }
073:
074:            public void close() {
075:                this .lastClosedCallTimestamp = System.currentTimeMillis();
076:                try {
077:                    closedCalls.put(new Object());
078:                } catch (InterruptedException e) {
079:                    e.printStackTrace();
080:                }
081:            }
082:
083:            public boolean waitForCloseCall(long timeout)
084:                    throws InterruptedException {
085:                return closedCalls.poll(timeout) != null;
086:            }
087:
088:            public ChannelID getChannelID() {
089:                return channelId;
090:            }
091:
092:            public void setSendLayer(NetworkLayer layer) {
093:                this .sendLayer = layer;
094:            }
095:
096:            public void setReceiveLayer(NetworkLayer layer) {
097:                throw new ImplementMe();
098:            }
099:
100:            public void send(TCNetworkMessage message) {
101:                ++this .numSends;
102:                this .lastSentMessage = message;
103:            }
104:
105:            public void receive(TCByteBuffer[] msgData) {
106:                throw new ImplementMe();
107:            }
108:
109:            public NetworkStackID open() {
110:                throw new ImplementMe();
111:            }
112:
113:            public Class getRegisteredMessageClass(TCMessageType type) {
114:                return (Class) this .knownMessageTypes.get(type);
115:            }
116:
117:            public TCMessage createMessage(TCMessageType type) {
118:                Class theClass = (Class) this .knownMessageTypes.get(type);
119:
120:                if (theClass == null)
121:                    throw new ImplementMe();
122:
123:                try {
124:                    Constructor constructor = theClass
125:                            .getConstructor(new Class[] { MessageMonitor.class,
126:                                    TCByteBufferOutput.class,
127:                                    MessageChannel.class, TCMessageType.class });
128:                    return (TCMessage) constructor.newInstance(new Object[] {
129:                            new NullMessageMonitor(),
130:                            new TCByteBufferOutputStream(4, 4096, false), this ,
131:                            type });
132:                } catch (Exception e) {
133:                    throw new ImplementMe("Failed", e);
134:                }
135:            }
136:
137:            public void notifyTransportConnected(MessageTransport transport) {
138:                throw new ImplementMe();
139:
140:            }
141:
142:            public void notifyTransportDisconnected(MessageTransport transport) {
143:                throw new ImplementMe();
144:
145:            }
146:
147:            public void notifyTransportConnectAttempt(MessageTransport transport) {
148:                throw new ImplementMe();
149:
150:            }
151:
152:            public void notifyTransportClosed(MessageTransport transport) {
153:                throw new ImplementMe();
154:            }
155:
156:            public long getLastClosedCallTimestamp() {
157:                return lastClosedCallTimestamp;
158:            }
159:
160:            public NetworkLayer getSendLayer() {
161:                return sendLayer;
162:            }
163:
164:            public Object getAttachment(String key) {
165:                throw new ImplementMe();
166:            }
167:
168:            public void addAttachment(String key, Object value, boolean replace) {
169:                throw new ImplementMe();
170:            }
171:
172:            public Object removeAttachment(String key) {
173:                throw new ImplementMe();
174:            }
175:
176:            public TCSocketAddress getLocalAddress() {
177:                throw new ImplementMe();
178:            }
179:
180:            public TCSocketAddress getRemoteAddress() {
181:                throw new ImplementMe();
182:            }
183:
184:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.