Source Code Cross Referenced for ProfilingXMLPipe.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » components » profiler » 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 » Content Management System » apache lenya 2.0 » org.apache.cocoon.components.profiler 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.cocoon.components.profiler;
018:
019:        import org.apache.cocoon.components.sax.XMLByteStreamCompiler;
020:        import org.apache.cocoon.components.sax.XMLByteStreamInterpreter;
021:        import org.apache.cocoon.components.sax.XMLDeserializer;
022:        import org.apache.cocoon.components.sax.XMLSerializer;
023:        import org.apache.cocoon.xml.XMLConsumer;
024:        import org.apache.cocoon.xml.XMLPipe;
025:        import org.xml.sax.Attributes;
026:        import org.xml.sax.Locator;
027:        import org.xml.sax.SAXException;
028:
029:        /**
030:         * This SAX connector measures time taken by each Sitemap component. This
031:         * class use the XMLSerializer/Interpreter to buffer the output, and to
032:         * seperate the measurement of the time. The SAX fragments were also stored
033:         * into the ProfilerData.
034:         *
035:         * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
036:         * @author <a href="mailto:bruno@outerthought.org">Bruno Dumon</a>
037:         * @version CVS $Id: ProfilingXMLPipe.java 433543 2006-08-22 06:22:54Z crossley $
038:         */
039:        public class ProfilingXMLPipe implements  XMLPipe {
040:
041:            private XMLConsumer consumer;
042:
043:            // Data of the profile
044:            private ProfilerData data;
045:
046:            // Index of the component
047:            private int index;
048:
049:            // Start time
050:            private long time;
051:
052:            // Time difference
053:            private long total;
054:
055:            private XMLDeserializer deserializer;
056:            private XMLSerializer serializer;
057:
058:            /**
059:             * Setup this XMLPipe.
060:             *
061:             * @param index Index of the component.
062:             * @param data Data of the profile.
063:             */
064:            public void setup(int index, ProfilerData data) {
065:                this .index = index;
066:                this .data = data;
067:
068:                // FIXME Retrieve components from the CM
069:                this .deserializer = new XMLByteStreamInterpreter();
070:                this .serializer = new XMLByteStreamCompiler();
071:            }
072:
073:            /**
074:             * Set the <code>XMLConsumer</code> that will receive XML data.
075:             */
076:            public void setConsumer(XMLConsumer consumer) {
077:                this .consumer = consumer;
078:            }
079:
080:            public void startDocument() throws SAXException {
081:                this .time = System.currentTimeMillis(); // Startup time
082:
083:                this .serializer.startDocument();
084:            }
085:
086:            public void endDocument() throws SAXException {
087:                this .total = System.currentTimeMillis() - this .time;
088:
089:                this .serializer.endDocument();
090:                if (this .index != -1)
091:                    this .data.setProcessingTime(this .index, this .total);
092:
093:                // push the content of the buffer through the next component
094:                Object fragment = this .serializer.getSAXFragment();
095:
096:                if (this .index != -1)
097:                    this .data.setSAXFragment(this .index, fragment);
098:
099:                this .deserializer.setConsumer(this .consumer);
100:
101:                this .time = System.currentTimeMillis(); // Startup time
102:                this .deserializer.deserialize(fragment);
103:                this .total = System.currentTimeMillis() - this .time;
104:
105:                if ((this .index != -1)
106:                        && (this .index == (this .data.getCount() - 2)))
107:                    this .data.setProcessingTime(this .index + 1, this .total);
108:            }
109:
110:            public void setDocumentLocator(Locator locator) {
111:                this .serializer.setDocumentLocator(locator);
112:            }
113:
114:            public void startPrefixMapping(String prefix, String uri)
115:                    throws SAXException {
116:                this .serializer.startPrefixMapping(prefix, uri);
117:            }
118:
119:            public void endPrefixMapping(String prefix) throws SAXException {
120:                this .serializer.endPrefixMapping(prefix);
121:            }
122:
123:            public void startElement(String uri, String loc, String raw,
124:                    Attributes a) throws SAXException {
125:                this .serializer.startElement(uri, loc, raw, a);
126:            }
127:
128:            public void endElement(String uri, String loc, String raw)
129:                    throws SAXException {
130:                this .serializer.endElement(uri, loc, raw);
131:            }
132:
133:            public void characters(char c[], int start, int len)
134:                    throws SAXException {
135:                this .serializer.characters(c, start, len);
136:            }
137:
138:            public void ignorableWhitespace(char c[], int start, int len)
139:                    throws SAXException {
140:                this .serializer.ignorableWhitespace(c, start, len);
141:            }
142:
143:            public void processingInstruction(String target, String data)
144:                    throws SAXException {
145:                this .serializer.processingInstruction(target, data);
146:            }
147:
148:            public void skippedEntity(String name) throws SAXException {
149:                this .serializer.skippedEntity(name);
150:            }
151:
152:            public void startDTD(String name, String publicId, String systemId)
153:                    throws SAXException {
154:                this .serializer.startDTD(name, publicId, systemId);
155:            }
156:
157:            public void endDTD() throws SAXException {
158:                this .serializer.endDTD();
159:            }
160:
161:            public void startEntity(String name) throws SAXException {
162:                this .serializer.startEntity(name);
163:            }
164:
165:            public void endEntity(String name) throws SAXException {
166:                this .serializer.endEntity(name);
167:            }
168:
169:            public void startCDATA() throws SAXException {
170:                this .serializer.startCDATA();
171:            }
172:
173:            public void endCDATA() throws SAXException {
174:                this .serializer.endCDATA();
175:            }
176:
177:            public void comment(char ch[], int start, int len)
178:                    throws SAXException {
179:                this.serializer.comment(ch, start, len);
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.