Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Passing a parameter created in the advice to the pointcut implementation

Dear mailing list participants,

I just moved a cross-cutting-concern (the creation and closing of a non-JDBC-connection) from a web service to a Spring AOP AspectJ implementation. This aspect is being called each time any method of the web service interface is requested.

The problem: the pointcut (= web service implementation) needs the connection being created in the advice! But as the method signatures are defined by the web service contract (the WSDL document has been converted to Java classes via "wsdl2java" based on the contract first approach) they cannot be adapted and modified to take over the new connection parameter.

It's clear that the other way around where the AspectJ advice gets the parameter used in the method call matching the pointcut defintion is possible.

Even changing existing parameter values and passing the same arguments list (having the same types) to the implementation where the pointcut matches does work (using "&& args()" in the pointcut in combination with joinpoint.proceed(jointpoint.getArgs()))

But here the problem exists, as it's not sufficient to just change parameter values. Instead, a complete new variable owning the connection created in the advice needs to be accessible in the objects the pointcut matches.

Do you have any idea how to realize that? Or is it a complete wrong approach to do that using Java aspects - although connection handling might be a typical cross-cutting-concern?

Your feedback is highly appreciated!

Kind regards
Holger


Back to the top