??xml version="1.0" encoding="utf-8" standalone="yes"?>伊人成人在线视频,国产专区一区,久久影院一区二区三区http://www.aygfsteel.com/improviser/category/26126.html思维是一U艺术,艺术需要灵?/description>zh-cnMon, 05 Nov 2007 04:13:20 GMTMon, 05 Nov 2007 04:13:20 GMT60偉Spring MVChttp://www.aygfsteel.com/improviser/archive/2007/11/04/158025.htmlimproviserimproviserSun, 04 Nov 2007 02:44:00 GMThttp://www.aygfsteel.com/improviser/archive/2007/11/04/158025.htmlhttp://www.aygfsteel.com/improviser/comments/158025.htmlhttp://www.aygfsteel.com/improviser/archive/2007/11/04/158025.html#Feedback5http://www.aygfsteel.com/improviser/comments/commentRss/158025.htmlhttp://www.aygfsteel.com/improviser/services/trackbacks/158025.html    个h认ؓSpring其核心是其IOC和AOP斚wQ对其SpirngMVC框架q不xQ我看好的是JSFQ简单易懂。但最q由于工作上需要,所以有需要对SpringMVC做个了解学习Q因此,本次对SpirngMVC的相遇纯属偶?...
    SpingMVC的架构其实也很简单,它通过一个共通的入门DispatcherServlet来接收所有的requestQ接下来Ҏrequest要求的页面通过handler转送给Controller处理Q处理结果返回Viewl用P因此对SpringMVC来说Q其核心为DispatcherServlet?br />    DispatcherServlet作ؓ一扇门Q我们要使用q个门,首先得安装上q个门,安装在哪呢?没错Q就安装在web.xmlq个大屋子,象其他servlet一P描述servlet的名字和c,再给他一个mapping描述对应映射的网c在下例中,我们lDispatcherServlet的v名ؓSpringMVCDemoQ?/font>q让container知道所?dol尾的request都丟ldispatcher?/span>
     < servlet >
        
< servlet-name > SpringMVCDemo </ servlet-name >
        
< servlet-class >
            org.springframework.web.servlet.DispatcherServlet
        
</ servlet-class >
        
< load-on-startup > 1 </ load-on-startup >
    
</ servlet >

    
< servlet-mapping >
        
< servlet-name > SpringMVCDemo </ servlet-name >
        
< url-pattern > *.do </ url-pattern >
    
</ servlet-mapping >
    门安装好了之后,我们需要定义门能打开的范_在哪定义呢?在门的上面贴上一张“入门指导”,介绍从哪斚w(hello.do)q门需要用何U交通方?springmvcController)q去Qƈ定义该交通方式?/font>
     < bean  id ="urlMapping"
        class
="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping" >
        
< property  name ="mappings" >
            
< props >
                
< prop  key ="/hello.do" > springmvcController </ prop >
            
</ props >
        
</ property >
    
</ bean >

    
<!--  SpringmvcController  -->
    
< bean  id ="springmvcController"
        class
="org.improviser.webapp.controller.SpringmvcController" >
    
</ bean >
    接下来该渲染一下页面了Q下面ؓ渲染所有以
WEB-INF/pages/ 开?/font>Q?font color="#0000ff">q以.jspl尾的页面?/font>
     <!--  ViewSolver  -->
    
< bean  id ="viewResolver"
        class
="org.springframework.web.servlet.view.InternalResourceViewResolver" >
        
< property  name ="viewClass" >
            
< value > org.springframework.web.servlet.view.JstlView </ value >
        
</ property >
        
< property  name ="prefix" >
            
< value > /WEB-INF/pages/ </ value >
        
</ property >
        
< property  name ="suffix" >
            
< value > .jsp </ value >
        
</ property >
    
</ bean >
   上面提到的SpringmvcControllerQ?/font>现在该作个定义了Q该c需要实现Controller接口?/font>
public class SpringmvcController implements Controller {
    
/** Logger for this class and subclasses */
    
protected final Log logger = LogFactory.getLog(getClass());

    
public ModelAndView handleRequest(HttpServletRequest request,
            HttpServletResponse response) 
throws ServletException, IOException {

        Map model 
= new HashMap();

        String str
= "卛_诗h";
        logger.info(
"returning hello view with " + currTime);
        model.put(
"coldice", str);

        
return new ModelAndView("hello""message", model);
    }
   ~写jsp试面?/font>
<html>
    
<head>
        
<title>Spring Application</title>
    
</head>
    
<body>
        
<h1>
            
<br />
            Hello
            <c:out value="${message.coldice}" /></br>
            Spring MVC 试成功Q?br />        </h1>
    
</body>
</html>
    现在对以上内容作个ȝQ正如上面所叙述QSpringMVC框架的处理过E机制如下图所C,接收h面Q通过DispatcherServlet映射到相应规则处理,q找到相应的控制器,l果控制器处理后q回相应的页面最后返回给用户?/font>
138199405_8b54d56b71_o.png



improviser 2007-11-04 10:44 发表评论
]]>
SpringW记之十QSpring研读ȝQ?/title><link>http://www.aygfsteel.com/improviser/archive/2007/09/29/149474.html</link><dc:creator>improviser</dc:creator><author>improviser</author><pubDate>Sat, 29 Sep 2007 02:07:00 GMT</pubDate><guid>http://www.aygfsteel.com/improviser/archive/2007/09/29/149474.html</guid><wfw:comment>http://www.aygfsteel.com/improviser/comments/149474.html</wfw:comment><comments>http://www.aygfsteel.com/improviser/archive/2007/09/29/149474.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.aygfsteel.com/improviser/comments/commentRss/149474.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/improviser/services/trackbacks/149474.html</trackback:ping><description><![CDATA[ <font color="#0000ff">    </font> <font color="#0000ff" size="4">通过q几天对Spring的研读,剖析了Spring的基本核心模块——IoC和AOP。今天将对其作个基础性的ȝ?br /><br />     Spring 是一个开源框Ӟ是ؓ了解决企业应用程序开发复杂性而创建的。框架的主要优势之一是其分层架构,分层架构允许您选择使用哪一个组Ӟ模块构徏在核心容器之上,核心容器定义了创建、配|和理 bean 的方?同时?J2EE 应用E序开发提供集成的框架。其中作为Spring的核心模块即是Spring面向斚w~程(AOP)和控制反?IOC)容器。Spring 设计的核心是 <code>org.springframework.beans</code> 包,<code>BeanFactory</code><code>BeanFactory</code> 支持两个对象模型单态和原型?code>BeanFactory</code>是Spring作ؓIOC 容器的基?br /><br />    控制反{模式Q不创徏对象Q但是描q创建它们的方式。在代码中不直接与对象和服务q接Q但在配|文件中描述哪一个组仉要哪一Ҏ务。容器(?Spring 框架中是 IOC 容器Q负责将q些联系在一赗在典型?IOC 场景中,容器创徏了所有对象,q设|必要的属性将它们q接在一P军_什么时间调用方法。IOC 的一个实现模?通过接口、通过 JavaBean 的属性、依赖性以构造函数的形式提供?br /><br />    面向斚w的编E,?AOPQ是一U编E技术,它允许程序员Ҏ切关注点或横切典型的职责分界U的行ؓQ例如日志和事务理Q进行模块化。AOP 的核心构造是斚wQ它那些媄响多个类的行为封装到可重用的模块中。AOP ?IOC 是补充性的技术,它们都运用模块化方式解决企业应用E序开发中的复杂问题。在典型的面向对象开发方式中Q可能要日志记录语句放在所有方法和 Java cM才能实现日志功能。在 AOP 方式中,可以反过来将日志服务模块化,q以声明的方式将它们应用到需要日志的lg上。当Ӟ优势是 Java cM需要知道日志服务的存在Q也不需要考虑相关的代码。所以,?Spring AOP ~写的应用程序代码是松散耦合的。AOP 的功能完全集成到?Spring 事务理、日志和其他各种Ҏ的上下文中?/font> <img src ="http://www.aygfsteel.com/improviser/aggbug/149474.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/improviser/" target="_blank">improviser</a> 2007-09-29 10:07 <a href="http://www.aygfsteel.com/improviser/archive/2007/09/29/149474.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SpringW记之九QAOP in SpringQ?/title><link>http://www.aygfsteel.com/improviser/archive/2007/09/29/149406.html</link><dc:creator>improviser</dc:creator><author>improviser</author><pubDate>Fri, 28 Sep 2007 17:50:00 GMT</pubDate><guid>http://www.aygfsteel.com/improviser/archive/2007/09/29/149406.html</guid><wfw:comment>http://www.aygfsteel.com/improviser/comments/149406.html</wfw:comment><comments>http://www.aygfsteel.com/improviser/archive/2007/09/29/149406.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.aygfsteel.com/improviser/comments/commentRss/149406.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/improviser/services/trackbacks/149406.html</trackback:ping><description><![CDATA[    <font size="4"><font color="#0000ff">Spring IoC?Spring AOPl合Q一起Ş成了SpringQ这样一个有机整体,使得构徏轻量U的J2EE架构成ؓ可能Q而且事实证明Q非常有效。没有Spring IoC的Spring AOP是不完善的,没有Spring AOP的Spring IoC是不健壮的?本文研究Spring框架中的面向斚w~?Aspect-Oriented ProgrammingQAOP)Q进而通过例子解析如何q用Spring中的所有通知cd和切入点来实现更实用的方面和面向斚w设计模式?/font><br /><br />    <b><font color="#000080">AOP概念Q?/font></b><br />    <font color="#000080"><b>AdviceQ?/b></font><font color="#0000ff">如何before通知、afterReturning通知和afterThrowing通知声明为bean?/font><br /> <font color="#000080"><b>Pointcut</b></font><b>Q?/b><font color="#0000ff">如何声明静态切入点逻辑以将XML Spring Bean Configuration文g中的所有内容联pd一赗?</font><br /> <font color="#000080"><b>AdvisorQ?/b></font><font color="#0000ff">兌切入点定义与通知bean的方式?/font><br /><br /><span style="font-size: 12pt; font-family: 宋体;" lang="EN-US">    <font color="#0000ff">Spring AOP</font></span><font color="#0000ff"><span style="font-size: 12pt; font-family: 宋体;">是用代理来完成的,<span lang="EN-US">Spring </span>两种方式Q?span lang="EN-US"></span><span lang="EN-US">JDK</span>动态代理,需要设定一l代理接口;<span lang="EN-US"></span><span lang="EN-US">CGLIB </span>代理Q可代理接口和类?span lang="EN-US"></span><span lang="EN-US"></span><span lang="EN-US"></span></span>Spring提供?UAdvicecdQInterception Around、Before、After Returning、Throw和Introduction。它们分别在以下情况下被调用Q在JointPoint前后、JointPoint前? JointPoint后、JointPoint抛出异常时、JointPoint调用完毕后?br /></font><br /><font color="#800080"><b>配置文gQ?/b></font></font><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">beans</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">bean </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">="myAOPProxy"</span><span style="color: rgb(255, 0, 0);"><br />             class</span><span style="color: rgb(0, 0, 255);">="org.springframework.aop.framework.ProxyFactoryBean"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">property </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="proxyInterfaces"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);">ITest</span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">property</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">property </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="target"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">ref </span><span style="color: rgb(255, 0, 0);">local </span><span style="color: rgb(0, 0, 255);">= "test"</span><span style="color: rgb(0, 0, 255);">/></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">property</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">property </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="interceptorNames"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);">myPotincutAdvisor</span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">property</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">bean</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 0, 0);">    <br /></span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">bean </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">="test"</span><span style="color: rgb(255, 0, 0);"> class</span><span style="color: rgb(0, 0, 255);">="Test"</span><span style="color: rgb(0, 0, 255);">/></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">15</span> <span style="color: rgb(0, 0, 0);">    <br /></span><span style="color: rgb(0, 128, 128);">16</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">bean </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">="MyInterceptor"</span><span style="color: rgb(255, 0, 0);"> class</span><span style="color: rgb(0, 0, 255);">="MethodTimeCostInterceptor"</span><span style="color: rgb(0, 0, 255);">/></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">17</span> <span style="color: rgb(0, 0, 0);">    <br /></span><span style="color: rgb(0, 128, 128);">18</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">bean </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">="myPotincutAdvisor"</span><span style="color: rgb(255, 0, 0);"><br />             class</span><span style="color: rgb(0, 0, 255);">="org.springframework.aop.support.RegexpMethodPointcutAdvisor"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">19</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">property </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="advice"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">20</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">ref </span><span style="color: rgb(255, 0, 0);">local</span><span style="color: rgb(0, 0, 255);">="MyInterceptor"</span><span style="color: rgb(0, 0, 255);">/></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">21</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">property</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">22</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">property </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="patterns"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">23</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">list</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">24</span> <span style="color: rgb(0, 0, 0);">                </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);">.*</span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">25</span> <span style="color: rgb(0, 0, 0);">                </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);">.*</span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">26</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">list</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">27</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">property</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">28</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">bean</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">29</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">beans</span><span style="color: rgb(0, 0, 255);">></span></div><br /><font size="4"><b><font color="#800080">分析代码Q?/font></b><br /><font color="#0000ff">1</font>?span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">bean </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">="myAOPProxy"</span><span style="color: rgb(255, 0, 0);"><br />     class</span><span style="color: rgb(0, 0, 255);">="org.springframework.aop.framework.ProxyFactoryBean"</span><span style="color: rgb(0, 0, 255);">>声明注入了代理实例myAOPProxy</span><span style="color: rgb(0, 0, 255);">?       <br />2?proxyInterfaces声明被代理接口ITest?/span><br /><span style="color: rgb(0, 0, 255);">3?target声明被代理目的类?br /></span><font color="#0000ff">4</font>?<span style="color: rgb(0, 0, 255);">interceptorNames讄拦截器ؓ</span><span style="color: rgb(0, 0, 255);"></span><font color="#330000"><span style="color: rgb(0, 0, 0);">myPotincutAdvisor</span></font><span style="color: rgb(0, 0, 255);">?br />5?</span></font><span style="color: rgb(0, 0, 255);"><font size="4">patterns为拦截器讄配匹方式Q即在所被配Ҏ功的Ҏ被调用时执行拦截器内宏V?/font><br /><font size="4"><br /></font></span><font size="4">    </font><font color="#993300"><font size="4">该配|文Ӟ指定要加载一个接口与ITest相匹配的bean。该bean随后被关联到Test实现cR看h好像是费了很大力气只Z加蝲一个简单的beanq调用一个方法,但是q个配置文g只是? Spring框架可以透明地对应用E序应用其组件的众多Ҏ的一个体?/font>?/font><br /><img src ="http://www.aygfsteel.com/improviser/aggbug/149406.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/improviser/" target="_blank">improviser</a> 2007-09-29 01:50 <a href="http://www.aygfsteel.com/improviser/archive/2007/09/29/149406.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SpringW记之八QInternationalization of springQ?/title><link>http://www.aygfsteel.com/improviser/archive/2007/09/27/148476.html</link><dc:creator>improviser</dc:creator><author>improviser</author><pubDate>Wed, 26 Sep 2007 17:00:00 GMT</pubDate><guid>http://www.aygfsteel.com/improviser/archive/2007/09/27/148476.html</guid><wfw:comment>http://www.aygfsteel.com/improviser/comments/148476.html</wfw:comment><comments>http://www.aygfsteel.com/improviser/archive/2007/09/27/148476.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.aygfsteel.com/improviser/comments/commentRss/148476.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/improviser/services/trackbacks/148476.html</trackback:ping><description><![CDATA[ <font size="4"> <span style="font-size: 10.5pt; font-family: 宋体;"> <font size="4">    <font color="#cc0000" size="4">国际化支持在实际开发中可能是最常用的特性,本文分析Spring?/font></font> <font size="4"> </font> </span> <font color="#cc0000" size="4"> <span style="font-family: 宋体;" lang="EN-US">ApplicationContext</span> </font> </font> <font color="#cc0000" size="4"> <span style="font-family: 宋体;">提供国际化支持,</span> <span style="font-family: 宋体;">其提供了更加强大的功能,如信息的自动装配以及热部|功能(配置文g修改后自动读取,而无需重新启动应用E序Q?span lang="EN-US"><o:p></o:p></span></span> </font> <span style="font-family: 宋体;"> <font color="#cc0000" size="4"> <br />    目前<span lang="EN-US">Spring</span>中提供了两个<span lang="EN-US"> MessageSource</span>接口的实玎ͼ?span lang="EN-US">ResourceBundleMessageSource</span>?span lang="EN-US">ReloadableResourceBundleMessageSource</span>Q后者提供了无需重启卛_重新加蝲配置信息的特性?/font> <font size="5"> </font> <br /> </span> <span style="font-family: 宋体;">    <br />   <font color="#666600" size="4"> 在下面的配置文g中,通过<span lang="EN-US">MessageResource</span>的一个实现类<span lang="EN-US">org.springframework.context.support.ResourceBundleMessageSource</span>来获得国际化的信息?/font><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">beans</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">description</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);">Spring Quick Start</span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">description</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">bean </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">="messageSource"</span><span style="color: rgb(255, 0, 0);"><br />     class</span><span style="color: rgb(0, 0, 255);">="org.springframework.context.support.ResourceBundleMessageSource"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">property </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="basenames"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">list</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);">messages</span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">list</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">property</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">bean</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">beans</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);"></span></div><br /></span> <p class="MsoNormal" style="text-indent: 21pt;"> <font color="#006600" size="4"> <span style="font-family: 宋体;">q里声明了一个名?/span> <b style=""> <span style="font-family: 宋体;" lang="EN-US">messageSource</span> </b> <span style="font-family: 宋体;">?span lang="EN-US">Bean</span>Q?/span> <b style=""> <span style="font-family: 宋体;">注意Q?/span> </b> </font> <font color="#006600"> <span style="font-family: 宋体;"> <font size="4">对于<span lang="EN-US">Message</span>定义Q?span lang="EN-US">Bean ID</span>必须?span lang="EN-US">messageSource</span>Q这是目?span lang="EN-US">Spring</span>的编码规U)Q对应类?span lang="EN-US">ResourceBundleMessageSource</span>?/font> <span lang="EN-US"> <o:p> </o:p> </span> </span> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <span style="font-family: 宋体;"> <font color="#663300" size="4">而其中的<span lang="EN-US">basename</span>属性用來设定资源信息文件的前置文g名称Q在本例中ؓ<span lang="EN-US">messages</span>?span lang="EN-US">Spring</span>会自动在<span lang="EN-US">CLASSPATH</span>根\径中按照如下序搜寻资源信息文gq进行加载(?span lang="EN-US">Locale</span>?span lang="EN-US">zh_CN</span>ZQ其?span lang="EN-US">Spring</span>在实际上调用?span lang="EN-US">JDK</span>?span lang="EN-US">ResourceBundle</span>d配置文gQ?/font> <span lang="EN-US"> <font color="#339900" size="4">:</font> <o:p> </o:p> </span> </span> </p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: 21pt;"> <font color="#333300" size="4"> <span style="font-family: 宋体;" lang="EN-US">messages_zh_CN.properties<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: 21pt;"> <font color="#333300" size="4"> <span style="font-family: 宋体;" lang="EN-US">messages_zh.properties<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: 21pt;"> <font color="#333300" size="4"> <span style="font-family: 宋体;" lang="EN-US">messages.properties<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: 21pt;"> <font color="#333300" size="4"> <span style="position: relative; z-index: 1;"> </span> <span style="font-family: 宋体;" lang="EN-US">messages_zh_CN.class<o:p></o:p></span> </font> <!--[endif]--> </p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: 21pt;"> <font color="#333300" size="4"> <span style="font-family: 宋体;" lang="EN-US">messages_zh.class<o:p></o:p></span> </font> </p> <p class="MsoNormal" style="margin-left: 21pt; text-indent: 21pt;"> <font color="#333300" size="4"> <span style="font-family: 宋体;" lang="EN-US">messages.class</span> </font> </p> <p class="MsoNormal" style="margin-left: 42pt; text-indent: -21pt;"> <!--[if !supportLists]--> <font color="#330000" size="4"> <span style="font-family: 宋体;">资源配置信息文g中的内容</span> </font> </p> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <font size="3"> <span style="color: rgb(0, 128, 128);">1</span> <span style="color: rgb(0, 0, 0);">messages_zh_CN.propertiesQ?br /></span><span style="color: rgb(0, 128, 128);">2</span> <span style="color: rgb(0, 0, 0);">userinfo</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">当前d用户: </span><span style="color: rgb(128, 0, 0); font-weight: bold;">[</span><span style="color: rgb(128, 0, 0);">{0}</span><span style="color: rgb(128, 0, 0); font-weight: bold;">]</span><span style="color: rgb(0, 0, 0);"> d旉:</span><span style="color: rgb(128, 0, 0); font-weight: bold;">[</span><span style="color: rgb(128, 0, 0);">{1}</span><span style="color: rgb(128, 0, 0); font-weight: bold;">]</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">3</span> <span style="color: rgb(0, 0, 0);">messages_en_US.propertiesQ?br /></span><span style="color: rgb(0, 128, 128);">4</span> <span style="color: rgb(0, 0, 0);">userinfo</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">Current Login user: </span><span style="color: rgb(128, 0, 0); font-weight: bold;">[</span><span style="color: rgb(128, 0, 0);">{0}</span><span style="color: rgb(128, 0, 0); font-weight: bold;">]</span><span style="color: rgb(0, 0, 0);"> Login time:</span><span style="color: rgb(128, 0, 0); font-weight: bold;">[</span><span style="color: rgb(128, 0, 0);">{1}</span><span style="color: rgb(128, 0, 0); font-weight: bold;">]</span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">5</span> </font> <span style="color: rgb(0, 0, 0);"> </span> </div> <br />  <b><font color="#333300">试代码Q?/font></b><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><font size="3"><span style="color: rgb(0, 128, 128);">1</span> <span style="color: rgb(0, 0, 0);">ApplicationContext ctx</span><span style="color: rgb(0, 0, 0);"> = <br />                </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> FileSystemXmlApplicationContext(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">bean.xml</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">2</span> <span style="color: rgb(0, 0, 0);">Object[] arg </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> Object[]<br /></span><span style="color: rgb(0, 128, 128);">3</span> <span style="color: rgb(0, 0, 0);">{ </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Erica</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, Calendar.getInstance().getTime()<br /></span><span style="color: rgb(0, 128, 128);">4</span> <span style="color: rgb(0, 0, 0);">};<br /></span><span style="color: rgb(0, 128, 128);">5</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 128, 0);">//</span><span style="color: rgb(0, 128, 0);">以系l默认Locale加蝲信息(对于中文WinXP而言Q默认ؓzh_CN)</span><span style="color: rgb(0, 128, 0);"><br /></span><span style="color: rgb(0, 128, 128);">6</span> <span style="color: rgb(0, 128, 0);"></span><span style="color: rgb(0, 0, 0);">String msg </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> ctx.getMessage(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">userinfo</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">, arg);<br /></span><span style="color: rgb(0, 128, 128);">7</span> <span style="color: rgb(0, 0, 0);">System.out.println(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Message is ===> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);">msg);<br /></span><span style="color: rgb(0, 128, 128);">8</span> </font><span style="color: rgb(0, 0, 0);"></span></div><br /><p class="MsoNormal" style="text-indent: 21pt;"><font color="#996600" face="Georgia" size="4"><span style="font-family: 宋体;" lang="EN-US">代码中,我们一?span lang="EN-US">Object</span>数组<span lang="EN-US">arg</span>作ؓ参数传递给<span lang="EN-US">ApplicationContext.getMessage</span>ҎQ这个参C包含了出现在最l文字信息中的可变内容,<span lang="EN-US">ApplicationContext</span>  根据参C?span lang="EN-US">Locale</span>信息对其q行处理Q如针对不同<span lang="EN-US">   Locale</span>讑֮日期输出格式Q,q用其替换配|文件中?span lang="EN-US">{n}</span>标识Q?span lang="EN-US">n</span>代表参数数组中的索引Q从<span lang="EN-US">1  </span>开始)?span lang="EN-US"><o:p></o:p></span><br /></span></font></p><p class="MsoNormal" style="text-indent: 21pt;"><font color="#996600" face="Georgia" size="4"><span style="font-family: 宋体;" lang="EN-US">q行上面的代码,得到以下输出的内容:<span lang="EN-US"><o:p></o:p></span><br />   Message is ===> |</span></font><font color="#996600" face="Georgia" size="4"><span style="font-family: 宋体;">ì〃?span lang="EN-US">?</span><span lang="EN-US">|</span>ì<span lang="EN-US">???</span>t<span lang="EN-US">???</span>?span lang="EN-US">: [Erica] |</span>ì<span lang="EN-US">???</span>t<span lang="EN-US">o</span>〃?span lang="EN-US">??:[07-9-27 </span>上午1<span lang="EN-US">:27]</span></span></font></p><p class="MsoNormal" style="text-indent: 21pt;"><font color="#996600" face="Georgia" size="4"><span style="font-family: 宋体;" lang="EN-US">针对<span lang="EN-US">ResourceBundle</span>的编码过E中发生的问题。这是由于{码过E中产生的编码问题引发的。比较简单的解决办法是通过<span lang="EN-US">JDK</span>提供的{码工?span lang="EN-US">native2ascii.exe</span>  q行转换。执行:<span lang="EN-US"><o:p></o:p></span>native2ascii messages_zh_CN.properties msg.txt?o:p></o:p></span></font><font color="#996600" face="Georgia" size="4">再用<span lang="EN-US">msg.txt</span>文g替换<span lang="EN-US">Messages_zh_CN.properties</span>       文g?/font><font face="Georgia"><br /></font></p><font color="#996600" face="Georgia" size="4"><span style="font-family: 宋体;">   再次q行CZ代码Q得到正输出:<span lang="EN-US"><o:p></o:p></span></span></font><p class="MsoNormal"><font color="#996600" face="Georgia" size="4"><span style="font-family: 宋体;" lang="EN-US">   Message is ===> </span><span style="font-family: 宋体;">当前d用户<span lang="EN-US">: [Erica] </span>d旉<span lang="EN-US">:[07-9-27 </span>上午<span lang="EN-US">1:30]<o:p></o:p></span></span></font></p><p class="MsoNormal" style="text-indent: 21pt;"><font color="#996600" face="Georgia" size="4"><span style="font-family: 宋体;">试在代码中指定不同?span lang="EN-US">Locale</span>参数Q?span lang="EN-US"><o:p></o:p></span></span></font></p><p class="MsoNormal" style="text-indent: 21pt;"><font color="#996600" face="Times New Roman" size="4"><span style="font-family: 宋体;"><font face="Georgia">String msg = ctx.getMessage("userinfo", arg, Locale.US);<o:p></o:p>再次q行Q可以看刎ͼ</font><span lang="EN-US"><o:p></o:p></span></span></font></p><p class="MsoNormal" style="text-indent: 21pt;"><font color="#996600" face="Times New Roman" size="4"><span style="font-family: 宋体;" lang="EN-US">Message is ===> Current Login user: [Erica] Login time::[9/27/07 1:35AM]</span></font></p><p class="MsoNormal" style="text-indent: 21pt;"><b><font color="#663300" face="Times New Roman" size="4"><span style="font-family: 宋体;">可见Q前者根据当前默?span lang="EN-US">Locale"zh_CN"</span>Q?span lang="EN-US">getMessage</span>Ҏ自动加蝲?span lang="EN-US">messages_zh_CN.properties</span>文gQ后?/span><font face="Georgia"><span style="font-size: 10.5pt; font-family: 宋体;" lang="EN-US">getMessage</span><span style="font-size: 10.5pt; font-family: 宋体;">ҎҎ指定~码<span lang="EN-US">"en_US"</span>加蝲?span lang="EN-US">messages_en_US.properties</span>文g?/span></font></font></b></p><font color="#996600" face="Times New Roman" size="4"><br /><span style="font-family: 宋体;"><br /><span lang="EN-US"><o:p></o:p></span></span></font><p class="MsoNormal" style="text-indent: 21pt;"><span style="font-family: 宋体;"><br /><span lang="EN-US"><o:p></o:p></span></span></p><b style=""><span style="font-family: 宋体;"><span lang="EN-US"><o:p></o:p></span></span></b><img src ="http://www.aygfsteel.com/improviser/aggbug/148476.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/improviser/" target="_blank">improviser</a> 2007-09-27 01:00 <a href="http://www.aygfsteel.com/improviser/archive/2007/09/27/148476.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SpringW记之七QTypes of InjectionQ?/title><link>http://www.aygfsteel.com/improviser/archive/2007/09/26/148472.html</link><dc:creator>improviser</dc:creator><author>improviser</author><pubDate>Wed, 26 Sep 2007 15:59:00 GMT</pubDate><guid>http://www.aygfsteel.com/improviser/archive/2007/09/26/148472.html</guid><wfw:comment>http://www.aygfsteel.com/improviser/comments/148472.html</wfw:comment><comments>http://www.aygfsteel.com/improviser/archive/2007/09/26/148472.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/improviser/comments/commentRss/148472.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/improviser/services/trackbacks/148472.html</trackback:ping><description><![CDATA[ <p> <b>本文研究Spring的三U依赖注入实现类?/b>—?b style=""><span style="font-size: 10.5pt; font-family: 宋体;">接口注入Q?span lang="EN-US">Interface Injection</span>Q?/span></b><b style=""><span style="font-size: 10.5pt; font-family: 宋体;">讑ր注入(<span lang="EN-US">Setter Injection</span>Q?/span></b><b style=""><span style="font-size: 10.5pt; font-family: 宋体;">构造子注入Q?span lang="EN-US">Constructor Injection</span>Q?/span></b></p> <p> <b style=""> <span style="font-size: 10.5pt; font-family: 宋体;" lang="EN-US">Type1 </span> <span style="font-size: 10.5pt; font-family: 宋体;">接口注入Q?/span> </b> <font color="#663300" size="2"> <span style="font-size: 10.5pt; font-family: 宋体;">传统的创建接口对象的ҎQ?/span> </font> <font color="#663300"> <span style="font-size: 10.5pt; font-family: 宋体;">借助接口来将调用者与实现者分R如下面的代码所C:</span> </font> </p> <p> <span style="font-size: 10.5pt; font-family: 宋体;"> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> ClassA <br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> InterfaceB clzB;<br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> doSomething() <br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 0, 0);">Ojbect obj </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> Class.forName(Config.BImplementation).newInstance();<br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);">clzB </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (InterfaceB)obj;<br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);">clzB.doIt();<br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);">…?br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);"></span></div> <br /> </span> </p> <p> <span style="font-size: 10.5pt; font-family: 宋体;"> </span> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <font color="#33cc00" size="4"> <span style="font-family: 宋体;">在代码中创徏<span lang="EN-US">InterfaceB</span>实现cȝ实例Qƈ该对象赋予<span lang="EN-US">clzB</span>。也是依据<span lang="EN-US">Java</span>中的对象动态多态技术:<span lang="EN-US"><o:p></o:p></span>InterfaceB clzB=new InterfaceBImpleClass();Z调用者与实现者在~译期分,于是有了上面的代码,我们Ҏ预先在配|文件中讑֮的实现类的类?span lang="EN-US">(Config.BImplementation)</span>Q动?span lang="EN-US"><o:p></o:p></span>加蝲实现c,q过<span lang="EN-US">InterfaceB</span>强制转型后ؓ<span lang="EN-US"> ClassA</span>所用?/span> </font> </p> <p class="MsoNormal" style="text-indent: 21pt;"> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <span style="font-family: 宋体;"> </span> <br /> <b style=""> <span style="font-size: 10.5pt; font-family: 宋体;" lang="EN-US"> <br />Type2 </span> <span style="font-size: 10.5pt; font-family: 宋体;">讑ր注入:</span> </b> <font color="#663300" size="3"> <span style="font-family: 宋体;">在各U类型的依赖注入模式中,讑ր注入模式在实际开发中得到了最q泛的应用(其中很大一部分得力?span lang="EN-US">Spring</span>框架?/span> </font> <font color="#663300"> <br /> </font> <span style="font-family: 宋体;"> <font color="#663300" size="3">影响Q?span lang="EN-US"><o:p></o:p></span>使用<span lang="EN-US">IoC</span>?span lang="EN-US">Setter</span>注射Q一些外部元数据被用于解决依赖性问题。ƈ且在<span lang="EN-US">Spring</span>中,q种元数据采取了单的<span lang="EN-US">XML</span>配置文g的Ş式?/font> <span lang="EN-US"> <o:p> </o:p> </span> </span> <br /> <b style=""> <span style="font-family: 宋体;"> <br /> 下面为某个类的示例代?span lang="EN-US"><o:p></o:p></span></span> </b> <span style="font-family: 宋体;"> <br /> <font size="4">(其中包含有一?span lang="EN-US">message</span>属性,该类通过?span lang="EN-US">setMessage()</span>Ҏ获得叛_器所提供的倹{?</font></span> </p> <p class="MsoNormal" style="text-indent: 21pt;"> </p> <p class="MsoNormal"> </p> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> UpperAction  </span><span style="color: rgb(0, 0, 255);">implements</span><span style="color: rgb(0, 0, 0);"> Action<br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> String message;<br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> String getMessage() <br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);">  {<br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">return</span><span style="color: rgb(0, 0, 0);"> message;<br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);">  }<br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> setMessage(String string) <br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);">  {<br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);">    message </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> string;<br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);">  }<br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 0, 0);"></span></div> <br /> <span style="font-family: 宋体;"> </span> <b style=""> <span style="font-family: 宋体;" lang="EN-US"> </span> </b> <font size="3"> <span style="font-family: 宋体;" lang="EN-US"> <font color="#663300">其中message</font> </span> </font> <font color="#663300" size="3"> <span style="font-family: 宋体;"> 属性的值通过配置文g来提? </span> </font> <p class="MsoNormal"> </p> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <span style="color: rgb(0, 128, 128);">1</span> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">bean </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">="theUpperAction"</span><span style="color: rgb(255, 0, 0);">  class</span><span style="color: rgb(0, 0, 255);">="springj2seapp.UpperAction"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">2</span> <span style="color: rgb(0, 0, 0);">     </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">property </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="message"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">3</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);">HeLLo,UpperAction </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">4</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">property</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">5</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">bean</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">6</span> <span style="color: rgb(0, 0, 0);"></span></div> <br /> <span style="font-family: 宋体;"> </span> <b style=""> <span style="font-family: 宋体;"> <span lang="EN-US"> <o:p> </o:p> </span> </span> </b> <b style=""> <span style="font-size: 10.5pt; font-family: 宋体;" lang="EN-US">Type3 </span> <span style="font-size: 10.5pt; font-family: 宋体;">构造子注入Q?/span> </b> <span style="font-size: 10.5pt; font-family: 宋体;"> <font color="#660000">?span lang="EN-US">Type3</span>cd的依赖注入机制中Q依赖关pL通过cL造函数徏立,容器通过调用cȝ构造方法,其所需的依赖关pL入其中?/font> <br /> </span> <b style=""> <span style="font-size: 10.5pt; font-family: 宋体;"> <br />CZ代码Q?br />配置文g如下<br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">bean </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">="exampleBean"</span><span style="color: rgb(255, 0, 0);"> class</span><span style="color: rgb(0, 0, 255);">="examples.ExampleBean"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">constructor-arg</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">ref </span><span style="color: rgb(255, 0, 0);">bean</span><span style="color: rgb(0, 0, 255);">="anotherExampleBean"</span><span style="color: rgb(0, 0, 255);">/></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">constructor-arg</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">constructor-arg</span><span style="color: rgb(0, 0, 255);">><</span><span style="color: rgb(128, 0, 0);">ref </span><span style="color: rgb(255, 0, 0);">bean</span><span style="color: rgb(0, 0, 255);">="yetAnotherBean"</span><span style="color: rgb(0, 0, 255);">/></</span><span style="color: rgb(128, 0, 0);">constructor-arg</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">constructor-arg </span><span style="color: rgb(255, 0, 0);">type</span><span style="color: rgb(0, 0, 255);">="int"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);">1</span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">constructor-arg</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">bean</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">bean </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">="anotherExampleBean"</span><span style="color: rgb(255, 0, 0);"> class</span><span style="color: rgb(0, 0, 255);">="examples.AnotherBean"</span><span style="color: rgb(0, 0, 255);">/></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">bean </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">="yetAnotherBean"</span><span style="color: rgb(255, 0, 0);"> class</span><span style="color: rgb(0, 0, 255);">="examples.YetAnotherBean"</span><span style="color: rgb(0, 0, 255);">/></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 0, 0);"></span></div><br /><br /></span> </b> <b> <span style="font-size: 10.5pt; font-family: 宋体;"> <span style="color: rgb(0, 0, 0);">ExampleBean代码Q?/span> </span> </b> <br /> <b style=""> <span style="font-size: 10.5pt; font-family: 宋体;"> <br /> </span> </b> <span style="font-size: 10.5pt; font-family: 宋体;"> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> ExampleBean <br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> AnotherBean beanOne;<br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> YetAnotherBean beanTwo;<br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">private</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> i;<br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> ExampleBean(AnotherBean anotherBean, YetAnotherBean yetAnotherBean, <br />                                                                    </span><span style="color: rgb(0, 0, 255);">int</span><span style="color: rgb(0, 0, 0);"> i) <br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);">{<br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.beanOne </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> anotherBean;<br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.beanTwo </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> yetAnotherBean;<br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">this</span><span style="color: rgb(0, 0, 0);">.i </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> i;<br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);">    }<br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);">}<br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 0, 0);"></span></div> </span> <span style="font-family: 宋体;"> <br /> <font color="#336600" size="4">当构造方法中带多个不同的基本数据cd的参数时Qؓ了避免生二义性,可以采用<span lang="EN-US">type</span>或?span lang="EN-US">index</span>来指定构造方法的参数的类型和序?/font> <font size="4"> <br />如:</font> <br />   <b>typeҎ</b><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);">1</span> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">constructor-arg </span><span style="color: rgb(255, 0, 0);">type</span><span style="color: rgb(0, 0, 255);">="int"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">2</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);">7500000</span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">3</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">constructor-arg</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">4</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">constructor-arg </span><span style="color: rgb(255, 0, 0);">type</span><span style="color: rgb(0, 0, 255);">="java.lang.String"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">5</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);">42</span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">6</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">constructor-arg</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">7</span> <span style="color: rgb(0, 0, 0);"></span></div><span lang="EN-US"><o:p></o:p></span></span> <br /> <span style="font-size: 10.5pt; font-family: 宋体;">    <b><font color="#330000">indexҎ</font></b><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: rgb(0, 128, 128);">1</span> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">bean </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">="exampleBean"</span><span style="color: rgb(255, 0, 0);"> class</span><span style="color: rgb(0, 0, 255);">="examples.ExampleBean"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">2</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">constructor-arg </span><span style="color: rgb(255, 0, 0);">index</span><span style="color: rgb(0, 0, 255);">="0"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">3</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);">7500000</span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">4</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">constructor-arg</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">5</span> <span style="color: rgb(0, 0, 0);">  </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">constructor-arg </span><span style="color: rgb(255, 0, 0);">index</span><span style="color: rgb(0, 0, 255);">="1"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">6</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);">42</span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">7</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">constructor-arg</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">8</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">bean</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">9</span> <span style="color: rgb(0, 0, 0);"></span></div><br /><font color="#663300"><b>ȝQ?/b></font></span> <span style="font-size: 10.5pt; font-family: 宋体;"> <br />     <font size="3"><b><font color="#003300">type1在灵zL、易用性上不如其他两种注入模式Q?/font></b></font></span> <b> <font color="#003300" size="4"> <font size="3"> <span style="font-size: 10.5pt; font-family: 宋体;" lang="EN-US">Type2</span> <span style="font-size: 10.5pt; font-family: 宋体;">?span lang="EN-US">Type3</span>型的依赖注入实现则是目前L?span lang="EN-US">IOC</span>实现模式Q?/span> <span style="font-size: 10.5pt; font-family: 宋体;" lang="EN-US">Type3</span> <span style="font-size: 10.5pt; font-family: 宋体;">?span lang="EN-US">Type2</span>模式各有千秋Q?span lang="EN-US">Spring</span>都对<span lang="EN-US">Type3</span>?span lang="EN-US">Type2</span>cd的依赖注入机制提供了良好支持?/span> <span style="font-family: 宋体;">?span lang="EN-US">Type3</span>cdZQ辅之以<span lang="EN-US">Type2</span>cd机制作ؓ补充Q可以达到最好的依赖注入效果Q不q对于基?span lang="EN-US">Spring Framework</span>开发的应用而言Q?span lang="EN-US">Type2</span>使用更加q泛?span lang="EN-US"><o:p></o:p></span></span> </font> </font> <i> <font color="#003300" size="4"> </font> </i> </b> <span style="font-size: 10.5pt; font-family: 宋体;"> <br /> </span> <p> <b style=""> <span style="font-size: 10.5pt; font-family: 宋体;"> </span> </b> </p> <img src ="http://www.aygfsteel.com/improviser/aggbug/148472.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/improviser/" target="_blank">improviser</a> 2007-09-26 23:59 <a href="http://www.aygfsteel.com/improviser/archive/2007/09/26/148472.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SpringW记之六QIoC SingletonQ?/title><link>http://www.aygfsteel.com/improviser/archive/2007/09/26/148298.html</link><dc:creator>improviser</dc:creator><author>improviser</author><pubDate>Wed, 26 Sep 2007 05:22:00 GMT</pubDate><guid>http://www.aygfsteel.com/improviser/archive/2007/09/26/148298.html</guid><wfw:comment>http://www.aygfsteel.com/improviser/comments/148298.html</wfw:comment><comments>http://www.aygfsteel.com/improviser/archive/2007/09/26/148298.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/improviser/comments/commentRss/148298.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/improviser/services/trackbacks/148298.html</trackback:ping><description><![CDATA[ <div align="justify">   <font color="#333300"><b style=""><font size="4">Spring中BeanFactory<span style="font-family: 宋体;">支持两个对象模型</span></font><span style="font-family: 宋体;"><span lang="EN-US"><o:p></o:p></span></span></b></font></div> <p class="MsoNormal" style="margin-left: 42pt; text-indent: -21pt;" align="justify"> <!--[if !supportLists]--> <font color="#333300"> <span style="font-family: Wingdings;" lang="EN-US"> <span style=""> <span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> </span> </span> </span> </font> <!--[endif]--> <font color="#333300"> <b> <span style="font-family: 宋体;">单态:</span> </b> <span style="font-family: 宋体;"> <font size="4">模型提供了具有特定名U的对象的共享实例,可以在查询时对其q行索?span lang="EN-US">Singleton </span>是默认的也是最常用的对象模型。对于无状态 ?服务对象很理惟?/font> <span lang="EN-US"> <o:p> </o:p> </span> </span> </font> </p> <p class="MsoNormal" style="margin-left: 42pt; text-indent: -21pt;" align="justify"> <!--[if !supportLists]--> <font color="#333300"> <span style="font-family: Wingdings;" lang="EN-US"> <span style=""> </span> </span> <b> <span style="font-family: 宋体;">原型Q?/span> <font size="4"> </font> </b> <font size="4"> <span style="font-family: 宋体;">模型保每次索都会创建单独的对象。在每个用户都需要自q对象Ӟ原型模型最适合?/span> </font> </font> </p> <p class="MsoNormal" style="margin-left: 42pt; text-indent: -21pt;" align="justify"> <span style="font-family: 宋体;"> <b> <font color="#333300" size="4">实例Q?/font> <font size="4"> </font> </b> <br /> </span> </p> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">  beans  </span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);">      <br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 0);">      </span><span style="color: rgb(0, 128, 0);"><!--</span><span style="color: rgb(0, 128, 0);"> non-singleton examples </span><span style="color: rgb(0, 128, 0);">--></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 0);">     </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">bean </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">="nonSingleton"</span><span style="color: rgb(255, 0, 0);"> class</span><span style="color: rgb(0, 0, 255);">="java.lang.String"</span><span style="color: rgb(255, 0, 0);"> singleton</span><span style="color: rgb(0, 0, 255);">="true"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);">         </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">constructor-arg</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 0, 0);">              </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);">Value</span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);">         </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">constructor-arg</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);">      </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">bean</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);">  <br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">beans</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);">singletonQ指定此JavaBean是否采用单例QSingletonQ模式,如果设ؓ"true"Q则在BeanFactory作用范围内,只维护此JavaBean  的一个实例,代码通过BeanFactory   获得此JavaBean  实例的引用。反之,如果设ؓ"false"Q则通过BeanFactory获取此Java Bean  实例ӞBeanFactory每次都将创徏一个新的实例返回?/span></div> <p class="MsoNormal" style="margin-left: 42pt; text-indent: -21pt;">    </p> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> <span style="color: rgb(0, 128, 128);">     1</span> <span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> NonSingleton {<br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 0);"></span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> main(String[] args) {<br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 0);"> <br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);">BeanFactory factory </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> XmlBeanFactory(</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> FileSystemResource(<br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 0, 0);">                    </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">build/beans.xml</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">));<br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);">       <br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);">   String s1 </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (String)factory.getBean(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">nonSingleton</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);">   String s2 </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (String)factory.getBean(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">nonSingleton</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);">   System.out.println(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Identity Equal?: </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> (s1 </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);">s2));<br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);">   System.out.println(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">Value Equal:? </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 0);"> s1.equals(s2));<br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);">   System.out.println(s1);<br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 0, 0);">   System.out.println(s2);<br /></span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 0, 0);"> }<br /></span><span style="color: rgb(0, 128, 128);">15</span> <span style="color: rgb(0, 0, 0);">}</span></div> <p> </p> <p class="MsoNormal" style="margin-left: 42pt; text-indent: -21pt;">   <i><b><font size="4"><font color="#003300">分析l果Q?/font></font></b></i></p> <p class="MsoNormal" style="margin-left: 42pt; text-indent: -21pt;">   <font color="#009900">Identity Equal?: true<br />Value Equal:? true<br />Value<br />Value</font><br /></p> <p class="MsoNormal" style="margin-left: 42pt; text-indent: -21pt;">   q果可以看出由fantory产生的bean对象只有一个?br /><span style="font-family: 宋体;"></span></p> <p class="MsoNormal" style="margin-left: 42pt; text-indent: -21pt;"> <span style="font-family: 宋体;"> <br /> </span> </p> <p class="MsoNormal" style="margin-left: 42pt; text-indent: -21pt;"> </p> <p class="MsoNormal" style="text-indent: 21pt;"> <b> <span style="font-family: 宋体;"> <font color="#ff0000"> 注意</font>Q?/span> </b> <font size="4"> <span style="font-family: 宋体;"> <font color="#33cc00">?span lang="EN-US">Spring</span>中消除了q戯己来实现<span lang="EN-US">Singleton</span>模式的应用,<span lang="EN-US">Spring Bean</span>的缺省行为就?span lang="EN-US">Singleton</span>Q不必再Z<span lang="EN-US">Singleton</span>~码?/font> <span lang="EN-US"> <o:p> </o:p> </span> </span> </font> </p> <p class="MsoNormal" style="margin-left: 42pt; text-indent: -21pt;"> <br /> <span style="font-family: 宋体;"> <span lang="EN-US"> <o:p> </o:p> </span> </span> </p> <img src ="http://www.aygfsteel.com/improviser/aggbug/148298.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/improviser/" target="_blank">improviser</a> 2007-09-26 13:22 <a href="http://www.aygfsteel.com/improviser/archive/2007/09/26/148298.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SpringW记之五QHierarchical Bean Factory UsageQ?/title><link>http://www.aygfsteel.com/improviser/archive/2007/09/25/147934.html</link><dc:creator>improviser</dc:creator><author>improviser</author><pubDate>Mon, 24 Sep 2007 16:05:00 GMT</pubDate><guid>http://www.aygfsteel.com/improviser/archive/2007/09/25/147934.html</guid><wfw:comment>http://www.aygfsteel.com/improviser/comments/147934.html</wfw:comment><comments>http://www.aygfsteel.com/improviser/archive/2007/09/25/147934.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.aygfsteel.com/improviser/comments/commentRss/147934.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/improviser/services/trackbacks/147934.html</trackback:ping><description><![CDATA[ <strong> <span style="font-size: 14pt;"> <span style="color: rgb(24, 38, 255);">本文研究Spring分层Bean Factory用法Q先看有关代码:</span> </span> </strong> <br /> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --> <span style="color: rgb(0, 128, 128);"> 1</span> parent<span style="color: rgb(0, 0, 0);">.xml<br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 255);"><!</span><span style="color: rgb(255, 0, 255);">DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" <br />       "http://www.springframework.org/dtd/spring-beans.dtd"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">beans</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">bean </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">="injectBean"</span><span style="color: rgb(255, 0, 0);"> class</span><span style="color: rgb(0, 0, 255);">="java.lang.String"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 0, 0);">           </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">constructor-arg</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);">               </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);">Bean In Parent</span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);">           </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">constructor-arg</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">bean</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">bean </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">="injectBeanParent"</span><span style="color: rgb(255, 0, 0);"> class</span><span style="color: rgb(0, 0, 255);">="java.lang.String"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);">           </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">constructor-arg</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);">               </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);">Bean In Parent</span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 0, 0);">           </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">constructor-arg</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">bean</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">15</span> <span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">beans</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);">  <br /></span></div> <br /> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --> <span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 0, 0);">beans.xml<br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 255);"><!</span><span style="color: rgb(255, 0, 255);">DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" <br />     "http://www.springframework.org/dtd/spring-beans.dtd"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">beans</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 128, 0);"><!--</span><span style="color: rgb(0, 128, 0);"> hierarchical bean factories </span><span style="color: rgb(0, 128, 0);">--></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">bean </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">="target1"</span><span style="color: rgb(255, 0, 0);"> class</span><span style="color: rgb(0, 0, 255);">="SimpleTarget"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">property </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="val"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">ref </span><span style="color: rgb(255, 0, 0);">bean</span><span style="color: rgb(0, 0, 255);">="injectBeanParent"</span><span style="color: rgb(0, 0, 255);">/></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">property</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">bean</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);">    <br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">bean </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">="target2"</span><span style="color: rgb(255, 0, 0);"> class</span><span style="color: rgb(0, 0, 255);">="SimpleTarget"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">property </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="val"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">ref </span><span style="color: rgb(255, 0, 0);">local</span><span style="color: rgb(0, 0, 255);">="injectBean"</span><span style="color: rgb(0, 0, 255);">/></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">15</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">property</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">16</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">bean</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">17</span> <span style="color: rgb(0, 0, 0);">    <br /></span><span style="color: rgb(0, 128, 128);">18</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">bean </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">="target3"</span><span style="color: rgb(255, 0, 0);"> class</span><span style="color: rgb(0, 0, 255);">="SimpleTarget"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">19</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">property </span><span style="color: rgb(255, 0, 0);">name</span><span style="color: rgb(0, 0, 255);">="val"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">20</span> <span style="color: rgb(0, 0, 0);">            </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">ref </span><span style="color: rgb(255, 0, 0);">parent</span><span style="color: rgb(0, 0, 255);">="injectBean"</span><span style="color: rgb(0, 0, 255);">/></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">21</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">property</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">22</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">bean</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">23</span> <span style="color: rgb(0, 0, 0);">    <br /></span><span style="color: rgb(0, 128, 128);">24</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">bean </span><span style="color: rgb(255, 0, 0);">id</span><span style="color: rgb(0, 0, 255);">="injectBean"</span><span style="color: rgb(255, 0, 0);"> class</span><span style="color: rgb(0, 0, 255);">="java.lang.String"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">25</span> <span style="color: rgb(0, 0, 0);">           </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">constructor-arg</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">26</span> <span style="color: rgb(0, 0, 0);">               </span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);">Bean In Child</span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">value</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">27</span> <span style="color: rgb(0, 0, 0);">           </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">constructor-arg</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">28</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">bean</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">29</span> <span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">beans</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">30</span> </div> <br /> <h1> <strong> <code> <font color="#000000"> <span style="color: rgb(24, 38, 255);">SimpleTarget中只有一属性String val</span> </font> </code> </strong> </h1> <br /> <div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"> <!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --> <span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> main(String[] args) {<br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);">        BeanFactory parent </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> XmlBeanFactory(</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> FileSystemResource(<br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 0);">                </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">build/parent.xml</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">));<br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 0);">        BeanFactory child </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> XmlBeanFactory(</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> FileSystemResource(<br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);">                </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">build/beans.xml</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">), parent);<br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);">        SimpleTarget target1 </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (SimpleTarget) child.getBean(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">target1</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);">        SimpleTarget target2 </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (SimpleTarget) child.getBean(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">target2</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);">        SimpleTarget target3 </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (SimpleTarget) child.getBean(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">target3</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);">        System.out.println(target1.getVal());<br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);">        System.out.println(target2.getVal());<br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 0, 0);">        System.out.println(target3.getVal());<br /></span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 0, 0);">    }</span></div> <br /> <strong> <font size="4"> <span style="color: rgb(24, 38, 255);">q行l果Q?/span> </font> </strong> <br /> <span style="color: rgb(24, 38, 255);"> <font size="4">Bean In Parent<br /> Bean In Child<br /> Bean In Parent</font> <br /> <br /> <font size="4"> <b> 分析q程Q?/b> </font> <br /> <font size="4"> 在bean factory被加载过E中分别加蝲各层Bean FactoryQ?/font> </span> <font size="4"> <span style="color: rgb(0, 0, 0);">BeanFactory parent </span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> XmlBeanFactory(</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> FileSystemResource(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">build/parent.xml</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">));<br /></span><span style="color: rgb(0, 0, 0);">BeanFactory child </span><span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> XmlBeanFactory(</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> FileSystemResource(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">build/beans.xml</span><span style="color: rgb(0, 0, 0);">"</span></font> <span style="color: rgb(0, 0, 0);"> <font size="4">), <span style="color: rgb(255, 0, 0);">parent</span>);<br /></font> <span style="color: rgb(24, 38, 255);"> <font size="4">其中parent参数指定了bean factory间的父子关系?/font> <br /> <br /> <font size="4"> <b> 分析l果Q?/b> </font> <br /> <font size="4"> W一行结果ؓ在父factory中定义的参数Q说明在子fantory中可以直接调用父fantory元素Q类gjava中的l承关系?br /> W二行结果说?/font> </span> </span> <font size="4"> <span style="color: rgb(0, 0, 255);"><</span> <span style="color: rgb(128, 0, 0);">ref </span> <span style="color: rgb(255, 0, 0);">local</span> <span style="color: rgb(0, 0, 255);">="injectBean"</span> <span style="color: rgb(0, 0, 255);">/>中local指向本fantory元素?br /> W三行结果ؓBean In ParentQ说?/span> <span style="color: rgb(0, 0, 255);"><</span> <span style="color: rgb(128, 0, 0);">ref </span> <span style="color: rgb(255, 0, 0);">parent</span> <span style="color: rgb(0, 0, 255);">="injectBean"</span> <span style="color: rgb(0, 0, 255);">/>中parent指向父fantory中元素?/span> </font> <br /> <br /> <br /> <br /> <img src ="http://www.aygfsteel.com/improviser/aggbug/147934.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/improviser/" target="_blank">improviser</a> 2007-09-25 00:05 <a href="http://www.aygfsteel.com/improviser/archive/2007/09/25/147934.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SpringW记之四QSpring EventQ?/title><link>http://www.aygfsteel.com/improviser/archive/2007/09/24/147914.html</link><dc:creator>improviser</dc:creator><author>improviser</author><pubDate>Mon, 24 Sep 2007 14:38:00 GMT</pubDate><guid>http://www.aygfsteel.com/improviser/archive/2007/09/24/147914.html</guid><wfw:comment>http://www.aygfsteel.com/improviser/comments/147914.html</wfw:comment><comments>http://www.aygfsteel.com/improviser/archive/2007/09/24/147914.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.aygfsteel.com/improviser/comments/commentRss/147914.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/improviser/services/trackbacks/147914.html</trackback:ping><description><![CDATA[     摘要: Spring中提供一些Aware相关的接口,BeanFactoryAware?ApplicationContextAware、ResourceLoaderAware、ServletContextAware{等Q其中最常用到的是ApplicationContextAware。实现ApplicationContextAware的BeanQ在Bean被初始后Q将会被注入 ApplicationContext的实例。ApplicationContextAware提供了publishEvent()ҎQ实现Observer(观察?设计模式的事件传播机Q提供了针对Bean的事件传播功能。通过Application.publishEventҎQ我们可以将事g通知pȝ内所有的ApplicationListener?nbsp; <a href='http://www.aygfsteel.com/improviser/archive/2007/09/24/147914.html'>阅读全文</a><img src ="http://www.aygfsteel.com/improviser/aggbug/147914.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/improviser/" target="_blank">improviser</a> 2007-09-24 22:38 <a href="http://www.aygfsteel.com/improviser/archive/2007/09/24/147914.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SpringW记之三QUsage of property configQ?/title><link>http://www.aygfsteel.com/improviser/archive/2007/09/24/147777.html</link><dc:creator>improviser</dc:creator><author>improviser</author><pubDate>Mon, 24 Sep 2007 05:51:00 GMT</pubDate><guid>http://www.aygfsteel.com/improviser/archive/2007/09/24/147777.html</guid><wfw:comment>http://www.aygfsteel.com/improviser/comments/147777.html</wfw:comment><comments>http://www.aygfsteel.com/improviser/archive/2007/09/24/147777.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.aygfsteel.com/improviser/comments/commentRss/147777.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/improviser/services/trackbacks/147777.html</trackback:ping><description><![CDATA[     摘要: 本文内容演示属性文件用法的单例子?<br>首先定义模型接口ModelQ视图接口ViewQ以及它们实现类ImpModelQImpView. <br>Model中定义方法getString();View中定义Model实例为其属性,在实现类ImpView中实现方?<br>disPlay(),其方法体为Model实例的getString()ҎQƈ其打印出来?nbsp; <a href='http://www.aygfsteel.com/improviser/archive/2007/09/24/147777.html'>阅读全文</a><img src ="http://www.aygfsteel.com/improviser/aggbug/147777.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/improviser/" target="_blank">improviser</a> 2007-09-24 13:51 <a href="http://www.aygfsteel.com/improviser/archive/2007/09/24/147777.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SpringW记之二QCollection InjectionQ?/title><link>http://www.aygfsteel.com/improviser/archive/2007/09/24/147710.html</link><dc:creator>improviser</dc:creator><author>improviser</author><pubDate>Mon, 24 Sep 2007 02:23:00 GMT</pubDate><guid>http://www.aygfsteel.com/improviser/archive/2007/09/24/147710.html</guid><wfw:comment>http://www.aygfsteel.com/improviser/comments/147710.html</wfw:comment><comments>http://www.aygfsteel.com/improviser/archive/2007/09/24/147710.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.aygfsteel.com/improviser/comments/commentRss/147710.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/improviser/services/trackbacks/147710.html</trackback:ping><description><![CDATA[     摘要: 通过<list/>,<set/>,<map/>以及<props/>元素定义和设|与java collectioncd对应的ListQSetQMapQRproperties的倹{?nbsp; <a href='http://www.aygfsteel.com/improviser/archive/2007/09/24/147710.html'>阅读全文</a><img src ="http://www.aygfsteel.com/improviser/aggbug/147710.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/improviser/" target="_blank">improviser</a> 2007-09-24 10:23 <a href="http://www.aygfsteel.com/improviser/archive/2007/09/24/147710.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SpringW记之一Q初探SpringQ?/title><link>http://www.aygfsteel.com/improviser/archive/2007/09/24/147650.html</link><dc:creator>improviser</dc:creator><author>improviser</author><pubDate>Sun, 23 Sep 2007 17:31:00 GMT</pubDate><guid>http://www.aygfsteel.com/improviser/archive/2007/09/24/147650.html</guid><wfw:comment>http://www.aygfsteel.com/improviser/comments/147650.html</wfw:comment><comments>http://www.aygfsteel.com/improviser/archive/2007/09/24/147650.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.aygfsteel.com/improviser/comments/commentRss/147650.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/improviser/services/trackbacks/147650.html</trackback:ping><description><![CDATA[   <font color="#333300" size="4"></font><span style="font-size: 10.5pt; font-family: 宋体;"><span style="font-family: Comic Sans MS;"><span style="font-family: Arial;"><span style="font-family: Comic Sans MS;"><span style="font-size: 12pt;"><span style="font-size: 18pt;"><span style="font-family: Verdana;"><span style="font-family: Comic Sans MS;"><span style="font-size: 10.5pt; font-family: 宋体;"><span><span style="font-size: 10.5pt; font-family: 宋体;"><span style="font-size: 24pt;"><span style="font-size: 14pt;"><span style="font-size: 10pt;"><span style="font-size: 10.5pt; font-family: 宋体;"><font color="#333300" size="4">初探SpringE序Q程序如下:</font><br /><br />      </span></span></span></span></span></span></span></span></span></span></span></span></span></span></span><br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 0, 0);">BeanNaming.java<br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">package</span><span style="color: rgb(0, 0, 0);"> spring.beantest;<br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> org.springframework.beans.factory.BeanFactory;<br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> org.springframework.beans.factory.xml.XmlBeanFactory;<br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> org.springframework.core.io.FileSystemResource;<br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> BeanNaming {<br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> main(String []args)<br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);">    {<br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);">        BeanFactory factory </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> XmlBeanFactory(</span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> FileSystemResource(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">src/applicationContext.xml</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">));<br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);">    <br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 0, 0);">        String s1 </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (String)factory.getBean(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">name1</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 0, 0);">        String s2 </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (String)factory.getBean(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">name2</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">15</span> <span style="color: rgb(0, 0, 0);">        String s3 </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (String)factory.getBean(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">name3</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">16</span> <span style="color: rgb(0, 0, 0);">        String s4 </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (String)factory.getBean(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">name4</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">17</span> <span style="color: rgb(0, 0, 0);">        <br /></span><span style="color: rgb(0, 128, 128);">18</span> <span style="color: rgb(0, 0, 0);">        System.out.println((s1 </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> s2));<br /></span><span style="color: rgb(0, 128, 128);">19</span> <span style="color: rgb(0, 0, 0);">        System.out.println((s2 </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> s3));<br /></span><span style="color: rgb(0, 128, 128);">20</span> <span style="color: rgb(0, 0, 0);">        System.out.println((s3 </span><span style="color: rgb(0, 0, 0);">==</span><span style="color: rgb(0, 0, 0);"> s4));<br /></span><span style="color: rgb(0, 128, 128);">21</span> <span style="color: rgb(0, 0, 0);">        <br /></span><span style="color: rgb(0, 128, 128);">22</span> <span style="color: rgb(0, 0, 0);">        String[] x </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> factory.getAliases(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">name3</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">23</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 255);">for</span><span style="color: rgb(0, 0, 0);">(String str:x)<br /></span><span style="color: rgb(0, 128, 128);">24</span> <span style="color: rgb(0, 0, 0);">        {<br /></span><span style="color: rgb(0, 128, 128);">25</span> <span style="color: rgb(0, 0, 0);">            System.out.println(str);<br /></span><span style="color: rgb(0, 128, 128);">26</span> <span style="color: rgb(0, 0, 0);">        }<br /></span><span style="color: rgb(0, 128, 128);">27</span> <span style="color: rgb(0, 0, 0);">        <br /></span><span style="color: rgb(0, 128, 128);">28</span> <span style="color: rgb(0, 0, 0);">      }<br /></span><span style="color: rgb(0, 128, 128);">29</span> <span style="color: rgb(0, 0, 0);">    }<br /></span><span style="color: rgb(0, 128, 128);">30</span> <span style="color: rgb(0, 0, 0);"> <br /></span><span style="color: rgb(0, 128, 128);">31</span> <span style="color: rgb(0, 0, 0);">      applicationContext.xml<br /></span><span style="color: rgb(0, 128, 128);">32</span> <span style="color: rgb(0, 0, 0);">     </span><span style="color: rgb(0, 0, 0);"><?</span><span style="color: rgb(0, 0, 0);">xml version</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">1.0</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> encoding</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">UTF-8</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">?></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">33</span> <span style="color: rgb(0, 0, 0);">     </span><span style="color: rgb(0, 0, 0);"><!</span><span style="color: rgb(0, 0, 0);">DOCTYPE beans PUBLIC </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">-//SPRING//DTD BEAN//EN</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">http://www.springframework.org/dtd/spring-beans.dtd</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">34</span> <span style="color: rgb(0, 0, 0);">     </span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">beans</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">35</span> <span style="color: rgb(0, 0, 0);">     </span><span style="color: rgb(0, 0, 0);"><!--</span><span style="color: rgb(0, 0, 0);"> aliasing examples </span><span style="color: rgb(0, 0, 0);">--></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">36</span> <span style="color: rgb(0, 0, 0);">     </span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">bean id</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">name1</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> name</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">name2,name3,name4</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">java.lang.String</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">/></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">37</span> <span style="color: rgb(0, 0, 0);">     </span><span style="color: rgb(0, 0, 0);"></</span><span style="color: rgb(0, 0, 0);">beans</span><span style="color: rgb(0, 0, 0);">></span></div><br />     <font size="4"><span style="color: red;">输出l果为:</span><br /><span style="color: rgb(24, 125, 255);">     true<br />     true<br />     true<br />     name1<br />     name4<br />     name2</span></font><br />     <br />     <font size="4"><span style="color: rgb(74, 48, 255);">可以看出Q用中id属性和name属性几乎没有Q何区别。调用beanfactory.getAliases(string)的方法时Q传入的参数可以是Q意一个bean名字Q输出的别名则是除去作ؓ参数本n之外的所? bean名?/span><br />    <br /><br />    <span style="color: rgb(24, 38, 255);">?/span>Q?span style="color: rgb(74, 48, 255);">在写 applicationContxt.xml文gӞ如果没有定义<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">Q则会抛?/span><span style="color: red;"><span style="color: rgb(14, 0, 0);"><span style="color: red;">Cannot find the declaration of element 'beans'</span></span></span><span style="color: rgb(74, 48, 255);">异常?/span></font><br />    <br />       <strong><font size="4"><span style="color: rgb(107, 40, 255);">以上使用BeanFactory寚w|文件进行加载,BeanFactoryQ是Ҏ配置文g负责创徏Bean的实例,q负责Bean的生命周期的理- --Q包括Bean的生成与销毁、Bean的创建方式的识别Q是否ؓsingletonQ、Bean的各个属性的讑֮、依赖关pȝ建立{?br />     ApplicationContext接口Q提供了国际化、事件处理及beans在context中的自查能力。它也可创徏h层次l构context? 境,bean的作用域和可讉K区域限制在应用程序的一个特定部分中。下面演C如何用ApplicationContext接口?/span></font><br /></strong><br />     <br /><div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: rgb(0, 128, 128);"> 1</span> <span style="color: rgb(0, 0, 0);"><!</span><span style="color: rgb(0, 0, 0);">DOCTYPE beans PUBLIC </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">-//SPRING//DTD BEAN//EN</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">http://www.springframework.org/dtd/spring-    beans.dtd</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 2</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">beans</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 3</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">bean id</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">bean_1</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">BeanTest</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">/></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 4</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 0);"><</span><span style="color: rgb(0, 0, 0);">bean id</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">bean_2</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">BeanTest</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">/></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 5</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 0);"></</span><span style="color: rgb(0, 0, 0);">beans</span><span style="color: rgb(0, 0, 0);">></span><span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 6</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 7</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);"> 8</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> BeanTest {<br /></span><span style="color: rgb(0, 128, 128);"> 9</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> test() {<br /></span><span style="color: rgb(0, 128, 128);">10</span> <span style="color: rgb(0, 0, 0);">        System.out.println(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">test..</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">11</span> <span style="color: rgb(0, 0, 0);">    }<br /></span><span style="color: rgb(0, 128, 128);">12</span> <span style="color: rgb(0, 0, 0);">   }<br /></span><span style="color: rgb(0, 128, 128);">13</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">14</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">15</span> <span style="color: rgb(0, 0, 0);">   </span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> org.springframework.context.ApplicationContext;<br /></span><span style="color: rgb(0, 128, 128);">16</span> <span style="color: rgb(0, 0, 0);">   </span><span style="color: rgb(0, 0, 255);">import</span><span style="color: rgb(0, 0, 0);"> org.springframework.context.support.FileSystemXmlApplicationContext;<br /></span><span style="color: rgb(0, 128, 128);">17</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">18</span> <span style="color: rgb(0, 0, 0);">   </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">class</span><span style="color: rgb(0, 0, 0);"> BeanNameExample {<br /></span><span style="color: rgb(0, 128, 128);">19</span> <span style="color: rgb(0, 0, 0);"><br /></span><span style="color: rgb(0, 128, 128);">20</span> <span style="color: rgb(0, 0, 0);">    </span><span style="color: rgb(0, 0, 255);">public</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">static</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">void</span><span style="color: rgb(0, 0, 0);"> main(String[] args) {<br /></span><span style="color: rgb(0, 128, 128);">21</span> <span style="color: rgb(0, 0, 0);">        ApplicationContext ctx </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 0, 255);">new</span><span style="color: rgb(0, 0, 0);"> FileSystemXmlApplicationContext(<br /></span><span style="color: rgb(0, 128, 128);">22</span> <span style="color: rgb(0, 0, 0);">        </span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">build/applicationContext.xml</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">23</span> <span style="color: rgb(0, 0, 0);">        <br /></span><span style="color: rgb(0, 128, 128);">24</span> <span style="color: rgb(0, 0, 0);">        BeanTest beanOne </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (BeanTest)ctx.getBean(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">bean_1</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">25</span> <span style="color: rgb(0, 0, 0);">        BeanTest beanTwo </span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);"> (BeanTest)ctx.getBean(</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">bean_2</span><span style="color: rgb(0, 0, 0);">"</span><span style="color: rgb(0, 0, 0);">);<br /></span><span style="color: rgb(0, 128, 128);">26</span> <span style="color: rgb(0, 0, 0);">        <br /></span><span style="color: rgb(0, 128, 128);">27</span> <span style="color: rgb(0, 0, 0);">        beanOne.test();<br /></span><span style="color: rgb(0, 128, 128);">28</span> <span style="color: rgb(0, 0, 0);">        beanTwo.test();<br /></span><span style="color: rgb(0, 128, 128);">29</span> <span style="color: rgb(0, 0, 0);">      }<br /></span><span style="color: rgb(0, 128, 128);">30</span> <span style="color: rgb(0, 0, 0);">   }<br /></span><span style="color: rgb(0, 128, 128);">31</span> </div>   <font size="4"><span style="color: rgb(107, 40, 255);"><strong>lgQApplicationContext与BeanFactory的不同点<br />    BeanFactory提供了针对JavaBean的管理功能,而ApplicationContext提供了一个更为框架化的实玎ͼ从上面的CZ中可? 看出QBeanFactory的用方式更加类g个APIQ而非Framework styleQ。ApplicationContext覆盖了BeanFactory的所有功能,q提供了更多的特性。此外, ApplicationContextZ现有应用框架相整合,提供了更为开攑ּ的实玎ͼ如对于Web应用Q我们可以在web.xml中对 ApplicationContextq行配置Q?/strong></span></font><strong></strong><img src ="http://www.aygfsteel.com/improviser/aggbug/147650.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/improviser/" target="_blank">improviser</a> 2007-09-24 01:31 <a href="http://www.aygfsteel.com/improviser/archive/2007/09/24/147650.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> վ֩ģ壺 <a href="http://" target="_blank">Ԫ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">͸</a>| <a href="http://" target="_blank">˲</a>| <a href="http://" target="_blank">÷</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ﴨ</a>| <a href="http://" target="_blank">̫</a>| <a href="http://" target="_blank">⴨</a>| <a href="http://" target="_blank">Ž</a>| <a href="http://" target="_blank">ⶫ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">̩</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ع</a>| <a href="http://" target="_blank">ˮ</a>| <a href="http://" target="_blank">ͬ</a>| <a href="http://" target="_blank">Ұ</a>| <a href="http://" target="_blank">ˮ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ʯȪ</a>| <a href="http://" target="_blank">¡</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ͨ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ֱ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ƽ</a>| <a href="http://" target="_blank">̳</a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɽʡ</a>| <a href="http://" target="_blank">ͨ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ԭ</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>