001    package org.apache.ojb.broker.util.configuration.impl;
002    
003    /* Copyright 2002-2005 The Apache Software Foundation
004     *
005     * Licensed under the Apache License, Version 2.0 (the "License");
006     * you may not use this file except in compliance with the License.
007     * 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     */
017    
018    import org.apache.ojb.broker.util.configuration.Configurable;
019    import org.apache.ojb.broker.util.configuration.Configuration;
020    import org.apache.ojb.broker.util.configuration.ConfigurationException;
021    import org.apache.ojb.broker.util.configuration.Configurator;
022    import org.apache.ojb.broker.util.logging.Logger;
023    import org.apache.ojb.broker.util.logging.LoggerFactory;
024    
025    /**
026     * The <code>Configurator</code> for the OJB system.
027     * Implemented as a singleton.
028     * @author Thomas Mahler
029     * @version $Id: OjbConfigurator.java,v 1.1 2007-08-24 22:17:42 ewestfal Exp $
030     */
031    public class OjbConfigurator implements Configurator
032    {
033            /**
034         * the logger instance.
035         */
036        private static Logger log = LoggerFactory.getBootLogger();
037    
038        /**
039         * the singleton instance of this class.
040         */
041        private static OjbConfigurator instance = new OjbConfigurator();
042    
043        /**
044             * the configuration to be used throught OJB
045             */
046        private OjbConfiguration configuration;
047    
048            /**
049             * private Constructor. There is no public Constructors.
050             * Use the static method <code>getInstance()</code> to obtain an
051             * instance of this class.
052             */
053        private OjbConfigurator()
054        {
055            configuration = new OjbConfiguration();
056        }
057    
058            /**
059             * returns the singleton instance.
060             * @return the singleton instance.
061             */
062        public static OjbConfigurator getInstance()
063        {
064            return instance;
065        }
066    
067        /**
068         * @see Configurator#setLogger(Logger)
069         */
070        public void setLogger(Logger logger)
071        {
072            log = logger;
073        }
074    
075        /**
076         * @see Configurator#configure(Configurable)
077         */
078        public void configure(Configurable target) throws ConfigurationException
079        {
080            target.configure(configuration);
081        }
082    
083        /**
084         * @see Configurator#getConfigurationFor(Configurable)
085         */
086        public Configuration getConfigurationFor(Configurable target)
087                throws ConfigurationException
088        {
089            return configuration;
090        }
091    
092    }