001    // Copyright 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.web;
016    
017    import org.apache.tapestry.describe.Describable;
018    
019    /**
020     * Primarily concerned with maintaining server-side state as attributes.
021     * 
022     * @author Howard M. Lewis Ship
023     * @since 4.0
024     */
025    public interface WebSession extends AttributeHolder, Describable
026    {
027        /**
028         * Returns a unique string identifier used to identify the session. This value is provided by
029         * the container, and is typically incorporated into URLs, or stored as a HTTP cookie.
030         * 
031         * @see org.apache.tapestry.web.WebResponse#encodeURL(String) .
032         */
033        String getId();
034    
035        /**
036         * Returns true if the client does not yet know about the session or if the client chooses not
037         * to join the session.
038         */
039        boolean isNew();
040    
041        /**
042         * Invalidates this session then unbinds any objects bound to it.
043         * 
044         * @throws IllegalStateException
045         *             if the session is already invalidated.
046         */
047    
048        void invalidate();
049        
050        /**
051         * Returns the time when this session was created, measured in milliseconds 
052         * since midnight January 1, 1970 GMT.
053         * 
054         * @return a long specifying when this session was created, 
055         *          expressed in milliseconds since 1/1/1970 GMT
056         */
057        
058        long getCreationTime();
059        
060        /**
061         * Returns the last time the client sent a request associated with this session, as 
062         * the number of milliseconds since midnight January 1, 1970 GMT, and marked by the 
063         * time the container recieved the request.
064         *
065         * <p> Actions that your application takes, such as getting or setting a value associated 
066         *  with the session, do not affect the access time.</p>
067         * 
068         * @return a long  representing the last time the client sent a request associated with 
069         *          this session, expressed in milliseconds since 1/1/1970 GMT
070         */
071        
072        long getLastAccessedTime();
073        
074        /**
075         * Returns the maximum time interval, in seconds, that the servlet container will 
076         * keep this session open between client accesses. After this interval, the servlet 
077         * container will invalidate the session. The maximum time interval can be set with 
078         * the setMaxInactiveInterval method. A negative time indicates the session should 
079         * never timeout.
080         * 
081         * @return an integer specifying the number of seconds this session 
082         *         remains open between client requests
083         */
084        
085        int getMaxInactiveInterval();
086        
087        /**
088         * Specifies the time, in seconds, between client requests before the servlet container 
089         * will invalidate this session. A negative time indicates the session should never timeout.
090         * 
091         * @param interval - An integer specifying the number of seconds
092         */
093        
094        void setMaxInactiveInterval(int interval);
095    }