01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: package org.apache.cocoon;
19:
20: import org.apache.avalon.framework.component.Component;
21: import org.apache.cocoon.environment.Environment;
22:
23: /**
24: * This is called from with {@link Cocoon#process(Environment)}, before any
25: * requests are passed onto the {@link Processor} and after the request has been
26: * processed. It allows all requests to be logged or monitored.
27: * NB Cocoon does not require an instance of this Component to function, but if
28: * there is one it will be used.
29: */
30: public interface RequestListener extends Component {
31: String ROLE = RequestListener.class.getName();
32:
33: /**
34: * <p>In this method you can call, for example:
35: * <code>Request req=ObjectModelHelper.getRequest(env.getObjectModel());</code>
36: * And then, you could use the following:
37: * <ul>
38: * <li>req.getRequestURI()</li>
39: * <li>req.getQueryString()</li>
40: * <li>req.getSession().getId()</li>
41: * <li>req.getLocale().getLanguage().toString()</li>
42: * </ul>
43: * <p>
44: * @param environment as supplied to {@link Processor#process(Environment)}
45: * from within {@link Cocoon#process(Environment)}.
46: */
47: public void onRequestStart(Environment environment);
48:
49: /**
50: * <p>This method is called when a request has completed. This method is
51: * called before the response is committed.
52: * @param environment as supplied to {@link Processor#process(Environment)}
53: * from within {@link Cocoon#process(Environment)}.
54: */
55: public void onRequestEnd(Environment environment);
56:
57: /**
58: * <p>This method is called when an exception has occurred processing the request.
59: * @param environment as supplied to {@link Processor#process(Environment)}
60: * from within {@link Cocoon#process(Environment)}.
61: * @param throwable the error that occurred processing the request.
62: */
63: public void onRequestException(Environment environment,
64: Throwable throwable);
65: }
|