Revising my opinion about Spring Framework

In past, at comm.world (Germany), I worked with projects based on Spring. At that time, I built my opinion about the framework: useless. It had nothing you couldn’t do without it. Everything that came with Spring could be done in simpler ways: PicoContainer or plain constructor injection for IoC/DI, plain decorators, dynamic proxies or Servlet Filters instead of AOP for the same results, WebWork simpler than Spring MVC, …

Some time has passed and, influenced by some friends in our endless discussions about Spring, I’ve decided to give it another try and I’ve started to refactor the VRaptor Web Framework, changing it to be fully Spring-based.

After this experience, I must admit: I was a bit wrong. I am going to explain it better, but I think the best part of Spring is that it already comes with many things done, ready to be used; out of the box. Furthermore, Spring 2.5 is much, much better.

Now, I have the sense that Spring brings some complexity, compared to lightweight alternatives; but not that much. This is the cost for the benefits the framework introduces. It is extremely flexible, supporting many different programming styles and idioms. I would be able to completely rewrite VRaptor to use Spring building blocks. Most of the current frameworks could be changed to be Spring-based, with little influence in their current APIs and programming styles!

People has already (re)implemented Google Guice on top of Spring. The EJB3 programming model (@EJB, @PersistenceContext, @Stateless, @Stateful, @Resource, …) can be easily replicated on Spring applications (old – 2005 – article that may be done better nowadays). One could even provide an EJB3 implementation on top of Spring, JBoss Seam could be rewritten on top of Spring and even PicoContainer could be Spring-based.

My current opinion is that Spring is a truly framework, in its original sense, because it acts as a solid base for applications to be built on top of it, without imposing any programming model, style or idiom. You aren’t required to use XML, Spring classes and even Spring annotations. The little bureaucracy comes with a bunch of ready functionality to be used, and with the great flexibility the framework has to be extended.

Today I can say I would consider using Spring Framework for new projects. I even consider it to be a good candidate to become one or more JSRs. It is a great base for applications and other frameworks to be built on top of it. Rod Johnson is a member of Java EE 6 Expert Group, which could point things to something in this direction.