The role

Source: Internet
Author: User
Tags aop

Weaving @aspectj Facets by configuration

Although the facets can be woven programmatically, in general, we use spring's configuration to automate the creation of the agent-woven facets.

The <aop:aspectj-autoproxy/> Declaration of the AOP namespace automatically creates an agent for those beans in the spring container that are configured with @aspectj facets, weaving the facets. Of course, spring

In the internal still use Annotationawareaspectjautoproxycreator for automatic proxy creation work, but the details of the implementation has been <aop:aspectj-autoproxy/> hidden up

<aop:aspectj-autoproxy/> has a Proxy-target-class property, which defaults to false, which means that the use of JDK dynamic agent weaving enhancements, when fitted as <aop:aspectj-autoproxy Poxy-target-class= "true"/> Represents the use of Cglib dynamic Agent technology to weave in the enhancement. However, even if the Proxy-target-class is set to False, if the target class does not declare an interface, spring will automatically use the Cglib dynamic proxy.

@AspectJ Grammar Basics

@AspectJ the facets are described using the jdk5.0 annotation and the tangent expression language of the regular AspectJ 5, because spring supports only the connection points of the method, spring supports only partial aspectj of the tangent language, and in this section, We will do the necessary learning for the aspectj tangent-point expression language.

Tangent-point expression functions

The pointcut expression for AspectJ 5 consists of a keyword and an action parameter. such as execution (*greeto (..)) The pointcut expression, "execute" is the keyword, and "*greeto (..)" is the action parameter. Here, execution executes a method on behalf of the target class, and "*greeto (..)" is a matching pattern string that describes the target method, which together represents the tangent point matching the target class Greeto (..) The connection point of the method. For the sake of convenience, we call execution () a function and match the string "*greeto (..)" Referred to as a function's entry parameter.

Role of ">

Role of ">

Role of ">

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.