spring framework introduction
TRANSCRIPT
![Page 1: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/1.jpg)
Copyright 2010 TCloud Computing Inc.
Spring Framework IntroductionAlex Su2010/06/14
![Page 2: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/2.jpg)
Agenda
Trend Micro Confidential
• 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)
![Page 3: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/3.jpg)
IOC
Trend Micro Confidential
• IOC Type• Type 1 : interface injection• Type 2 : setter injection• Type 3 : constructor injection
![Page 4: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/4.jpg)
AOP
Trend Micro Confidential
![Page 5: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/5.jpg)
AOP
Trend Micro Confidential
![Page 6: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/6.jpg)
AOP
Trend Micro Confidential
• Aspect• Advice• Interceptor• Introduction• Joinpoint• Pointcut• Target• Proxy• Weave
![Page 7: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/7.jpg)
AOP
Trend Micro Confidential
![Page 8: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/8.jpg)
AOP
Trend Micro Confidential
@Aspectclass BeforeExample { @Before("execution(* com.xyz.myapp.dao.*.*(..))") public void doAccessCheck() { // ... }}
@Aspectclass AfterReturningExample { @AfterReturning("com.xyz.myapp.SystemArchitecture.dataAccessOperation()") public void doAccessCheck() { // ... }}
![Page 9: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/9.jpg)
AOP
Trend Micro Confidential
@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; }}
![Page 10: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/10.jpg)
Pointcut designator
Trend Micro Confidential
• 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)
![Page 11: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/11.jpg)
Architecture
Trend Micro Confidential
![Page 12: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/12.jpg)
Architecture
Trend Micro Confidential
![Page 13: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/13.jpg)
Architecture
Trend Micro Confidential
• Bean Scope• Singleton• Prototype• Request• Session• Custom
![Page 14: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/14.jpg)
Architecture
Trend Micro Confidential
![Page 15: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/15.jpg)
Architecture
Trend Micro Confidential
![Page 16: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/16.jpg)
Xml v.s. Annotation
Trend Micro Confidential
public class SimpleMovieLister { private MovieFinder movieFinder;
public void find() { movieFinder.find(); }
public void setMovieFinder(MovieFinder movieFinder) {
this.movieFinder = movieFinder; }}
![Page 17: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/17.jpg)
Xml v.s. Annotation
Trend Micro Confidential
<bean id="movieFinder" class="com.sample.MovieFinder"/>
<bean id="simpleMovieLister” class="com.sample.SimpleMovieLister">
<property name="movieFinder"> <ref local="movieFinder"/>
</property></bean>
![Page 18: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/18.jpg)
Xml v.s. Annotation
Trend Micro Confidential
@Service
public class SimpleMovieLister {
@Resource
private MovieFinder movieFinder;
public void find() {
movieFinder.find();
}
}
![Page 19: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/19.jpg)
Xml v.s. Annotation
Trend Micro Confidential
• stereotype annotations• @Component• @Service• @Controller• @Repository
Controller Service Repository
![Page 20: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/20.jpg)
SpEL
Trend Micro Confidential
• 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
![Page 21: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/21.jpg)
Testing
Trend Micro Confidential
@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(locations = { "classpath:appContext_core.xml",
"classpath:appContext_index.xml”})public abstract class AbstractTestCase {
}
![Page 22: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/22.jpg)
Testing
Trend Micro Confidential
• Spring-specific annotations–@TransactionConfiguration–@BeforeTransaction–@AfterTransaction–@IfProfileValue–@ExpectedException–@Timed–@Repeat
![Page 23: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/23.jpg)
CXF
Trend Micro Confidential
• 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
![Page 24: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/24.jpg)
CXF
Trend Micro Confidential
• RESTful services–JAX-RS–JAX-WS Provider and Dispatch–HTTP Binding(deprecated)
![Page 25: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/25.jpg)
CXF
Trend Micro Confidential
• Parameters–@PathParam–@QueryParam–@HttpHeader–@MatrixParam–@FormParam–@CookieParam–PathSegment
![Page 26: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/26.jpg)
Reference
Trend Micro Confidential
• http://caterpillar.onlyfun.net/Gossip/• http://www.springsource.org/• http://cxf.apache.org/
![Page 27: Spring Framework Introduction](https://reader036.vdocuments.site/reader036/viewer/2022062307/5562f730d8b42a62598b4759/html5/thumbnails/27.jpg)
Trend Micro Confidential
THANK YOU!