Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

AOP and webservices  RSS feed

 
kg manuel
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello all,

im currently trying to use aspect to implement closing of a connection object after each method call. i was hoping to use aspects to speed up the implementation and organize the code. but it seems it is only being able to intercept calls from within the pre-compiled code. calls to the public methods via webservice doesn't seem to get affected and skips the process.

here is a screen shot of the code:

public aspect wsAspect {
pointcut callWSMethod(String username, String pwd) :
(call(* ws_*(String , String, ..)) || call(* ws_*(String , String)))
&& args(username, pwd)
&& target(WebServiceBase)
;

before(String username, String pwd) : callWSMethod(username, pwd){
System.out.println("username: " + username);
System.out.println("pwd: " + pwd);
System.out.println("aspect before method call");
}

after(String username, String pwd) : callWSMethod(username, pwd){
System.out.println("username: " + username);
System.out.println("pwd: " + pwd);
System.out.println("aspect after method call");
}
}

i skipped the connection.close part and the authentications coz its a lengthy part.

problem is, if the ws_Auth(String, String) is called via soap, the println's doesnt get printed out. but if i call ws_Auth2 which calls ws_Auth internally, aspect works.

public boolean ws_Auth(String usr, String pwd){
boolean result = false;
... some processing
return result;
}

public boolean ws_Auth2(String usr, String pwd){
return ws_Auth(usr,pwd);
}

please advise.

kgmanuel
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!