Feb 7th, 2008, 11:41 AM
Using AOP with annotations on interface
I need to use an advice with the public methods of my business services. I started by creating an empty "tag" interface and I have my business service interfaces extend it. That works. Only the methods in the interface receive the advice and the private methods in the business service do not.
So then I thought it'd be more appropriate to use annotations. It'd keep the public interface simpler. But unfortunately it doesn't work. It seems that the implementation class doesn't receive the annotations of the interface. I can understand this, although I think it's a bummer. It'd be nice to have another option, like @targetIncludingInterfaces for lack of a better name.
I'm curious how others are doing it and if there is a better way than using market interfaces?
Feb 11th, 2008, 05:21 AM
After further research, lots of test cases, and searching, I found out that annotations in interfaces aren't inherited.
Originally Posted by cunparis
but yet some frameworks do it (supposedly CXF, I haven't verified it):
Hope that helps someone and saves some time searching.
My solution is I use the business service annotation on my implementation classes. After all, I'm using it for technical reasons (exception barrier, caching, security, whatever) and that shouldn't be in the interface.