Source Code Cross Referenced for RequestInfo.java in  » Sevlet-Container » tomcat-connectors » org » apache » coyote » 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 » tomcat connectors » org.apache.coyote 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Copyright 1999-2004 The Apache Software Foundation
003:         *
004:         *  Licensed under the Apache License, Version 2.0 (the "License");
005:         *  you may not use this file except in compliance with the License.
006:         *  You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         *  Unless required by applicable law or agreed to in writing, software
011:         *  distributed under the License is distributed on an "AS IS" BASIS,
012:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         *  See the License for the specific language governing permissions and
014:         *  limitations under the License.
015:         */
016:
017:        package org.apache.coyote;
018:
019:        /**
020:         * Structure holding the Request and Response objects. It also holds statistical
021:         * informations about request processing and provide management informations
022:         * about the requests beeing processed.
023:         *
024:         * Each thread uses a Request/Response pair that is recycled on each request.
025:         * This object provides a place to collect global low-level statistics - without
026:         * having to deal with synchronization ( since each thread will have it's own
027:         * RequestProcessorMX ).
028:         *
029:         * TODO: Request notifications will be registered here.
030:         *
031:         * @author Costin Manolache
032:         */
033:        public class RequestInfo {
034:            RequestGroupInfo global = null;
035:
036:            // ----------------------------------------------------------- Constructors
037:
038:            public RequestInfo(Request req) {
039:                this .req = req;
040:            }
041:
042:            public RequestGroupInfo getGlobalProcessor() {
043:                return global;
044:            }
045:
046:            public void setGlobalProcessor(RequestGroupInfo global) {
047:                if (global != null) {
048:                    this .global = global;
049:                    global.addRequestProcessor(this );
050:                } else {
051:                    if (this .global != null) {
052:                        this .global.removeRequestProcessor(this );
053:                        this .global = null;
054:                    }
055:                }
056:            }
057:
058:            // ----------------------------------------------------- Instance Variables
059:            Request req;
060:            Response res;
061:            int stage = Constants.STAGE_NEW;
062:
063:            // -------------------- Information about the current request  -----------
064:            // This is usefull for long-running requests only
065:
066:            public String getMethod() {
067:                return req.method().toString();
068:            }
069:
070:            public String getCurrentUri() {
071:                return req.requestURI().toString();
072:            }
073:
074:            public String getCurrentQueryString() {
075:                return req.queryString().toString();
076:            }
077:
078:            public String getProtocol() {
079:                return req.protocol().toString();
080:            }
081:
082:            public String getVirtualHost() {
083:                return req.serverName().toString();
084:            }
085:
086:            public int getServerPort() {
087:                return req.getServerPort();
088:            }
089:
090:            public String getRemoteAddr() {
091:                req.action(ActionCode.ACTION_REQ_HOST_ADDR_ATTRIBUTE, null);
092:                return req.remoteAddr().toString();
093:            }
094:
095:            public int getContentLength() {
096:                return req.getContentLength();
097:            }
098:
099:            public long getRequestBytesReceived() {
100:                return req.getBytesRead();
101:            }
102:
103:            public long getRequestBytesSent() {
104:                return req.getResponse().getBytesWritten();
105:            }
106:
107:            public long getRequestProcessingTime() {
108:                return (System.currentTimeMillis() - req.getStartTime());
109:            }
110:
111:            // -------------------- Statistical data  --------------------
112:            // Collected at the end of each request.
113:            private long bytesSent;
114:            private long bytesReceived;
115:
116:            // Total time = divide by requestCount to get average.
117:            private long processingTime;
118:            // The longest response time for a request
119:            private long maxTime;
120:            // URI of the request that took maxTime
121:            private String maxRequestUri;
122:
123:            private int requestCount;
124:            // number of response codes >= 400
125:            private int errorCount;
126:
127:            /** Called by the processor before recycling the request. It'll collect
128:             * statistic information.
129:             */
130:            void updateCounters() {
131:                bytesReceived += req.getBytesRead();
132:                bytesSent += req.getResponse().getBytesWritten();
133:
134:                requestCount++;
135:                if (req.getResponse().getStatus() >= 400)
136:                    errorCount++;
137:                long t0 = req.getStartTime();
138:                long t1 = System.currentTimeMillis();
139:                long time = t1 - t0;
140:                processingTime += time;
141:                if (maxTime < time) {
142:                    maxTime = time;
143:                    maxRequestUri = req.requestURI().toString();
144:                }
145:            }
146:
147:            public int getStage() {
148:                return stage;
149:            }
150:
151:            public void setStage(int stage) {
152:                this .stage = stage;
153:            }
154:
155:            public long getBytesSent() {
156:                return bytesSent;
157:            }
158:
159:            public void setBytesSent(long bytesSent) {
160:                this .bytesSent = bytesSent;
161:            }
162:
163:            public long getBytesReceived() {
164:                return bytesReceived;
165:            }
166:
167:            public void setBytesReceived(long bytesReceived) {
168:                this .bytesReceived = bytesReceived;
169:            }
170:
171:            public long getProcessingTime() {
172:                return processingTime;
173:            }
174:
175:            public void setProcessingTime(long processingTime) {
176:                this .processingTime = processingTime;
177:            }
178:
179:            public long getMaxTime() {
180:                return maxTime;
181:            }
182:
183:            public void setMaxTime(long maxTime) {
184:                this .maxTime = maxTime;
185:            }
186:
187:            public String getMaxRequestUri() {
188:                return maxRequestUri;
189:            }
190:
191:            public void setMaxRequestUri(String maxRequestUri) {
192:                this .maxRequestUri = maxRequestUri;
193:            }
194:
195:            public int getRequestCount() {
196:                return requestCount;
197:            }
198:
199:            public void setRequestCount(int requestCount) {
200:                this .requestCount = requestCount;
201:            }
202:
203:            public int getErrorCount() {
204:                return errorCount;
205:            }
206:
207:            public void setErrorCount(int errorCount) {
208:                this.errorCount = errorCount;
209:            }
210:
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.