Traditional AOP has aspects, i.e. the classes doing the work, and pointcuts: the places where an aspect squeezes itself into.
JEE has some AOP as well, but this is only annotation-bound. So I can define an aspect TimeStuff and an annotation @Timed then all methods or classes need to have an the @Timed annotation added to trigger TimeStuff.
This is a bit sad, because it means having to modify code which we might not control, nor want to modify since it's nice and clean. With Spring (or full) AOP, we can define a pointcut which cuts to all the methods/classes which we want (either in configuration, or in the aspect itself with an annotation), and the original code is none the wiser. Lovely! Nothing to see here, nothing to forget here.
I want that in JEE. It's not quite so simple, but it's doable.
See:
https://github.com/softwaremill/softwaremill-common/blob/master/softwaremill-debug/src/main/java/com/softwaremill/common/debug/timing/TimingExtension.java
Roughly said: in JEE you can create an Extension which extends the startup of the container, and it can then modify the classes... in this case, adding the @Timed annotation to those classes which we want. It just means that our code for the pointcut needs to be programmed out a bit more, but at least we can!
Well, not so fast. It works, but that doesn't make it easy.
I'll show that in a different post. Possibly fully integrated with maven, and liberty-run...
JEE has some AOP as well, but this is only annotation-bound. So I can define an aspect TimeStuff and an annotation @Timed then all methods or classes need to have an the @Timed annotation added to trigger TimeStuff.
This is a bit sad, because it means having to modify code which we might not control, nor want to modify since it's nice and clean. With Spring (or full) AOP, we can define a pointcut which cuts to all the methods/classes which we want (either in configuration, or in the aspect itself with an annotation), and the original code is none the wiser. Lovely! Nothing to see here, nothing to forget here.
I want that in JEE. It's not quite so simple, but it's doable.
See:
https://github.com/softwaremill/softwaremill-common/blob/master/softwaremill-debug/src/main/java/com/softwaremill/common/debug/timing/TimingExtension.java
Roughly said: in JEE you can create an Extension which extends the startup of the container, and it can then modify the classes... in this case, adding the @Timed annotation to those classes which we want. It just means that our code for the pointcut needs to be programmed out a bit more, but at least we can!
Well, not so fast. It works, but that doesn't make it easy.
I'll show that in a different post. Possibly fully integrated with maven, and liberty-run...
Reacties
Een reactie posten