Announcement Announcement Module
No announcement yet.
AOP Basics? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • AOP Basics?

    Trying to use AOP with Spring 2.56.

    I have been through the manual and looked at examples and believe I have most of what I need. What I'm confused about is how to pass parameters into my before advice method when I define it. The docs seem to be lacking.

    Whatever we do needs to be upward compatible with 3.0.


  • #2
    you're kidding right?

    From the reference documentation, page 248:

    The MethodBeforeAdvice interface is shown below.

    public interface MethodBeforeAdvice extends BeforeAdvice {
    void before(Method m, Object[] args, Object target) throws Throwable;
    your before method has the advised method's calling parameters passed as an array of objects.


    • #3
      But that's Spring 1.0, right? 2.0 says I can create advices that don't implement any particular interface or extend a superclass.


      • #4
        that's Spring 1,2 and 3. That's the interface the before advice is modelled upon. Your aspect class doesn't need to implement it, but nonetheless if you declare that class as a before-advice in the aop:config you CAN pass the Object[]args to your aspect method and Spring will be smart enough to fill it with the parameters used to call the advised method.


        • #5
          hi thehl

          i found a very useful post that would help us digest and understand Spring AOP more. it has some samples too.

          hope this helps