Spring to Java EE Migration – Part 4, the Finale

In a new article, now up on otn/java, titled “Spring to Java EE Migration, Part 4,” David Heffelfinger presents the final part of his series in which he demonstrates the ease of migration from the Spring Framework to Java EE. Here he compares equivalent functionality in Java EE and Spring in areas such as MVC design pattern implementation, data access, transaction management, and dependency injection.

He concludes the series with these remarks:

“In this series of articles, we developed a Java EE version of Spring’s Pet Clinic application. We saw how the advanced tooling provided by NetBeans enables us to quickly develop a Java EE application…. Once we were done building the Java EE version of the application, we compared it with the Spring version, noting that the original version has several dependencies whereas the Java EE version has none, because it takes advantage of all the services provided by the Java EE application server.

Finally, we compared how to implement similar functionality such as MVC and DAO implementation, transaction management, and dependency injection with Spring and Java EE. In every case with Spring, some XML configuration needs to be done besides adding annotations to the code. Java EE relies on convention, and in most cases, no XML configuration is needed in order to implement these services.

Although newer versions of Spring rely a lot less on explicit XML configuration than earlier versions, there are always a few little lines here and there that we need to add to an XML configuration file in order to get most of the Spring annotations to work, violating the DRY (don’t repeat yourself) principle...

Additionally, Spring applications tend to have several dependencies, because they are meant to run in a “lightweight” Servlet container such as Tomcat or Jetty and these containers don’t provide all the required functionality. In contrast, Java EE applications are meant to be deployed in a full-blown Java EE 6 application server such as Oracle GlassFish Server...

For these reasons, I always recommend Java EE over Spring for enterprise application development.”

Have a look at the article here.

Sorry but I'm furious about your articles.

Spring is certainly far more better than JEE, for multiples reasons, but with your blinder and formatted mind you'll never see why.

Let me take each of your sentences and give my point of view:

* "with the Spring version, noting that the original version has several dependencies whereas the Java EE version has none" :
Your app server have no dependence on third parties? Have you tried to migrate from one EE appserv to an other (hibernate vs eclipselink between jboss & glassfish for example)? Do you need JMS jars for your petclinic? Because I'm pretty sure your appserver started it...

* DAO: in your article, you just use hibernatetemplate vs entity manager, do you know that you can inject localcontainerentitymanager with Spring?
That you can use spring-data-jpa (now try to see differences on line numbers...).
Can you show us the difference when you make atomical transaction with Spring @Transactionnal(isolation="nested") and the jee one?

* MVC: You can make JSF with Spring too, Spring MVC is an equivalent of old servlets (can you compare it?). JSF with Spring is far more simple than with JEE (No need to this @ManagedBean useless annotation, @Inject is doing the same).

* "there are always a few little lines here and there that we need to add to an XML ": Have you seen a single line of xml with Spring 3 and Servlet 3? There is no empty bean.xml file :p

And finally: can you make different configuration profile with a JEE app?

For sure Spring is more complicated than EE when you start making apps because with EE you don't need to know all the underlying libraries. But if you have the knowledge on this, just don't use EE if you want to make your project maintainable...

Regards Charlie (@tcharl on tweeter),

Posted by Tcharl on April 26, 2012 at 05:45 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

Insider News from the Java Team at Oracle!



« June 2016