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
015package org.apache.tapestry;
016
017import org.apache.hivemind.ApplicationRuntimeException;
018
019/**
020 *  Exception thrown by an {@link org.apache.tapestry.engine.IEngineService} when it discovers that
021 *  the {@link javax.servlet.http.HttpSession}
022 *  has timed out (and been replaced by a new, empty
023 *  one).
024 *
025 *  <p>The application should redirect to the stale-session page.
026 *
027 *
028 *  @author Howard Lewis Ship
029 *
030 **/
031
032public class StaleSessionException extends ApplicationRuntimeException
033{
034    private static final long serialVersionUID = 6733303549871198597L;
035    
036        private transient IPage _page;
037    private String _pageName;
038
039    public StaleSessionException()
040    {
041        this(null, null);
042    }
043
044    public StaleSessionException(String message, IPage page)
045    {
046        super(message, page, null, null);
047        _page = page;
048
049        if (page != null)
050            _pageName = page.getPageName();
051    }
052
053    public String getPageName()
054    {
055        return _pageName;
056    }
057
058    /**
059     *  Returns the page referenced by the service URL, if known, or null otherwise.
060     *
061     **/
062
063    public IPage getPage()
064    {
065        return _page;
066    }
067}