Open-Tao Spring3 (6.8)-AOP 6.8 facet instantiation Model

Source: Internet
Author: User

The so-called facet instantiation model refers to when a slice is instantiated.

Spring AOP supports AspectJ's Singleton, Perthis, and Pertarget instantiation models (Percflow, Percflowbelow, and Pertypewithin are not currently supported).

    • Singleton : that is, there will only be one instance of the slice;
    • Perthis : an AOP object that corresponds to a connection point that matches each pointcut expression creates a new slice instance;
    • Pertarget : The target object of the connection point corresponding to each pointcut expression will create a new slice instance;

The default is the singleton instantiation model, which supports only the singleton instantiation model, while the @aspectj style supports these three instantiation models.

Singleton : using @aspect () specifies that the default is singleton instantiation mode, where the example is not shown.

Perthis : an AOP object corresponding to a connection point that matches each pointcut expression creates a new slice instance that specifies the pointcut expression using @aspect ("perthis (pointcut expression)").

such as @Aspect ("Perthis (Cn.javass.spring.chapter6.service.IIntroductionService)") will match each "this" ( Cn.javass.spring.chapter6.service.IIntroductionService) "The AOP proxy object of the Pointcut expression creates a facet instance, noting that" Iintroductionservice "may be the introduction of an interface.

Pertarget : the target object for each connection point that matches each pointcut expression creates a new slice instance that specifies the pointcut expression using @aspect ("Pertarget (pointcut expression)").

such as @aspect ("Pertarget" (Target (CN.JAVASS.SPRING.CHAPTER6). Service. Ipointcutservice) ") will match" target (Cn.javass.spring.chapter6.service) for each Ipointcutservice) "The target object of the Pointcut expression creates a slice, noting that" ipointcutservice "cannot be an introduction interface.

the tangent scope definition must be defined as "prototype", such as "<bean class=" ... Aspect "scope=" prototype "/>", otherwise you cannot create a slice for each matching connection point's target object or AOP proxy object.

Open-Tao Spring3 (6.8)-AOP 6.8 facet instantiation Model

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.