001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.configuration2.reloading;
018
019/**
020 * <p>
021 * An interface to be implemented by objects which can detect whether a reload
022 * operation is required.
023 * </p>
024 * <p>
025 * This interface is used by a {@link ReloadingController} object. When a
026 * reloading check is to be performed, it is delegated to a concrete
027 * implementation. The implementation decides whether (specific) criteria for a
028 * reload are fulfilled, so that the controller can react accordingly.
029 * </p>
030 * <p>
031 * This interface does not define how a check for a reload is performed. This is
032 * completely up to a concrete implementation. There is just one method for
033 * executing the check and one method to notify the {@code ReloadingDetector}
034 * that the reload actually happened; this method can be used to reset the
035 * internal state so that the conditions for the next reload can be detected.
036 * </p>
037 * <p>
038 * When used together with {@code ReloadingController} an implementation does
039 * not have to be thread-safe. The controller takes care for synchronization so
040 * that an instance is accessed by a single thread only.
041 * </p>
042 *
043 * @since 2.0
044 */
045public interface ReloadingDetector
046{
047    /**
048     * Checks whether all criteria for a reload operation are fulfilled. This
049     * method is called by external components to find out when reloading should
050     * take place.
051     *
052     * @return <b>true</b> if a reload operation should be performed,
053     *         <b>false</b> otherwise
054     */
055    boolean isReloadingRequired();
056
057    /**
058     * Notifies this object that a reload operation has been performed. This
059     * method is called after {@code reloadingRequired()} has returned
060     * <b>true</b>. It can be used to reset internal state in order to detect
061     * the next reload operation.
062     */
063    void reloadingPerformed();
064}