001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.spring.context;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    
020    import java.io.FileNotFoundException;
021    
022    import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
023    import org.springframework.context.support.ClassPathXmlApplicationContext;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     */
028    public class ArrayApplicationContext extends ClassPathXmlApplicationContext {
029    
030            public ArrayApplicationContext(String[] configLocations) {
031                    super(configLocations);
032            }
033    
034            protected void loadBeanDefinitions(XmlBeanDefinitionReader reader) {
035                    String[] configLocations = getConfigLocations();
036    
037                    if (configLocations == null) {
038                            return;
039                    }
040    
041                    for (String configLocation : configLocations) {
042                            try {
043                                    reader.loadBeanDefinitions(configLocation);
044                            }
045                            catch (Exception e) {
046                                    Throwable cause = e.getCause();
047    
048                                    if (cause instanceof FileNotFoundException) {
049                                            if (_log.isWarnEnabled()) {
050                                                    _log.warn(cause.getMessage());
051                                            }
052                                    }
053                                    else {
054                                            _log.error(e, e);
055                                    }
056                            }
057                    }
058            }
059    
060            private static Log _log = LogFactoryUtil.getLog(
061                    ArrayApplicationContext.class);
062    
063    }