Spring_培训.ppt
《Spring_培训.ppt》由会员分享,可在线阅读,更多相关《Spring_培训.ppt(50页珍藏版)》请在三一办公上搜索。
1、Spring 培训,Agenda,到底什么是Spring Framework?,Open source(LGPL)网址:http:/www.springframework.org,http:/www.springframework.org,一种Light-weight ContainerLight-weight是相对于J2EE Container而言,到底什么是Spring Framework?,一个易于整合各种构件、服务的应用程序框架(Application Framework),到底什么是Spring Framework?,Quartz,JSF,Webwork,JDO,Spring fra
2、mework的组成要素,Spring framework的组成要素,Dependency Injection,是一种Design Pattern目的在于将对象之间的依赖性(Dependency)分离强化了以接口为基础的软件设计,Loose coupling,Dependency Injection“In a Nutshell”,以下是一个经常见到的Design,Dependency Injection“In a Nutshell”,在上述的情况下,虽然有Interface based design的概念,但仍然存在着一个失落的环节ServiceCaller.java:DumbService a
3、Service=new DumbServiceImplementation();,Dependency Injection“In a Nutshell”,设计(Design)和实现(Implementation)有了落差!,Dependency Injection“In a Nutshell”,解决方法:,Dependency Injection“In a Nutshell”Assembler.java的程序,Dependency Injection!,Dependency Injection“In a Nutshell”Assembler所扮演的角色,Assembler负责:管理对象生命周期
4、初始化参数设定销毁对象实例处理对象之间的依赖性SetterConstructor,Spring framework的Dependency Injection,Spring framework扮演Assembler的角色利用 XmlAppicationContext描述对象之间的依赖性对象的初始参数对象实例的管理模式:PrototypeSingleton,Dependency Injection!,Dependency lookup(Service Locator),在Spring中使用Dependency Lookup,在Spring中使用Dependency Lookup,使用Depende
5、ncy Lookup的影响,类/构件之间的依赖性減少到接口(Interface)名称(id/name)然而却对Service Locator机制的API以及Container产生Dependency其他使用类似机制的技术:EJB JNDI LookupCorba CosNamingAvalon Framework,Dependency Injection:Setter based,在Spring中使用Setter based Dependency Injection,在Spring中使用Setter based Dependency Injection,ServiceCaller.java,將
6、对象之间的依赖性从主动的取得转成被动的使用:Dependency Lookup:打电话订PizzaSetter based:带饭盒Setter based相对于Dependency Lookup,是一种进步:系统模块间的整合,变成一种依赖性的整合,使用Setter based Dependency Injection的影响,Dependency Injection:Constructor based,在Spring中使用Constructor based Dependency Injection,在Spring中使用Constructor based Dependency Injection,
7、ServiceCaller.java,使用Constructor based Dependency Injection的影响,Constructor based强制的将一个对象所需要的依赖对象在实例化的同时注入Constructor based借此比较容易避免Setter based可能发生的问題:当对象调用外部服务时,却因为没有设置对象和服务之间的依赖而产生NullPointerException,其他提供Dependency Injection的Container,PicoContainer网址:http:/www.picocontainer.org/,为什么选择Spring Framew
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Spring_ 培训

链接地址:https://www.31ppt.com/p-2310650.html