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