01: package org.swingml.errors.handlers;
02:
03: import org.swingml.model.*;
04:
05: /**
06: * This factory should be looking at XML files for registries of error handlers.
07: *
08: * For now, use the 'name' paramter as the classname and reflection to
09: * instantiate a new error handler.
10: *
11: * @author CrossLogic
12: */
13: public class ErrorHandlerFactory {
14:
15: public static ISwingMLErrorHandler getDefaultHandler() {
16: return new DefaultErrorHandler();
17: }
18:
19: public static ISwingMLErrorHandler getErrorHandler(
20: ErrorHandlerModel model) {
21: ISwingMLErrorHandler result = null;
22:
23: try {
24: Class handler = ErrorHandlerFactory.class.getClassLoader()
25: .loadClass(model.getName());
26: result = (ISwingMLErrorHandler) handler.newInstance();
27: } catch (Throwable t) {
28: result = new DefaultErrorHandler();
29: }
30:
31: return result;
32: }
33:
34: public static ISwingMLErrorHandler getNullHandler() {
35: return new NullErrorHandler();
36: }
37:
38: }
|