spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
56.59k stars 38.13k forks source link

Clearly document interaction of argNames/arg-names and JoinPoint/ProceedingJoinPoint parameter [SPR-3723] #8404

Closed spring-projects-issues closed 12 years ago

spring-projects-issues commented 17 years ago

Taras Tielkes opened SPR-3723 and commented

The first parameter of an advice method can be of type JoinPoint/ProceedingJoinPoint. The documentation is unclear whether the argNames annotation parameter and the arg-names XML attribute should include such a parameter when it is present in the method signature.

Worse, actual behavior differs between schema and @Aspect styles.

For example, consider the following schema-based aspect: — <aop:around method="doAround" pointcut="execution( foo.Bar.(..)) and args(a)" arg-names="a"/> — public Object doAround(ProceedingJoinPoint p, String a) throws Throwable { return p.proceed(); } — Running this with 2.1M2 will throw: — java.lang.IllegalStateException: Expecting to find 2 arguments to bind by name in advice, but actually found 1 arguments. — Changing the value of "arg-names" to "p,a" makes the exception disappear.

However, translating this to the @Aspect style, and applying it with seems not to require the ProceedingJoinPoint argument to be included in the corresponding argNames annotation argument.

So, two things are requested: 1) Clearly document (with examples) if a first advice method parameter of type JoinPoint (or a subtype) needs to be included in argNames/arg-names 2) Make the behavior consistent between schema and @Aspect styles of AOP


Affects: 2.1 M2

spring-projects-issues commented 17 years ago

Taras Tielkes commented

Still present in 2.1M4

spring-projects-issues commented 17 years ago

Juergen Hoeller commented

Ramnivas, can you please have a look at this for RC1?

spring-projects-issues commented 17 years ago

Taras Tielkes commented

Having this cleared up / fixed for a 2.0.x release would not hurt either :)

spring-projects-issues commented 17 years ago

Ramnivas Laddad commented

Now the schema-style aspects process arg-names attribute in the exact same manner as the argNames attribute to advice in @AspectJ aspects. Documentation updated to explicitly discuss the treatment of the first argument of JoinPoint, ProceedingJoinPoint, and JoinPoint.StaticPart types. Also added examples to illustrate the point.

Taras, when you get a chance, please go over the documentation changes and provide feedback as o its adequacy and clarity. Thanks.

As to back porting to 2.0.x, Juergen will decide that based on if and when there will be another release of the 2.0.x series and other considerations.

spring-projects-issues commented 17 years ago

Juergen Hoeller commented

There are currently no plans for further backporting to 2.0.x. We'll see whether there's enough stuff to justify a 2.0.8 release, but generally speaking, we recommend to upgrade to 2.5 RC1 straight away once it is available.

Juergen