Announcement Announcement Module
No announcement yet.
Dynamic configuration of pointcuts (from database) Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dynamic configuration of pointcuts (from database)

    Hi everyone.

    In my (web) app will to fire some events. Of course I can open my source code and insert some code :
    EventManager evtManager = EventManager.getInstance();
    Event event = new Event(this.getClass(), "currentMethodName", methodArg1, methodArg2);;
    But I want to dynamically decide if an event will be fired and use Spring..
    ConfigDao dao = // Injected
    EventManager evtManager = // Injected
    Event event = new Event(this.getClass(), "currentMethodName", methodArg1, methodArg2);
    if ( dao.willFireEvent(event) ) {;
    That's not really good (I think) so insted of calling the ConfigDao and copying this code in many classes I will use the AOP capabilities.
    I want to write a "ConfiguredPointcut" which use the "ConfigDao" to know if a method will fire an event. But I never have used Spring AOP and really don't know here to start.

    I have tried to write a custom "org.springframework.aop.Pointcut" but I d'ont know how to use It..

    Can someone help me ?


  • #2
    You should be able to achieve this with the existing mechanism available in Spring AOP. Essentially, you will write a poitncut to select methods of your choice, inject the aspect with your DAO, and the advice in the aspect will call dao.willFireEvent(event).