Over the last few years, Spring has grown substantially, surpassing many other frameworks. Spring enables you to concentrate on writing less Spring-Framework-related code and more application code, which is vital in the fast-changing and cost-sensitive world of enterprise applications. Since its initial release in 2004, Spring has reinvented itself multiple times and become prominent in the industry as a strong force in the framework market. This has not only made the Spring Framework renowned, but it has also put healthy pressure or rather competition on well-known industry specifications (Java EE) and the application-server market. In the Java world, this is a very exciting time and a very important turning point.
In this chapter, I introduce Spring Framework as a whole (If I could, I would compel you to use it). Before explaining the nitty-gritty, I give you reasons to choose Spring for your application. Then I explain the Spring framework architecture and its features and, more important, introduce you to the main modules on which Spring Framework is based.
Spring provides an extensive, portable, open source-application-development framework for Enterprise Java. Starting with Spring, you can build whatever you want: reservations system, banking systems, social networks, and more. Spring expands to meet your needs; you can integrate various security models, databases, web services, mobile clients, messaging systems, and so on that are required in today’s agile enterprise applications. Another key advantage is that Spring fits directly into your current infrastructure, because Spring uses the same Plain Old Java Objects (POJOs) you use every day. Once you start creating applications with Spring, you can deploy it everywhere in the certainty that it will thrive and adapt to the environment with ease.
If you need your application to be better, newer, and speedier, Spring is the right alternative for development. Surveys suggest that more and more Java developers around the world are moving toward Spring. For instance, recent analysis from Evans Data (“Spring Usage Study,” Evans Data Corporation, September 2011) analyzes the ubiquity achieved by Spring as summarized below:
- Spring is the framework of choice among knowledgeable Java developers.
- Spring developers report productivity and speed of deployment as the top reasons for using it: 70 percent of Spring users report at least a 50 percent productivity gain by using it, and 73 percent report that the framework allows them to deliver projects twice as fast.
- It is estimated that more than two thirds of Java developers today are either using Spring or plan to do so within the next two years.
- More than half of all existing Spring users expect to considerably increase their use of this framework over the next few years.
- Spring users are more cloud ready and it is considered that heavy Spring adopters are more likely to have already deployed their applications to the cloud.
- More than half of all existing Spring developers report that they plan to move their Java applications to a lightweight server, such as Apache Tomcat, within one year. ( Get more information from http://www.vmware.com/company/news/releases/vmw-spring-momentum-3-14-12.html )
Shared feedback from developers around the world highlights the following advantages of Spring Framework:
- Easier to understand. Not rocket science.
- If you have any issues with the framework code, you can just open the source code and with minimal effort understand it very easily.
- Makes users highly productive, shortens development time.
- For junior developers, it’s an excellent learning tool because so many live, proven Java pattern examples can be seen throughout the framework code.
- Enables developers to cut out tons of redundant code, reducing boilerplate code in their applications. Programmatic catching of exceptions and cleaning up of resources, etc., are things of the past.
- Spring’s ability to wire objects at runtime is incredible. Injection of right type-safe objects wherever needed is transparently handled by the Spring container.
- A la carte framework—Plug-in what you want and use it.
What Is Spring Framework?
Spring Framework is built on well-defined goals and a coherent philosophy. Its main aim is to make Java EE development easier. This section explains Spring Framework’s main goals and its role in the development of enterprise applications.
Spring’s main aim, according to Rod Johnson (see sidebar) is to make Java EE easier to use and promote good programming practice. Even though POJO-based programming model is practiced in many enterprise applications, Spring Framework takes this concept into a different level by incorporating this model into it and making it applicable in a wide range of environments available. Due to this style of programming model, the framework keeps itself open to take advantages provided by the environment it works on without losing portability in the process.
Rather than Spring writing its own bit of code for common functionalities like logging, connection pools, transaction coordinators etc., it allows the developers to appropriately plug in the various packages available as open-source projects (For example, Commons Logging package can be used for all common logging purposes, Commons DBCP package can be used for connection pooling etc.) into the framework with mere configuration and with ease. By doing so it allows using the best package available in the open-source world and also keeps it open for future change as the case may be. All of this Spring does by keeping in mind that it doesn’t gets itself locked to any platform-specific or non-standard technology making it one of reason to use the framework in any enterprise application development.
Spring over the period has grown into a mature framework transforming itself into a one-stop shop capable of handling most of the infrastructural concerns which exists in a typical modern enterprise application. Applications are there because it has to support a business requirement. Spring provides applications with the capability of taking care of your core business objects easily and also allows changing it with minimal impact on the application as a whole according to changing business scenarios.
Rod Johnson is an enterprise Java architect specializing in scalable web applications. He has worked with both Java and JEE since their release and is also a core member of JSR 154 Expert Group entrusted with defining the Servlet 2.4 specification. He started developing frameworks for web application in 2000 while working as independent consultant. The Spring project was started by him in 2002, and it first official release was in March 2004. Johnson released this framework with the publication of his book Expert One-on-One Java EE Design and Development (Wrox Press, 2002).
Spring Framework’s Role in Enterprise Applications
Spring Framework includes core support for:
- Application configuration
- Enterprise integration
- Data access
- Web application-development support
- Enterprise application-development support
A typical application comprises various components working together to carry out a particular application-use case. Spring helps you build this configuration with ease. With Spring, components constituting a use case don’t worry about one another and at any point they can be swapped to keep up with the business change (agility).
An enterprise application doesn’t work in isolation. It requires various enterprise services and resources such as security, messaging, caching, transactions, etc., to constitute an end-to-end application to meet real-life application needs. With ease and agility, Spring does this by keeping your application code simple and both unit and integration testable. It can be easily plugged into any standard Java EE application server and also is capable of stand-alone usage.
An enterprise application accesses data stored in a relational database to carry out various business functions and to enforce various business validations. Spring makes data access easy and effective. It supports all major data-access technologies, such as Hibernate, JPA, JDBC, etc.; manages these resources transparently from the developer; and also offers tons of APIs, which enables developers to concentrate more on the core business coding and thereby increase productivity.
Unit and integration testing is essential for any enterprise application. It helps with decompiling objects from the environment where it resides and makes it easier to test the application in isolation from its actual deployment environment. More important, it helps in system/integration testing to see that all the components constituting an enterprise application work properly. This testing can be done in the actual environment as well as in isolation from the actual environment, which is a big plus compared to other framework platforms.
Web Application-Development Support
Spring includes a powerful and highly configurable Model-View-Controller web framework called Spring MVC. Even though very much similar to Apache Struts, it can never be said as derived from it. Frankly saying no copyright infringement spotted. Now to look into the similarities, Struts Action class is similar to Spring MVC Controller class and this object is multi-threaded in nature will a single instance being used for servicing all the clients. Spring MVC has some significant advantages over Struts, however—it has a powerful navigation rule framework, Spring Web Flow, which equals its powerful web framework for application development. Even though Spring has its own implementation for a web framework, it has kept its main goal of seamlessly integrating with other famous web frameworks, such as Struts and Java Server Faces (JSF).
Enterprise Application-Development Support
Spring’s core strength lies in its ability to integrate with common and most required services in enterprise applications. It has modules for creating and maintaining web services, scheduling jobs, integrating with messaging services, and so on. This modular coding support ensures good manageability for applications.
Page Visitors: 1586