Source Code Cross Referenced for ResponderPROFILE.java in  » Ajax » Laszlo-4.0.10 » org » openlaszlo » servlets » responders » 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 » Ajax » Laszlo 4.0.10 » org.openlaszlo.servlets.responders 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /******************************************************************************
002:         * ResponderPROFILE.java
003:         * ****************************************************************************/package org.openlaszlo.servlets.responders;
004:
005:        import java.io.*;
006:        import javax.servlet.*;
007:        import javax.servlet.http.*;
008:        import javax.servlet.ServletOutputStream;
009:        import org.openlaszlo.compiler.Compiler;
010:        import org.openlaszlo.compiler.CompilationEnvironment;
011:        import org.openlaszlo.utils.LZHttpUtils;
012:        import org.openlaszlo.media.MimeType;
013:        import org.openlaszlo.sc.ScriptCompiler;
014:        import org.openlaszlo.server.LPS;
015:        import org.openlaszlo.utils.FileUtils;
016:        import java.util.*;
017:        import org.apache.log4j.Logger;
018:
019:        // We don't expect a lot of use of this, for simplicity, we make it
020:        // single-threaded (so the open file is shared without collisions)
021:        public final class ResponderPROFILE extends Responder implements 
022:                SingleThreadModel {
023:            private static Logger mLogger = Logger
024:                    .getLogger(ResponderPROFILE.class);
025:            private static OutputStream output;
026:
027:            private HashMap datachunks;
028:
029:            protected void respondImpl(HttpServletRequest req,
030:                    HttpServletResponse res) throws IOException {
031:                synchronized (this ) {
032:                    String command = req.getParameter("command");
033:                    String seqparam = req.getParameter("seqnum");
034:
035:                    mLogger.info("PROFILE_OUTPUT = " + command + " ["
036:                            + seqparam != null ? seqparam : "] " + output);
037:                    if (output != null) {
038:                        if ("data".equals(command)) {
039:                            mLogger.info("PROFILE_DATA");
040:
041:                            Integer seqnum = new Integer(0);
042:                            try {
043:                                seqnum = new Integer(seqparam);
044:                            } catch (NumberFormatException e) {
045:                                mLogger.info("PROFILE couldn't parse seqnum: "
046:                                        + seqparam);
047:                            }
048:
049:                            ByteArrayOutputStream dout = new ByteArrayOutputStream();
050:                            // Create a data chunk for this sequence number
051:                            this .datachunks.put(seqnum, dout);
052:                            String pdata = req.getParameter("pdata");
053:                            byte data[] = pdata.getBytes();
054:                            // Copy the data into the chunk 
055:                            mLogger.info("PROFILE_DATA storing chunk #"
056:                                    + seqnum + ", write len: " + data.length);
057:                            dout.write(data, 0, data.length);
058:                            respondWithMessage(res, "Data");
059:                        } else if ("close".equals(command)) {
060:                            mLogger.info("PROFILE_CLOSE");
061:
062:                            String nitems = req.getParameter("nchunks");
063:                            int nchunks = 0;
064:
065:                            try {
066:                                nchunks = Integer.parseInt(nitems);
067:                            } catch (NumberFormatException e) {
068:                                mLogger
069:                                        .info("PROFILE couldn't parse nchunks arg: "
070:                                                + nitems);
071:                            }
072:                            mLogger.info("PROFILE client close expects "
073:                                    + nitems + " data chunks");
074:
075:                            // Copy data chunks in sequence order. Count index from zero
076:                            // up to the number of expected messages.
077:                            int k = 0;
078:                            for (k = 0; k < nchunks; k++) {
079:                                Integer i = new Integer(k);
080:                                if (!datachunks.containsKey(i)) {
081:                                    mLogger.info("PROFILE missing data chunk "
082:                                            + k + ", expected " + nchunks);
083:                                    continue;
084:                                }
085:                                ByteArrayOutputStream b = (ByteArrayOutputStream) datachunks
086:                                        .get(i);
087:                                byte bdata[] = b.toByteArray();
088:                                // copy message to output stream
089:                                mLogger.info("PROFILE_DATA write chunk #" + i
090:                                        + ", length:" + bdata.length);
091:                                output.write(bdata, 0, bdata.length);
092:                            }
093:
094:                            output.flush();
095:                            output.close();
096:                            output = null;
097:                            respondWithMessage(res, "Closed");
098:                        }
099:                    } else if ("open".equals(command)) {
100:                        // getRealPath?
101:                        String uri = LZHttpUtils.getRealPath(mContext, req);
102:                        this .datachunks = new HashMap();
103:
104:                        // try to clean up a little 
105:                        try {
106:                            if (output != null) {
107:                                output.close();
108:                            }
109:                        } catch (Exception e) {
110:                        }
111:
112:                        // Modicum of security: Only profile apps that exist
113:                        if ((new File(uri)).exists()) {
114:                            uri = uri.substring(0, uri.lastIndexOf('.'));
115:                            File file = new File(uri + ".profiler");
116:                            mLogger.info("PROFILE_OPEN " + file);
117:                            file.createNewFile();
118:                            output = new FileOutputStream(file);
119:                            respondWithMessage(res, "Open");
120:                        }
121:                    }
122:                }
123:            }
124:
125:            public int getMimeType() {
126:                return MIME_TYPE_XML;
127:            }
128:        }
129:
130:        /*
131:         * Copyright 2006 Laszlo Systems, Inc.  All Rights Reserved.  Use is
132:         * subject to license terms.
133:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.