Pointcut is the pointcut that configures the cut-in position of the slice. Because the granularity of pointcuts in spring is a method level, the role of pointcut in spring AOP is to configure which of the classes are within the point of our definition and which methods should be filtered out. Spring's pointcut is divided into static pointcut, dynamic pointcut and user-defined pointcut three kinds, in which static pointcut only need to consider class name, method name; dynamic Pointcut In addition, consider the parameters of the method, So that the location of the pointcut can be determined dynamically at run time.
1. Static Pointcut
Static means invariant, such as the names of methods and classes. So we can determine which methods of those classes are based on the signatures of classes and methods within the pointcut we define, and which should be filtered out.
The following implementation classes for the static pointcut in the definition in spring are described below:
1, Namematchmethodpointcut: Only on the method name discriminant static Pointcut implementation class.
Examples of usage are as follows:
Code
<bean id="NameMatchMethodPointcut" class="org.springframework.aop.support.NameMatchMethodPointcut">
<property name="mappedNames">
<list>
<value>pos*</value>
<value>start</value>
</list>
</property>
</bean>
Note: post* represents all methods that start with a POS. (case sensitive).
In addition, Namematchmethodpointcut exposes the Classfilter attribute of the Classfilter type, which can be used to specify the implementation class of the Classfilter interface to set the class filter. The Classfilter interface is defined as follows:
Code
package org.springframework.aop;
public interface ClassFilter {
boolean matches(Class clazz);
ClassFilter TRUE = TrueClassFilter.INSTANCE;
}
package org.springframework.aop;
Where the matches method is used for the match of the class, the parameter clazz is the target class that needs to match, and returns true if the match succeeds.