Spring Framework Introduction

1,153 views
1,082 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,153
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
35
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Spring Framework Introduction

  1. 1. Spring Framework IntroductionAlex Su2010/06/14 Copyright 2010 TCloud Computing Inc.
  2. 2. Agenda•Concept – IOC(Inverse of Control and Dependency Injection) – AOP(Aspect-Oriented Programming)•Core Technologies – Architecture – Xml v.s. Annotation – SpEL – Testing•Integration – CXF(web services and restful services) Trend Micro Confidential
  3. 3. IOC•IOC Type •Type 1 : interface injection •Type 2 : setter injection •Type 3 : constructor injection Trend Micro Confidential
  4. 4. AOPTrend Micro Confidential
  5. 5. AOPTrend Micro Confidential
  6. 6. AOP• Aspect• Advice• Interceptor• Introduction• Joinpoint• Pointcut• Target• Proxy• Weave Trend Micro Confidential
  7. 7. AOPTrend Micro Confidential
  8. 8. AOP@Aspectclass BeforeExample { @Before("execution(* com.xyz.myapp.dao.*.*(..))") public void doAccessCheck() { // ... }}@Aspectclass AfterReturningExample {@AfterReturning("com.xyz.myapp.SystemArchitecture.dataAccessOperation()") public void doAccessCheck() { // ... }} Trend Micro Confidential
  9. 9. AOP@Aspectclass AroundExample {@Around("com.xyz.myapp.SystemArchitecture.businessService()") public Object doBasicProfiling(ProceedingJoinPoint pjp)throws Throwable { // start stopwatch Object retVal = pjp.proceed(); // stop stopwatch return retVal; }} Trend Micro Confidential
  10. 10. Pointcut designator• execution(modifiers-pattern? ret-type-pattern declaring-type-pattern? name- pattern(param-pattern) throws-pattern?)• execution(public * *(..))• execution(* com.xyz.service.AccountService.*(..))• within(com.xyz.service.*)• within(com.xyz.service..*)• this(com.xyz.service.AccountService)• target(com.xyz.service.AccountService) Trend Micro Confidential
  11. 11. Architecture Trend Micro Confidential
  12. 12. Architecture Trend Micro Confidential
  13. 13. Architecture• Bean Scope • Singleton • Prototype • Request • Session • Custom Trend Micro Confidential
  14. 14. Architecture Trend Micro Confidential
  15. 15. Architecture Trend Micro Confidential
  16. 16. Xml v.s. Annotationpublic class SimpleMovieLister { private MovieFinder movieFinder; public void find() { movieFinder.find(); } public void setMovieFinder(MovieFinder movieFinder) { this.movieFinder = movieFinder; }} Trend Micro Confidential
  17. 17. Xml v.s. Annotation<bean id="movieFinder" class="com.sample.MovieFinder"/><bean id="simpleMovieLister” class="com.sample.SimpleMovieLister"> <property name="movieFinder"> <ref local="movieFinder"/> </property></bean> Trend Micro Confidential
  18. 18. Xml v.s. Annotation@Servicepublic class SimpleMovieLister { @Resource private MovieFinder movieFinder; public void find() { movieFinder.find(); }} Trend Micro Confidential
  19. 19. Xml v.s. Annotation• stereotype annotations • @Component • @Service • @Controller • @Repository Controller Service Repository Trend Micro Confidential
  20. 20. SpEL• Literal expressions• Properties, Arrays, Lists, Maps, Indexers• Methods• Operators• Assignment• Types• Constructors• Variables• User defined functions• Ternary Operator• Elvis Operator• Safe Navigation operator• Collection Selection• Collection Projection• Expression templating Trend Micro Confidential
  21. 21. Testing@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(locations = { "classpath:appContext_core.xml", "classpath:appContext_index.xml”})public abstract class AbstractTestCase {} Trend Micro Confidential
  22. 22. Testing• Spring-specific annotations – @TransactionConfiguration – @BeforeTransaction – @AfterTransaction – @IfProfileValue – @ExpectedException – @Timed – @Repeat Trend Micro Confidential
  23. 23. CXF• JAX-WS Support – SOAP 1.1, 1.2• RESTful services – JSON & XML support• WS-* Support – WS-Addressing, WS-Policy, WS-ReliableMessaging and WS-Security• Spring Integration• Bus – Fast Infoset Trend Micro Confidential
  24. 24. CXF• RESTful services – JAX-RS – JAX-WS Provider and Dispatch – HTTP Binding(deprecated) Trend Micro Confidential
  25. 25. CXF• Parameters – @PathParam – @QueryParam – @HttpHeader – @MatrixParam – @FormParam – @CookieParam – PathSegment Trend Micro Confidential
  26. 26. Reference• http://caterpillar.onlyfun.net/Gossip/• http://www.springsource.org/• http://cxf.apache.org/ Trend Micro Confidential
  27. 27. THANK YOU! Trend Micro Confidential

×