Results 1 to 2 of 2

Thread: AOP to generate ApplicationEvents

  1. #1
    Join Date
    Nov 2004
    Location
    St. Louis, Missouri USA
    Posts
    33

    Default AOP to generate ApplicationEvents

    We have employees, for example. EmployeeDAO and the standard hibernatetemplate stuff with OpenSessionInViewInterceptor. It's all working fine. The "owned" objects (declared in the mapping) are cascade deleted successfully.
    As we add new subsystems to the application, we find other domain objects which refer to an association with an employee. We would like to be able to add such subsystems without having to alter the existing mapping of the Employee - we're using XDoclet to generate those by the way. The Employee doesn't own these other objects (object graphs), doesn't own the associations, to be exact doesn't even know they exist.

    Some of these other systems are interested in Employee delete events. I may not have access to the EmployeeDAO code, so I can't just add new methods to it to generate or publish events. Is AOP an answer here? Can I intercept delete methods in various DAOs and have them publish EmployeeDeleteApplicationEvents, so to speak? Is this a path worth pursuing, does anybody here have experience with similar situations?

    I don't see a lot in the docs about ApplicationEvents, I would also appreciate any advice as to their successful implemention in Spring.

    Thanks,
    K

  2. #2
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    Yes you could intercept delete methods on your DAOs and publish an ApplicationEvent. We use ApplicationEvent extensively within Acegi Security. It's pretty straight-forward, it just works.

    In relation to your interceptor, the easiest way is to write an implementation of MethodInterceptor, extend Spring's StaticMethodMatcherPointcutAdvisor, and use a DefaultAdvisorAutoProxyCreator in your application context. I posted some source code for a similar DAO advisor and interceptor at http://forum.springframework.org/showthread.php?t=11293. You'd just need your MethodInterceptor to implement ApplicationContextAware to get hold of the ApplicationContext so it can applicationContext.publishEvent(yourEvent).
    Last edited by robyn; May 14th, 2006 at 11:58 AM.

Similar Threads

  1. Generate Unit Tests
    By schuer in forum Container
    Replies: 4
    Last Post: Oct 2nd, 2005, 11:27 AM
  2. Generate xml files based off different schemas?
    By realdahan in forum Architecture
    Replies: 3
    Last Post: Jun 20th, 2005, 09:31 AM
  3. I didn't Generate PDF File
    By Yashima in forum Web
    Replies: 2
    Last Post: Apr 8th, 2005, 02:37 AM
  4. Cant Generate Warfile
    By ynkian in forum Swing
    Replies: 2
    Last Post: Mar 10th, 2005, 09:42 PM
  5. Replies: 3
    Last Post: Jan 17th, 2005, 03:52 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
  •