Hi Rajat,
whie it may sound confusing the first time, you can use "Object around(...)"
also to weave around void methods. For example :
Object around() : execution(.. something matching methods here ...) {
System.out.println("Doing something");
return proceed();
}
AspectJ will know that the method it is weaving is a void method, and return
a special value that represents "void".
If you use "return proceed(input)" in the second advice in your example, it
will apply to both cases.
Hope this helps,
Simone
2010/4/16 Rajat Gupta <[email protected]>
> I got a solution.
> Is this a correct way or there is a better way for solving this issue,
> please tell.
>
> pointcut setterPointcut(Object input): within(pkg.*) && args(input) &&
> execution(*void* jsSet_*(*));
> pointcut setterPointcut1(Object input): within(pkg.*) && args(input) &&
> execution(*Object* jsSet_*(*));
>
>
> void around(Object input) : setterPointcut(input){
> if (input != null) {
> System.out.println(input);
> proceed(input);
>
> }
> }
>
> Object around(Object input) : setterPointcut1(input){
> if (input != null) {
> System.out.println(input + " 2 ");
> proceed(input);
> }
> return null;
> }
>
>
> Thanks
> Rajat
>
> ------------------------------
> *From:* Rajat Gupta <[email protected]>
> *To:* aspect-J <[email protected]>
> *Sent:* Fri, April 16, 2010 3:56:14 PM
> *Subject:* [aspectj-users] around advice and return type mismatch ?
>
> Hi All,
>
> File for this example are attached.
> The main problem is the around advice, how should i call that around
> advice?
>
> I want to insert put around advice on these both following methods,
>
> public void jsSet_print(String xyz) throws Exception, IOException
>
> public Object jsSet_print3(String xyz) throws Exception, IOException
>
> so i created a pointcut, i think should be
> pointcut setterPointcut(Object input): within(pkg.*) && args(input) &&
> execution(* jsSet_*(*));
> to match with both.
>
> now by doing this advice
> void around(Object input) : setterPointcut(input){
>
> it gave the error (runs fine though).
>
> I had also tried with,
> Object around(Object input) : setterPointcut(input){
>
> please suggest how should i do it so that both the methods has the aspect
> inserted.
>
>
> Thanks
> Rajat
>
>
>
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users