I’m using Spring 2.5 for dependency injection management. I have a few classes that need to have some action triggered in the background when certain methods are called. I figured that the easiest way to do this would be with an annotation, like:
class MyClass {
//...
@DoSomethingElseInTheBackground
function void doSomething() {
//...
}
//...
}
I’ve written a BeanPostProcessor before and that was quite simple. So is there a way to do what I’m looking for? I’m inspired, in part, by @Transational.
You are correctly inspired by
@Transactional. It uses Spring AOP, built-in feature of Spring framework.Have a look at: @AspectJ examples with pointcuts based on annotations which describes the exact same use case.