KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > web > context > support > ServletRequestHandledEvent


1 /*
2  * Copyright 2002-2005 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.web.context.support;
18
19 /**
20  * Servlet-specific subclass of RequestHandledEvent,
21  * adding servlet-specific context information.
22  *
23  * @author Juergen Hoeller
24  * @since 2.0
25  * @see org.springframework.web.servlet.FrameworkServlet
26  * @see org.springframework.context.ApplicationContext#publishEvent
27  */

28 public class ServletRequestHandledEvent extends RequestHandledEvent {
29
30     /** URL that the triggered the request */
31     private final String JavaDoc requestUrl;
32
33     /** IP address that the request came from */
34     private final String JavaDoc clientAddress;
35
36     /** Usually GET or POST */
37     private final String JavaDoc method;
38
39     /** Name of the servlet that handled the request */
40     private final String JavaDoc servletName;
41
42
43     /**
44      * Create a new ServletRequestHandledEvent.
45      * @param source the component that published the event
46      * @param requestUrl the URL of the request
47      * @param clientAddress the IP address that the request came from
48      * @param method the HTTP method of the request (usually GET or POST)
49      * @param servletName the name of the servlet that handled the request
50      * @param sessionId the id of the HTTP session, if any
51      * @param userName the name of the user that was associated with the
52      * request, if any (usually the UserPrincipal)
53      * @param processingTimeMillis the processing time of the request in milliseconds
54      */

55     public ServletRequestHandledEvent(Object JavaDoc source, String JavaDoc requestUrl,
56             String JavaDoc clientAddress, String JavaDoc method, String JavaDoc servletName,
57             String JavaDoc sessionId, String JavaDoc userName, long processingTimeMillis) {
58
59         super(source, sessionId, userName, processingTimeMillis);
60         this.requestUrl = requestUrl;
61         this.clientAddress = clientAddress;
62         this.method = method;
63         this.servletName = servletName;
64     }
65
66     /**
67      * Create a new ServletRequestHandledEvent.
68      * @param source the component that published the event
69      * @param requestUrl the URL of the request
70      * @param clientAddress the IP address that the request came from
71      * @param method the HTTP method of the request (usually GET or POST)
72      * @param servletName the name of the servlet that handled the request
73      * @param sessionId the id of the HTTP session, if any
74      * @param userName the name of the user that was associated with the
75      * request, if any (usually the UserPrincipal)
76      * @param processingTimeMillis the processing time of the request in milliseconds
77      * @param failureCause the cause of failure, if any
78      */

79     public ServletRequestHandledEvent(Object JavaDoc source, String JavaDoc requestUrl,
80             String JavaDoc clientAddress, String JavaDoc method, String JavaDoc servletName, String JavaDoc sessionId,
81             String JavaDoc userName, long processingTimeMillis, Throwable JavaDoc failureCause) {
82
83         super(source, sessionId, userName, processingTimeMillis, failureCause);
84         this.requestUrl = requestUrl;
85         this.clientAddress = clientAddress;
86         this.method = method;
87         this.servletName = servletName;
88     }
89
90
91     /**
92      * Return the URL of the request.
93      */

94     public String JavaDoc getRequestUrl() {
95         return requestUrl;
96     }
97
98     /**
99      * Return the IP address that the request came from.
100      */

101     public String JavaDoc getClientAddress() {
102         return clientAddress;
103     }
104
105     /**
106      * Return the HTTP method of the request (usually GET or POST).
107      */

108     public String JavaDoc getMethod() {
109         return method;
110     }
111
112     /**
113      * Return the name of the servlet that handled the request.
114      */

115     public String JavaDoc getServletName() {
116         return servletName;
117     }
118
119
120     public String JavaDoc getShortDescription() {
121         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
122         sb.append("url=[").append(getRequestUrl()).append("]; ");
123         sb.append("client=[").append(getClientAddress()).append("]; ");
124         sb.append(super.getShortDescription());
125         return sb.toString();
126     }
127
128     public String JavaDoc getDescription() {
129         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
130         sb.append("url=[").append(getRequestUrl()).append("]; ");
131         sb.append("client=[").append(getClientAddress()).append("]; ");
132         sb.append("method=[").append(getMethod()).append("]; ");
133         sb.append("servlet=[").append(getServletName()).append("]; ");
134         sb.append(super.getDescription());
135         return sb.toString();
136     }
137
138     public String JavaDoc toString() {
139         return ("ServletRequestHandledEvent: " + getDescription());
140     }
141
142 }
143
Popular Tags