开发者

Using AOP or Annotations to extend a service functionality

开发者 https://www.devze.com 2023-03-31 12:40 出处:网络
I would like to know what is the best way in which I can extend an existing functionality (probably by using AOP or Annotations). The scenario which I am looking for is.

I would like to know what is the best way in which I can extend an existing functionality (probably by using AOP or Annotations). The scenario which I am looking for is.

We have one service say DisableEmployee which uses an entity Employee which does some validation and then disables access to employee. For certain customers I would like to extend this functionality where DisableEmployee not only disables the access but also imposes some penalty points.

One approach would be I extend the base class and then add the additional functionality.

Is it possible (or advisable) to use AOP and annotations here; where in I annotate my DisableEmployee and then at compile time I weave the additional code into the class. (using aspect) I have read about APT and Velocity which should be able to help me in achieving it. The reason I am looking at APT because we might have to extend the entity classes also to 开发者_如何学Goadd some new attributes.

The idea of having this approach is to see if we can classify service extension as a form of cross-cutting functionality (like traditional logging, auditing ....)

Thanks in advance


Your question is too general to get reliable answer. But at the moment I cannot see anything what cannot be implemented in AspectJ.

0

精彩评论

暂无评论...
验证码 换一张
取 消