Development of WebSphere application based on spring framework

Source: Internet
Author: User
Tags aop websphere application server

Overview

Lightweight enterprise application development is increasingly popular with Java application developers, and the spring Framework is an outstanding representative of lightweight containers. Because of the growing use of spring, there are many applications based on WebSphere Application Server (was) that use the spring framework. This article first introduces the basic issues of using spring to develop Web applications, and then combines the WebSphere application server to describe how the spring application combines the services provided by the container. The purpose of this article is to explore with you how to better use the spring framework to develop applications based on WebSphere application servers.

1, the main idea of Spring framework description

The core idea of the spring framework can be described in two words, which is decoupling. Try to create a loosely coupled structure between the parts of the application, both inside and between the code and the platform, making the application more flexible. The application of internal decoupling is mainly achieved by a technique called control inversion (IOC). The basic idea of control inversion is that the logic of the call, which is originally controlled by the application itself, is changed into passive control by external configuration file. Usually we use a so-called Hollywood principle (Don T call me.) I'll call you to figure out the relationship between this control reversal. Because the concept of control reversal is relatively broad, many application servers actually implement varying degrees of control reversal technology, but these application servers are too intrusive to the application. So Martin Fowler wrote an article on the concept of control reversal and proposed a more accurate description of the concept, called Dependency Injection (Dependency injection).

Each part of the spring framework fully uses the technology implementation of this dependency injection, giving the application the greatest degree of flexibility. In fact, the parameterized application control of dependency injection is not the first of spring, for example, IBM's multi-channel Application integration platform (Branch transformation TOOLKIT,BTT) has long used this kind of external parametric control technology. The "Object Factory" in BTT is similar to the beanfactory in the spring framework.

Another important technology of the spring Framework is its support for slicing-oriented programming (AOP). As application complexity increases and demand for application flexibility increases, so does the call for it logic and business logic to be separated as much as possible. As a better way to realize this separation, AOP technology has been paid more and more attention. Spring provides a dynamic AOP implementation that dynamically inserts the appropriate processing code before and after the target object's methods through proxy mode. The decoupling of applications from the underlying application server platform can also be achieved with the help of AOP technology. Spring's built-in AOP support is a feature that is icing on the cake. It makes some functions that must be supported by the container, such as transaction control can be separated from the opening of the container to achieve "slimming" purpose. This is one reason why the spring framework is often used as a lightweight container.

The spring framework can be used in conjunction with many existing framework technologies. An important feature of the application of Java EE technology is that the relevant open source community is very active. There are a number of excellent open source frameworks available at different levels of Web applications. For example, the web layer of the Struts,or mapping layer of hibernate and so on. The spring framework does not reinvent the wheel, and it does not appear to replace these existing frameworks. Instead, the spring framework can be designed to build applications either independently or together with existing frameworks. Another place to point out is that the spring framework has very little coupling between the modules, so the spring framework can be used in a step-by-step manner depending on the actual need, rather than being copied.

2. Web application base based on spring

Typical level of 2.1 Web applications

Web applications are generally logically divided into the following layers according to functionality:

1. Display Layer

This layer mainly generates the interface that is displayed to the end user and contains as few business logic as possible. JSP is one of the most common technologies for Web applications based on Java EE. Spring's support for the presentation layer is very flexible, in addition to supporting JSP directly, it also supports performance layers based on Freemarker templates, interfaces based on velocity templates or other document types.

2. Business Layer

The business layer typically contains the main business logic, especially those that correspond to the use case. In addition, this layer is suitable for the logic that includes transaction management and security control. A good business layer design enables the presentation layer to adopt different technologies without impacting the business layer. The function of the business layer can be likened to the stateless session bean hierarchy in Java EE technology.

3. Data Access Object (DAO) interface layer

DAO is actually the data interface layer, which is recommended to be embodied through interfaces in the application. The existence of DAO enables data access to be separated from the concrete implementation of the underlying persistence layer. Generally in the DAO interface is mainly to implement the data object query, storage, deletion and other operations. Theoretically, the DAO layer and the underlying data storage mode is independent, that is, does not necessarily require a relational database. The spring framework also takes into account the situation of other relational database data sources when it is designed.

4. Persistent Business Objects

Persistent Business objects are persistent representations of business objects in the problem domain, such as a user object, a bank account, and so on. We generally use some O/R mapping technology to achieve the persistence of these business objects. A persistent business object is one that can contain business logic, and what is different from the business logic contained in the business layer is that the persistent business object contains the business logic that is directly related to the specific business object and is more general.

5. Enterprise Information System

Enterprise Information system refers to Web applications need to connect the background system, generally can be divided into three categories, namely, ERP system, Enterprise legacy system and relational database. Most Web applications are based on relational databases, which are the enterprise information systems that are primarily considered in common frameworks like spring.

Well-designed web applications tend to rely on the next level in the hierarchy, but the next level is not dependent on the previous layer. We can briefly summarize the principle of "downward and not upward dependence". Interface coupling is recommended in order to minimize dependency between levels. This is where the spring framework plays its external configuration advantages.

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.