View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.configuration2.reloading;
18  
19  /**
20   * <p>
21   * An interface to be implemented by objects which can detect whether a reload operation is required.
22   * </p>
23   * <p>
24   * This interface is used by a {@link ReloadingController} object. When a reloading check is to be performed, it is
25   * delegated to a concrete implementation. The implementation decides whether (specific) criteria for a reload are
26   * fulfilled, so that the controller can react accordingly.
27   * </p>
28   * <p>
29   * This interface does not define how a check for a reload is performed. This is completely up to a concrete
30   * implementation. There is just one method for executing the check and one method to notify the
31   * {@code ReloadingDetector} that the reload actually happened; this method can be used to reset the internal state so
32   * that the conditions for the next reload can be detected.
33   * </p>
34   * <p>
35   * When used together with {@code ReloadingController} an implementation does not have to be thread-safe. The controller
36   * takes care for synchronization so that an instance is accessed by a single thread only.
37   * </p>
38   *
39   * @since 2.0
40   */
41  public interface ReloadingDetector {
42      /**
43       * Checks whether all criteria for a reload operation are fulfilled. This method is called by external components to
44       * find out when reloading should take place.
45       *
46       * @return <b>true</b> if a reload operation should be performed, <b>false</b> otherwise
47       */
48      boolean isReloadingRequired();
49  
50      /**
51       * Notifies this object that a reload operation has been performed. This method is called after
52       * {@code reloadingRequired()} has returned <b>true</b>. It can be used to reset internal state in order to detect the
53       * next reload operation.
54       */
55      void reloadingPerformed();
56  }