Advice not behaving properly [message #662923] |
Fri, 01 April 2011 13:52 |
Robert Brown III Messages: 36 Registered: July 2009 |
Member |
|
|
Greetings:
I have the following interface, with classes that implement it:
public interface IServiceProvider
{
public String getServiceName();
public String getProviderName();
public String getFriendlyServiceName();
public ServiceResult performService(Map<String,String> theParams);
public String getResponseType();
}
And I have the following aspect:
public aspect TestAspect
{
pointcut nameCatch() : call(String IServiceProvider.getFriendlyServiceName());
pointcut serviceCatch(Map<String,String> theMap) :
call(ServiceResult IServiceProvider.performService(Map<String,String>)) &&
args(theMap);
String around() : nameCatch() && !within(TestAspect)
{
System.out.println("Caught a Service Name");
return("MyService");
}
ServiceResult around(Map<String,String> theMap) : serviceCatch(theMap)
&& !within(TestAspect)
{
System.out.println("A Service was called!");
return(proceed(theMap));
}
void around() : call(void PrintStream.println(String))
&& !within(TestAspect) {
System.out.println("Hi from HelloAspect ;-)");
}
}
For some reason, the around advice for the nameCatch() pointcut does not seem to be properly advising the getFriendlyServiceName() method. In Eclipse I get a warning saying that "advice was not applied" and that it doesn't match anything. It also does not engage when I run my test application.
But my pointcut is pretty straightforward and is in the proper syntax for its method! Unless I am wrong (please let me know if I am!) the pointcut was properly formed and should advise the getFriendlyServiceName() method.
Worse: it seems like none of the get methods within the interface can be advised. When I change the nameCatch() pointcut to use any of the get methods in ISereviceProvider, the advice simply doesn't work.
All other advice within the aspect works properly. It seems that, for the IServiceProvider interface, advice only works for the performService() method.
Have I found a bug in AJDT? Or is it an AspectJ bug?
Someone please advise (no pun intended... ).
|
|
|
|
Powered by
FUDForum. Page generated in 0.03541 seconds