[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] Passing a parameter created in the advice to the pointcut implementation
|
I forgot to mention: An alternative approach might be aspects instantiated perthis or pertarget, keeping state for your objects if you want to avoid ITD.
> Hi Holger.
>
> Some more or less extensive code snippets would be helpful, but as far as I
> understand you want to inject a value into certain objects. Unless there is
> some kind of "value store" such as a map of key/value pairs or so in your
> object, you can use ITD (inter-type definition) in order to add members to the
> desired types.
>
> If you provide some sample code - ideally a fully functional SSCCE
> (http://sscce.org/) - I am sure someone will suggest an aspect which will show
> you how to do that based on your code. Concrete examples are usually more
> helpful than abstract ones.
>
> Tit for tat, code for code - deal? ;-)
>
> Regards
> --
> Alexander Kriegisch
> http://scrum-master.de
>
>
> Holger King schrieb am 18.02.2015 23:04:
>
>> 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?
>