Clover coverage report - Code Coverage for tapestry-contrib release 4.0-beta-6
Coverage timestamp: Wed Sep 7 2005 18:46:47 EDT
file stats: LOC: 83   Methods: 5
NCLOC: 50   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
Timeout.java 0% 0% 0% 0%
coverage
 1    // Copyright 2004, 2005 The Apache Software Foundation
 2    //
 3    // Licensed under the Apache License, Version 2.0 (the "License");
 4    // you may not use this file except in compliance with the License.
 5    // You may obtain a copy of the License at
 6    //
 7    // http://www.apache.org/licenses/LICENSE-2.0
 8    //
 9    // Unless required by applicable law or agreed to in writing, software
 10    // distributed under the License is distributed on an "AS IS" BASIS,
 11    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12    // See the License for the specific language governing permissions and
 13    // limitations under the License.
 14   
 15    package org.apache.tapestry.contrib.ajax;
 16   
 17    import java.util.HashMap;
 18    import java.util.Map;
 19   
 20    import javax.servlet.http.HttpSession;
 21   
 22    import org.apache.tapestry.BaseComponent;
 23    import org.apache.tapestry.IRequestCycle;
 24   
 25    /**
 26    * @author mb
 27    * @since 4.0
 28    */
 29    public abstract class Timeout extends BaseComponent {
 30    public abstract int getWarningTime();
 31    public abstract int getAutoProlongTime();
 32   
 33    public abstract String getWarningMessage();
 34    public abstract String getExpirationMessage();
 35   
 36    public abstract boolean getDisableWarning();
 37    public abstract boolean getDisableAutoProlong();
 38   
 39    public abstract String getExpirationFunction();
 40   
 41  0 protected HttpSession getSession()
 42    {
 43  0 return getPage().getRequestCycle().getRequestContext().getSession();
 44    }
 45   
 46  0 protected int getSessionTime()
 47    {
 48  0 return getSession().getMaxInactiveInterval();
 49    }
 50   
 51  0 public boolean isInSession()
 52    {
 53  0 HttpSession session = getSession();
 54  0 return session != null;
 55    }
 56   
 57  0 public Map getScriptSymbols()
 58    {
 59  0 int nSessionTime = getSessionTime();
 60  0 int nTimeToMessage = nSessionTime - getWarningTime();
 61  0 if (nTimeToMessage < 0)
 62  0 nTimeToMessage = 0;
 63  0 int nRemainingTime = nSessionTime - nTimeToMessage;
 64  0 int nAutoProlongTime = nSessionTime - getAutoProlongTime();
 65   
 66  0 Map mapSymbols = new HashMap();
 67  0 mapSymbols.put("confirmTimeout", new Integer(nTimeToMessage*1000));
 68  0 mapSymbols.put("expirationTimeout", new Integer(nRemainingTime*1000));
 69  0 mapSymbols.put("prolongSessionPeriod", new Integer(nAutoProlongTime*1000));
 70  0 mapSymbols.put("confirmMessage", getWarningMessage());
 71  0 mapSymbols.put("expirationMessage", getExpirationMessage());
 72  0 mapSymbols.put("disableWarning", new Boolean(getDisableWarning()));
 73  0 mapSymbols.put("disableAutoProlong", new Boolean(getDisableAutoProlong()));
 74  0 mapSymbols.put("expirationFunction", getExpirationFunction());
 75  0 return mapSymbols;
 76    }
 77   
 78  0 public void renewSession(IRequestCycle cycle)
 79    {
 80    // calling this method via the XTile service will automatically renew the session
 81    // System.out.println("Prolonging session...");
 82    }
 83    }