1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.xml.spring;
17
18 import org.kuali.common.util.spring.env.EnvironmentService;
19 import org.kuali.common.util.spring.service.SpringServiceConfig;
20 import org.kuali.common.util.xml.jaxb.JAXBXmlService;
21 import org.kuali.common.util.xml.service.XmlService;
22 import org.springframework.beans.factory.annotation.Autowired;
23 import org.springframework.context.annotation.Bean;
24 import org.springframework.context.annotation.Configuration;
25 import org.springframework.context.annotation.Import;
26
27 @Configuration
28 @Import({ SpringServiceConfig.class })
29 public class XmlServiceConfig {
30
31 private static final String FORMAT_OUTPUT_KEY = "jaxb.formatOutput";
32 private static final String USE_NAMESPACE_AWARE_PARSER_KEY = "jaxb.useNamespaceAwareParser";
33 private static final String USE_ECLIPSE_LINK_MOXY_PROVIDER_KEY = "jaxb.useEclipseLinkMoxyProvider";
34
35 @Autowired
36 EnvironmentService env;
37
38 @Bean
39 public XmlService xmlService() {
40 boolean formatOutput = env.getBoolean(FORMAT_OUTPUT_KEY, JAXBXmlService.Builder.FORMAT_OUTPUT);
41 boolean nap = env.getBoolean(USE_NAMESPACE_AWARE_PARSER_KEY, JAXBXmlService.Builder.USE_NAMESPACE_AWARE_PARSER);
42 boolean elmp = env.getBoolean(USE_ECLIPSE_LINK_MOXY_PROVIDER_KEY, JAXBXmlService.Builder.USE_ECLIPSE_LINK_MOXY_PROVIDER);
43 return JAXBXmlService.builder().formatOutput(formatOutput).useNamespaceAwareParser(nap).useEclipseLinkMoxyProvider(elmp).build();
44 }
45 }