    001    // Copyright 2010 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
    015    package org.apache.tapestry5.ioc;
    016
    017    import org.apache.tapestry5.ioc.annotations.EagerLoad;
    018    import org.apache.tapestry5.services.UpdateListenerHub;
    019
    020    /**
    021     * Optional interface that may be implemented by a service implementation (or even
    022     * a {@linkplain ObjectLocator#proxy(Class, Class) proxy} to give the service implementation
    023     * more control over its lifecyle.
    024     *
    025     * @since 5.2.2
    026     */
    027    public interface ReloadAware
    028    {
    029        /**
    030         * Invoked when Tapestry {@linkplain UpdateListenerHub#fireCheckForUpdates() notices
    031         * that the implementation class has changed}. The existing instance is notified, so that
    032         * it can cleanly shutdown now, before being re-instantiated. This is necessary when the
    033         * service implementation retains some form of external resources.
    034         * <p>
    035         * In addition, the implementation may request an immediate reload. Normally, reloading of the service is deferred
    036         * until a method of the proxy object is invoked (this causes the normal just-in-time instantiation of the
    037         * implementation). When this method returns true, the implementation is re-created immediately. This is most often
    038         * the case for services that are {@linkplain EagerLoad eagerly loaded} in the first place.
    039         *
    040         * @return true if the service should be reloaded immediately, false if reload should be deferred
    041         */
    042        boolean shutdownImplementationForReload();
    043    }