现在的位置: 首页 > 综合 > 正文

在EasyJWeb使用spring容器

2013年11月26日 ⁄ 综合 ⁄ 共 739字 ⁄ 字号 评论关闭
在EasyJWeb里面可以使用spring容器来帮助管理bean:
 
在JWeb的配置文件中加入:
   class="org.springframework.context.support.ClassPathXmlApplicationContext">
   
          classpath:applicationContext.xml
    
   

  
     class="com.easyjf.container.impl.SpringContainer">
      
其中的 classpath:dao.xml为spring配置文件的路径,
现在暂时使用的是ClassPathXmlApplicationContext。
 
现在在applicationContext.xml中配置一个bean(片断):
   class="com.easyjf.core.service.impl.QueryServiceImpl">
      
    
     java.lang.Object
    

   

  
 
 
然后在Action中:
private IQueryService service;
 public void setService(IQueryService service) {
  this.service = service;
 }
 
在Action的配置中:
   ...
       
  ...
  
在配置中用ref指定spring中的bean。
好,
到这里就OK了。
easyJWeb会在框架初始化的时候发现spring容器并初始化,
并从其中加载需要的bean 。
 
 
该功能暂定如此,
还会有更多细节的改进。
请继续关注。谢谢!

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

 

【上篇】
【下篇】

抱歉!评论已关闭.