Spring Series, part 1th: Introduction to Spring Framework

Source: Internet
Author: User
Tags aop error handling exception handling to domain

In this first installment of a three-part series that introduces the spring framework, you will begin to learn how to build lightweight, robust Java EE applications with spring technology. DeveloperWorks's regular contributor, Naveen Balani, began his three-part spring series by introducing the spring framework, which will also introduce the spring aspect-oriented programming (AOP) and control inversion (IOC) containers.

Spring is an open source framework that is created to address the complexity of enterprise application development. One of the main advantages of the framework is its tiered architecture, which allows you to choose which components to use, while providing an integrated framework for Java EE application development.

In part 1th of this three-part spring series, I'll introduce the spring framework. I first describe the framework's functionality from the perspective of the framework's underlying model, and then discuss the two most interesting modules: Spring aspect-oriented programming (AOP) and the control reversal (IOC) container. A few examples will then be used to demonstrate the application of the IOC container in a typical application use case scenario. These examples will also serve as the basis for the expanded discussion later in this series, which will cover the way the spring framework implements AOP constructs through spring AOP.

See downloading, downloading the Spring framework and Apache Ant, and running the sample application in this series requires them.

Spring Framework

The Spring framework is a layered architecture consisting of 7 well-defined modules. The Spring module is built on top of the core container, and the core container defines how the bean is created, configured, and managed, as shown in Figure 1.

Figure 1. 7 Modules of the Spring framework

Each module (or component) that makes up the Spring framework can exist either independently or jointly with one or more other modules. The functions of each module are as follows:

Core container: The core container provides the basic functionality of the Spring framework. The main component of the core container is Beanfactory, which is the implementation of the factory pattern. Beanfactory uses control reversal (IOC) mode to separate the application's configuration and dependency specifications from the actual application code.

Spring Context: The spring context is a configuration file that provides contextual information to the spring framework. The Spring context includes enterprise services such as JNDI, EJB, e-mail, internationalization, checksums, and scheduling capabilities.

Spring AOP: Through configuration management features, the Spring AOP module integrates aspect-oriented programming capabilities directly into the spring framework. Therefore, it is easy to make any object managed by the Spring framework support AOP. The spring AOP module provides transaction management services for objects in a spring-based application. By using Spring AOP, you can integrate declarative transaction management into your application without relying on EJB components.

The Spring dao:jdbc DAO Abstraction Layer provides a meaningful exception hierarchy that can be used to manage exception handling and error messages thrown by different database vendors. The exception hierarchy simplifies error handling and greatly reduces the number of exception codes that need to be written (for example, opening and closing connections). The Spring DAO's JDBC-oriented exception conforms to the common DAO exception hierarchy.

The Spring orm:spring Framework inserts several ORM frameworks, providing an ORM object-relational tool that includes JDO, Hibernate, and IBatis SQL maps. All of these conform to Spring's common transaction and DAO exception hierarchy.

Spring Web module: The Web context module is built on top of the application context module, providing a context for web-based applications. So, the Spring framework supports integration with Jakarta Struts. The Web module also simplifies the work of processing multiple-part requests and binding request parameters to domain objects.

Spring MVC framework: The MVC Framework is a fully functional MVC implementation that builds WEB applications. With the policy interface, the MVC framework becomes highly configurable, and MVC accommodates a large number of view technologies, including JSP, Velocity, Tiles, IText, and POI.

The Spring framework features can be used in any Java EE server, and most of the functionality also applies to an environment that is not managed. The central point of Spring is to support reusable business and data access objects that are not bound to a specific Java EE service. There is no doubt that such objects can be reused in different Java EE environments (Web or EJB), stand-alone applications, and test environments.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.