Osgi and spring: What is spring dynamic model (Spring DM )?

Source: Internet
Author: User

[51cto] This article is "Hello, osgi
Series
Part 5. Starting from this article, we will introduce the spring dynamic model. Let's take a look at why spring dynamic models are so exciting for developers. These developers have
Spring configurations are very familiar and need to explore osgi's modularity, simple version control, and application Lifecycle Support.

51cto editing recommendations:
Osgi introduction and Practice

Use osgi and spring to build service-oriented applications

Osgi, also known as Java
Language dynamic module system
, It is Java
Application Development specifies a module method and a set of standardized modules to manage the attributes between modules. Spring Dynamic Model Project of the osgi service platform (That is
Spring dynamic model (Spring DM for short)

) Allows developers to build spring applications that can be deployed in osgi containers. Familiar
Java for spring programming and configuration models
Spring dynamic model is a simple method for enterprise developers to familiarize themselves with osgi Application Development modularization. In addition to the osgi module that allows spring developers
In addition to the architecture and dynamic configuration, the spring dynamic model also provides low-level programming required by most osgi applications, so you can focus on the business logic of the application.

In the first section of this series of articles (hello, osgi, first
Section: getting started with bundles
), We introduced a standard osgi development method, using osgiapi and open-source equinox
Container implementation. You have learned about the osgi architecture, especially the container and bundle, and developed an osgi-based Hello world for the first time.
Application. The purpose of this example is only to understand the basic functions of osgi, so the application example is not very in-depth.

In this section, you will build a hello World
Ying
This time, we will use the spring dynamic model framework. What is spring?
DM and its use of osgi application logic separation in the module, as well as its module boundary runtime enforcement. In addition, you will learn how to use the spring dynamic model to complete the following tasks:

Dynamically install, upgrade, and uninstall modules in a running system.

Build a service-oriented application (SOA) by dynamically discovering and using the services provided by other modules in the system ).

Use spring datasource
Class instantiates, configures, assembles, and adds decorative functions between system modules and components that span system modules.

You will see that using spring dynamic models can free you from some rigid mechanical work and more difficult work: understanding what happened under the osgi framework. Therefore, you will be able to dig deeper
Explore the application logic and perform this mining more quickly in the development process.

To understand the examples in this section, you need a development environment that includes the eclipse 3.3 and spring dynamic models.

Osgi and spring frameworks

The popularity of osgi has increased rapidly. Some application servers have recorded reconfiguration of osgi-based modular frameworks, including IBM WebSphere
Application Server, Bea microservice architecture (MSA), and Jonas
5. An open-source application server built on the osgi architecture. JBoss
We are also developing osgi-based class loaders and plan to participate in an osgi core rule implementation. Perhaps most importantly, eclipse
Foundation (eclipse Foundation) osgi container/runtime component engine equinox
Recently, it has been upgraded to the top-level project status. In this status, it will be used as a new eclipse runtime specification (eclipse Runtime
Initiative.

Even before osgi's current popularity surge, there was a discussion about it and spring combination. This discussion brought about the spring dynamic model of the osgi service platform.
(Springdynamic modules forosgiservice platforms
) Project. Spring dynamic model features can be divided into two main parts: The first feature is that it provides the Spring framework in the form of osgi bundle
Jar. As you have learned from the previous chapter, the osgi suite is only a Java achive (jar) file.
META-INF/manifest. MF
The file contains additional entries, which can be used as the descriptor of the osgi suite ). (Note that when using osgi, you cannot directly deploy jar
File; you need to use the osgi Suite Format to assemble it .)

The second feature, spring DM provides three osgi-specific spring suites/jar:

1. org. springframeork. osgi. Bundle. Extender
2. org. springframeork. osgi. Bundle. Core
3. org. springframeork. osgi. Bundle. Io

Applications built using the spring dynamic model are built in a different way than those using the Spring framework. When you build a spring application
The configuration information is defined in spring configuration files. The vast majority of such configuration files are XML
File. When an application starts, the Spring framework uses these configuration files to create an application context object. After the application context is created,
It will be used to instantiate, configure, assemble (assemble) the objects in the application and add decorative features.

For the spring dynamic model, at startup, org. springframeork. osgi. Bundle. Extender
Query all resolution (resolved) statuses to see if they are provided by spring (springpowered ). If the suite has spring-Context
Manifest header, or include the XML file in its META-INF/spring folder, Extender
The suite will assume that it is provided by spring.

When you find the suite provided by spring, org. springframeork. osgi. Bundle. Extender
The spring configuration file will be loaded in the suite to create an application-context object. The Extender
It also checks whether the suite is outputting the osgi service. If yes, it will output the springbean
To the osgi sharing service register (Registry ). If the suite is importing the osgi service, it will find the service and use it as the bean
In the application context. The Extender
A listener is also registered for the suite event, so that, whether or not any osgi suite enters the parsing state, it will check whether it is provided by spring and follow the same steps.

In the next article, you will start from setting up the relevant environment and develop your first spring dynamic model application. In this process, the above issues will become clear. Coming soon!

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.