001// Copyright 2008, 2011 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.tapestry5.services; 016 017import org.apache.tapestry5.ioc.annotations.UsesMappedConfiguration; 018 019/** 020 * Analyzes a session-persisted object, specifically to see if it is dirty or not. 021 * <p/> 022 * This service is provided to support applications which store mutable session attributes where the 023 * session is replicated to a slower medium (e.g. RDMBS, Cluster, etc) this can help alleviate excessive writes 024 * to the session store while ensuring changes are propagated. 025 * <p/> 026 * The service implementation uses a mapped configuration to form a 027 * {@linkplain org.apache.tapestry5.ioc.services.StrategyBuilder strategy} based on object type. The service may be 028 * injected using the {@link org.apache.tapestry5.ioc.annotations.Primary} marker annotation. 029 * 030 * @see org.apache.tapestry5.annotations.ImmutableSessionPersistedObject 031 * @see org.apache.tapestry5.OptimizedSessionPersistedObject 032 * @since 5.1.0.0 033 */ 034@UsesMappedConfiguration(key = Class.class, value = SessionPersistedObjectAnalyzer.class) 035public interface SessionPersistedObjectAnalyzer<T> 036{ 037 /** 038 * Atomically check and reset the dirty state of the session persisted object. 039 * <p/> 040 * The implementer should take consideration for the fact that session attributes are accessed concurrently. A 041 * naive check/set algorithm may allow changes to go un-noticed. 042 * 043 * @param sessionPersistedObject the session attribute (never null) 044 * @return true if the object needs to be re-stored into the session 045 * @since 5.3 046 */ 047 boolean checkAndResetDirtyState(T sessionPersistedObject); 048 049}