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