001 /** 002 * Copyright 2011 The Kuali Foundation Licensed under the 003 * Educational Community License, Version 2.0 (the "License"); you may 004 * not use this file except in compliance with the License. You may 005 * obtain a copy of the License at 006 * 007 * http://www.osedu.org/licenses/ECL-2.0 008 * 009 * Unless required by applicable law or agreed to in writing, 010 * software distributed under the License is distributed on an "AS IS" 011 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 012 * or implied. See the License for the specific language governing 013 * permissions and limitations under the License. 014 */ 015 016 package org.kuali.common.impex.spring; 017 018 import java.io.IOException; 019 import javax.xml.bind.JAXBException; 020 021 import org.kuali.common.impex.ProducerUtils; 022 import org.kuali.common.impex.model.Schema; 023 import org.kuali.common.util.spring.SpringUtils; 024 import org.springframework.beans.factory.annotation.Autowired; 025 import org.springframework.context.annotation.Bean; 026 import org.springframework.context.annotation.Configuration; 027 import org.springframework.core.env.Environment; 028 029 @Configuration 030 public class XmlSchemaConfig { 031 032 protected final static String XML_LOCATION_KEY = "impex.schema.location"; 033 034 @Autowired 035 Environment env; 036 037 @Bean 038 public Schema schema() throws JAXBException, IOException { 039 String xmlLocation = SpringUtils.getProperty(env, XML_LOCATION_KEY); 040 041 return ProducerUtils.unmarshalSchema(xmlLocation); 042 } 043 044 }