Our Java Stack: Swiss Army Knife (Spring)
Spring is a lot larger than a Web Application Framework. Swiss Army Knife is the best analogy I can come up with for how we use Spring.
Most importantly, we use it for Dependency Injection. Specifically, we program all data access to interfaces and have Spring inject the actual implementation classes at runtime. Early on in our work with ORM tools, we weren't sure which tool we would end up choosing. Having an easy way to keep our service objects independent from the underlying data access was very important to us so that we could switch data access methods if we changed our minds. Programming to interfaces provides endless flexibility, and Spring makes it simple.
As mentioned in the Web Application Framework article, we also use it to annotate transactions. Having experienced problems in older JDBC projects from leaking resources, Spring helped our application stability immensely by taking away an opportunity for programmer error to cause systems to become unavailable.
Other helpful Spring tools are its wrappers for several of the major data access technologies. Right now, we're using Hibernate v3.x, but it also supports other popular tools like iBatis, JDBC, and EJB.
Beyond some of those basics, we also had a few problems pop up in one project which were solved less painfully than normal using AoP (Aspect Oriented Programming). Spring's built-in AoP support meant we could implement some aspects without adding any dependencies to the project, and they saved us the trouble of major architecture changes to get the right information info the right piece of code.
There's little doubt we'll find further use for Spring as the years go by. The nice thing about it is that even if you don't want to use one piece of it, you can still easily use the rest of it.
Links:
Posted at 07:00AM Dec 17, 2006 by Jason Koeninger in Java | Comments[0]