In Spring AOP and configuration

In Spring AOP and configuration

    AOP (Aspect Oriented Programming) namely: Aspect-oriented programming, dynamic proxies
        advantages: reduces code duplication, providing development efficiency, easy maintenance
        AOP Related Terms:
            Joinpoint (connection points): refers to those intercepted point, the spring finger the method is, because spring supports only method type of connection points
            pointcut (entry point): is what we want to define Joinpoint intercepted
            Advice (notification / enhancements): is after intercepting Joinpoint thing to do is to inform.
Type of notification: notification front, rear notification, abnormality notification, the final notification, the notification surround
            Introduction (introducing): is a special notification without modifying the code to the premise, may add some class dynamically at runtime method or Field,
            target (target audience): proxy target object
            weaving (weaving): refers to the enhancement applied to the target object to the process of creating a new proxy object, spring dynamic weaving, and AspectJ using compile time weaving and weaving class loading of
            the proxy (agent): after being woven into a class enhanced AOP, to produce a resultant proxy class
            Aspect (section): the entry point and the notification (introducing) the binding

spring AOP xml-based configuration:

    1. The notification also to the spring managed bean
    2. aop: config tag indicates the start AOP configuration
    3. aop: aspect tag indicates that the configuration section
        id attribute is cut to provide a unique identification
        ref attribute specifies the notification of the bean class id
    . 4 in aop: corresponding tag type using the internal aspect tag configured notifications
        aop: before: pre-notification showing the configuration
        method attribute specifies: Logger class which is pre-notification
        pointcut attribute specifies the pointcut expression, pointed out that the business layer which methods to enhance
    writing pointcut expressions:
        keywords: execution (expression)
        expression: access modifiers return value package names package name ... the name of the class method name (parameter list).
        standard wording:

public void com.ycl.servicer.impl.AccountServicer.saveAccount()

        The return value can use wildcards, represent any return value

* com.ycl.servicer.impl.AccountServicer.saveAccount()

        Package name can use wildcards, it represents any package, but there are a few levels to write several packages

* *.*.*.*AccountServicer.saveAccount()

        You can use the package name and its children ... represent the current package

 * *..AccountServicer.saveAccount()

        Class and method names can be used to achieve a wildcard *

* *..*.*()

    Parameter List:
        can write data directly to the type of
            basic types of direct write Name: int
            reference type name of the class to write the package name of ways:. Java.lang.String
        can use wildcard represents any type, but must have parameters
        you can use ... indicate whether the parameters are can
    all pass with the wording:

execution(* *..*.*(..))

    Pointcut expression in the actual development of the usual wording:

切到业务层实现类下的所有方法:* com.ycl.service.impl.*.*(..)
Published 21 original articles · won praise 2 · Views 266

Guess you like

Origin blog.csdn.net/weixin_45636641/article/details/104147507