Coverage Report - org.apache.turbine.pipeline.DefaultSessionTimeoutValve
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultSessionTimeoutValve
100%
9/9
75%
3/4
2
 
 1  
 package org.apache.turbine.pipeline;
 2  
 
 3  
 
 4  
 /*
 5  
  * Licensed to the Apache Software Foundation (ASF) under one
 6  
  * or more contributor license agreements.  See the NOTICE file
 7  
  * distributed with this work for additional information
 8  
  * regarding copyright ownership.  The ASF licenses this file
 9  
  * to you under the Apache License, Version 2.0 (the
 10  
  * "License"); you may not use this file except in compliance
 11  
  * with the License.  You may obtain a copy of the License at
 12  
  *
 13  
  *   http://www.apache.org/licenses/LICENSE-2.0
 14  
  *
 15  
  * Unless required by applicable law or agreed to in writing,
 16  
  * software distributed under the License is distributed on an
 17  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 18  
  * KIND, either express or implied.  See the License for the
 19  
  * specific language governing permissions and limitations
 20  
  * under the License.
 21  
  */
 22  
 
 23  
 
 24  
 import java.io.IOException;
 25  
 
 26  
 import org.apache.commons.configuration.Configuration;
 27  
 import org.apache.turbine.Turbine;
 28  
 import org.apache.turbine.TurbineConstants;
 29  
 import org.apache.turbine.util.RunData;
 30  
 import org.apache.turbine.util.TurbineException;
 31  
 
 32  
 /**
 33  
  * Implements the action portion of the "Turbine classic" processing
 34  
  * pipeline (from the Turbine 2.x series).
 35  
  *
 36  
  * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
 37  
  * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
 38  
  * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
 39  
  * @version $Id: DefaultSessionTimeoutValve.java 1706239 2015-10-01 13:18:35Z tv $
 40  
  */
 41  
 public class DefaultSessionTimeoutValve
 42  
     extends AbstractValve
 43  
 {
 44  
     protected int timeout;
 45  
 
 46  
     /**
 47  
      * Here we can setup objects that are thread safe and can be
 48  
      * reused, so we get the timeout from the configuration..
 49  
      */
 50  
     public DefaultSessionTimeoutValve()
 51  2
     {
 52  2
         Configuration cfg = Turbine.getConfiguration();
 53  
 
 54  
         // Get the session timeout.
 55  2
             timeout = cfg.getInt(TurbineConstants.SESSION_TIMEOUT_KEY,
 56  
                 TurbineConstants.SESSION_TIMEOUT_DEFAULT);
 57  2
     }
 58  
 
 59  
     /**
 60  
      * @see org.apache.turbine.pipeline.Valve#invoke(PipelineData, ValveContext)
 61  
      */
 62  
     @Override
 63  
     public void invoke(PipelineData pipelineData, ValveContext context)
 64  
         throws IOException, TurbineException
 65  
     {
 66  3
         RunData runData = getRunData(pipelineData);
 67  
         // If the session is new take this opportunity to
 68  
         // set the session timeout if specified in TR.properties
 69  3
         if (runData.getSession().isNew() && timeout != TurbineConstants.SESSION_TIMEOUT_DEFAULT)
 70  
         {
 71  2
             runData.getSession().setMaxInactiveInterval(timeout);
 72  
         }
 73  
 
 74  
         // Pass control to the next Valve in the Pipeline
 75  3
         context.invokeNext(pipelineData);
 76  2
     }
 77  
 }