您的位置:首页 > 编程语言 > Java开发

在EasyJWeb使用spring容器

2007-12-17 10:28 218 查看
在EasyJWeb里面可以使用spring容器来帮助管理bean: 在JWeb的配置文件中加入:<bean name="springContainer"
class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg type="java.lang.String[]">
<list>
<value>classpath:applicationContext.xml</value>
</list>
</constructor-arg>
</bean> <bean name="innerSpringContainer"
class="com.easyjf.container.impl.SpringContainer">
<property name="factory" ref="springContainer" />
</bean>其中的<list><value>classpath:dao.xml</value></list>为spring配置文件的路径,现在暂时使用的是ClassPathXmlApplicationContext。 现在在applicationContext.xml中配置一个bean(片断): <bean id="queryService"
class="com.easyjf.core.service.impl.QueryServiceImpl">
<property name="dao">
<bean parent="baseDAO">
<constructor-arg>
<value>java.lang.Object</value>
</constructor-arg>
</bean>
</property>
</bean> 然后在Action中:private IQueryService service; public void setService(IQueryService service) {
this.service = service;
} 在Action的配置中:<module name="nesource" path="/nesource" form="" scope="request"
...
<page name="edit" url="/cms/newsSourceEdit.html" type="template" />
<property name="service" ref="cmsManageService" /> ...
</module>在配置中用ref指定spring中的bean。好,到这里就OK了。easyJWeb会在框架初始化的时候发现spring容器并初始化,并从其中加载需要的bean 。 该功能暂定如此,还会有更多细节的改进。请继续关注。谢谢!

(注:本文作者,EasyJF开源团队 stef_wu,转载请保留作者声明!)

Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1535034
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: