Spring Framework Features
Spring Framework provides a comprehensive programming and configuration model for Java-based enterprise applications, saving the developer from worrying about deployment considerations. Instead, the developer can concentrate on the application-level business logic and completely leave the infrastructure maintenance (plumbing) to Spring Framework. Spring does all this without unnecessary ties to specific deployment environments, which is key in modern Java-based enterprise applications.
- The most complete lightweight container which provides centralized and automated and flexible configuration and helps wiring all of your business objects together. The power of Spring can be realized when it assembles a set of loosely coupled simple components in a consistent and transparent manner to a more complex component to be used in an enterprise application. The container brings agility and leverage, and it improves application testability and scalability by allowing software components to first be developed and tested in isolation and then scaled up for deployment in any environment (J2SE or J2EE).
- Flexible dependency injection with Java, XML, and annotation-based configuration styles.
- Advanced support for variants of aspect-oriented programming paradigms in the form of support for proxy-based and AspectJ-based.
- Capability of handling many of the advanced featured in an enterprise application declaratively like transactions, caching, validation and much more.
- Good and easy abstraction over some of the complex Java EE specifications like JDBC, JPA, JMS etc.
- Support for well-known open source frameworks like the support for scheduling framework Quartz and much more.
- Similar to Apache Struts but enhanced web framework in the form of Spring MVC which can be used to build MVC based application.
- Testing support both while unit and integration testing phases of application development.
What’s New in Spring 3.1
I won’t go into detail about the new features of Spring 3.1 at this point. For readers who already have expertise developing applications using Spring, however, I want to give you some idea of the new features in Spring 3.1, in case you’re ready to migrate your application to the new version of Spring Framework. One important feature is that Spring 3.1 allows you to avoid XML completely in your code and to use Java instead for configuring your Spring application. Spring 3.1 introduces these new features:
- Cache abstraction
- Bean definition profiles
- Java 7 support
- Servlet 3.0 support
- Hibernate 4 support
- Java configuration
You can see the complete list of new features in Spring 3.1 at http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/new-in-3.1.html
Spring frees you from writing the logic of caching but does not provide stores such as EhCache or JDK ConcurrentMap. Spring uses annotations such as @Cacheable and @CacheEvict to achieve declarative caching. These annotations are triggered by declaring <cache:annotation-driven/> in the configuration XML. It allows for declarative caching of Spring applications with minimal impact on code and plugs in easily with various caching solutions available in the industry today.
Bean Definition Profiles
Profiles are present in earlier versions, but Spring 3.1 enables profile configuration without XML. Spring 3.1 allows logical grouping of bean definitions, which can be activated according to specific environments. These profiles can be activated programmatically, using web.xml, using system property, and in tests using annotation @ActiveProfiles.
Java 7 Support
Spring 3.1 supports new features introduced by Java 7, including fork/join support, JDBC 4.1 support, and so on.
Servlet 3.0 Support
Spring 3.1 supports these new features in Servlet 3.0:
- Web fragments.
- Programmatic definition of filter (@WebFilter), Servlet (@WebServlet), listener (@WebListener) and URL patterns.
- Moving 90 percent of the code away from Web-application context file (web.xml) by using WebApplicationInitializer.
Hibernate 4 Support
Spring 3.1 supports Hibernate 4.x, including the use of Java 6. JDBC 4.x as baseline and multitenant database support, using native support in a dedicated org.springframework.orm.hibernate4 package. It supports Hibernate 4 but makes sure that it preserves compatibility with Hibernate 3.2+ in the org.springframework.orm.hibernate3 package.
Again, with Spring 3.1, you can now completely avoid Spring XML configuration and move all your Spring configurations into Java. The TestContext Framework provides annotation-driven testing support for JavaConfig and Profiles. Using Java configuration you can make the most of what the language Java has to offer when writing your application in Spring. You now have an option to have intuitive annotation-oriented container configuration in your Spring application.
In this chapter, I introduced you to the basics of Spring Framework. I started by discussing why you should use Spring Framework to develop your enterprise application and then explained the main philosophy and goals upon which the framework was built. I then explained its role in enterprise application and covered all the building blocks that comprise the Spring Framework.
I briefly explained the history of Spring Framework to provide a snapshot of its evolution. I also covered the main features of the framework and described the advantages that have caught the attention of so many developers. I also briefly covered the new features in Spring 3.1.
You now have an idea of what Spring Framework is all about and what it can do for you and your organization. In subsequent chapters, I will explain how you can use each of Spring’s powerful features to solve real-life problems.
Page Visitors: 1791