Results 1 to 2 of 2

Thread: Dynamic configuration of pointcuts (from database)

  1. #1

    Default 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. #2
    Join Date
    Jun 2006
    Location
    SF Bay Area, California
    Posts
    524

    Default

    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
    Ramnivas Laddad (Follow me on Twitter)
    AspectJ in Action: Enterprise AOP with Spring Applications (2nd edition). Now available!

Posting Permissions

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