1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.spring.context;
16  
17  import com.liferay.portal.kernel.log.Log;
18  import com.liferay.portal.kernel.log.LogFactoryUtil;
19  
20  import java.io.FileNotFoundException;
21  
22  import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
23  import org.springframework.context.support.ClassPathXmlApplicationContext;
24  
25  /**
26   * <a href="ArrayApplicationContext.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Brian Wing Shun Chan
29   */
30  public class ArrayApplicationContext extends ClassPathXmlApplicationContext {
31  
32      public ArrayApplicationContext(String[] configLocations) {
33          super(configLocations);
34      }
35  
36      protected void loadBeanDefinitions(XmlBeanDefinitionReader reader) {
37          String[] configLocations = getConfigLocations();
38  
39          if (configLocations == null) {
40              return;
41          }
42  
43          for (String configLocation : configLocations) {
44              try {
45                  reader.loadBeanDefinitions(configLocation);
46              }
47              catch (Exception e) {
48                  Throwable cause = e.getCause();
49  
50                  if (cause instanceof FileNotFoundException) {
51                      if (_log.isWarnEnabled()) {
52                          _log.warn(cause.getMessage());
53                      }
54                  }
55                  else {
56                      _log.error(e, e);
57                  }
58              }
59          }
60      }
61  
62      private static Log _log = LogFactoryUtil.getLog(
63          ArrayApplicationContext.class);
64  
65  }