01: /*
02: * Created on 05.07.2004
03: * Created by crappy eclipse.
04: */
05: package org.jzonic.jlo.error;
06:
07: import java.io.InputStream;
08: import java.util.Properties;
09:
10: /**
11: * @author Mecky
12: */
13: public class ErrorHandlerFactory {
14:
15: private static final ErrorReporter defaultReporter = new NullDeviceErrorReporter();
16:
17: private static ErrorReporter er = null;
18:
19: public static ErrorReporter getErrorReporter() {
20: if (er == null) {
21: String tmp = System.getProperty("jlo.errorhandler");
22: if (tmp != null) {
23: try {
24: er = (ErrorReporter) Class.forName(tmp)
25: .newInstance();
26: } catch (Exception e) {
27: e.printStackTrace();
28: er = defaultReporter;
29: }
30: } else {
31: try {
32: ClassLoader cl = ErrorHandlerFactory.class
33: .getClass().getClassLoader();
34: InputStream fis = cl
35: .getResourceAsStream("jlo.properties");
36: if (fis == null) {
37: er = defaultReporter;
38: } else {
39: Properties properties = new Properties();
40: properties.load(fis);
41: String ptype = properties
42: .getProperty("jlo.errorhandler");
43: if (ptype != null) {
44: er = (ErrorReporter) Class.forName(ptype)
45: .newInstance();
46: } else {
47: er = defaultReporter;
48: }
49: }
50: } catch (Exception e) {
51: er = defaultReporter;
52: }
53: }
54: }
55: return er;
56: }
57: }
|