Developing Web applications based on OSGi and spring

Source: Internet
Author: User

As a new de facto industrial standard, OSGi has received wide attention, its service-oriented (interface) basic idea and the capability of dynamic module deployment are the goals that enterprise applications have been pursuing for a long time. Spring is a well-known lightweight Java development framework characterized by interface-oriented programming and non-invasive dependency injection. The combination of OSGi and Spring can give full play to their respective strengths, better meet the needs of enterprise-level application development. In 2008, the Spring Development Organization released the first version of the combination of OSGi and Spring: SPRING-DM. This paper presents a simple example of how to use SPRING-DM to develop WEB applications based on OSGi and Spring architectures, while exploring the key technologies and their basic ideas.

Develop a simple example of an OSGi Web application

A simple Web application

We write a simple WEB application compute.html: Compute the sum or product of two digits. As shown in the following illustration:

Figure 1. A simple example

To reflect the dynamic deployment capabilities of the OSGi bundle, we write two service bundle, one of which computes two digits and (called Add bundle), and the other calculates the product of two digits (called multiply bundle). When we click on the "Compute" button, if the add bundle is deployed at this time, the page will return two digits of the and, otherwise if the multiply bundle is deployed at this time, the page will return two number of the product. Development environment Preparation

1. Download Eclipse 3.4

2. Get all the plug-ins for OSGi, Equinox, and Spring, as shown in the following illustration:

1. Open Eclipse, set target platform to the above plug-in collection

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.