1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package ch.elca.el4j.services.xmlmerge.config;
18
19 import ch.elca.el4j.services.xmlmerge.ConfigurationException;
20 import ch.elca.el4j.services.xmlmerge.Configurer;
21 import ch.elca.el4j.services.xmlmerge.Mapper;
22 import ch.elca.el4j.services.xmlmerge.Matcher;
23 import ch.elca.el4j.services.xmlmerge.MergeAction;
24 import ch.elca.el4j.services.xmlmerge.XmlMerge;
25 import ch.elca.el4j.services.xmlmerge.action.OrderedMergeAction;
26 import ch.elca.el4j.services.xmlmerge.action.StandardActions;
27 import ch.elca.el4j.services.xmlmerge.factory.AttributeOperationFactory;
28 import ch.elca.el4j.services.xmlmerge.factory.OperationResolver;
29 import ch.elca.el4j.services.xmlmerge.factory.StaticOperationFactory;
30 import ch.elca.el4j.services.xmlmerge.mapper.NamespaceFilterMapper;
31 import ch.elca.el4j.services.xmlmerge.matcher.StandardMatchers;
32 import ch.elca.el4j.services.xmlmerge.matcher.TagMatcher;
33
34
35
36
37
38
39
40
41
42 public class AttributeMergeConfigurer implements Configurer {
43
44
45
46
47 public static final String ATTRIBUTE_NAMESPACE
48 = "http://xmlmerge.el4j.elca.ch";
49
50
51
52
53 public static final String ACTION_ATTRIBUTE = "action";
54
55
56
57
58 public static final String MATCHER_ATTRIBUTE = "matcher";
59
60
61
62
63 public void configure(XmlMerge xmlMerge) throws ConfigurationException {
64
65 MergeAction defaultMergeAction = new OrderedMergeAction();
66
67 Mapper mapper = new NamespaceFilterMapper(ATTRIBUTE_NAMESPACE);
68
69 defaultMergeAction.setMapperFactory(new StaticOperationFactory(mapper));
70
71
72 OperationResolver actionResolver = new OperationResolver(
73 StandardActions.class);
74
75 defaultMergeAction.setActionFactory(new AttributeOperationFactory(
76 defaultMergeAction, actionResolver, ACTION_ATTRIBUTE,
77 ATTRIBUTE_NAMESPACE));
78
79
80 Matcher defaultMatcher = new TagMatcher();
81
82 OperationResolver matcherResolver = new OperationResolver(
83 StandardMatchers.class);
84
85 defaultMergeAction.setMatcherFactory(new AttributeOperationFactory(
86 defaultMatcher, matcherResolver, MATCHER_ATTRIBUTE,
87 ATTRIBUTE_NAMESPACE));
88
89 xmlMerge.setRootMapper(mapper);
90 xmlMerge.setRootMergeAction(defaultMergeAction);
91 }
92
93 }