开发者

Adding Spring Framework to existing JSP/EJB application

I had an existing 开发者_运维问答application developed in JSP and EJB 2.1 years ago. Now i want to enhance the application with new features. Is there a way to use Spring and Hibernate frameworks within the same old application for adding new features or do i need to go for developing new application to use latest frameworks.

Thanks in advance.


First, why do you want to add Spring? What is your goal in doing so? To answer the question, yes, you could find a way to slowly start integrating it into an existing app, but you'll need a pretty good reason in my opinion.

If you really want to 'modernize' the application with a major change like that (and you have a justification), personally I'd start with a brand new project and just import the stuff you can reuse into that.

Applications that change over time (virtually all) get messy and accumulate a lot of "junk" the older they get. Eventually they're unmaintainable, whether it's because some SME in the app finds another job, or because it just gets too confusing and fragile. I can't help but think doing something like this (adding into an existing app) is just accelerating that aging process (how confident will you be in removing the "old" stuff without the urge to leave it "just in case"?), so much better to clean house while you can. Unless you're talking a small app that's in pretty good shape, but that's rarely the case in my experience.


You can add Spring and Hibernate to your existing application (after all, they're just a bunch of jar files), although I wouldn't really recommend doing so.

First of all, EJB 2.1 and Hibernate will clash since EJB 2.1 doesn't have standard JPA and uses the old EJB query language.

For persistence, I'd suggest using one or other and not mixing them. If you have significant amount of database access code written using EJB 2.1, then avoid introducing Hibernate into your mix. It will be a mess. If you're just using JDBC, then I guess Hibernate could be a nice fit.

As for Spring, since it's a framework, it's not really trivial to just "add Spring" to your application. Spring is huge and you should ask yourself what would be the benefits. Which parts do you want to use? Just dependency injection? Abstraction layers that aren't present in EJB 2.1? Not easy.

Bottom line: introducing Spring and Hibernate to your application is doable, although it's gonna be a messy, painful and time consuming endaveour without serious considerations, especially if your application is large.


Thanks for the response.

My old application (JSP+EJB 2.1) is a big one. We got some enhancements on the system. Now we have 2 choices.

  1. Replace old system and develop more modular system with rules engine and latest frameworks, so that adding new features/enhancements in future takes less time to implement. Nearly it takes a year to migrate the old system to new application.

  2. Add enhancements to the existing system using latest frameworks like spring, hibernate, rules engine etc. and slowly migrate the old stuff into new technology platform depending on time/budget. (Not sure this will work or not technically).

Now you had more info, so what is the best way to proceed.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜