001    package echopoint.template;
002    
003    /* 
004     * This file is part of the Echo Point Project.  This project is a collection
005     * of Components that have extended the Echo Web Application Framework.
006     *
007     * Version: MPL 1.1/GPL 2.0/LGPL 2.1
008     *
009     * The contents of this file are subject to the Mozilla Public License Version
010     * 1.1 (the "License"); you may not use this file except in compliance with
011     * the License. You may obtain a copy of the License at
012     * http://www.mozilla.org/MPL/
013     *
014     * Software distributed under the License is distributed on an "AS IS" basis,
015     * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
016     * for the specific language governing rights and limitations under the
017     * License.
018     *
019     * Alternatively, the contents of this file may be used under the terms of
020     * either the GNU General Public License Version 2 or later (the "GPL"), or
021     * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
022     * in which case the provisions of the GPL or the LGPL are applicable instead
023     * of those above. If you wish to allow use of your version of this file only
024     * under the terms of either the GPL or the LGPL, and not to allow others to
025     * use your version of this file under the terms of the MPL, indicate your
026     * decision by deleting the provisions above and replace them with the notice
027     * and other provisions required by the GPL or the LGPL. If you do not delete
028     * the provisions above, a recipient may use your version of this file under
029     * the terms of any one of the MPL, the GPL or the LGPL.
030     */
031    import java.io.Serializable;
032    
033    /**
034     * <code>SimpleTemplateCachingHints</code> is used to indicate to the
035     * templating rendering mechanism whether the compiled template data should be
036     * cached and for how long.
037     */
038    public class SimpleTemplateCachingHints implements TemplateCachingHints, Serializable {
039    
040            /** the default cache time-to-live is 120 minutes */
041            public static final long DEFAULT_TIME_TO_LIVE = 120 * 60 * 1000;
042    
043            /** the default cache access time out 5 minutes */
044            public static final long DEFAULT_ACCESS_TIMEOUT = 5 * 60 * 1000;
045    
046            private long timeToLive;
047            private long accessTimeout;
048            private long lastModified;
049    
050            /**
051             * Constructs a <code>SimpleTemplateCachingHints</code>
052             */
053            public SimpleTemplateCachingHints() {
054                    this.timeToLive = DEFAULT_TIME_TO_LIVE;
055                    this.accessTimeout = DEFAULT_ACCESS_TIMEOUT;
056                    this.lastModified = -1;
057            }
058            /**
059             * @see TemplateCachingHints#getAccessTimeout()
060             */
061            public long getAccessTimeout() {
062                    return accessTimeout;
063            }
064    
065            /**
066             * Sets the time after which a cached entry will expire if it not accessed,
067             * in milliseconds.
068             * 
069             * @param accessTimeout -
070             *            The newValue to set.
071             */
072            public void setAccessTimeout(long accessTimeout) {
073                    this.accessTimeout = accessTimeout;
074            }
075    
076            /**
077             * @see TemplateCachingHints#getLastModified()
078             */
079            public long getLastModified() {
080                    return lastModified;
081            }
082    
083            /**
084             * Sets the last modified time.
085             * 
086             * @param lastModified -
087             *            The newValue to set.
088             */
089            public void setLastModified(long lastModified) {
090                    this.lastModified = lastModified;
091            }
092    
093            /**
094             * @see TemplateCachingHints#getTimeToLive()
095             */
096            public long getTimeToLive() {
097                    return timeToLive;
098            }
099    
100            /**
101             * Sets the time this template data can reside in the cache in milliseconds.
102             * 
103             * @param timeToLive -
104             *            The newValue to set.
105             */
106            public void setTimeToLive(long timeToLive) {
107                    this.timeToLive = timeToLive;
108            }
109    }