Announcement Announcement Module
Collapse
No announcement yet.
How-to use dynamic pointcut Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How-to use dynamic pointcut

    I'm using Spring and EhCache to implement method caching. It works like a charm!

    Now I want to be able to intercept a method depending on it's parameters.

    Code:
    public interface StuffDao {
        void getStuff(String id);
        void getStuff(String id, Date date);
    }
    For example, if I only want to intercept the method :

    void getStuff(String id);

    and not

    void getStuff(String id, Date date);


    How to built my pointcut. I'm use to the RegexpMethodPointcutAdvisor. But I don't think I can use this one for what I want.


    Code:
    <bean id="PointCutStuffDao" class="This is my question???">
    	<property name="advice">			
                 <ref local="IntercepteurCache" />
    	</property>
    	<property name="pattern">
                 <value>.*getStuff&#40;String&#41;</value>     <!-- I want to do something similar to this -->
    	</property>
    </bean>

  • #2
    Extend DynamicMethodMatcherPointcut or DynamicMethodMatcherPointcutAdvisor. You can then implement the following method to check arguments:

    Code:
    boolean matches&#40;Method method, Class targetClass, Object&#91;&#93; args&#41;;
    Rgds
    Rod

    Comment


    • #3
      thank you

      This is what I needed.

      Comment

      Working...
      X