ImageVerifierCode 换一换
格式:PPT , 页数:59 ,大小:515.50KB ,
资源ID:378080      下载积分:2000 积分
快捷下载
登录下载
邮箱/手机:
温馨提示:
如需开发票,请勿充值!快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝扫码支付 微信扫码支付   
注意:如需开发票,请勿充值!
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【http://www.mydoc123.com/d-378080.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Advanced Spring Framework.ppt)为本站会员(李朗)主动上传,麦多课文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知麦多课文库(发送邮件至master@mydoc123.com或直接QQ联系客服),我们立即给予删除!

Advanced Spring Framework.ppt

1、Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,Advanced Spring Framework,Rod Johnson CEO Interface21 ,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is pro

2、hibited.,Aims,Understand the capabilities of the Spring Framework component model, and how you can use them to add new power to your POJO-based applications,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,Agenda,Spring co

3、mponent model fundamentals Value adds out of the box User extension points Spring 2.0 configuration extensions Spring 2.1: New Scaling out the Spring component model,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,What Is

4、 Spring?,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,Much More Than an IoC Container,Core component model + Services + Patterns (Recipes) + Integration (Ecosystem) + Portability (Runs everywhere) = Universal POJO prog

5、ramming modelEmbraced by more and more enterprise vendors,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,Simple Object,Enabling Technologies,Simple Object,Dependency Injection,AOP,Portable Service Abstractions (PSA),Copy

6、right 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,Simple POJO,public class DefaultWeatherService implements WeatherService public String getShortSummary(String location) .public String getLongSummary(String location) .public vo

7、id update(String location, WeatherData newData)No special requirements No dependencies on Spring,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,Applying Declarative Transactions,Pointcut identifies business service metho

8、ds,Advice adds behavior. This advice makes business services transactional.,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,Value add: Exporting a Remote Endpoint,Can add any number of server side Exporters for each Sprin

9、g managed bean Dont need to write any Java code,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,Remote Client: POJO,public class MyClient private WeatherService ws;public void setWeatherService(WeatherService ws) this.ws

10、= ws;/ Business methods omitted ,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,Configuring the Remote Client POJO,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written perm

11、ission is prohibited.,Unit Testing the Dependency Injected Client,public void testForMyClient() MyClient mc = new MyClient();mc.setWeatherService(myMockService);/ Test mc Can simply inject proxy into client Imagine how much harder testing would be if we had coded the lookup method in the client,Copy

12、right 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,Value add: Java Management Extensions (JMX) API Export,Can expose any bean as a JMX API MBean without writing JMX API code,Copyright 2004-2007, Interface21 Ltd. Copying, publish

13、ing, or distributing without expressed written permission is prohibited.,Extension Point: Auditing Aspect,Spring container can weave any managed POJO with aspects This aspect monitors access to the methods that ask for weather summary strings Single code module addresses single requirement (auditing

14、) Type safe with argument bindingAspect public class WeatherMonitorAuditAspect After(“execution(String *.WeatherService.*(String) & args(location) & this(ws)“)public void onQuery(String location WeatherService ws) / Location and WeatherService are bound/ to the aspect ,Pointcut identifies the method

15、s that should be affected,Advice method contains code to execute,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,Applying the Aspect,Ensure an tag is used to turn on automatic application of any AspectJ aspects found in t

16、he contextSimply define the aspect as a Spring bean,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,User Extension Points,The Spring IoC container provides many extension points Can easily modify the behavior of the conta

17、iner to do custom annotation processing, specific callbacks, validation etc. or even to wrap managed objects in proxies For example: FactoryBeanobject configured by the container that creates a component, introducing a level of indirection BeanPostProcessorcalled on every bean instantiation BeanFact

18、oryPostProcessorcan modify container metadata BeanDefinitionprovides ability to add custom metadata for processing by post processors,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,User Extension Point Example,Example: I

19、ntroducing a LogAware interface Components implementing this are given a log instanceThe AccountService bean needs a Log:public class AccountService implements LogAwareprivate Log log;public void setLog(Log log) this.log = log;/ Business methods omitted. ,Copyright 2004-2007, Interface21 Ltd. Copyin

20、g, publishing, or distributing without expressed written permission is prohibited.,User Extension Point Example (Cont.),public class LogInjectingBeanPostProcessor implements BeanPostProcessor public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException if (bean i

21、nstanceof LogAware) injectLog(LogAware) bean);return bean;public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException return bean; ,Called as every bean is initialized,Return value can be any object that is type compatible with the bean being processed,Copyright

22、2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,Activating a BeanPostProcessor,Like most Spring IoC extension points, simply define as a bean Automatically gets applied to all other beans Customizes the behavior of the container,Co

23、pyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,Agenda,Spring component model fundamentals Value adds out of the box User extension points Spring 2.0 configuration extensions Dynamic language support Scaling out the Spring

24、component model,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,XML Configuration Extensions in Spring 2.0: Important New Extension Point,A bean definition is a recipe for creating one object Spring 2.0 added the ability

25、to define new XML tags to produce zero or more Spring bean definitions Important new extension point, offering: Higher level of abstraction can simplify many tasks Enables group beans that need to work together into a single configuration unit Can allow existing XML configuration formats to be used

26、to build Spring configuration,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,How Are XML Configuration Extensions Used?,Tags out of the box for common configuration tasks Many third party products integrating with Spring

27、 Including Java API for XML Web Services (JAX-WS) Reference Implementation User Extensions: Problem-specific configuration Makes it easier to develop and maintain applications Allow XML schema validation Better out of the box tool support Code completion for free Exploit the full power of XML Namesp

28、aces, schema, tooling,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,XML Configuration in Spring 2.0,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is proh

29、ibited.,XML Configuration in Spring 2.0,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,Transaction Simplification,Specialized tags for making objects transactional Benefit from code assistCode assist for transaction attr

30、ibutes,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,Annotation Driven Transactions,Transactional(readOnly=true) interface TestService Transactional(readOnly=false,rollbackFor=DuplicateOrderIdException.class)void create

31、Order(Order order)throws DuplicateOrderIdException;List queryByCriteria(Order criteria); ,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,Annotation Driven Transactions,Copyright 2004-2007, Interface21 Ltd. Copying, publi

32、shing, or distributing without expressed written permission is prohibited.,Out-of-the-Box Namespaces,AOP JMX API Remoting Scheduling MVC Suggestions and contributions welcome A rich library will build over time,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expres

33、sed written permission is prohibited.,Authoring Custom Extensions: Step 1,Write an XSD to define element content Allows sophisticated validation, well beyond DTD Amenable to tool support during development Author with XML tools XML Spy,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or di

34、stributing without expressed written permission is prohibited.,Authoring Custom Extensions: Step 2,Implement a NamespaceHandler to generate Spring BeanDefinitions from element content Helper classes such as BeanDefinitionBuilder to make this easypublic interface NamespaceHandler void init();BeanDefi

35、nition parse(Element element, ParserContext parserContext);BeanDefinitionHolder decorate(Node source,BeanDefinitionHolder definition, ParserContext parserContext); ,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,Authorin

36、g Custom Extensions: Step 3,Add a mapping in a META-INF/spring.handlers filehttp:/www.springframework.org/schema/util=org.springframework.beans.factory.xml.UtilNamespaceHandler http:/www.springframework.org/schema/aop=org.springframework.aop.config.AopNamespaceHandler http:/www.springframework.org/s

37、chema/jndi=org.springframework.jndi.config.JndiNamespaceHandler http:/www.springframework.org/schema/tx=org.springframework.transaction.config.TxNamespaceHandler http:/www.springframework.org/schema/mvc=org.springframework.web.servlet.config.MvcNamespaceHandler,Copyright 2004-2007, Interface21 Ltd.

38、Copying, publishing, or distributing without expressed written permission is prohibited.,Using Custom Extensions,Import relevant XSD Use the new elements,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,Agenda,Spring compo

39、nent model fundamentals Value adds out of the box User extension points Spring 2.0 configuration extensions Spring 2.1 Scaling out the Spring component model,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,Whats New in Sp

40、ring 2.1?,Spring 2.1 Allows use of annotations for configuration, as well as XML Can mix and match annotations and XML JCA 1.5 support Further enhancements in JPA supportAims: Make Spring still easier to use,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed

41、 written permission is prohibited.,Java code: Annotations autoscanned,Component public class FooServiceImpl implements FooService Autowired private FooDao fooDao; public String foo(int id) return fooDao.findFoo(id); ,Aspect public class ServiceInvocationCounter private int useCount; Pointcut(“execut

42、ion(* demo.FooService+.*()“) public void serviceExecution() Before(“serviceExecution()“) public void countUse() this.useCount+; public int getCount() return this.useCount; ,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,

43、Bootstrap configuration,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,One component model,Contributions from different sources of configuration XML Java codeInternal Java metadata not coupled to configuration format,Cop

44、yright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,Agenda,Spring component model fundamentals Value adds out of the box User extension points Spring 2.0 configuration extensions Spring 2.1 Scaling out the Spring component model

45、,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,Scaling Out Spring,Spring can consume objects written in dynamic languages It can also make it easier to scale out applications by deploying and exposing POJOs in new model

46、s Examples Other deployment models such as grid SOA with SCA and ESBs OSGi dynamic modularization,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,Scaling POJOs Out to Grid Deployment,Spring enables applications to be impl

47、emented in POJOs Avoids assumptions about environment in application code Environment changes over time Ignorance is bliss: What your objects dont know cant break them if it changes Hence deployment model can change without breaking code Servlet Application Server Standalone client Grid distribution

48、 technology,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,SCA (Service Component Architecture): A Standard for SOA,Assembly model Service components, references, wires Policy framework QoS etc. Service implementation an

49、d client API Spring Java API C+ BPEL EJB architecture Bindings Web Services, Java Message Service (JMS), Java Cryptography Architecture (JCA),Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,The Open SOA Collaboration,BEA IBM Oracle SAP Sun Interface21 Red Hat Cape Clear Software IONA Primeton Technologies,Sybase Siemens Software AG TIBCO Rogue Wave Software,Copyright 2004-2007, Interface21 Ltd. Copying, publishing, or distributing without expressed written permission is prohibited.,

copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
备案/许可证编号:苏ICP备17064731号-1