001/*
002 * Copyright 2007 The Kuali Foundation.
003 *
004 * Licensed under the Educational Community License, Version 1.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/ecl1.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.ole.sys.context;
017
018import java.util.Properties;
019
020import org.kuali.rice.core.api.config.property.ConfigContext;
021import org.kuali.rice.core.impl.config.property.JAXBConfigImpl;
022import org.springframework.context.support.ClassPathXmlApplicationContext;
023
024public class SpringContextForBatchRunner {
025    private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(SpringContextForBatchRunner.class);
026
027    private static ClassPathXmlApplicationContext context;
028
029    public static void initializeKfs() {
030        long startInit = System.currentTimeMillis();
031        LOG.info("Initializing Kuali Rice Application...");
032
033        String bootstrapSpringBeans = "ole-startup.xml";
034
035        Properties baseProps = new Properties();
036        baseProps.putAll(System.getProperties());
037        JAXBConfigImpl config = new JAXBConfigImpl(baseProps);
038        ConfigContext.init(config);
039
040        context = new ClassPathXmlApplicationContext(bootstrapSpringBeans);
041
042        context.start();
043        long endInit = System.currentTimeMillis();
044        LOG.info("...Kuali Rice Application successfully initialized, startup took " + (endInit - startInit) + " ms.");
045        SpringContext.finishInitializationAfterRiceStartup();
046        
047        SpringContext.initMemoryMonitor();
048        SpringContext.initMonitoringThread();
049    }
050
051}