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; 018 019/** 020 * <p> 021 * Definition of an interface to be implemented by {@code Configuration} 022 * implementations which support a special initialization method. 023 * </p> 024 * <p> 025 * This interface is mainly evaluated by <em>configuration builder</em> 026 * implementations: If a newly created configuration instance implements this 027 * interface, the builder calls the {@code initialize()} method. This gives 028 * {@code Configuration} classes the opportunity to perform additional 029 * initializations after all properties passed to the builder have been set. 030 * </p> 031 * <p> 032 * Another use case for this interface is to perform initializations directly 033 * which otherwise would have been done lazily. Lazy initializations can be 034 * problematic regarding thread-safety. If in contrast a configuration instance 035 * has been fully initialized when it is returned from the builder, it may be 036 * used with a {@code NoOpSynchronizer} if it is not modified. 037 * </p> 038 * 039 * @since 2.0 040 */ 041public interface Initializable 042{ 043 /** 044 * Initializes this object. A concrete implementation can use this method to 045 * perform arbitrary initialization. Typically, this method is invoked by a 046 * <em>configuration builder</em>. In this case, the builder's lock is held, 047 * so that all member fields set by this method are safely published. 048 */ 049 void initialize(); 050}