001/** 002 * Copyright 2010-2014 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.common.util.xml.spring; 017 018import org.kuali.common.util.spring.env.EnvironmentService; 019import org.kuali.common.util.spring.service.SpringServiceConfig; 020import org.kuali.common.util.xml.jaxb.JAXBXmlService; 021import org.kuali.common.util.xml.service.XmlService; 022import org.springframework.beans.factory.annotation.Autowired; 023import org.springframework.context.annotation.Bean; 024import org.springframework.context.annotation.Configuration; 025import org.springframework.context.annotation.Import; 026 027@Configuration 028@Import({ SpringServiceConfig.class }) 029public class XmlServiceConfig { 030 031 private static final String FORMAT_OUTPUT_KEY = "jaxb.formatOutput"; 032 private static final String USE_NAMESPACE_AWARE_PARSER_KEY = "jaxb.useNamespaceAwareParser"; 033 private static final String USE_ECLIPSE_LINK_MOXY_PROVIDER_KEY = "jaxb.useEclipseLinkMoxyProvider"; 034 035 @Autowired 036 EnvironmentService env; 037 038 @Bean 039 public XmlService xmlService() { 040 boolean formatOutput = env.getBoolean(FORMAT_OUTPUT_KEY, JAXBXmlService.Builder.FORMAT_OUTPUT); 041 boolean nap = env.getBoolean(USE_NAMESPACE_AWARE_PARSER_KEY, JAXBXmlService.Builder.USE_NAMESPACE_AWARE_PARSER); 042 boolean elmp = env.getBoolean(USE_ECLIPSE_LINK_MOXY_PROVIDER_KEY, JAXBXmlService.Builder.USE_ECLIPSE_LINK_MOXY_PROVIDER); 043 return JAXBXmlService.builder().formatOutput(formatOutput).useNamespaceAwareParser(nap).useEclipseLinkMoxyProvider(elmp).build(); 044 } 045}