[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[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
import java.lang.reflect.Field;
import java.lang.reflect.Method;
public aspect Internal {
pointcut setterPointcut(Object input): within(pkg.*) && args(input) && execution(* jsSet_*(*));
void around(Object input) : setterPointcut(input){
if (input != null) {
System.out.println(input);
proceed(input);
}
}
}
package pkg;
import java.io.IOException;
public class RunAspect {
public int x;
private String y;
public static void main(String[] args) throws Exception{
RunAspect runAspect = new RunAspect();
runAspect.jsSet_print(null);
runAspect.jsSet_print("abc");
runAspect.jsSet_print2(null);
runAspect.jsSet_print2("xyz");
runAspect.jsSet_print3(null);
runAspect.jsSet_print3("lmn");
}
public void jsSet_print(String xyz) throws Exception, IOException {
System.out.println("Printing .... ");
}
public Object jsSet_print3(String xyz) throws Exception, IOException {
System.out.println("Printing .... ");
return xyz;
}
public void jsSet_print2(String xyz){
System.out.println("Printing 2222 .... ");
}
}