RegularExpressionMethodPointcut Class In Spring AOP
RegularExpressionMethodPointcut class is going to verify whether the method name of the class is matching with the given regular expression or not. If matches then those methods are eligible to get Advices. While configuring these classes into xml file, we are going to configure any one of following 2 properties..
<bean id="id1" class="org.spfw.aop.support.RegularExpressionMethodPointcut">
According to above configuration, a method name should start with get, and between get and letter N there should be one or more characters and finally that should end with a digit. If method name satisfies this pattern then it is eligible for getting advices.
While working with regular expressions, we have following indications..
. – matches for single character
.* – matches for zero [or] more characters
.+ – matches for 1 [or] more characters
.? – matches for zero [or] 1 character
[A-Z] – matches for an upper case alphabet
[abc] – matches for either a or b or c
[0-9] – matches for a digit
If we want to configure multiple regular expressions then we need to configure patterns property with list as NameMatchMethodPointcut, will see the example in the next article.
Sivateja Kandula ♦ [ Java/J2EE Developer & Web Designer ]
Founder of Java4s.com - Indian, lives in United States. You can contact me at sivateja [at] java4s.com
Follow me on