Tijs Rademakers

Subscribe to Tijs Rademakers: eMailAlertsEmail Alerts
Get Tijs Rademakers: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn

Related Topics: Java EE Journal, Java Developer Magazine

J2EE Journal: Article

Using Spring as an Object Container

Enhancing ESB functionality

This article is based on the book Open Source ESBs in Action: Implementation Examples in Mule and ServiceMix scheduled to print September 30, 2008. This article is courtesy of Manning Publications. The ebook is available and sold exclusively through Manning Publications.

When you work with open source ESBs, you can use other tools and frameworks to help you solve common problems. Spring is one of the tools that extends the basic functionality of the ESBs Mule and ServiceMix and makes solving integration problems a lot easier. Spring is a component framework that makes it easy to work with Plain Old Java Objects (POJOs). We will use this framework to create and configure our custom components. Spring is also integrated out-of-the-box in both ServiceMix and Mule 2, so having a basic understanding of this technology is very useful.

Spring was started in 2002 with Rod Johnson's book J2EE Design and Development. In this book Rod described a framework that could be used to make lightweight Java applications. The general response to this framework was so overwhelming that Rod decided to make it open source and this was the first version of the Spring Framework. Nowadays, Spring is used by many tools and other frameworks, including ServiceMix and Mule, which use Spring for their configuration. The Spring Framework has evolved from a dependency injection framework to a mature and full-grown Java application framework that includes, among others, Model View Controller (MVC), Data Access Object (DAO), security and web services modules.

What Is Spring and How Does It Work
We won't dive too much into this framework; we'll just introduce you to the most important aspects. Spring was created to accomplish the following goals:

Simplify J2EE development: J2EE development is hard and complex. There are a lot of different standards you need to know before you can start developing. For those of you who have worked with J2EE, you'll know that it's very hard to work with the component model of J2EE. What Spring aims to do is make J2EE simpler, without sacrificing any of its power. You will still have access to transactions, persistency, messaging, etc., but it's a lot simpler. Remember that when Spring was started, J2EE wasn't as easy as it is now. When you needed to write an EJB in those days, you had to write a whole lot of boilerplate code and XML descriptors to expose a simple bean as an EJB.

Facilitate best practices: Besides simplifying J2EE development, Spring also makes it easier to follow best practices. It provides a very clean separation between your business logic and the enterprise services such as persistency, transactions, and security, which Spring applies using aspects.

Provide a simple POJO-based programming model: The last goal of Spring, and the one which we'll see coming back in the examples in this book, is the programming model. Spring's programming model is based on POJOs. We won't need to write session beans following the rules set out by the J2EE specification or implement all kinds of life-cycle interfaces; we can just create a simple, testable POJO and use Spring to glue everything together.

More Stories By Tijs Rademakers

Tijs Rademakers is a software architect with more than six years of experience in designing and developing Java and EE applications. He works for Atos Origin, a large European system integrator, where he is responsible for SOA and BPM services and knowledge development. He has designed and implemented large process- and application-integration solutions, primarily focused on open standards. Tijs is a regular speaker at Java conferences, where he talks about open source integration topics like Mule and ServiceMix.

More Stories By Jos Dirksen

Jos Dirksen has been working with Java and J2EE applications for more than six years as a software architect. The last couple of years, his focus topics have been open source, security, and quality. He has worked with various open source and commercial integration solutions, mostly in the government and the health care areas. Jos has a lot of project experience working with Mule, Apache Synapse, and Apache Axis2 and has also completed projects based on the integration tooling from IBM. Jos regularly gives presentations on open source, Mule, and other related topics.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.