起走时间

我的首页
文章
相册
圈子
留言
管理
 
    当前所在页面:首页>>文章>>Super IOC containers SuperContainer
Super IOC containers SuperContainer
    作者:威廉姆 来源:http://bloginside.cn/read.php/141678.htm 发表时间:2007-12-21

 
 

Even in JavaEE other java applications, containers become very important. Web containers, applet containers, EJB containers, containers is everywhere.
From the programmer's perspective, IOC containers is a very good thing, he is able to make us very flexible management components and dependent relationship. It is no exaggeration to say that Spring is relying on a set of full-featured, flexible containers IOC became rich. EasyJWeb characteristics as the fifth series of articles, we look at the IOC EasyJWeb containers characteristics.
If you read the brief EasyJWeb1.0, he will find not only a MVC. In order to achieve the target very good business management, calling for the core MVC in EasyJWeb, we provide a super IOC containers. This "super" reflected in the fact that he belongs to the container vessel, he can accommodate all other outstanding containers, and they have their own independent individual containers of organic necessary convergence, and together we need to do to complete the matter.
Of course, EasyJWeb also provide a simple IOC containers, or if you do not want to not come into contact with other containers, then you can only EasyJWeb the IOC containers, like writing is elegant, loose coupling of the JavaEE application.
The use of containers is very simple, but is fully configurable, you may need to Spring containers, Guice containers, or even EJB container is EasyJWeb into the SuperContainer to China. So in their respective professional fields, to work for you. See code :
  @ Inject (name = "personDao")
  Private GenericDAO <Person> dao;
Public void setDao (GenericDAO <Person> dao) (...
   Dao this.dao =;
  )

CrudAction In the above example, a DAO PersonAction need in order to work, and here we use the statement GenericDAO <Person, "and then the specific procedures DAO in the process of running from where the store where? EasyJWeb do not care about these things, you only need @ Inject label, tell us from the Super IOC containers Kai personDao one of the named object. This program runs in the process, from the Super EasyJWeb IOC containers called personDao find the target and injected into the Action, which has enabled us to Action to work properly.
Achieving Dependency injection and control reversal, this is not an unusual thing, every one IOC framework can realize this function. Not the same, not only from their own EasyJWeb the IOC containers to be dependent on targets, but also from any other IOC containers were the target. For instance, we can Spring containers personDao this configuration, or use Guice personDao to manage this, and even directly to the personDao stored in a separate server EJB containers. EasyJWeb will automatically go to find these places, and they can coordinate.
With Super IOC containers, the system administrator no longer worried about our business logic tier components of the management, the boss does not need to worry about the need to be replaced by the IOC containers cost of the transplant.
EasyJWeb the IOC to achieve the same containers of the automatic name, by category, such as injection, in addition to achieving a range of different life-cycle management of Bean. In the default situation, to support the singleton, prototype, session, request other types of Bean.
In addition, EasyJWeb, including CPUs RequestProcessor, validator Validator, abnormal processor ExceptionHandler category in the bottom of these core components, through the Super EasyJWeb containers to management. So you can very easily according to their own needs, the replacement of some components EasyJWeb.
Below are the EasyJWeb Super containers into containers Spring configuration :
<Bean name = "springContainer"
    Class = "org.springframework.web.context.support.XmlWebApplicationContext">
    <property Name="configLocations">
     <list>
      <value> WEB-INF/classes/application.xml </ value>
     </ List>
    </ Property>
   </ Bean>
   <Bean name = "innerSpringContainer"
    Class = "com.easyjf.container.impl.SpringContainer">
    <property Name="factory" ref="springContainer" />
   </ Bean>

 

The Spring container EasyJWeb CPU configuration, or even can be configured affairs, such as the Spring following configuration :
 
<? Xml version = "1.0" encoding = "UTF-8"? >
<Beans xmlns = "http://www.springframework.org/schema/beans"
  Xmlns : xsi = "http://www.w3.org/2001/XMLSchema-instance"
  Xmlns : AOR = "http://www.springframework.org/schema/aop"
  Xmlns : tx = "http://www.springframework.org/schema/tx"
  Thrown : schemaLocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        Http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
        Http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd ">
  <import Resource="jpa-base.xml"/>
  <import Resource="service.xml"/>
  <import Resource="dao.xml"/>
  <aop:config>
   <AOR : pointcut id = "easyjwebProcessor"
    Expression = "execution (* com.easyjf.web.RequestProcessor.process (..))" />
   <AOR : advisor advice - ref = "txEasyjwebProcessorAdvice"
    Pointcut - ref = "easyjwebProcessor" />
  </ AOR : config>
  <Tx : advice id = "txEasyjwebProcessorAdvice"
   Transaction-manager = "transactionManager">
   <tx:attributes>
    <tx:method Name="*" propagation="REQUIRED" read-only="true" />
   </ Tx : attributes>
  </ Tx : advice>
  <bean Name="EasyJWeb-Processor" class="com.easyjf.web.core.DefaultRequestProcessor"/>

 
 

(阅读 )   评论数(:0)
评论】 【收藏】
评论:共0条

发表评论:
发表人:
评论: 
    
 
关于我们 | 诚聘英才 | 联系我们 | 广告业务 | 网站地图 | 法律声明

EasyJF开源团队版权所有  建议使用1024*768分辨率