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;
18  
19  /**
20   * <p>
21   * Definition of an interface to be implemented by {@code Configuration} implementations which support a special
22   * initialization method.
23   * </p>
24   * <p>
25   * This interface is mainly evaluated by <em>configuration builder</em> implementations: If a newly created
26   * configuration instance implements this interface, the builder calls the {@code initialize()} method. This gives
27   * {@code Configuration} classes the opportunity to perform additional initializations after all properties passed to
28   * the builder have been set.
29   * </p>
30   * <p>
31   * Another use case for this interface is to perform initializations directly which otherwise would have been done
32   * lazily. Lazy initializations can be problematic regarding thread-safety. If in contrast a configuration instance has
33   * been fully initialized when it is returned from the builder, it may be used with a {@code NoOpSynchronizer} if it is
34   * not modified.
35   * </p>
36   *
37   * @since 2.0
38   */
39  public interface Initializable {
40      /**
41       * Initializes this object. A concrete implementation can use this method to perform arbitrary initialization.
42       * Typically, this method is invoked by a <em>configuration builder</em>. In this case, the builder's lock is held, so
43       * that all member fields set by this method are safely published.
44       */
45      void initialize();
46  }