1 /* 2 * Copyright 2005 Joe Walker 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 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 /** 37 * The <code>doFilter</code> method of the AjaxFilter is called by DWR each 38 * time an Ajax request is made on a method that this filter is configured 39 * against. The <code>AjaxFilterChain<code> passed in to this method allows 40 * the filter to pass on method details to next entity in the chain. 41 * <p>Typically the method would do the following:</p> 42 * <ol> 43 * <li>Examine the request</li> 44 * <li>Optionally alter the method, object or parameters</li> 45 * <li>Either invoke the next entity in the chain using the AjaxFilterChain 46 * or decide to take some other action instead.</li> 47 * <li>Optionally modify the value returned to the user</li> 48 * <li>Take some other action (e.g. logging)</li> 49 * </ol> 50 * @param obj The object to execute the method on (i.e. 'this') 51 * @param method The method to execute 52 * @param params The parameters to the method call 53 * @param chain Allow the request to be passed on 54 * @return The results of the method execution 55 * @throws IOException When some I/O error occurs 56 * @throws Exception When some processing goes wrong 57 */ 58 public Object doFilter(Object obj, Method method, Object[] params, AjaxFilterChain chain) throws Exception; 59 } 60