Source Code Cross Referenced for IFrameTransport.java in  » Sevlet-Container » jetty-extras » org » mortbay » cometd » 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 » Sevlet Container » jetty extras » org.mortbay.cometd 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.mortbay.cometd;
002:
003:        import java.io.IOException;
004:        import java.io.PrintWriter;
005:        import java.util.List;
006:        import java.util.Map;
007:
008:        import javax.servlet.http.HttpServletResponse;
009:
010:        public class IFrameTransport extends AbstractTransport {
011:            PrintWriter _writer;
012:            boolean _initialized = false;
013:
014:            public void setResponse(HttpServletResponse response)
015:                    throws IOException {
016:                _initialized = false;
017:                super .setResponse(response);
018:            }
019:
020:            private void init(Map reply) throws IOException {
021:                if (_initialized)
022:                    return;
023:                _initialized = true;
024:
025:                String channel = (String) reply.get("channel");
026:                if (!"/meta/connect".equals(channel)
027:                        && !"/meta/reconnect".equals(channel))
028:                    reply = null;
029:
030:                getResponse().setContentType("text/html; charset=UTF-8");
031:                _writer = getResponse().getWriter();
032:
033:                _writer
034:                        .println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
035:                _writer
036:                        .println("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">");
037:                _writer.println("<head>");
038:                _writer
039:                        .println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></meta>");
040:                _writer.println("<title>cometd: over jetty</title>");
041:
042:                if (reply != null) {
043:                    _writer.write("<script type=\"text/javascript\">");
044:                    _writer.write("window.parent.cometd.deliver([");
045:                    _writer.write(JSON.toString(reply));
046:                    _writer.write("]);");
047:                    _writer.write("</script>");
048:                }
049:                _writer.println("</head>");
050:                _writer
051:                        .println("<body onload=\"window.parent.cometd.tunnelCollapse();\">");
052:                _writer.flush();
053:            }
054:
055:            public void send(Map reply) throws IOException {
056:                if (!_initialized)
057:                    init(reply);
058:                else {
059:                    _writer.write("<br /><script type=\"text/javascript\">");
060:                    _writer.write("window.parent.cometd.deliver([");
061:                    _writer.write(JSON.toString(reply));
062:                    _writer.write("]);");
063:                    _writer.write("</script><br/>");
064:                    for (int i = 0; i < 16; i++)
065:                        _writer
066:                                .write("                                                                                                                                ");
067:                    _writer.write("<br/>");
068:                    _writer.flush();
069:                }
070:            }
071:
072:            public void send(List replies) throws IOException {
073:                if (replies == null)
074:                    return;
075:
076:                int m = 0;
077:
078:                if (!_initialized) {
079:                    if (replies.size() > 0)
080:                        init((Map) replies.get(m++));
081:                    else
082:                        init(null);
083:                }
084:
085:                if (replies.size() > m) {
086:                    _writer.write("<br /><script type=\"text/javascript\">");
087:                    _writer.write("window.parent.cometd.deliver([");
088:
089:                    for (int i = m; i < replies.size(); i++) {
090:
091:                        // encode((Map)replies.get(i));
092:                        // do multiple messages in one deliver
093:                        _writer.write(JSON.toString(replies.get(i)));
094:                        if (i != replies.size() - 1)
095:                            _writer.write(", ");
096:                    }
097:                    _writer.write("]);");
098:                    _writer.write("</script><br/>");
099:                    for (int i = 0; i < 16; i++)
100:                        _writer
101:                                .write("                                                                                                                                ");
102:                    _writer.write("<br/>");
103:                    _writer.flush();
104:                }
105:            }
106:
107:            public void complete() throws IOException {
108:                // _writer.write("<script
109:                // type=\"text/javascript\">window.parent.cometd.tunnelCollapse();");
110:                // _writer.write("</script>");
111:                _writer.write("</body>");
112:                _writer.write("</html>");
113:                _writer.flush();
114:            }
115:
116:            public boolean keepAlive() throws IOException {
117:                return false;
118:            }
119:
120:            public void initTunnel(HttpServletResponse response)
121:                    throws IOException {
122:                response.setContentType("text/html; charset=utf-8");
123:                _writer = response.getWriter();
124:                _writer
125:                        .println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"");
126:                _writer
127:                        .println(" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
128:                _writer.println("");
129:                _writer
130:                        .println("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">");
131:                _writer.println(" <head>");
132:                _writer
133:                        .println("  <title>cometd: The Long Tail of Comet</title>");
134:                _writer
135:                        .println("  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></meta>");
136:                _writer.println("  <script type=\"text/javascript\">");
137:                _writer
138:                        .println("   // window.parent.dojo.debug(\"tunnelInit\");");
139:                _writer.println("   var noInit = false;");
140:                _writer.println("   var domain = \"\";");
141:                _writer.println("   function init(){");
142:                _writer.println("    var sparams = document.location.search;");
143:                _writer.println("    if(sparams.length >= 0){");
144:                _writer.println("     if(sparams.charAt(0) == \"?\"){");
145:                _writer.println("      sparams = sparams.substring(1);");
146:                _writer.println("     }");
147:                _writer
148:                        .println("     var ss = (sparams.indexOf(\"&amp;\") >= 0) ? \"&amp;\" : \"&\";");
149:                _writer.println("     sparams = sparams.split(ss);");
150:                _writer.println("     for(var x=0; x<sparams.length; x++){");
151:                _writer.println("      var tp = sparams[x].split(\"=\");");
152:                _writer
153:                        .println("      if(typeof window[tp[0]] != \"undefined\"){");
154:                _writer
155:                        .println("       window[tp[0]] = ((tp[1]==\"true\")||(tp[1]==\"false\")) ? eval(tp[1]) : tp[1];");
156:                _writer.println("      }");
157:                _writer.println("     }");
158:                _writer.println("    }");
159:                _writer.println("    if(noInit){ return; }");
160:                _writer.println("    /*");
161:                _writer.println("    if(domain.length > 0){");
162:                _writer.println("     document.domain = domain;");
163:                _writer.println("    }");
164:                _writer.println("    */");
165:                _writer.println("    if(window.parent != window){");
166:                _writer.println("     //Notify parent that we are loaded.");
167:                _writer
168:                        .println("     window.parent.cometd.tunnelInit(window.location, document.domain);");
169:                _writer.println("    }");
170:                _writer.println("   }");
171:                _writer.println("  </script>");
172:                _writer.println(" </head>");
173:                _writer
174:                        .println(" <body onload=\"try{ init(); }catch(e){ alert(e); }\">");
175:                _writer.println("  <h4>cometd: The Long Tail of Comet</h4>");
176:                _writer.println(" </body>");
177:                _writer.println("</html>");
178:
179:            }
180:
181:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.