Newsletter

RegularExpressionMethodPointcut Class In Spring AOP

Spring » on Sep 21, 2012 { 6 Comments } By Sivateja

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..

  • pattern
  • patterns

some thing…

<bean id="id1" class="org.spfw.aop.support.RegularExpressionMethodPointcut">
    <property name="pattern">
       <value>get.*N.+[0-9]</value>
    </property>
</bean>

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.

​​

  ::. About the Author .::

Java4s_Author
Sivateja Kandula - Java/J2EE Full Stack Developer
Founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog, Love Java and UI frameworks.
You can sign-up for the Email Newsletter for your daily dose of Java tutorials.

Comments

6 Responses to “RegularExpressionMethodPointcut Class In Spring AOP”
  1. sridhar says:

    Thanks to java4s for giving the wonderful tutorial.But where is the rest of the topics in Spring AOP i.e., Dynamic PointCut etc..???Am excepting you to finish this AOP Tutorial ASAP.

  2. debasish says:

    Where is the rest of the part….it is really good..but need to complete rest of the topic with detailed example and explanation

  3. prasad says:

    good website.
    please post dynamic pointcut in aop of spring framework

  4. pandu says:

    please post in what are the ways to integrate spring with hibernate and explain them?
    from my analysis 2 ways
    1. by using hibernate template class
    2. by using MVC with DAO design pattern
    please tell me other ways

  5. nath says:

    Hi Sivateja…. Nice website for easy learning as you website tag line saying “get it your self”. 🙂

    You said at starting there are 9 concepts in AOP (Aspect,Advice,JoinPoint,Pointcut,Introduction,Target,Proxy,Weaving,Adviser), so far we covered 4 concepts only. What about other concepts? those not much used or you are going to cover those soon?

    looking ahead for remaining concepts(Introduction,Target,Proxy,Weaving,Adviser).

  6. Venkatesh says:

    Hi,
    please provide spring JPA concepts

    Regards,
    Venkatesh.

Name*
Mail*
Website



By posting your answer, you agree to our comments policy.
Most Recent Posts from Top Categories
Spring Boot Hibernate Spring
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2024 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.