XWork-Spring Container Hierarchy

本文详细介绍了XWork-Spring框架中容器层级的构造方式,包括应用范围、会话范围及请求范围容器的实现机制。揭示了如何通过不同的监听器和过滤器管理这些容器,并解释了组件查找的流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[size=medium]简言之,XWork-Spring 的 Container Hierarchy 按照从 parent 到 child 的顺序依次为:
application-scope containers,session-scope containers , request-scope containers。详细解释如下(源自:[url]http://jira.opensymphony.com/browse/XOP-1[/url]):
[/size]

[quote]The following describes how the spring container hierarchy is constructed.

ContextLoaderListener starts up Spring's root WebApplicationContext which becomes
the application-scope container. Once the web application has initialised this
can be retrieved using WebApplicationContextUtils.getWebApplicationContext(servletContext).
Bean definitions are stored on the classpath in a file whose location is specified by
the contextConfigLocation context-param in the webapp deployment descriptor (web.xml).

SpringSessionLifecycleListener manages session-scope containers.
Bean definitions are stored on the classpath in a file whose name is specified by the
RESOURCEPATH constant of the listener class. The container can be retrieved from
the session using the BEANFACTORY_KEY key.

SpringRequestLifecycleFilter manages request-scope containers. It sets each such
container on the request object and should be used in conjunction with
SpringWebInterceptor. This interceptor takes the container from the request and
puts it in the Action context. By this stage the full container hierarchy is
complete so SpringComponentInterceptor can be used to wire up an action's
dependencies. Alternatively another interceptor further down the stack could
retrieve the request-scope BeanFactory by using the following:

ActionContext.getContext().get(SpringComponentInterceptor.BEAN_FACTORY)

The request-scope container forms the top of the hierarchy so if a component is
requested by not found then the parent container (session) is tried. Likewise
if not found here its parent (application) is then tried.[/quote]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值