View Javadoc
1   /**
2    * Copyright 2010-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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  }