1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.strutsit.chain.configuration;
25
26 import org.strutsit.chain.interfaces.ChainConfiguration;
27
28 /***
29 * Factory for instanciating the properbly configuration class.
30 *
31 * @author <a href="mailto:wolff@struts-it.de">Manfred Wolff </a>
32 * @since JDK 1.4
33 * @version $Revision: 1.3 $
34 */
35 public final class ChainConfigurationFactory {
36
37
38 private static ChainConfigurationFactory instance;
39
40 /***
41 * The Factorymethod of this Factory ;-)
42 *
43 * @return The one and only ChainConfigurationFactory object.
44 */
45 public static synchronized ChainConfigurationFactory getInstance() {
46
47 if (instance == null) {
48 instance = new ChainConfigurationFactory();
49 }
50 return instance;
51 }
52
53 /***
54 * Returns the right configuration configured in the chain.properties.
55 *
56 * @return A [@link ChainConfiguration} object.
57 *
58 * @TODO Do something if the configuration is missed. Currently returns the
59 * method null.
60 */
61 public ChainConfiguration createConfiguration() {
62
63 PropertyReader reader = PropertyReader.getInstance();
64
65 Object config = null;
66 if (PropertyReader.XML_MODE.equals(reader.getConfigMode())) {
67 try {
68 config = Class.forName(reader.getXmlClass()).newInstance();
69 } catch (Exception e) {
70 ;
71 }
72 }
73 return (ChainConfiguration) config;
74 }
75 }
76