KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > catalina > InstanceEvent


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18
19 package org.apache.catalina;
20
21
22 import java.util.EventObject JavaDoc;
23 import javax.servlet.Filter JavaDoc;
24 import javax.servlet.Servlet JavaDoc;
25 import javax.servlet.ServletRequest JavaDoc;
26 import javax.servlet.ServletResponse JavaDoc;
27
28
29 /**
30  * General event for notifying listeners of significant events related to
31  * a specific instance of a Servlet, or a specific instance of a Filter,
32  * as opposed to the Wrapper component that manages it.
33  *
34  * @author Craig R. McClanahan
35  * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
36  */

37
38 public final class InstanceEvent
39     extends EventObject JavaDoc {
40
41
42     // ----------------------------------------------------- Manifest Constants
43

44
45     /**
46      * The event indicating that the <code>init()</code> method is about
47      * to be called for this instance.
48      */

49     public static final String JavaDoc BEFORE_INIT_EVENT = "beforeInit";
50
51
52     /**
53      * The event indicating that the <code>init()</code> method has returned.
54      */

55     public static final String JavaDoc AFTER_INIT_EVENT = "afterInit";
56
57
58     /**
59      * The event indicating that the <code>service()</code> method is about
60      * to be called on a servlet. The <code>servlet</code> property contains
61      * the servlet being called, and the <code>request</code> and
62      * <code>response</code> properties contain the current request and
63      * response being processed.
64      */

65     public static final String JavaDoc BEFORE_SERVICE_EVENT = "beforeService";
66
67
68     /**
69      * The event indicating that the <code>service()</code> method has
70      * returned. The <code>servlet</code> property contains the servlet
71      * that was called, and the <code>request</code> and
72      * <code>response</code> properties contain the current request and
73      * response being processed.
74      */

75     public static final String JavaDoc AFTER_SERVICE_EVENT = "afterService";
76
77
78     /**
79      * The event indicating that the <code>destroy</code> method is about
80      * to be called for this instance.
81      */

82     public static final String JavaDoc BEFORE_DESTROY_EVENT = "beforeDestroy";
83
84
85     /**
86      * The event indicating that the <code>destroy()</code> method has
87      * returned.
88      */

89     public static final String JavaDoc AFTER_DESTROY_EVENT = "afterDestroy";
90
91
92     /**
93      * The event indicating that the <code>service()</code> method of a
94      * servlet accessed via a request dispatcher is about to be called.
95      * The <code>servlet</code> property contains a reference to the
96      * dispatched-to servlet instance, and the <code>request</code> and
97      * <code>response</code> properties contain the current request and
98      * response being processed. The <code>wrapper</code> property will
99      * contain a reference to the dispatched-to Wrapper.
100      */

101     public static final String JavaDoc BEFORE_DISPATCH_EVENT = "beforeDispatch";
102
103
104     /**
105      * The event indicating that the <code>service()</code> method of a
106      * servlet accessed via a request dispatcher has returned. The
107      * <code>servlet</code> property contains a reference to the
108      * dispatched-to servlet instance, and the <code>request</code> and
109      * <code>response</code> properties contain the current request and
110      * response being processed. The <code>wrapper</code> property will
111      * contain a reference to the dispatched-to Wrapper.
112      */

113     public static final String JavaDoc AFTER_DISPATCH_EVENT = "afterDispatch";
114
115
116     /**
117      * The event indicating that the <code>doFilter()</code> method of a
118      * Filter is about to be called. The <code>filter</code> property
119      * contains a reference to the relevant filter instance, and the
120      * <code>request</code> and <code>response</code> properties contain
121      * the current request and response being processed.
122      */

123     public static final String JavaDoc BEFORE_FILTER_EVENT = "beforeFilter";
124
125
126     /**
127      * The event indicating that the <code>doFilter()</code> method of a
128      * Filter has returned. The <code>filter</code> property contains
129      * a reference to the relevant filter instance, and the
130      * <code>request</code> and <code>response</code> properties contain
131      * the current request and response being processed.
132      */

133     public static final String JavaDoc AFTER_FILTER_EVENT = "afterFilter";
134
135
136     // ----------------------------------------------------------- Constructors
137

138
139     /**
140      * Construct a new InstanceEvent with the specified parameters. This
141      * constructor is used for filter lifecycle events.
142      *
143      * @param wrapper Wrapper managing this servlet instance
144      * @param filter Filter instance for which this event occurred
145      * @param type Event type (required)
146      */

147     public InstanceEvent(Wrapper wrapper, Filter JavaDoc filter, String JavaDoc type) {
148
149       super(wrapper);
150       this.wrapper = wrapper;
151       this.filter = filter;
152       this.servlet = null;
153       this.type = type;
154
155     }
156
157
158     /**
159      * Construct a new InstanceEvent with the specified parameters. This
160      * constructor is used for filter lifecycle events.
161      *
162      * @param wrapper Wrapper managing this servlet instance
163      * @param filter Filter instance for which this event occurred
164      * @param type Event type (required)
165      * @param exception Exception that occurred
166      */

167     public InstanceEvent(Wrapper wrapper, Filter JavaDoc filter, String JavaDoc type,
168                          Throwable JavaDoc exception) {
169
170       super(wrapper);
171       this.wrapper = wrapper;
172       this.filter = filter;
173       this.servlet = null;
174       this.type = type;
175       this.exception = exception;
176
177     }
178
179
180     /**
181      * Construct a new InstanceEvent with the specified parameters. This
182      * constructor is used for filter processing events.
183      *
184      * @param wrapper Wrapper managing this servlet instance
185      * @param filter Filter instance for which this event occurred
186      * @param type Event type (required)
187      * @param request Servlet request we are processing
188      * @param response Servlet response we are processing
189      */

190     public InstanceEvent(Wrapper wrapper, Filter JavaDoc filter, String JavaDoc type,
191                          ServletRequest JavaDoc request, ServletResponse JavaDoc response) {
192
193       super(wrapper);
194       this.wrapper = wrapper;
195       this.filter = filter;
196       this.servlet = null;
197       this.type = type;
198       this.request = request;
199       this.response = response;
200
201     }
202
203
204     /**
205      * Construct a new InstanceEvent with the specified parameters. This
206      * constructor is used for filter processing events.
207      *
208      * @param wrapper Wrapper managing this servlet instance
209      * @param filter Filter instance for which this event occurred
210      * @param type Event type (required)
211      * @param request Servlet request we are processing
212      * @param response Servlet response we are processing
213      * @param exception Exception that occurred
214      */

215     public InstanceEvent(Wrapper wrapper, Filter JavaDoc filter, String JavaDoc type,
216                          ServletRequest JavaDoc request, ServletResponse JavaDoc response,
217                          Throwable JavaDoc exception) {
218
219       super(wrapper);
220       this.wrapper = wrapper;
221       this.filter = filter;
222       this.servlet = null;
223       this.type = type;
224       this.request = request;
225       this.response = response;
226       this.exception = exception;
227
228     }
229
230
231     /**
232      * Construct a new InstanceEvent with the specified parameters. This
233      * constructor is used for processing servlet lifecycle events.
234      *
235      * @param wrapper Wrapper managing this servlet instance
236      * @param servlet Servlet instance for which this event occurred
237      * @param type Event type (required)
238      */

239     public InstanceEvent(Wrapper wrapper, Servlet JavaDoc servlet, String JavaDoc type) {
240
241       super(wrapper);
242       this.wrapper = wrapper;
243       this.filter = null;
244       this.servlet = servlet;
245       this.type = type;
246
247     }
248
249
250     /**
251      * Construct a new InstanceEvent with the specified parameters. This
252      * constructor is used for processing servlet lifecycle events.
253      *
254      * @param wrapper Wrapper managing this servlet instance
255      * @param servlet Servlet instance for which this event occurred
256      * @param type Event type (required)
257      * @param exception Exception that occurred
258      */

259     public InstanceEvent(Wrapper wrapper, Servlet JavaDoc servlet, String JavaDoc type,
260                          Throwable JavaDoc exception) {
261
262       super(wrapper);
263       this.wrapper = wrapper;
264       this.filter = null;
265       this.servlet = servlet;
266       this.type = type;
267       this.exception = exception;
268
269     }
270
271
272     /**
273      * Construct a new InstanceEvent with the specified parameters. This
274      * constructor is used for processing servlet processing events.
275      *
276      * @param wrapper Wrapper managing this servlet instance
277      * @param servlet Servlet instance for which this event occurred
278      * @param type Event type (required)
279      * @param request Servlet request we are processing
280      * @param response Servlet response we are processing
281      */

282     public InstanceEvent(Wrapper wrapper, Servlet JavaDoc servlet, String JavaDoc type,
283                          ServletRequest JavaDoc request, ServletResponse JavaDoc response) {
284
285       super(wrapper);
286       this.wrapper = wrapper;
287       this.filter = null;
288       this.servlet = servlet;
289       this.type = type;
290       this.request = request;
291       this.response = response;
292
293     }
294
295
296     /**
297      * Construct a new InstanceEvent with the specified parameters. This
298      * constructor is used for processing servlet processing events.
299      *
300      * @param wrapper Wrapper managing this servlet instance
301      * @param servlet Servlet instance for which this event occurred
302      * @param type Event type (required)
303      * @param request Servlet request we are processing
304      * @param response Servlet response we are processing
305      * @param exception Exception that occurred
306      */

307     public InstanceEvent(Wrapper wrapper, Servlet JavaDoc servlet, String JavaDoc type,
308                          ServletRequest JavaDoc request, ServletResponse JavaDoc response,
309                          Throwable JavaDoc exception) {
310
311       super(wrapper);
312       this.wrapper = wrapper;
313       this.filter = null;
314       this.servlet = servlet;
315       this.type = type;
316       this.request = request;
317       this.response = response;
318       this.exception = exception;
319
320     }
321
322
323     // ----------------------------------------------------- Instance Variables
324

325
326     /**
327      * The exception that was thrown during the processing being reported
328      * by this event (AFTER_INIT_EVENT, AFTER_SERVICE_EVENT,
329      * AFTER_DESTROY_EVENT, AFTER_DISPATCH_EVENT, and AFTER_FILTER_EVENT only).
330      */

331     private Throwable JavaDoc exception = null;
332
333
334     /**
335      * The Filter instance for which this event occurred (BEFORE_FILTER_EVENT
336      * and AFTER_FILTER_EVENT only).
337      */

338     private Filter JavaDoc filter = null;
339
340
341     /**
342      * The servlet request being processed (BEFORE_FILTER_EVENT,
343      * AFTER_FILTER_EVENT, BEFORE_SERVICE_EVENT, and AFTER_SERVICE_EVENT).
344      */

345     private ServletRequest JavaDoc request = null;
346
347
348     /**
349      * The servlet response being processed (BEFORE_FILTER_EVENT,
350      * AFTER_FILTER_EVENT, BEFORE_SERVICE_EVENT, and AFTER_SERVICE_EVENT).
351      */

352     private ServletResponse JavaDoc response = null;
353
354
355     /**
356      * The Servlet instance for which this event occurred (not present on
357      * BEFORE_FILTER_EVENT or AFTER_FILTER_EVENT events).
358      */

359     private Servlet JavaDoc servlet = null;
360
361
362     /**
363      * The event type this instance represents.
364      */

365     private String JavaDoc type = null;
366
367
368     /**
369      * The Wrapper managing the servlet instance for which this event occurred.
370      */

371     private Wrapper wrapper = null;
372
373
374     // ------------------------------------------------------------- Properties
375

376
377     /**
378      * Return the exception that occurred during the processing
379      * that was reported by this event.
380      */

381     public Throwable JavaDoc getException() {
382
383         return (this.exception);
384
385     }
386
387
388     /**
389      * Return the filter instance for which this event occurred.
390      */

391     public Filter JavaDoc getFilter() {
392
393         return (this.filter);
394
395     }
396
397
398     /**
399      * Return the servlet request for which this event occurred.
400      */

401     public ServletRequest JavaDoc getRequest() {
402
403         return (this.request);
404
405     }
406
407
408     /**
409      * Return the servlet response for which this event occurred.
410      */

411     public ServletResponse JavaDoc getResponse() {
412
413         return (this.response);
414
415     }
416
417
418     /**
419      * Return the servlet instance for which this event occurred.
420      */

421     public Servlet JavaDoc getServlet() {
422
423         return (this.servlet);
424
425     }
426
427
428     /**
429      * Return the event type of this event.
430      */

431     public String JavaDoc getType() {
432
433         return (this.type);
434
435     }
436
437
438     /**
439      * Return the Wrapper managing the servlet instance for which this
440      * event occurred.
441      */

442     public Wrapper getWrapper() {
443
444         return (this.wrapper);
445
446     }
447
448
449 }
450
Popular Tags