001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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    }