Results 1 to 2 of 2

Thread: how to match to method name

  1. #1
    Join Date
    Aug 2004
    Posts
    12

    Default how to match to method name

    how to match method name? for example:
    public interface IMyBussessObject {
    public String getSomething();
    [b]public String doOtherthing();
    }

    I only want to do scuritycheck on getSomething, and do advice doOtherthing();
    here is my application.xml:which will apply to all the method

    <beans>
    <bean id="myAdvice" class="com.ping.springdemo.MyAdvice">
    </bean>
    <bean id="businessObjectTarget" class="com.ping.MyBusinessObject" />
    <bean id="securityInterceptor" class="com.ping.springdemo.SecurityInterceptor" />
    <bean id="businessObject"
    class="org.springframework.aop.framework.ProxyFact oryBean">
    <property name="target"><ref local="businessObjectTarget"/>
    </property>
    <property name="interceptorNames">
    <list>
    <value>securityInterceptor</value>
    <value>myAdvice</value>
    </list>
    </property>
    </bean>
    </beans>

  2. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    You need to define two pointCuts:
    1. pointCut for getSomething
    Code:
      <bean id="SecurityPointCut" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
        <property name="advice">
          <ref local="securityInterceptor"/>
        </property>
        <property name="pattern">
          <value>.*get.*</value>
        </property>
      </bean>
    2. pointCut for doOtherThing
    Code:
      <bean id="AdvisorPointCut" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
        <property name="advice">
          <ref local="myAdvice"/>
        </property>
        <property name="pattern">
          <value>.*do.*</value>
        </property>
      </bean>
    then you have to apply these pointCuts to your businessObject
    Code:
      <bean id="businessObject" class="org.springframework.aop.framework.ProxyFactoryBean">
        <property name="target">
          <ref local="businessObjectTarget"/>
        </property>
        <property name="interceptorNames">
          <list>
            <value>SecurityPointCut</value>
            <value>AdvisorPointCut</value>
          </list>
        </property>
      </bean>
    HTH
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. EHCaching Hibernate
    By dencamel in forum Data
    Replies: 3
    Last Post: Sep 6th, 2005, 09:03 PM
  4. PerformanceMonitorInterceptor
    By tnist in forum AOP
    Replies: 3
    Last Post: Aug 24th, 2005, 01:39 PM
  5. Replies: 1
    Last Post: Jul 28th, 2005, 05:08 PM

Posting Permissions

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