Source Code Cross Referenced for MuxClient.java in  » Web-Server » Jigsaw » org » w3c » jigsaw » http » mux » 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 » Web Server » Jigsaw » org.w3c.jigsaw.http.mux 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // MuxClient.java
002:        // $Id: MuxClient.java,v 1.6 2000/08/16 21:37:42 ylafon Exp $
003:        // (c) COPYRIGHT MIT and INRIA, 1996.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:
006:        package org.w3c.jigsaw.http.mux;
007:
008:        import java.io.BufferedOutputStream;
009:        import java.io.DataOutputStream;
010:        import java.io.IOException;
011:        import java.io.PrintStream;
012:
013:        import java.net.InetAddress;
014:
015:        import org.w3c.www.mux.MuxSession;
016:
017:        import org.w3c.www.http.HttpMessage;
018:
019:        import org.w3c.jigsaw.http.Client;
020:        import org.w3c.jigsaw.http.Reply;
021:        import org.w3c.jigsaw.http.Request;
022:        import org.w3c.jigsaw.http.httpd;
023:
024:        public class MuxClient extends Client implements  Runnable {
025:            /**
026:             * The InetAddress of the session we are currently handling.
027:             */
028:            private InetAddress addr = null;
029:            /**
030:             * The MuxSession we are currently handling.
031:             */
032:            private MuxSession session = null;
033:            /**
034:             * The MuxHttpHandler that createed us.
035:             */
036:            private MuxHttpHandler handler = null;
037:            /**
038:             * MuxHttpHandler maintained klist of clients.
039:             */
040:            MuxClient next = null;
041:            /**
042:             * The thread powering that client connection.
043:             */
044:            protected Thread thread = null;
045:
046:            protected boolean tryKeepConnection(Request request, Reply reply) {
047:                reply.addConnection("close");
048:                return false;
049:            }
050:
051:            /**
052:             * Client implementation - Get the IP address of this client.
053:             * @return An InetAddress instance, or <strong>null</strong> if the
054:             * client is not currently running.
055:             */
056:
057:            public InetAddress getInetAddress() {
058:                return addr;
059:            }
060:
061:            /**
062:             * Run HTTP on the newly created mux session.
063:             */
064:
065:            public void run() {
066:                try {
067:                    startConnection(session.getInputStream(),
068:                            (new DataOutputStream(new BufferedOutputStream(
069:                                    session.getOutputStream()))));
070:                } catch (Exception ex) {
071:                    System.out.println(this  + ": erred !");
072:                    ex.printStackTrace();
073:                }
074:            }
075:
076:            /**
077:             * Client implementation - The current connection is now idle.
078:             * We always close the mux session at that time, since creating a new
079:             * mux session has nearly no overhead.
080:             */
081:
082:            protected boolean idleConnection() {
083:                return true;
084:            }
085:
086:            /**
087:             * Client implementation - The current connection is now in use.
088:             * Nothing special done.
089:             */
090:
091:            protected void usedConnection() {
092:                return;
093:            }
094:
095:            /**
096:             * Client implementation - The current connection was terminated.
097:             * We make sure the underlying mux session is closed properly, and 
098:             * terminate the underlying thread.
099:             */
100:
101:            protected void stopConnection() {
102:                // Terminate the session properly:
103:                try {
104:                    session.shutdown();
105:                } catch (IOException ex) {
106:                    ex.printStackTrace();
107:                }
108:                session = null;
109:                // Mark that MuxClient instance ready for re-used.
110:                handler.markIdle(this );
111:            }
112:
113:            /**
114:             * Bind that client to the given connection.
115:             * @param session The mux session to handle.
116:             */
117:
118:            protected void bind(MuxSession session) throws IOException {
119:                this .session = session;
120:                this .addr = session.getInetAddress();
121:            }
122:
123:            /**
124:             * Get the thread powering that client.
125:             * @return A Thread instance, or <strong>null</strong>.
126:             */
127:
128:            protected Thread getThread() {
129:                return thread;
130:            }
131:
132:            MuxClient(httpd server, MuxHttpHandler handler, int identifier) {
133:                initialize(server, identifier);
134:                this.handler = handler;
135:            }
136:
137:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.