001
014
015 package com.liferay.portal.spring.context;
016
017 import com.liferay.portal.bean.BeanLocatorImpl;
018 import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
019 import com.liferay.portal.kernel.log.Log;
020 import com.liferay.portal.kernel.log.LogFactoryUtil;
021
022 import java.io.FileNotFoundException;
023
024 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
025 import org.springframework.context.ApplicationContext;
026 import org.springframework.web.context.support.XmlWebApplicationContext;
027
028
031 public class TunnelApplicationContext extends XmlWebApplicationContext {
032
033 public void setParent(ApplicationContext parent) {
034 if (parent == null) {
035 BeanLocatorImpl beanLocatorImpl =
036 (BeanLocatorImpl)PortalBeanLocatorUtil.getBeanLocator();
037
038 parent = beanLocatorImpl.getApplicationContext();
039 }
040
041 super.setParent(parent);
042 }
043
044 protected void loadBeanDefinitions(XmlBeanDefinitionReader reader) {
045 String[] configLocations = getConfigLocations();
046
047 if (configLocations == null) {
048 return;
049 }
050
051 for (String configLocation : configLocations) {
052 try {
053 reader.loadBeanDefinitions(configLocation);
054 }
055 catch (Exception e) {
056 Throwable cause = e.getCause();
057
058 if (cause instanceof FileNotFoundException) {
059 if (_log.isWarnEnabled()) {
060 _log.warn(cause.getMessage());
061 }
062 }
063 else {
064 _log.error(e, e);
065 }
066 }
067 }
068 }
069
070 private static Log _log = LogFactoryUtil.getLog(
071 TunnelApplicationContext.class);
072
073 }