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 @Override
034 public void setParent(ApplicationContext parent) {
035 if (parent == null) {
036 BeanLocatorImpl beanLocatorImpl =
037 (BeanLocatorImpl)PortalBeanLocatorUtil.getBeanLocator();
038
039 parent = beanLocatorImpl.getApplicationContext();
040 }
041
042 super.setParent(parent);
043 }
044
045 @Override
046 protected void loadBeanDefinitions(XmlBeanDefinitionReader reader) {
047 String[] configLocations = getConfigLocations();
048
049 if (configLocations == null) {
050 return;
051 }
052
053 for (String configLocation : configLocations) {
054 try {
055 reader.loadBeanDefinitions(configLocation);
056 }
057 catch (Exception e) {
058 Throwable cause = e.getCause();
059
060 if (cause instanceof FileNotFoundException) {
061 if (_log.isWarnEnabled()) {
062 _log.warn(cause.getMessage());
063 }
064 }
065 else {
066 _log.error(e, e);
067 }
068 }
069 }
070 }
071
072 private static Log _log = LogFactoryUtil.getLog(
073 TunnelApplicationContext.class);
074
075 }