Announcement Announcement Module
Collapse
No announcement yet.
Intercepting Method Calls to POJO Domain Entities Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Intercepting Method Calls to POJO Domain Entities

    Ok, here's the deal. I have a bunch of domain entity (POJO's) being persisted through Hibernate. I have an application facade making the service calls to Hibernate to get 'em, save 'em, and delete them. But I want to intercept calls to the POJO's getters, setters, and whatever other methods I feel like auditing. Since auditing is a cross cutting concern, I went with good design practice (this time) and kept the auditing concern seperate from the domain model, and would like to intercept calls to both logic classes (singletons), and entity classes (non-singleton / POJO) in order to log them, or who knows what down the road.

    Is the AutoProxyCreator thingy the right way to go, or should I be looking at a standard Interface Proxy... Or is it impossible unless I perform the logging directly from my POJO's? (I doubt that seriously).

    Need some help looking under the right hood.

    Thanks in advance...
    -tyson

  • #2
    Tyson,

    When Spring doesn't control the lifecycle of an object it is often difficult for it to actually proxy an object. Hibernate itself support an Interceptor which can be used to modify entities and perform certain amounts of logging. However, I recommend that for such fine-grained usage of AOP you look to AspectJ which will give you a really elegant solution to this problem.

    Rob

    Comment

    Working...
    X