Announcement Announcement Module
Collapse
No announcement yet.
Aspect vs. Abstract Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Aspect vs. Abstract

    Opinions please....

    I have a hibernate entity where I'd like to enforce some before advise. An interceptor won't work in the entity though because the annotation is being picked up as a hibernate annotation and not a spring annotation (at least, to the best of my knowlege).

    So, the options are...

    1. Implement an interceptor at the manager level to intercept any execution of the executeStuff method. However, anybody writing a manager that interacts with my entity would need to know to add that annotation to the manager to trigger that interceptor.

    2. Make the entity implement an abstract class that would contain something like ...

    public void executeStuff() {
    ...
    ...
    doStuff();
    ...
    ...
    }

    where doStuff is ...

    protected abstract void doStuff();

    So, any class extending the entity would need to implement doStuff, but that would handle all prerequisite processing.


    What I'm looking for is...which one is a better architecture decision and why?

    Thank you,

    Aaron

  • #2
    To me. The second option seems better.

    Why? Because the intent is clearer.

    Comment


    • #3
      Glad you confirmed.... We ended up going with the 2nd route for precisely that reasoning....

      Comment

      Working...
      X