| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| BaseOptimizedSessionPersistedObject |
|
| 1.0;1 |
| 1 | // Copyright 2008 The Apache Software Foundation | |
| 2 | // | |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 | // you may not use this file except in compliance with the License. | |
| 5 | // You may obtain a copy of the License at | |
| 6 | // | |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 | // | |
| 9 | // Unless required by applicable law or agreed to in writing, software | |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 | // See the License for the specific language governing permissions and | |
| 13 | // limitations under the License. | |
| 14 | ||
| 15 | package org.apache.tapestry5; | |
| 16 | ||
| 17 | import javax.servlet.http.HttpSessionBindingEvent; | |
| 18 | import javax.servlet.http.HttpSessionBindingListener; | |
| 19 | ||
| 20 | /** | |
| 21 | * Base implementation of {@link org.apache.tapestry5.OptimizedSessionPersistedObject}. Subclasses should invoke {@link | |
| 22 | * #markDirty()} when internal state of the object changes. | |
| 23 | * | |
| 24 | * @since 5.1.1.0 | |
| 25 | */ | |
| 26 | 316 | public abstract class BaseOptimizedSessionPersistedObject implements OptimizedSessionPersistedObject, HttpSessionBindingListener |
| 27 | { | |
| 28 | private transient boolean dirty; | |
| 29 | ||
| 30 | public final boolean isSessionPersistedObjectDirty() | |
| 31 | { | |
| 32 | 1270 | return dirty; |
| 33 | } | |
| 34 | ||
| 35 | /** | |
| 36 | * Invoked by the servlet container when the value is stored (or re-stored) as an attribute of the session. This | |
| 37 | * clears the dirty flag. Subclasses may override this method, but should invoke this implementation. | |
| 38 | */ | |
| 39 | public void valueBound(HttpSessionBindingEvent event) | |
| 40 | { | |
| 41 | 340 | dirty = false; |
| 42 | 340 | } |
| 43 | ||
| 44 | /** | |
| 45 | * Does nothing. | |
| 46 | */ | |
| 47 | public void valueUnbound(HttpSessionBindingEvent event) | |
| 48 | { | |
| 49 | 340 | } |
| 50 | ||
| 51 | /** | |
| 52 | * Invoked by the subclass whenever the internal state of the object changes. Typically, this is invoked from | |
| 53 | * mutator methods. | |
| 54 | */ | |
| 55 | protected final void markDirty() | |
| 56 | { | |
| 57 | 764 | dirty = true; |
| 58 | 764 | } |
| 59 | } |