01: package de.schlund.pfixxml.perflogging;
02:
03: import java.util.HashMap;
04: import java.util.Map;
05:
06: import org.apache.log4j.Logger;
07:
08: public class AdditionalTrailInfoFactory {
09: private static AdditionalTrailInfoFactory instance = new AdditionalTrailInfoFactory();
10: private final static Logger LOG = Logger
11: .getLogger(AdditionalTrailInfoFactory.class);
12:
13: private AdditionalTrailInfoFactory() {
14: }
15:
16: private Map<String, AdditionalTrailInfo> implementors = new HashMap<String, AdditionalTrailInfo>();
17:
18: public static AdditionalTrailInfoFactory getInstance() {
19: return instance;
20: }
21:
22: public synchronized AdditionalTrailInfo getAdditionalTrailInfo(
23: String implemenation_class) {
24:
25: if (implementors.get(implemenation_class) == null) {
26: LOG.info("Creating object from class "
27: + implemenation_class);
28: try {
29: Class<?> clazz = Class.forName(implemenation_class);
30: AdditionalTrailInfo info = (AdditionalTrailInfo) clazz
31: .newInstance();
32: implementors.put(implemenation_class, info);
33: } catch (ClassNotFoundException e) {
34: throw new IllegalStateException("Didn't find class "
35: + implemenation_class, e);
36: } catch (InstantiationException e) {
37: throw new IllegalStateException("Couldn't instantiate "
38: + implemenation_class, e);
39: } catch (IllegalAccessException e) {
40: throw new IllegalStateException(e);
41: }
42: }
43: return implementors.get(implemenation_class);
44: }
45:
46: }
|