    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 *     https://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 operation is required.
    022 * </p>
    023 * <p>
    024 * This interface is used by a {@link ReloadingController} object. When a reloading check is to be performed, it is
    025 * delegated to a concrete implementation. The implementation decides whether (specific) criteria for a reload are
    026 * fulfilled, so that the controller can react accordingly.
    027 * </p>
    028 * <p>
    029 * This interface does not define how a check for a reload is performed. This is completely up to a concrete
    030 * implementation. There is just one method for executing the check and one method to notify the
    031 * {@code ReloadingDetector} that the reload actually happened; this method can be used to reset the internal state so
    032 * that the conditions for the next reload can be detected.
    033 * </p>
    034 * <p>
    035 * When used together with {@code ReloadingController} an implementation does not have to be thread-safe. The controller
    036 * takes care for synchronization so that an instance is accessed by a single thread only.
    037 * </p>
    038 *
    039 * @since 2.0
    040 */
    041public interface ReloadingDetector {
    042    /**
    043     * Checks whether all criteria for a reload operation are fulfilled. This method is called by external components to
    044     * find out when reloading should take place.
    045     *
    046     * @return <strong>true</strong> if a reload operation should be performed, <strong>false</strong> otherwise
    047     */
    048    boolean isReloadingRequired();
    049
    050    /**
    051     * Notifies this object that a reload operation has been performed. This method is called after
    052     * {@code reloadingRequired()} has returned <strong>true</strong>. It can be used to reset internal state in order to detect the
    053     * next reload operation.
    054     */
    055    void reloadingPerformed();
    056}