01: /*
02: * Copyright 2005 Joe Walker
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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: package org.directwebremoting;
17:
18: import java.io.IOException;
19: import java.lang.reflect.Method;
20:
21: /**
22: * A filter is a way to insert procesing tasks at various points during the
23: * processing of an Ajax call.
24: * <p>Example filters:</p>
25: * <ul>
26: * <li>Authentication</li>
27: * <li>Latency simulators</li>
28: * <li>Data cleansing - remove private data</li>
29: * <li>Logging filters - when you need specific logging action</li>
30: * </ul>
31: * @since DWR 2.0
32: * @author Joe Walker [joe at getahead dot ltd dot uk]
33: */
34: public interface AjaxFilter {
35: /**
36: * The <code>doFilter</code> method of the AjaxFilter is called by DWR each
37: * time an Ajax request is made on a method that this filter is configured
38: * against. The <code>AjaxFilterChain<code> passed in to this method allows
39: * the filter to pass on method details to next entity in the chain.
40: * <p>Typically the method would do the following:</p>
41: * <ol>
42: * <li>Examine the request</li>
43: * <li>Optionally alter the method, object or parameters</li>
44: * <li>Either invoke the next entity in the chain using the AjaxFilterChain
45: * or decide to take some other action instead.</li>
46: * <li>Optionally modify the value returned to the user</li>
47: * <li>Take some other action (e.g. logging)</li>
48: * </ol>
49: * @param obj The object to execute the method on (i.e. 'this')
50: * @param method The method to execute
51: * @param params The parameters to the method call
52: * @param chain Allow the request to be passed on
53: * @return The results of the method execution
54: * @throws IOException When some I/O error occurs
55: * @throws Exception When some processing goes wrong
56: */
57: public Object doFilter(Object obj, Method method, Object[] params,
58: AjaxFilterChain chain) throws Exception;
59: }
|