2 * Copyright 2004-2005 the original author or authors.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org
.codehaus
.groovy
.grails
.plugins
.web
.filters
18 import org
.springframework
.web
.servlet
.HandlerInterceptor
19 import javax
.servlet
.http
.HttpServletRequest
20 import javax
.servlet
.http
.HttpServletResponse
21 import org
.springframework
.web
.servlet
.ModelAndView
22 import org
.apache
.commons
.logging
.LogFactory
25 * A HandlerInterceptor that is composed of other HandlerInterceptor instances
28 * @author Graeme Rocher
30 class CompositeInterceptor
implements HandlerInterceptor
{
31 static final LOG
= LogFactory
.getLog(CompositeInterceptor
)
35 boolean preHandle(HttpServletRequest request
, HttpServletResponse response
, Object o
) {
36 if (LOG
.isDebugEnabled()) LOG
.debug
"preHandle ${request}, ${response}, ${o}"
38 for (handler in handlers
) {
39 if (!handler
.preHandle(request
, response
, o
)) return false;
44 void postHandle(HttpServletRequest request
, HttpServletResponse response
,Object o
, ModelAndView modelAndView
) throws java
.lang
.Exception
{
45 if (LOG
.isDebugEnabled()) LOG
.debug
"postHandle ${request}, ${response}, ${o}, ${modelAndView}"
47 handlers
.reverseEach
{ handler
->
48 handler
.postHandle(request
, response
, o
, modelAndView
);
52 void afterCompletion(HttpServletRequest request
, HttpServletResponse response
, Object o
, Exception e
) throws java
.lang
.Exception
{
53 if (LOG
.isDebugEnabled()) LOG
.debug
"afterCompletion ${request}, ${response}, ${o}, ${e}"
55 handlers
.reverseEach
{ handler
->
56 handler
.afterCompletion(request
, response
, o
, e
);