Spring Learning--4

Source: Internet
Author: User

Refer to the book "Spring in Action" 1. Aopbefore you wak the walk that you had to learn to walk the Walk.1) advice---the job of a aspect (what and when)/before/aft Er/after-returning/after Throwing/around:beforen and After2) join points---a point in the execution of the application WH Ere an aspect can is plugged in.3) pointcuts---where the advice should be WOVEN4) aspects---advice & joincuts5) Introduc tion---Add new methods or attributes to existing classes.6) weaving---the process of applyng aspects to target object to CR Eate a new proxied object./compile time/class load time/runtime2. How spring supports AOP 1) Classic spring proxy-based AOP2) pure-pojo aspects3) @AspectJ annotation driven aspects.4) injected Aspe CTJ aspects. 3.creating aspect in spring1) selecting join points with pointcuts.eg:execution (* concert. Performance.perform ())
and Bean (' Woodstock ') 2) Creating annotated aspects
@Aspect Public classAudience {@Pointcut ("Execution (* * concert. Performance.perform (..)) ") Public voidperformance () {} @Before ("Performance ()") Public voidSilencecellphones () {System.out.println ("Silencing cell Phones");} @Before ("Performance ()") Public voidtakeseats () {System.out.println ("Taking seats");} @AfterReturning ("Performance ()") Public voidapplause () {System.out.println ("Clap clap Clap!!!");} @AfterThrowing ("Performance ()") Public voidDemandrefund () {System.out.println ("Demanding a refund");}}

Configuration:

@Configuration @enableaspectjautoproxy@componentscan  Public class concertconfig {@Bean public audience audience () {returnnew  audience ();}}

3) handling Params in advice

4) Annotation Introductions

Dynamic language like Ruby and groovy can add new methods to an object or class.

Spring Learning--4

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.