Continuing my miniseries on Spring, this article looks at the important area of application contexts. In many ways, the application context and the lower-level BeanFactory lie at the very heart of Spring's inversion of control mechanism. Also, you'll find that application contexts are commonly used in a number of Spring offerings.
Having Problems Using Spring?
Once I had written a few application context files, I finally began to understand the whole idea of inversion of control (IoC) and dependency injection. However, this success wasn't without difficulties, underlining the fact that (in my humble opinion) much of the Spring documentation is aimed at fairly advanced users. Few of us start out as advanced users! For this reason, my target audience for this series of articles is anybody who is trying to get started with this important technology.
The Spring Forum increasingly recommends the use of application contexts for J2EE development. After you master this important area, you're beginning to get a good grasp of the Spring philosophy. Spring technology is not restricted to development of web applications; you can use Spring in any application that supports the use of JAR files.
Are IoC and Spring just a fad? Other software offerings such as JBoss 5 and Struts 2 increasingly facilitate IoC mechanisms. In a sense, IoC is becoming a mainstream software technology (if it isn't already), so it's likely that at some point IoC will be added to the Java language itself. In other words, it's possible that you'll be able to incorporate IoC by using just the JDK, with no need for external JAR files.
One scenario for IoC in Java might be the Spring technology itself being subsumed via the JSR process. This would potentially be a very reliable way of updating the Java platform, because Spring is already mature and widely used. Incorporating Spring into Java is an interesting and compelling possibility, but only time will tell whether it becomes a reality.
Regardless of what path IoC takes, it will continue to evolve as a technology. So even if you're not yet using Spring in your daily work, my guess is that it will become part of your work at some point. For this reason, learning Spring now will enable you to move up the value chain before reaching a point in your career where you may be under some pressure to learn it.