    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.services;
    014
    015import org.apache.tapestry5.ioc.ObjectLocator;
    016
    017/**
    018 * Manages a set of {@link org.apache.tapestry5.services.UpdateListener}s. Periodically (say, every request during
    019 * development, or every minute or so during production), request processing is locked down so that only a single thread
    020 * is active, and the active thread invokes {@link #fireCheckForUpdates()}. Various services that are dependent on
    021 * external resource files (such as classes or template files) can check to see if any file they've used has changed. If
    022 * so, the service can invalidate its internal cache, or notify other services (typically via
    023 * {@link org.apache.tapestry5.services.InvalidationListener} that they should do the same.
    024 *
    025 * Note that this interface has moved from module tapestry-core to tapestry-ioc, but has kept the same package (for
    026 * backwards compatibility reasons).
    027 *
    028 * A <em>weak reference</em> to the listener is kept; this ensures that registering as a listener will not prevent a
    029 * listener instance from being reclaimed by the garbage collector (this is useful as proxies created by
    030 * {@link ObjectLocator#proxy(Class, Class)} may register as listeners, but still be ephemeral).
    031 *
    032 * Starting in Tapestry 5.3, this services does <em>nothing</em> in production mode.
    033 *
    034 * @since 5.1.0.0
    035 */
    036public interface UpdateListenerHub
    037{
    038    /**
    039     * Adds a listener.
    040     */
    041    void addUpdateListener(UpdateListener listener);
    042
    043    /**
    044     * Invoked periodically to allow services to check if underlying state has changed. For example, a template file may
    045     * have changed. Listeners will typically notify applicable listeners of their own (they usually implement
    046     * {@link org.apache.tapestry5.services.InvalidationEventHub}) when such a change occurs.
    047     */
    048    void fireCheckForUpdates();
    049}