001    /**
002     * Copyright (c) 2000-2013 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            @Override
035            protected void loadBeanDefinitions(XmlBeanDefinitionReader reader) {
036                    String[] configLocations = getConfigLocations();
037    
038                    if (configLocations == null) {
039                            return;
040                    }
041    
042                    for (String configLocation : configLocations) {
043                            try {
044                                    reader.loadBeanDefinitions(configLocation);
045                            }
046                            catch (Exception e) {
047                                    Throwable cause = e.getCause();
048    
049                                    if (cause instanceof FileNotFoundException) {
050                                            if (_log.isWarnEnabled()) {
051                                                    _log.warn(cause.getMessage());
052                                            }
053                                    }
054                                    else {
055                                            _log.error(e, e);
056                                    }
057                            }
058                    }
059            }
060    
061            private static Log _log = LogFactoryUtil.getLog(
062                    ArrayApplicationContext.class);
063    
064    }