Source Code Cross Referenced for ProfilerData.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.util.HashUtil;
020:
021:        import java.util.ArrayList;
022:
023:        /**
024:         * Request-time profiler information.
025:         *
026:         * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
027:         * @author <a href="mailto:bruno@outerthought.org">Bruno Dumon</a>
028:         * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
029:         * @version CVS $Id: ProfilerData.java 433543 2006-08-22 06:22:54Z crossley $
030:         */
031:        public class ProfilerData {
032:
033:            /**
034:             * Entry, which stores the role and source of a component from a pipeline.
035:             */
036:            public static class Entry {
037:
038:                public String role;
039:                public String source;
040:                public long setup;
041:                public long time;
042:                public Object fragment;
043:
044:                protected Entry(String role, String source) {
045:                    this .role = role;
046:                    this .source = source;
047:                }
048:            }
049:
050:            // List of all entries
051:            private ArrayList entries = null;
052:
053:            // Environment information
054:            private EnvironmentInfo environmentinfo;
055:
056:            // Measured total time
057:            private long totaltime = 0;
058:
059:            /**
060:             * Create a new profiler dataset.
061:             */
062:            public ProfilerData() {
063:                entries = new ArrayList();
064:            }
065:
066:            /**
067:             * Add new component from the pipeling, which should be measured.
068:             *
069:             * @param component Component of the pipeline.
070:             * @param role Role of the component.
071:             * @param source Source attribute of the component.
072:             */
073:            public void addComponent(Object component, String role,
074:                    String source) {
075:                entries.add(new Entry((role != null) ? role : component
076:                        .getClass().getName(), source));
077:            }
078:
079:            /**
080:             * Returns the count of components.
081:             *
082:             * @return Count of components.
083:             */
084:            public int getCount() {
085:                return entries.size();
086:            }
087:
088:            /**
089:             * Set the environment information.
090:             *
091:             * @param environmentinfo Environment information.
092:             */
093:            public void setEnvironmentInfo(EnvironmentInfo environmentinfo) {
094:                this .environmentinfo = environmentinfo;
095:            }
096:
097:            /**
098:             * Returns the environment information.
099:             *
100:             * @return Environment information.
101:             */
102:            public EnvironmentInfo getEnvironmentInfo() {
103:                return this .environmentinfo;
104:            }
105:
106:            /**
107:             * Set measured time of precessing from the pipeline.
108:             *
109:             * @param time Total time of all components.
110:             */
111:            public void setTotalTime(long time) {
112:                this .totaltime = time;
113:            }
114:
115:            /**
116:             * Return measured time of precessing from the pipeline.
117:             *
118:             * @return Total time of all components.
119:             */
120:            public long getTotalTime() {
121:                return this .totaltime;
122:            }
123:
124:            /**
125:             * Set measured setup time of the i-th component of the pipeline.
126:             *
127:             * @param index Index of the component.
128:             * @param time Measured setup time of the component.
129:             */
130:            public void setSetupTime(int index, long time) {
131:                ((Entry) entries.get(index)).setup = time;
132:            }
133:
134:            /**
135:             * Get measured setup time of the i-th component of the pipeline.
136:             *
137:             * @param index Index of the component.
138:             * @return Measured setup time of the component.
139:             */
140:            public long getSetupTime(int index) {
141:                return ((Entry) entries.get(index)).setup;
142:            }
143:
144:            /**
145:             * Set measured processing time of the i-th component of the pipeline.
146:             *
147:             * @param index Index of the component.
148:             * @param time Measured processing time of the component.
149:             */
150:            public void setProcessingTime(int index, long time) {
151:                ((Entry) entries.get(index)).time = time;
152:            }
153:
154:            /**
155:             * Get measured processing time of the i-th component of the pipeline.
156:             *
157:             * @param index Index of the component.
158:             * @return Measured processing time of the component.
159:             */
160:            public long getProcessingTime(int index) {
161:                return ((Entry) entries.get(index)).time;
162:            }
163:
164:            /**
165:             * Set the SAX fragment for the i-th component of the pipeline.
166:             *
167:             * @param index Index of the component.
168:             * @param fragment SAX fragment of the component.
169:             */
170:            public void setSAXFragment(int index, Object fragment) {
171:                ((Entry) entries.get(index)).fragment = fragment;
172:            }
173:
174:            /**
175:             * Returns all measured times.
176:             *
177:             * @return Array of all entries.
178:             */
179:            public Entry[] getEntries() {
180:                return (Entry[]) entries.toArray(new Entry[entries.size()]);
181:            }
182:
183:            /**
184:             * Generate a key for a given URI for this pipeline
185:             *
186:             * @param uri URI
187:             * @return Hash key.
188:             */
189:            public long getKey(String uri) {
190:                StringBuffer key = new StringBuffer(uri);
191:
192:                for (int i = 0; i < entries.size(); i++) {
193:                    Entry entry = (Entry) entries.get(i);
194:
195:                    key.append(':');
196:                    key.append(entry.role);
197:                    key.append(':');
198:                    key.append(entry.source);
199:                }
200:                return HashUtil.hash(key);
201:            }
202:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.