Source Code Cross Referenced for RequestInfo.java in  » Sevlet-Container » apache-tomcat-6.0.14 » 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 » apache tomcat 6.0.14 » org.apache.coyote 
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:
018:        package org.apache.coyote;
019:
020:        import javax.management.ObjectName;
021:
022:        /**
023:         * Structure holding the Request and Response objects. It also holds statistical
024:         * informations about request processing and provide management informations
025:         * about the requests beeing processed.
026:         *
027:         * Each thread uses a Request/Response pair that is recycled on each request.
028:         * This object provides a place to collect global low-level statistics - without
029:         * having to deal with synchronization ( since each thread will have it's own
030:         * RequestProcessorMX ).
031:         *
032:         * TODO: Request notifications will be registered here.
033:         *
034:         * @author Costin Manolache
035:         */
036:        public class RequestInfo {
037:            RequestGroupInfo global = null;
038:
039:            // ----------------------------------------------------------- Constructors
040:
041:            public RequestInfo(Request req) {
042:                this .req = req;
043:            }
044:
045:            public RequestGroupInfo getGlobalProcessor() {
046:                return global;
047:            }
048:
049:            public void setGlobalProcessor(RequestGroupInfo global) {
050:                if (global != null) {
051:                    this .global = global;
052:                    global.addRequestProcessor(this );
053:                } else {
054:                    if (this .global != null) {
055:                        this .global.removeRequestProcessor(this );
056:                        this .global = null;
057:                    }
058:                }
059:            }
060:
061:            // ----------------------------------------------------- Instance Variables
062:            Request req;
063:            Response res;
064:            int stage = Constants.STAGE_NEW;
065:            String workerThreadName;
066:            ObjectName rpName;
067:
068:            // -------------------- Information about the current request  -----------
069:            // This is usefull for long-running requests only
070:
071:            public String getMethod() {
072:                return req.method().toString();
073:            }
074:
075:            public String getCurrentUri() {
076:                return req.requestURI().toString();
077:            }
078:
079:            public String getCurrentQueryString() {
080:                return req.queryString().toString();
081:            }
082:
083:            public String getProtocol() {
084:                return req.protocol().toString();
085:            }
086:
087:            public String getVirtualHost() {
088:                return req.serverName().toString();
089:            }
090:
091:            public int getServerPort() {
092:                return req.getServerPort();
093:            }
094:
095:            public String getRemoteAddr() {
096:                req.action(ActionCode.ACTION_REQ_HOST_ADDR_ATTRIBUTE, null);
097:                return req.remoteAddr().toString();
098:            }
099:
100:            public int getContentLength() {
101:                return req.getContentLength();
102:            }
103:
104:            public long getRequestBytesReceived() {
105:                return req.getBytesRead();
106:            }
107:
108:            public long getRequestBytesSent() {
109:                return req.getResponse().getBytesWritten();
110:            }
111:
112:            public long getRequestProcessingTime() {
113:                return (System.currentTimeMillis() - req.getStartTime());
114:            }
115:
116:            // -------------------- Statistical data  --------------------
117:            // Collected at the end of each request.
118:            private long bytesSent;
119:            private long bytesReceived;
120:
121:            // Total time = divide by requestCount to get average.
122:            private long processingTime;
123:            // The longest response time for a request
124:            private long maxTime;
125:            // URI of the request that took maxTime
126:            private String maxRequestUri;
127:
128:            private int requestCount;
129:            // number of response codes >= 400
130:            private int errorCount;
131:
132:            /** Called by the processor before recycling the request. It'll collect
133:             * statistic information.
134:             */
135:            void updateCounters() {
136:                bytesReceived += req.getBytesRead();
137:                bytesSent += req.getResponse().getBytesWritten();
138:
139:                requestCount++;
140:                if (req.getResponse().getStatus() >= 400)
141:                    errorCount++;
142:                long t0 = req.getStartTime();
143:                long t1 = System.currentTimeMillis();
144:                long time = t1 - t0;
145:                processingTime += time;
146:                if (maxTime < time) {
147:                    maxTime = time;
148:                    maxRequestUri = req.requestURI().toString();
149:                }
150:            }
151:
152:            public int getStage() {
153:                return stage;
154:            }
155:
156:            public void setStage(int stage) {
157:                this .stage = stage;
158:            }
159:
160:            public long getBytesSent() {
161:                return bytesSent;
162:            }
163:
164:            public void setBytesSent(long bytesSent) {
165:                this .bytesSent = bytesSent;
166:            }
167:
168:            public long getBytesReceived() {
169:                return bytesReceived;
170:            }
171:
172:            public void setBytesReceived(long bytesReceived) {
173:                this .bytesReceived = bytesReceived;
174:            }
175:
176:            public long getProcessingTime() {
177:                return processingTime;
178:            }
179:
180:            public void setProcessingTime(long processingTime) {
181:                this .processingTime = processingTime;
182:            }
183:
184:            public long getMaxTime() {
185:                return maxTime;
186:            }
187:
188:            public void setMaxTime(long maxTime) {
189:                this .maxTime = maxTime;
190:            }
191:
192:            public String getMaxRequestUri() {
193:                return maxRequestUri;
194:            }
195:
196:            public void setMaxRequestUri(String maxRequestUri) {
197:                this .maxRequestUri = maxRequestUri;
198:            }
199:
200:            public int getRequestCount() {
201:                return requestCount;
202:            }
203:
204:            public void setRequestCount(int requestCount) {
205:                this .requestCount = requestCount;
206:            }
207:
208:            public int getErrorCount() {
209:                return errorCount;
210:            }
211:
212:            public void setErrorCount(int errorCount) {
213:                this .errorCount = errorCount;
214:            }
215:
216:            public String getWorkerThreadName() {
217:                return workerThreadName;
218:            }
219:
220:            public ObjectName getRpName() {
221:                return rpName;
222:            }
223:
224:            public void setWorkerThreadName(String workerThreadName) {
225:                this .workerThreadName = workerThreadName;
226:            }
227:
228:            public void setRpName(ObjectName rpName) {
229:                this.rpName = rpName;
230:            }
231:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.