Announcement Announcement Module
Collapse
No announcement yet.
Using AOP with annotations on interface Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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?

  • #2
    Originally posted by cunparis View Post
    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?
    After further research, lots of test cases, and searching, I found out that annotations in interfaces aren't inherited.

    http://java.sun.com/j2se/1.5.0/docs/...Inherited.html

    but yet some frameworks do it (supposedly CXF, I haven't verified it):

    http://www.jroller.com/melix/entry/t...ns_inheritance

    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.

    Comment

    Working...
    X