01: /*
02: * CoadunationLib: The coaduntion implementation library.
03: * Copyright (C) 2006 Rift IT Contracting
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18: *
19: * ConfigurationFactory.java
20: *
21: * The configuration factory object. This object is responsible for retrieving
22: * the configuration information.
23: */
24:
25: // The package
26: package com.rift.coad.lib.configuration;
27:
28: /**
29: * The configuration factory. Responsible for the initial read of the
30: * configuration file.
31: *
32: * @author Brett Chaldecott
33: */
34: public abstract class ConfigurationFactory {
35:
36: // classes private member variables
37: private static ConfigurationFactory singleton = null;
38:
39: /**
40: * Creates a new instance of ConfigurationFactory
41: */
42: public ConfigurationFactory() {
43: }
44:
45: /**
46: * This method will return the singleton reference to the configration class
47: *
48: * @return The reference to the singleton configuration class.
49: */
50: static synchronized public ConfigurationFactory getInstance()
51: throws ConfigurationException {
52: if (singleton != null) {
53: return singleton;
54: }
55: try {
56: // instanciate the singleton
57: singleton = (ConfigurationFactory) Class.forName(
58: System.getProperty("coad.config")).newInstance();
59: return singleton;
60: } catch (Exception ex) {
61: throw new ConfigurationException(
62: "Failed to load the class ["
63: + System.getProperty("coad.config")
64: + "] because : " + ex.getMessage(), ex);
65: }
66: }
67:
68: /**
69: * This method returns a reference to the configuration class scoped for the
70: * class reference.
71: *
72: * @return Configuration The reference to the configuration class.
73: * @param classRef The reference to the class that the configuration will be
74: * retrieve for
75: * @exception ConfigurationException
76: */
77: public abstract Configuration getConfig(Class classRef)
78: throws ConfigurationException;
79:
80: }
|