Expression asterisk (*) in Spring AOP

Source: Internet
Author: User
<AOP: config> <AOP: pointcut id = "method" expression = "execution (** .. service. Save (...)"/> </AOP: config>

Complete Expression type, as follows:
Execution (modifiers-pattern?Ret-type-PatternDeclaring-type-pattern?Name-pattern (param-pattern)Throws-Pattern ?)

Modifiers-pattern indicates the modifier (public/protect, etc)

Ret-type-pattern indicates the return type (INT/string/long, etc)

Declaring-type-pattern indicates the matched path (under what package)

Name-pattern indicates the name of the matching method.

Throws-Pattern: exception matching type
Can I leave it blank with a question mark ,? 0 or 1 in a regular expression.

The return type mode determines that the return type of the method must match a connection point in sequence. The most frequently used return type mode is*It indicates matching any return type. Only the methods of the given type are returned. The name pattern matches the method name. You can use
*Wildcard characters are used as all or part of naming rules. The parameter mode is a bit complicated:()Matches a method that does not accept any parameters, while
(..)
Matches a method that accepts any number of parameters (zero or more ). Mode(*)Matches a method that accepts any type of parameter. Mode
(*, String)
Matches a method that accepts two parameters. The first method can be of any type, and the second method must be of the string type. See
Language semantics section.

 

Below are some examples of common entry point expressions.

    •  

      Match all methods

    • Execution (**(..))
    • Execution of any public method:
    • Execution (Public **(..))
    • Execution of any method starting with "set:

      Execution (* Set *(..))
    • UserserviceExecution of any method of the interface:

      Execution (* COM. Service. userservice .*(..))
    • Define the execution of any method in the service package:

      Execution (* COM. Service .*.*(..))
    • Define the execution of any method in the service package or sub-package:

      Execution (* COM. Service ..*.*(..))

 

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.