Liferay spring mvc portlets webapplication context

时间:2013-03-21 12:05:42

标签: spring liferay

我有一个war文件,里面有10个portlet。 所以在每个acc-portlet.xml(所有10个portlets.xml)中,我已经在其中添加了spring inject beans声明,并且我有common.xml,它通常在其中的portlet中使用bean并使用tag在其中导入此xml文件每个portlet xml文件。

在portlet的控制器类中,我实现了ApplicationContextAware。 当我打印applicationcontext时,我实际上看到10 diff webapplicationcontext。

但根据我的理解(如果我没有错),应该只有webapplicationcontext,因为这是一场战争。

由于我在每个portlet中导入了common.xml,因此spring会为每个portlet实例化单例bean。

查看日志内容:

13:03:44,795 INFO  [XmlPortletApplicationContext:500] Refreshing PortletApplicationContext for namespace 'acc1-portlet': startup date [Thu Mar 21 13:03:44 GMT 2013]; parent: Root WebApplicationContext
13:03:44,795 INFO  [XmlBeanDefinitionReader:315] Loading XML bean definitions from PortletContext resource [/WEB-INF/acc1-portlet.xml]
13:03:44,827 INFO  [XmlBeanDefinitionReader:315] Loading XML bean definitions from PortletContext resource [/WEB-INF/common.xml]
13:03:44,858 INFO  [DefaultListableBeanFactory:581] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@e894e0: defining beans [org.springframework.web.servlet.handler.SimpleMappingExceptionResolver#0,viewResolver,messageSource,jaxbMarshaller


13:03:44,795 INFO  [XmlPortletApplicationContext:500] Refreshing PortletApplicationContext for namespace 'bcc1-portlet': startup date [Thu Mar 21 13:03:44 GMT 2013]; parent: Root WebApplicationContext
13:03:44,795 INFO  [XmlBeanDefinitionReader:315] Loading XML bean definitions from PortletContext resource [/WEB-INF/bcc1-portlet.xml]
13:03:44,827 INFO  [XmlBeanDefinitionReader:315] Loading XML bean definitions from PortletContext resource [/WEB-INF/common.xml]
13:03:44,858 INFO  [DefaultListableBeanFactory:581] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@e894e0: defining beans [org.springframework.web.servlet.handler.SimpleMappingExceptionResolver#0,viewResolver,messageSource,jaxbMarshaller.

如何使common.xml内容只加载一次并有一个signle spring applicationcontext?

0 个答案:

没有答案
相关问题