I have a Java servlet website, but does not use any frameworks like Spring or even Struts! It does have hibernate in it which it uses along side regular sql. It also has no unit tests. It uses cvs and ant. The server can only run Java 1.4 in the JSP's.
Aside from that, the code is fairly well structured.
Are there good ways to add more modern features to the code while minimizing the risk? It seems like we could add some spring features onto new code. And maybe replace the the cvs and Ant with Subversion and Maven, or perhaps something else.
Would it be possible to have new parts of the site running in something like Spring MVC or even JRuby on Rails?
If that is the case, I would start by writing several tests that ensure that current behavior/business stays the same, while you go ahead and introduce Spring in the mix.
Everything is possible, but since the code is already Java, and as you pointed out "well structured", I would go with Spring.
The easiest place to start is to figure out what depends on what in order to start the "website". Once you have that, you would already have different components (on paper + in the code) that you can draft with a Spring "starter" application context, that you can load with web.xml
as:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:META-INF/spring/starter-application-context.xml /WEB-INF/spring/transportes-webflow.xml ... </param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
That is before you use any Spring MVC features. Once you have that, see if you can define a domain model for this project. Then you can start converting Servlets to Spring MVC Controllers and Models ( those domains ).
As you move one step at a time, run those tests, to make sure the behavior is still solid. These can be simple JUnit tests, as well as Selenium tests that would ensure that the "website" flow is still intact.
I would recommend to switch your build architecture to Gradle, it does take a bit or a learning curve to wrap your head around accessing everything in a build script (which is a good thing), but it really pays off.
As to CVS, I prefer git
, but if you feel strong about SVN, you can switch to that as well. git
, in my opinion, became as standard to Version Control System, as Spring to Java development.
Understand the reasons regular SQL
is used. If these are performance reasons, you can use store procedures instead (that you can work with from within Spring). Also see the reason Hibernate
is used, as it may bring additional complexity, that you may not need, and would be better off with a simple Spring JdbcTemplate
.