    001// Licensed under the Apache License, Version 2.0 (the "License");
    002// you may not use this file except in compliance with the License.
    003// You may obtain a copy of the License at
    004//
    005//     http://www.apache.org/licenses/LICENSE-2.0
    006//
    007// Unless required by applicable law or agreed to in writing, software
    008// distributed under the License is distributed on an "AS IS" BASIS,
    009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    010// See the License for the specific language governing permissions and
    011// limitations under the License.
    012
    013package org.apache.tapestry5.http;
    014
    015/**
    016 * An optional interface implemented by objects that are persisted in the {@link org.apache.tapestry5.http.services.Session}.
    017 * At the end of each request, any objects read from the session are re-stored into the session, to ensure that
    018 * in-memory changes are flushed to other persistent session stores (e.g. RDBMS, servers in a cluster, etc). Objects
    019 * that implement this interface are expected to track when they are dirty (have pending changes), so that the save
    020 * back into the session can be avoided when not necessary.
    021 *
    022 * This method is accessed concurrently.
    023 *
    024 * @see org.apache.tapestry5.http.annotations.ImmutableSessionPersistedObject
    025 * @see org.apache.tapestry5.http.services.SessionPersistedObjectAnalyzer
    026 * @since 5.1.1.0
    027 */
    028public interface OptimizedSessionPersistedObject
    029{
    030    /**
    031     * @return true if the object has in-memory changes since the last time this method was called.
    032     */
    033    boolean checkAndResetDirtyMarker();
    034}