Describes the OSGi runtime features and the dynamic compilation capabilities provided by JDK6

Source: Internet
Author: User
Keywords OSGI JDK6 dynamic compilation function running characteristics
Tags aliyun application based bundle code compile developing development

But we know that one of the most troublesome steps in developing a Bundle in an OSGi environment is to build a compilation environment. Even with the http://www.aliyun.com/zixun/aggregation/13428.html ">eclipse such efficient development tools, due to the large number of Bundle and the same Bundle version diversity, Maintaining a compilation environment becomes cumbersome. Often we need to develop two times for an OSGi Bundle, just a small change that takes a lot of time to build a compilation environment for this program. We are eager to have a run-time compilation environment that simplifies these steps and compiles the code with dependencies that exist in the environment.

This article describes the operational characteristics of OSGi, how the Bundle is dependent on the runtime, and the dynamic compilation capabilities provided by JDK6, and then describes how to use these features to build a development environment that can compile at run time, and finally, through IBM System Director, to develop Bundle is installed on the above demo to give the reader an intuitive experience. This article assumes that the reader has a certain OSGi basic knowledge and Java basics. After reading this article, if the reader has an OSGI runtime environment and the Java source code that you want to compile to run the environment, you can build the module that compiles the bytecode file for release and two development using this running environment.

Figure 1 depicts the traditional OSGi-based application architecture:

Figure 1. OSGi-based application architecture

To implement the functionality described in the article, the application only needs to meet the following system requirements:

An implementation version based on any OSGi4, such as Knopflerfish or Equinox. Run JDK version 6.0 or more.

Figure 2 provides an overview of the purpose described in this article:

Figure 2. Runtime Compilation Environment model

where Bundle1, 2, and so on are the existing Bundle in the OSGi runtime environment, where OSGi has loaded their corresponding jar packages or bytecode files. The brown block diagram is the OSGi runtime dynamic compilation Bundle we want to make.

The user enters the Java source code (either as a command line or a file) to dynamically compile the module to scan all Bundle, storing all the jar and class files in the runtime environment as compile-time dependencies. Dynamically compiling your own Javafileobject objects using the dynamic compilation components provided by JDK6, and specifying Standardjavafilemanager compilation destinations (these are JDK6 dynamic compilation components will be described in detail later), You can compile the Java bytecode file [optional] to send the class file to the specified mailbox to complete the Run-time compilation process.

Let's take a look at how to build this Run-time compilation Bundle using the JDK6 Dynamic compilation component and the related functionality provided by OSGi. Before that, however, it is necessary to understand how the Bundle is communicated.

Related Article

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.