Annotated configuration of Spring's AOP

Source: Internet
Author: User

The configuration process can be easily divided into 3 steps:

1, Business class configuration

Join before the business class and leave the business class to spring management

@Component ("s")

This indicates that the bean name of this business class is S.

2, associating tangency and tangent classes

Put two sentences in front of the slicing class

@Aspect annotations indicate that this is a facet
@Component says this is a bean, managed by spring

In addition to the specific method of the slice class, it means that when the pointcut is triggered, the function is executed in the around manner, which is equivalent to associating the tangent point with the processing method of the tangent line.

The @Around (value = "Execution (* com.how2java.service.productservice.* (..))") represents the Com.how2java.service.ProductService All methods in this class are tangent

The implication is that when a function in expression is called, the tangent function is triggered in the form of around, which precedes who is defined as the tangent function, which is the accessibility function.

3, add some content to the XML:

<base-package= "Com.how2java.aspect"/><   Base-package= "Com.how2java.service"/>  Scan packages Com.how2java.aspect and Com.how2java.service, locate business classes and slice classes
< Aop:aspectj-autoproxy />
Find the annotated slice class, and make a slice configuration

Annotated configuration of Spring's AOP

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.