Coverage Report - edu.sampleu.travel.infrastructure.TravelServiceLocator
 
Classes in this File Line Coverage Branch Coverage Complexity
TravelServiceLocator
0%
0/10
0%
0/4
2
 
 1  
 /**
 2  
  * Copyright 2005-2011 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 edu.sampleu.travel.infrastructure;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.apache.log4j.Logger;
 20  
 import org.springframework.context.ConfigurableApplicationContext;
 21  
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 22  
 
 23  
 /**
 24  
  * Initializes the Travel App Spring context.
 25  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 26  
  */
 27  0
 public class TravelServiceLocator {
 28  0
     private static final Logger LOG = Logger.getLogger(TravelServiceLocator.class);
 29  
 
 30  
     private static final String STANDARD_CONTEXT = "classpath:SampleAppBeans.xml";
 31  
     private static final String TEST_CONTEXT = "classpath:SampleAppBeans-test.xml";
 32  
 
 33  
     private static ConfigurableApplicationContext appContext;
 34  
 
 35  
         public static synchronized void initialize(boolean test) {
 36  0
                 if (appContext == null) {
 37  
                     final String[] resources;
 38  
                     // check if we are running in unit tests, and if so, add the test context resource
 39  0
                     if (test) {
 40  0
                         resources = new String[] { STANDARD_CONTEXT, TEST_CONTEXT };
 41  
                     } else {
 42  0
                         resources = new String[] { STANDARD_CONTEXT };
 43  
                     }
 44  0
                     LOG.info("Loading contexts: " + StringUtils.join(resources, ", "));
 45  0
                         appContext = new ClassPathXmlApplicationContext(resources);
 46  
                 }
 47  0
         }
 48  
 
 49  
         public static synchronized ConfigurableApplicationContext getAppContext() {
 50  0
                 return appContext;
 51  
         }        
 52  
 }