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;
016
017 import java.io.Serializable;
018
019 import javax.servlet.http.HttpSessionBindingEvent;
020 import javax.servlet.http.HttpSessionBindingListener;
021
022 /**
023 * Base implementation of {@link org.apache.tapestry.SessionStoreOptimized}. Subclasses should
024 * invoke {@link #markSessionStoreNeeded()} any time internal state changed.
025 *
026 * @author Howard M. Lewis Ship
027 * @since 4.0
028 */
029 public class BaseSessionStoreOptimized implements SessionStoreOptimized, Serializable,
030 HttpSessionBindingListener
031 {
032 private static final long serialVersionUID = -2786704444616789831L;
033
034 private transient boolean _dirty;
035
036 /**
037 * Clears the dirty flag.
038 */
039 public void valueBound(HttpSessionBindingEvent event)
040 {
041 _dirty = false;
042 }
043
044 /**
045 * Does nothing.
046 */
047 public void valueUnbound(HttpSessionBindingEvent event)
048 {
049 }
050
051 /**
052 * Sets the dirty flag.
053 */
054 protected void markSessionStoreNeeded()
055 {
056 _dirty = true;
057 }
058
059 /**
060 * Returns the dirty flag.
061 */
062 public boolean isStoreToSessionNeeded()
063 {
064 return _dirty;
065 }
066
067 }