001    /**
002     * Copyright (c) 2000-2011 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            @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    }