1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.commons.spring.map.config;
17
18 import org.openehealth.ipf.commons.core.config.Configurer;
19 import org.openehealth.ipf.commons.core.config.OrderedConfigurer;
20 import org.openehealth.ipf.commons.core.config.Registry;
21 import org.openehealth.ipf.commons.spring.map.MappingResourceHolder;
22 import org.openehealth.ipf.commons.spring.map.SpringBidiMappingService;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
25
26 import java.util.Collection;
27
28
29
30
31
32
33
34
35 public class CustomMappingsConfigurer<R extends Registry> extends OrderedConfigurer<MappingResourceHolder, R> {
36
37 private SpringBidiMappingService mappingService;
38
39 private static final Logger LOG = LoggerFactory.getLogger(CustomMappingsConfigurer.class);
40
41
42
43
44
45
46
47 @Override
48 public Collection<MappingResourceHolder> lookup(Registry registry) {
49 return registry.beans(MappingResourceHolder.class).values();
50 }
51
52
53
54
55 @Override
56 public void configure(MappingResourceHolder configuration) throws Exception {
57 if (configuration.getMappingResources() != null) {
58 mappingService.setMappingResources(configuration.getMappingResources());
59 LOG.debug("Mapping scripts added {}", configuration);
60 }
61 }
62
63 public SpringBidiMappingService getMappingService() {
64 return mappingService;
65 }
66
67 public void setMappingService(SpringBidiMappingService mappingService) {
68 this.mappingService = mappingService;
69 }
70
71 }