Announcement Announcement Module
Collapse
No announcement yet.
Dynamic configuration of pointcuts (from database) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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 :
    Code:
    EventManager evtManager = EventManager.getInstance();
    Event event = new Event(this.getClass(), "currentMethodName", methodArg1, methodArg2);
    evtManager.fire(event);
    But I want to dynamically decide if an event will be fired and use Spring..
    Code:
    ConfigDao dao = // Injected
    EventManager evtManager = // Injected
    Event event = new Event(this.getClass(), "currentMethodName", methodArg1, methodArg2);
    if ( dao.willFireEvent(event) ) {
      evtManager.fire(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 ?

    Thanks

  • #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).

    -Ramnivas

    Comment

    Working...
    X