Coverage Report - org.seasar.cubby.filter.CubbyFilter
 
Classes in this File Line Coverage Branch Coverage Complexity
CubbyFilter
0%
0/15
N/A
1.667
 
 1  
 /*
 2  
  * Copyright 2004-2008 the Seasar Foundation and the Others.
 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,
 13  
  * either express or implied. See the License for the specific language
 14  
  * governing permissions and limitations under the License.
 15  
  */
 16  
 package org.seasar.cubby.filter;
 17  
 
 18  
 import java.io.IOException;
 19  
 
 20  
 import javax.servlet.Filter;
 21  
 import javax.servlet.FilterChain;
 22  
 import javax.servlet.FilterConfig;
 23  
 import javax.servlet.ServletException;
 24  
 import javax.servlet.ServletRequest;
 25  
 import javax.servlet.ServletResponse;
 26  
 import javax.servlet.http.HttpServletRequest;
 27  
 import javax.servlet.http.HttpServletResponse;
 28  
 
 29  
 import org.seasar.cubby.controller.ActionProcessor;
 30  
 import org.seasar.cubby.controller.ThreadContext;
 31  
 import org.seasar.framework.container.SingletonS2Container;
 32  
 import org.seasar.framework.log.Logger;
 33  
 
 34  
 /**
 35  
  * Cubby用のフィルター。
 36  
  * リクエストの処理をActionProcesserに委譲します。
 37  
  * 
 38  
  * @author agata
 39  
  * @author baba
 40  
  */
 41  0
 public class CubbyFilter implements Filter {
 42  
 
 43  
         /**
 44  
          * ログ 
 45  
          */
 46  0
         private static final Logger logger = Logger.getLogger(CubbyFilter.class);
 47  
 
 48  
         /**
 49  
          * 初期化処理。
 50  
          * 特に何も処理しません。
 51  
          */
 52  
         public void init(final FilterConfig config) throws ServletException {
 53  0
         }
 54  
 
 55  
         /**
 56  
          * 廃棄処理。
 57  
          * 特に何も処理しません。
 58  
          */
 59  
         public void destroy() {
 60  0
         }
 61  
 
 62  
         /**
 63  
          * フィルター処理。
 64  
          * リクエストの処理をS2Containerから取得したActionProcesserに委譲します。
 65  
          */
 66  
         public void doFilter(final ServletRequest req, final ServletResponse res,
 67  
                         final FilterChain chain) throws IOException, ServletException {
 68  
                 try {
 69  0
                         final HttpServletRequest request = (HttpServletRequest) req;
 70  0
                         final HttpServletResponse response = (HttpServletResponse) res;
 71  0
                         ThreadContext.setRequest(request);
 72  
 
 73  0
                         final ActionProcessor processor = SingletonS2Container
 74  
                                         .getComponent(ActionProcessor.class);
 75  0
                         processor.process(request, response, chain);
 76  0
                 } catch (final Throwable e) {
 77  0
                         logger.log(e);
 78  0
                         throw new ServletException(e);
 79  
                 } finally {
 80  0
                         ThreadContext.remove();
 81  0
                 }
 82  0
         }
 83  
 
 84  
 }