01: package org.conform.mdl;
02:
03: import java.util.*;
04: import java.beans.ExceptionListener;
05:
06: public class DefaultHandlerFactory implements HandlerFactory {
07: private static final HandlerFactory instance = new DefaultHandlerFactory();
08:
09: private Map map = new HashMap();
10: public static final ExceptionListener EXCEPTION_LISTENER = new ExceptionListener() {
11: public void exceptionThrown(Exception e) {
12: e.printStackTrace(System.err);
13: }
14: };
15:
16: private DefaultHandlerFactory() {
17: map.put("java", new ObjectHandler(getExceptionListener()));
18: map
19: .put("readable", new ReadableHandler(
20: getExceptionListener()));
21: map.put("mandatory", new MandatoryHandler(
22: getExceptionListener()));
23: map
24: .put("writable", new WritableHandler(
25: getExceptionListener()));
26: map
27: .put("priority", new PriorityHandler(
28: getExceptionListener()));
29: map.put("relation-type", new RelationTypeHandler(
30: getExceptionListener()));
31: map.put("relation-bean", new RelationBeanHandler(
32: getExceptionListener()));
33: map.put("relation-property", new RelationPropertyHandler(
34: getExceptionListener()));
35: map.put("attribute", new AttributeHandler(
36: getExceptionListener()));
37: map.put("domain-provider", new DomainProviderHandler(
38: getExceptionListener()));
39: map.put("validation", new ValidationHandler(
40: getExceptionListener()));
41: map.put("format", new FormatHandler(getExceptionListener()));
42: }
43:
44: public ScopeHandler getHandler(String name) {
45: return (ScopeHandler) map.get(name);
46: }
47:
48: public ExceptionListener getExceptionListener() {
49: return EXCEPTION_LISTENER;
50: }
51:
52: public static HandlerFactory getInstance() {
53: return instance;
54: }
55: }
|