01: package org.apache.ojb.broker.util.configuration.impl;
02:
03: /* Copyright 2002-2005 The Apache Software Foundation
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * 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:
18: import org.apache.ojb.broker.util.configuration.Configurable;
19: import org.apache.ojb.broker.util.configuration.Configuration;
20: import org.apache.ojb.broker.util.configuration.ConfigurationException;
21: import org.apache.ojb.broker.util.configuration.Configurator;
22: import org.apache.ojb.broker.util.logging.Logger;
23: import org.apache.ojb.broker.util.logging.LoggerFactory;
24:
25: /**
26: * The <code>Configurator</code> for the OJB system.
27: * Implemented as a singleton.
28: * @author Thomas Mahler
29: * @version $Id: OjbConfigurator.java,v 1.7.2.1 2005/12/21 22:28:15 tomdz Exp $
30: */
31: public class OjbConfigurator implements Configurator {
32: /**
33: * the logger instance.
34: */
35: private static Logger log = LoggerFactory.getBootLogger();
36:
37: /**
38: * the singleton instance of this class.
39: */
40: private static OjbConfigurator instance = new OjbConfigurator();
41:
42: /**
43: * the configuration to be used throught OJB
44: */
45: private OjbConfiguration configuration;
46:
47: /**
48: * private Constructor. There is no public Constructors.
49: * Use the static method <code>getInstance()</code> to obtain an
50: * instance of this class.
51: */
52: private OjbConfigurator() {
53: configuration = new OjbConfiguration();
54: }
55:
56: /**
57: * returns the singleton instance.
58: * @return the singleton instance.
59: */
60: public static OjbConfigurator getInstance() {
61: return instance;
62: }
63:
64: /**
65: * @see Configurator#setLogger(Logger)
66: */
67: public void setLogger(Logger logger) {
68: log = logger;
69: }
70:
71: /**
72: * @see Configurator#configure(Configurable)
73: */
74: public void configure(Configurable target)
75: throws ConfigurationException {
76: target.configure(configuration);
77: }
78:
79: /**
80: * @see Configurator#getConfigurationFor(Configurable)
81: */
82: public Configuration getConfigurationFor(Configurable target)
83: throws ConfigurationException {
84: return configuration;
85: }
86:
87: }
|