1
19
20 package com.liferay.portal.spring.context;
21
22 import com.liferay.portal.bean.BeanLocatorImpl;
23 import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
24 import com.liferay.portal.kernel.log.Log;
25 import com.liferay.portal.kernel.log.LogFactoryUtil;
26
27 import java.io.FileNotFoundException;
28
29 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
30 import org.springframework.context.ApplicationContext;
31 import org.springframework.web.context.support.XmlWebApplicationContext;
32
33
39 public class TunnelApplicationContext extends XmlWebApplicationContext {
40
41 public void setParent(ApplicationContext parent) {
42 if (parent == null) {
43 BeanLocatorImpl beanLocatorImpl =
44 (BeanLocatorImpl)PortalBeanLocatorUtil.getBeanLocator();
45
46 parent = beanLocatorImpl.getApplicationContext();
47 }
48
49 super.setParent(parent);
50 }
51
52 protected void loadBeanDefinitions(XmlBeanDefinitionReader reader) {
53 String[] configLocations = getConfigLocations();
54
55 if (configLocations == null) {
56 return;
57 }
58
59 for (String configLocation : configLocations) {
60 try {
61 reader.loadBeanDefinitions(configLocation);
62 }
63 catch (Exception e) {
64 Throwable cause = e.getCause();
65
66 if (cause instanceof FileNotFoundException) {
67 if (_log.isWarnEnabled()) {
68 _log.warn(cause.getMessage());
69 }
70 }
71 else {
72 _log.error(e, e);
73 }
74 }
75 }
76 }
77
78 private static Log _log =
79 LogFactoryUtil.getLog(TunnelApplicationContext.class);
80
81 }