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