Results 1 to 5 of 5

Thread: apply JdkRegexpMethodPointcut to multiple beans? how?

  1. #1

    Default apply JdkRegexpMethodPointcut to multiple beans? how?

    Hi, I want to apply an advisor to multiple beans at the same time. I tried BeanNameAutoProxyCreator as follows:

    <bean id="myAutoProxyCreator"
    class="org.springframework.aop.framework.autoproxy .BeanNameAutoProxyCreator">
    <property name="beanNames">
    <value>*Manager</value>
    </property>
    <property name="interceptorNames">
    <list>
    <idref bean="myAdvisor"/>
    </list>
    </property>
    </bean>

    <bean id="advisor" class="org.springframework.aop.support.DefaultPoin tcutAdvisor">
    <property name="advice">
    <ref local="myInterceptor"/>
    </property>
    <property name="pointcut">
    <bean class="org.springframework.aop.support.JdkRegexpMe thodPointcut">
    <property name="pattern">
    <value>^org.example.service.[a-zA-Z]{1}(\\w)*Manager.(\\w)*</value>
    </property>
    </bean>
    </property>
    </bean>

    The reason why I am using JdkRegexpMethodPointcut is because there are many other Manager objects that are from the Spring and other packages. So I want to add some restriction.

    The problem is that none of my service methods get called. Am I doing something wrong? Is the above declaration correct?

    Thanks, Pete

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    Don't you get a NoSuchBeanDefinitionException?
    Shouldn't <idref bean="myAdvisor"/> be <idref bean="advisor"/>?

  3. #3

    Default

    you are right. it should be <idref bean=advisor"/> and it is in my
    application. it is a typo here only.

    i did not get any exception.

    thanks, pete

  4. #4
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    Your cofiguration looks right - try testing with a simpler regular expression.

  5. #5
    Join Date
    Jul 2008
    Posts
    2

    Default Regex for a DAO method

    I made this one to look for DAO methods:

    <bean id="daoPointcut"
    class="org.springframework.aop.support.JdkRegexpMe thodPointcut">
    <property name="pattern"
    value="^[a-zA-Z0-9.]+Dao.[a-zA-Z0-9() ]+$" />
    </bean>

    Just change the "Dao" for Manager, Service, Controller, etc.

    Regards,
    Omar

Similar Threads

  1. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  2. Beans from multiple projects
    By sbhatti in forum Data
    Replies: 1
    Last Post: Mar 31st, 2005, 02:50 PM
  3. Replies: 1
    Last Post: Feb 24th, 2005, 03:18 PM
  4. Replies: 2
    Last Post: Jan 14th, 2005, 11:04 AM
  5. Configuring multiple similar beans
    By jonmor in forum Container
    Replies: 3
    Last Post: Nov 11th, 2004, 11:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •