开发者

What is the best way to have interceptors for POJO?

开发者 https://www.devze.com 2023-03-01 06:17 出处:网络
EJB 3.0 comes with the concept of Interceptors, but then again they are applicable to EJBs only. My project requires developing Interceptors for POJO classes. One option for this开发者_JAVA技巧 is to

EJB 3.0 comes with the concept of Interceptors, but then again they are applicable to EJBs only. My project requires developing Interceptors for POJO classes. One option for this开发者_JAVA技巧 is to use Spring AOP. I want to know if it's worth the overhead of including the libraries such as commons-logging, spring-aop, cglib that are required for Spring AOP.


Spring is much more than Spring AOP, and you can not use Spring AOP without Spring, and I am talking not only to the Spring libs, but to the Spring programming model too!

So if you think Spring is useful for your application (believe me, it is very useful to many application), then you can use it. - But it is a complete programming model, like EJB, not only a lib or a simple framework.

But I think every modern not trivial application should have a ICO container, so Spring is one of the choices you have.


Sure, it's worth, but be aware it won't be enough if you need to have interceptors for you POJOs : You will also need a "spring agent" to be passed as an argument to your jvm ("Load-Time Weaving"), or you won't be able to intercept your pojos methods, or you will have to use "Compile-Time Weaving".

In short : POJOs have to be created via Spring for them to be "interceptable".

CTW (or LTW) makes compilation (or startup) quite slower.

0

精彩评论

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

关注公众号