Announcement Announcement Module
Collapse
No announcement yet.
Did I use AOP wrongly? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Did I use AOP wrongly?

    Hi,

    (soory, I'm a beginner in english and AOP)

    Hi,

    I have and/or would like two proxy objects, which are bi-directional connected:

    AProxy <-> BProxy

    Code:
    A.setB&#40;B&#41; &#123;
      B.setA&#40;A&#41;
    &#125;
    A and B are POJOs.

    I use the MethodIntercepter to recognize changes to the object.
    New values over the setters are logged into a database.
    Unfortunately the proxy objekt (AProxy) is lost through AProxy.setB(B).
    B.getA() supplies A but I would have gladly AProxy.

    Is there a solution with AOP for my requirement? Or must I code
    this for each setter: ?

    Code:
    setName&#40;String newName&#41; &#123;
      if &#40;name.compareTo&#40;newName&#41; != 0&#41; &#123;
        addHistory&#40;new History&#40;this, "name", newName&#41;&#41;;
      &#125;
      name = newName
    &#125;
    Thanks for a help
    Torsten

  • #2
    Did I use AOP wrongly?
    Well you can't access the proxy internally, unless it's inserted by Spring. This sort of thing could be done with AspectJ.

    Is there a solution with AOP for my requirement? Or must I code
    this for each setter: ?
    This should work OK with non-proxied objects in Spring AOP.

    Comment

    Working...
    X