Source Code Cross Referenced for TerracottaConnector.java in  » Net » Terracotta » com » tc » server » 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.server 
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.server;
005:
006:        import org.mortbay.jetty.bio.SocketConnector;
007:
008:        import java.io.IOException;
009:        import java.io.InputStream;
010:        import java.io.OutputStream;
011:        import java.io.PushbackInputStream;
012:        import java.net.InetAddress;
013:        import java.net.Socket;
014:        import java.net.SocketAddress;
015:        import java.net.SocketException;
016:        import java.nio.channels.SocketChannel;
017:
018:        /**
019:         * A Jettu connector that is handed sockets from the DSO listen port once they are identified as HTTP requests
020:         */
021:        public class TerracottaConnector extends SocketConnector {
022:            private boolean shutdown = false;
023:
024:            public void shutdown() {
025:                synchronized (this ) {
026:                    shutdown = true;
027:                    notifyAll();
028:                }
029:            }
030:
031:            public void handleSocketFromDSO(Socket s, byte[] data)
032:                    throws InterruptedException, IOException {
033:                Connection connection = new Connection(new SocketWrapper(s,
034:                        data));
035:                connection.dispatch();
036:            }
037:
038:            public void open() {
039:                // don't call supper since it would open another server socket here
040:            }
041:
042:            public void accept(int acceptorID) throws InterruptedException {
043:                // Jetty's accept thread will call here continuously , so we need to block it
044:                synchronized (this ) {
045:                    while (!shutdown) {
046:                        wait();
047:                    }
048:                }
049:            }
050:
051:            /**
052:             * Wraps an existing socket such that we can wrap the input stream and provide the bytes already read
053:             */
054:            private static class SocketWrapper extends Socket {
055:
056:                private final byte[] data;
057:                private final Socket s;
058:
059:                public SocketWrapper(Socket s, byte[] data) {
060:                    this .s = s;
061:                    this .data = data;
062:                }
063:
064:                public void bind(SocketAddress bindpoint) throws IOException {
065:                    s.bind(bindpoint);
066:                }
067:
068:                public void close() throws IOException {
069:                    s.close();
070:                }
071:
072:                public void connect(SocketAddress endpoint, int timeout)
073:                        throws IOException {
074:                    s.connect(endpoint, timeout);
075:                }
076:
077:                public void connect(SocketAddress endpoint) throws IOException {
078:                    s.connect(endpoint);
079:                }
080:
081:                public boolean equals(Object obj) {
082:                    return s.equals(obj);
083:                }
084:
085:                public SocketChannel getChannel() {
086:                    return s.getChannel();
087:                }
088:
089:                public InetAddress getInetAddress() {
090:                    return s.getInetAddress();
091:                }
092:
093:                public InputStream getInputStream() throws IOException {
094:                    PushbackInputStream pis = new PushbackInputStream(s
095:                            .getInputStream(), data.length);
096:                    pis.unread(data);
097:                    return pis;
098:                }
099:
100:                public boolean getKeepAlive() throws SocketException {
101:                    return s.getKeepAlive();
102:                }
103:
104:                public InetAddress getLocalAddress() {
105:                    return s.getLocalAddress();
106:                }
107:
108:                public int getLocalPort() {
109:                    return s.getLocalPort();
110:                }
111:
112:                public SocketAddress getLocalSocketAddress() {
113:                    return s.getLocalSocketAddress();
114:                }
115:
116:                public boolean getOOBInline() throws SocketException {
117:                    return s.getOOBInline();
118:                }
119:
120:                public OutputStream getOutputStream() throws IOException {
121:                    return s.getOutputStream();
122:                }
123:
124:                public int getPort() {
125:                    return s.getPort();
126:                }
127:
128:                public int getReceiveBufferSize() throws SocketException {
129:                    return s.getReceiveBufferSize();
130:                }
131:
132:                public SocketAddress getRemoteSocketAddress() {
133:                    return s.getRemoteSocketAddress();
134:                }
135:
136:                public boolean getReuseAddress() throws SocketException {
137:                    return s.getReuseAddress();
138:                }
139:
140:                public int getSendBufferSize() throws SocketException {
141:                    return s.getSendBufferSize();
142:                }
143:
144:                public int getSoLinger() throws SocketException {
145:                    return s.getSoLinger();
146:                }
147:
148:                public int getSoTimeout() throws SocketException {
149:                    return s.getSoTimeout();
150:                }
151:
152:                public boolean getTcpNoDelay() throws SocketException {
153:                    return s.getTcpNoDelay();
154:                }
155:
156:                public int getTrafficClass() throws SocketException {
157:                    return s.getTrafficClass();
158:                }
159:
160:                public int hashCode() {
161:                    return s.hashCode();
162:                }
163:
164:                public boolean isBound() {
165:                    return s.isBound();
166:                }
167:
168:                public boolean isClosed() {
169:                    return s.isClosed();
170:                }
171:
172:                public boolean isConnected() {
173:                    return s.isConnected();
174:                }
175:
176:                public boolean isInputShutdown() {
177:                    return s.isInputShutdown();
178:                }
179:
180:                public boolean isOutputShutdown() {
181:                    return s.isOutputShutdown();
182:                }
183:
184:                public void sendUrgentData(int d) throws IOException {
185:                    s.sendUrgentData(d);
186:                }
187:
188:                public void setKeepAlive(boolean on) throws SocketException {
189:                    s.setKeepAlive(on);
190:                }
191:
192:                public void setOOBInline(boolean on) throws SocketException {
193:                    s.setOOBInline(on);
194:                }
195:
196:                // public void setPerformancePreferences(int connectionTime, int latency, int bandwidth) {
197:                // s.setPerformancePreferences(connectionTime, latency, bandwidth);
198:                // }
199:
200:                public void setReceiveBufferSize(int size)
201:                        throws SocketException {
202:                    s.setReceiveBufferSize(size);
203:                }
204:
205:                public void setReuseAddress(boolean on) throws SocketException {
206:                    s.setReuseAddress(on);
207:                }
208:
209:                public void setSendBufferSize(int size) throws SocketException {
210:                    s.setSendBufferSize(size);
211:                }
212:
213:                public void setSoLinger(boolean on, int linger)
214:                        throws SocketException {
215:                    s.setSoLinger(on, linger);
216:                }
217:
218:                public void setSoTimeout(int timeout) throws SocketException {
219:                    s.setSoTimeout(timeout);
220:                }
221:
222:                public void setTcpNoDelay(boolean on) throws SocketException {
223:                    s.setTcpNoDelay(on);
224:                }
225:
226:                public void setTrafficClass(int tc) throws SocketException {
227:                    s.setTrafficClass(tc);
228:                }
229:
230:                public void shutdownInput() throws IOException {
231:                    s.shutdownInput();
232:                }
233:
234:                public void shutdownOutput() throws IOException {
235:                    s.shutdownOutput();
236:                }
237:
238:                public String toString() {
239:                    return s.toString();
240:                }
241:
242:            }
243:
244:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.