001    // Copyright 2004, 2005 The Apache Software Foundation
002    //
003    // Licensed under the Apache License, Version 2.0 (the "License");
004    // you may not use this file except in compliance with the License.
005    // You may obtain a copy of the License at
006    //
007    //     http://www.apache.org/licenses/LICENSE-2.0
008    //
009    // Unless required by applicable law or agreed to in writing, software
010    // distributed under the License is distributed on an "AS IS" BASIS,
011    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012    // See the License for the specific language governing permissions and
013    // limitations under the License.
014    
015    package org.apache.tapestry;
016    
017    import org.apache.hivemind.ApplicationRuntimeException;
018    
019    /**
020     * Exception thrown by an {@link org.apache.tapestry.engine.IEngineService} when
021     * it discovers that the {@link javax.servlet.http.HttpSession} has timed out
022     * (and been replaced by a new, empty one).
023     * <p>
024     * The application should redirect to the stale-session page.
025     * 
026     * @author Howard Lewis Ship
027     */
028    
029    public class StaleSessionException extends ApplicationRuntimeException
030    {
031    
032        private static final long serialVersionUID = 6733303549871198597L;
033    
034        private final transient IPage _page;
035        private final String _pageName;
036    
037        public StaleSessionException()
038        {
039            this(null, null);
040        }
041    
042        public StaleSessionException(String message, IPage page)
043        {
044            super(message, page, null, null);
045            _page = page;
046    
047            if (page != null) _pageName = page.getPageName();
048            else _pageName = null;
049        }
050    
051        public String getPageName()
052        {
053            return _pageName;
054        }
055    
056        /**
057         * Returns the page referenced by the service URL, if known, or null
058         * otherwise.
059         */
060    
061        public IPage getPage()
062        {
063            return _page;
064        }
065    }