1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
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  }