Announcement Announcement Module
Collapse
No announcement yet.
Spring Doc aop:config example doesnt work Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Doc aop:config example doesnt work

    The schema-based aop config example at http://static.springframework.org/sp...-schema-params doesnt work unless a few changes were made.
    1. Change all fooName to name
    2. Change the advice config like so:

    <aop:around pointcut-ref="theExecutionOfSomeFooServiceMethod"
    method="profile" arg-names="call,name,age"/>

    Does this mean that the JoinPoint param also has to be explicitly declared for methods to be matched up correctly? Or am I missing something?

    FYI the Foo implementation I provided was:
    package x.y.service;

    public class Foo {

    private String name;
    private int age;

    public Foo (String name, int age)
    {
    this.name=name;
    this.age=age;
    }
    public String getName() {return name;}
    public int getAge() {return age;}
    }

  • #2
    1) 'fooName' only applies to the parameter of the intercepted method. "args(name, age)" refers to the advice method only, meaning SimpleProfiler#profile().

    2) Should "argNames" (in annotation style) or "arg-names" (in schema style) include the first parameter if it is of type JoinPoint/ProceedingJoinPoint?
    That's a good question. This is not documented anywhere .
    Even worse: the behavior differs between @Aspect and Schema styles of Spring AOP.

    Comment


    • #3
      1) Yes, I thought so too; I just mentioned that change as well on the outside chance that it might be pertinent.
      2) In fact, it IS documented that its not required . Here's my other question: How is the output shown in the doc got if not by actually running a program, ie, shouldnt the code shown in the doc work? Hence my qn: am I missing something?

      Also, would you care to elaborate on how the Annotation and schema styles differ in behavior? i'm specifically interested in the schema style as I'm using this with a pre-1.5 app, and would like to have my pointcuts configurable.

      Originally posted by plethora View Post
      1) 'fooName' only applies to the parameter of the intercepted method. "args(name, age)" refers to the advice method only, meaning SimpleProfiler#profile().

      2) Should "argNames" (in annotation style) or "arg-names" (in schema style) include the first parameter if it is of type JoinPoint/ProceedingJoinPoint?
      That's a good question. This is not documented anywhere .
      Even worse: the behavior differs between @Aspect and Schema styles of Spring AOP.

      Comment


      • #4
        Originally posted by vinodkd View Post
        2) In fact, it IS documented that its not required .
        Could you provide a link to the part of the documentation that states this?

        As for the difference between @Aspect and Schema styles: it seems that Schema style requires a first parameter of type JoinPoint/ProceedingJoinPoint to be specified in the "arg-names" attributes, while the @Aspect style does not require this.

        Comment


        • #5
          Originally posted by plethora View Post
          Could you provide a link to the part of the documentation that states this?
          No; and that's my point. Most of the documentation uses the Annotation style, and the sections that do talk about the Schema style say nothing about having to declare the JoinPoint param. More specifically - the one complete example does indeed not have the JP param in the point cut declaration. Thats what i meant by "it is documented" - by example.

          Btw, my aim is not to slam the docs. I found by trail and error that adding it gets the code to work; and am still willing to believe that I've got it wrong and there is code in the framework handling the JP param behind-the-scenes - as it well should,imo. hence my questions.

          if the fix for now is to actually declare the param, so be it

          Originally posted by plethora View Post
          As for the difference between @Aspect and Schema styles: it seems that Schema style requires a first parameter of type JoinPoint/ProceedingJoinPoint to be specified in the "arg-names" attributes, while the @Aspect style does not require this.
          Is this a known thing then, or is this the first report of this disconnect?

          Comment


          • #6
            I think this existing JIRA request is about the same thing: http://opensource.atlassian.com/proj...rowse/SPR-3723

            Comment

            Working...
            X