View Javadoc
1   /*
2    * Copyright 2007 The Kuali Foundation.
3    *
4    * Licensed under the Educational Community License, Version 1.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/ecl1.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.ole.sys.context;
17  
18  import java.util.Properties;
19  
20  import org.kuali.rice.core.api.config.property.ConfigContext;
21  import org.kuali.rice.core.impl.config.property.JAXBConfigImpl;
22  import org.springframework.context.support.ClassPathXmlApplicationContext;
23  
24  public class SpringContextForBatchRunner {
25      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(SpringContextForBatchRunner.class);
26  
27      private static ClassPathXmlApplicationContext context;
28  
29      public static void initializeKfs() {
30          long startInit = System.currentTimeMillis();
31          LOG.info("Initializing Kuali Rice Application...");
32  
33          String bootstrapSpringBeans = "ole-startup.xml";
34  
35          Properties baseProps = new Properties();
36          baseProps.putAll(System.getProperties());
37          JAXBConfigImpl config = new JAXBConfigImpl(baseProps);
38          ConfigContext.init(config);
39  
40          context = new ClassPathXmlApplicationContext(bootstrapSpringBeans);
41  
42          context.start();
43          long endInit = System.currentTimeMillis();
44          LOG.info("...Kuali Rice Application successfully initialized, startup took " + (endInit - startInit) + " ms.");
45          SpringContext.finishInitializationAfterRiceStartup();
46          
47          SpringContext.initMemoryMonitor();
48          SpringContext.initMonitoringThread();
49      }
50  
51  }