001: /*
002: * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/InstanceEvent.java,v 1.7 2001/10/11 23:30:58 craigmcc Exp $
003: * $Revision: 1.7 $
004: * $Date: 2001/10/11 23:30:58 $
005: *
006: * ====================================================================
007: *
008: * The Apache Software License, Version 1.1
009: *
010: * Copyright (c) 1999 The Apache Software Foundation. All rights
011: * reserved.
012: *
013: * Redistribution and use in source and binary forms, with or without
014: * modification, are permitted provided that the following conditions
015: * are met:
016: *
017: * 1. Redistributions of source code must retain the above copyright
018: * notice, this list of conditions and the following disclaimer.
019: *
020: * 2. Redistributions in binary form must reproduce the above copyright
021: * notice, this list of conditions and the following disclaimer in
022: * the documentation and/or other materials provided with the
023: * distribution.
024: *
025: * 3. The end-user documentation included with the redistribution, if
026: * any, must include the following acknowlegement:
027: * "This product includes software developed by the
028: * Apache Software Foundation (http://www.apache.org/)."
029: * Alternately, this acknowlegement may appear in the software itself,
030: * if and wherever such third-party acknowlegements normally appear.
031: *
032: * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
033: * Foundation" must not be used to endorse or promote products derived
034: * from this software without prior written permission. For written
035: * permission, please contact apache@apache.org.
036: *
037: * 5. Products derived from this software may not be called "Apache"
038: * nor may "Apache" appear in their names without prior written
039: * permission of the Apache Group.
040: *
041: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
042: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
043: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
044: * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
045: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
046: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
047: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
048: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
049: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
050: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
051: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
052: * SUCH DAMAGE.
053: * ====================================================================
054: *
055: * This software consists of voluntary contributions made by many
056: * individuals on behalf of the Apache Software Foundation. For more
057: * information on the Apache Software Foundation, please see
058: * <http://www.apache.org/>.
059: *
060: * [Additional notices, if required by prior licensing conditions]
061: *
062: */
063:
064: package org.apache.catalina;
065:
066: import java.util.EventObject;
067: import javax.servlet.Filter;
068: import javax.servlet.Servlet;
069: import javax.servlet.ServletRequest;
070: import javax.servlet.ServletResponse;
071:
072: /**
073: * General event for notifying listeners of significant events related to
074: * a specific instance of a Servlet, or a specific instance of a Filter,
075: * as opposed to the Wrapper component that manages it.
076: *
077: * @author Craig R. McClanahan
078: * @version $Revision: 1.7 $ $Date: 2001/10/11 23:30:58 $
079: */
080:
081: public final class InstanceEvent extends EventObject {
082:
083: // ----------------------------------------------------- Manifest Constants
084:
085: /**
086: * The event indicating that the <code>init()</code> method is about
087: * to be called for this instance.
088: */
089: public static final String BEFORE_INIT_EVENT = "beforeInit";
090:
091: /**
092: * The event indicating that the <code>init()</code> method has returned.
093: */
094: public static final String AFTER_INIT_EVENT = "afterInit";
095:
096: /**
097: * The event indicating that the <code>service()</code> method is about
098: * to be called on a servlet. The <code>servlet</code> property contains
099: * the servlet being called, and the <code>request</code> and
100: * <code>response</code> properties contain the current request and
101: * response being processed.
102: */
103: public static final String BEFORE_SERVICE_EVENT = "beforeService";
104:
105: /**
106: * The event indicating that the <code>service()</code> method has
107: * returned. The <code>servlet</code> property contains the servlet
108: * that was called, and the <code>request</code> and
109: * <code>response</code> properties contain the current request and
110: * response being processed.
111: */
112: public static final String AFTER_SERVICE_EVENT = "afterService";
113:
114: /**
115: * The event indicating that the <code>destroy</code> method is about
116: * to be called for this instance.
117: */
118: public static final String BEFORE_DESTROY_EVENT = "beforeDestroy";
119:
120: /**
121: * The event indicating that the <code>destroy()</code> method has
122: * returned.
123: */
124: public static final String AFTER_DESTROY_EVENT = "afterDestroy";
125:
126: /**
127: * The event indicating that the <code>service()</code> method of a
128: * servlet accessed via a request dispatcher is about to be called.
129: * The <code>servlet</code> property contains a reference to the
130: * dispatched-to servlet instance, and the <code>request</code> and
131: * <code>response</code> properties contain the current request and
132: * response being processed. The <code>wrapper</code> property will
133: * contain a reference to the dispatched-to Wrapper.
134: */
135: public static final String BEFORE_DISPATCH_EVENT = "beforeDispatch";
136:
137: /**
138: * The event indicating that the <code>service()</code> method of a
139: * servlet accessed via a request dispatcher has returned. The
140: * <code>servlet</code> property contains a reference to the
141: * dispatched-to servlet instance, and the <code>request</code> and
142: * <code>response</code> properties contain the current request and
143: * response being processed. The <code>wrapper</code> property will
144: * contain a reference to the dispatched-to Wrapper.
145: */
146: public static final String AFTER_DISPATCH_EVENT = "afterDispatch";
147:
148: /**
149: * The event indicating that the <code>doFilter()</code> method of a
150: * Filter is about to be called. The <code>filter</code> property
151: * contains a reference to the relevant filter instance, and the
152: * <code>request</code> and <code>response</code> properties contain
153: * the current request and response being processed.
154: */
155: public static final String BEFORE_FILTER_EVENT = "beforeFilter";
156:
157: /**
158: * The event indicating that the <code>doFilter()</code> method of a
159: * Filter has returned. The <code>filter</code> property contains
160: * a reference to the relevant filter instance, and the
161: * <code>request</code> and <code>response</code> properties contain
162: * the current request and response being processed.
163: */
164: public static final String AFTER_FILTER_EVENT = "afterFilter";
165:
166: // ----------------------------------------------------------- Constructors
167:
168: /**
169: * Construct a new InstanceEvent with the specified parameters. This
170: * constructor is used for filter lifecycle events.
171: *
172: * @param wrapper Wrapper managing this servlet instance
173: * @param filter Filter instance for which this event occurred
174: * @param type Event type (required)
175: */
176: public InstanceEvent(Wrapper wrapper, Filter filter, String type) {
177:
178: super (wrapper);
179: this .wrapper = wrapper;
180: this .filter = filter;
181: this .servlet = null;
182: this .type = type;
183:
184: }
185:
186: /**
187: * Construct a new InstanceEvent with the specified parameters. This
188: * constructor is used for filter lifecycle events.
189: *
190: * @param wrapper Wrapper managing this servlet instance
191: * @param filter Filter instance for which this event occurred
192: * @param type Event type (required)
193: * @param exception Exception that occurred
194: */
195: public InstanceEvent(Wrapper wrapper, Filter filter, String type,
196: Throwable exception) {
197:
198: super (wrapper);
199: this .wrapper = wrapper;
200: this .filter = filter;
201: this .servlet = null;
202: this .type = type;
203: this .exception = exception;
204:
205: }
206:
207: /**
208: * Construct a new InstanceEvent with the specified parameters. This
209: * constructor is used for filter processing events.
210: *
211: * @param wrapper Wrapper managing this servlet instance
212: * @param filter Filter instance for which this event occurred
213: * @param type Event type (required)
214: * @param request Servlet request we are processing
215: * @param response Servlet response we are processing
216: */
217: public InstanceEvent(Wrapper wrapper, Filter filter, String type,
218: ServletRequest request, ServletResponse response) {
219:
220: super (wrapper);
221: this .wrapper = wrapper;
222: this .filter = filter;
223: this .servlet = null;
224: this .type = type;
225: this .request = request;
226: this .response = response;
227:
228: }
229:
230: /**
231: * Construct a new InstanceEvent with the specified parameters. This
232: * constructor is used for filter processing events.
233: *
234: * @param wrapper Wrapper managing this servlet instance
235: * @param filter Filter instance for which this event occurred
236: * @param type Event type (required)
237: * @param request Servlet request we are processing
238: * @param response Servlet response we are processing
239: * @param exception Exception that occurred
240: */
241: public InstanceEvent(Wrapper wrapper, Filter filter, String type,
242: ServletRequest request, ServletResponse response,
243: Throwable exception) {
244:
245: super (wrapper);
246: this .wrapper = wrapper;
247: this .filter = filter;
248: this .servlet = null;
249: this .type = type;
250: this .request = request;
251: this .response = response;
252: this .exception = exception;
253:
254: }
255:
256: /**
257: * Construct a new InstanceEvent with the specified parameters. This
258: * constructor is used for processing servlet lifecycle events.
259: *
260: * @param wrapper Wrapper managing this servlet instance
261: * @param servlet Servlet instance for which this event occurred
262: * @param type Event type (required)
263: */
264: public InstanceEvent(Wrapper wrapper, Servlet servlet, String type) {
265:
266: super (wrapper);
267: this .wrapper = wrapper;
268: this .filter = null;
269: this .servlet = servlet;
270: this .type = type;
271:
272: }
273:
274: /**
275: * Construct a new InstanceEvent with the specified parameters. This
276: * constructor is used for processing servlet lifecycle events.
277: *
278: * @param wrapper Wrapper managing this servlet instance
279: * @param servlet Servlet instance for which this event occurred
280: * @param type Event type (required)
281: * @param exception Exception that occurred
282: */
283: public InstanceEvent(Wrapper wrapper, Servlet servlet, String type,
284: Throwable exception) {
285:
286: super (wrapper);
287: this .wrapper = wrapper;
288: this .filter = null;
289: this .servlet = servlet;
290: this .type = type;
291: this .exception = exception;
292:
293: }
294:
295: /**
296: * Construct a new InstanceEvent with the specified parameters. This
297: * constructor is used for processing servlet processing events.
298: *
299: * @param wrapper Wrapper managing this servlet instance
300: * @param servlet Servlet instance for which this event occurred
301: * @param type Event type (required)
302: * @param request Servlet request we are processing
303: * @param response Servlet response we are processing
304: */
305: public InstanceEvent(Wrapper wrapper, Servlet servlet, String type,
306: ServletRequest request, ServletResponse response) {
307:
308: super (wrapper);
309: this .wrapper = wrapper;
310: this .filter = null;
311: this .servlet = servlet;
312: this .type = type;
313: this .request = request;
314: this .response = response;
315:
316: }
317:
318: /**
319: * Construct a new InstanceEvent with the specified parameters. This
320: * constructor is used for processing servlet processing events.
321: *
322: * @param wrapper Wrapper managing this servlet instance
323: * @param servlet Servlet instance for which this event occurred
324: * @param type Event type (required)
325: * @param request Servlet request we are processing
326: * @param response Servlet response we are processing
327: * @param exception Exception that occurred
328: */
329: public InstanceEvent(Wrapper wrapper, Servlet servlet, String type,
330: ServletRequest request, ServletResponse response,
331: Throwable exception) {
332:
333: super (wrapper);
334: this .wrapper = wrapper;
335: this .filter = null;
336: this .servlet = servlet;
337: this .type = type;
338: this .request = request;
339: this .response = response;
340: this .exception = exception;
341:
342: }
343:
344: // ----------------------------------------------------- Instance Variables
345:
346: /**
347: * The exception that was thrown during the processing being reported
348: * by this event (AFTER_INIT_EVENT, AFTER_SERVICE_EVENT,
349: * AFTER_DESTROY_EVENT, AFTER_DISPATCH_EVENT, and AFTER_FILTER_EVENT only).
350: */
351: private Throwable exception = null;
352:
353: /**
354: * The Filter instance for which this event occurred (BEFORE_FILTER_EVENT
355: * and AFTER_FILTER_EVENT only).
356: */
357: private Filter filter = null;
358:
359: /**
360: * The servlet request being processed (BEFORE_FILTER_EVENT,
361: * AFTER_FILTER_EVENT, BEFORE_SERVICE_EVENT, and AFTER_SERVICE_EVENT).
362: */
363: private ServletRequest request = null;
364:
365: /**
366: * The servlet response being processed (BEFORE_FILTER_EVENT,
367: * AFTER_FILTER_EVENT, BEFORE_SERVICE_EVENT, and AFTER_SERVICE_EVENT).
368: */
369: private ServletResponse response = null;
370:
371: /**
372: * The Servlet instance for which this event occurred (not present on
373: * BEFORE_FILTER_EVENT or AFTER_FILTER_EVENT events).
374: */
375: private Servlet servlet = null;
376:
377: /**
378: * The event type this instance represents.
379: */
380: private String type = null;
381:
382: /**
383: * The Wrapper managing the servlet instance for which this event occurred.
384: */
385: private Wrapper wrapper = null;
386:
387: // ------------------------------------------------------------- Properties
388:
389: /**
390: * Return the exception that occurred during the processing
391: * that was reported by this event.
392: */
393: public Throwable getException() {
394:
395: return (this .exception);
396:
397: }
398:
399: /**
400: * Return the filter instance for which this event occurred.
401: */
402: public Filter getFilter() {
403:
404: return (this .filter);
405:
406: }
407:
408: /**
409: * Return the servlet request for which this event occurred.
410: */
411: public ServletRequest getRequest() {
412:
413: return (this .request);
414:
415: }
416:
417: /**
418: * Return the servlet response for which this event occurred.
419: */
420: public ServletResponse getResponse() {
421:
422: return (this .response);
423:
424: }
425:
426: /**
427: * Return the servlet instance for which this event occurred.
428: */
429: public Servlet getServlet() {
430:
431: return (this .servlet);
432:
433: }
434:
435: /**
436: * Return the event type of this event.
437: */
438: public String getType() {
439:
440: return (this .type);
441:
442: }
443:
444: /**
445: * Return the Wrapper managing the servlet instance for which this
446: * event occurred.
447: */
448: public Wrapper getWrapper() {
449:
450: return (this.wrapper);
451:
452: }
453:
454: }
|