欢迎来到麦多课文档分享! | 帮助中心 海量文档,免费浏览,给你所需,享你所想!
麦多课文档分享
全部分类
  • 标准规范>
  • 教学课件>
  • 考试资料>
  • 办公文档>
  • 学术论文>
  • 行业资料>
  • 易语言源码>
  • ImageVerifierCode 换一换
    首页 麦多课文档分享 > 资源分类 > PPT文档下载
    分享到微信 分享到微博 分享到QQ空间

    Advanced Spring Framework.ppt

    • 资源ID:378080       资源大小:515.50KB        全文页数:59页
    • 资源格式: PPT        下载积分:2000积分
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    二维码
    微信扫一扫登录
    下载资源需要2000积分(如需开发票,请勿充值!)
    邮箱/手机:
    温馨提示:
    如需开发票,请勿充值!快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如需开发票,请勿充值!如填写123,账号就是123,密码也是123。
    支付方式: 支付宝扫码支付    微信扫码支付   
    验证码:   换一换

    加入VIP,交流精品资源
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    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.,


    注意事项

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




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

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

    收起
    展开