Osgi series-use eclipse to develop bundle

Source: Internet
Author: User

How to debug bundle during development has always been a problem. Today, let's look at how eclipse solves this problem.

 

I usedEclipse javaee indigo 3.7.2Version.

 

Step 1: Enable eclipse and addPlug-inProject.

 

Step 2: Enter the project nameHelloworldbundleNote that you must select the running mode of the plug-in here.An osgi framework.

 

Step 3: Enter the metadata information related to the bundle. Here we use the default value. We choose to generate automaticallyActivatorClass to simplify the subsequent processing.

 

Step 4: selectHello osgi bundleTemplate generation bundle project.

 

Step 5: Enter the startup and stop information required by the hello osgi bundle template.

 

Step 6: by now, eclipse automatically generates the helloworldbundle plug-in based on our selection. Although this is a very simple bundle, there is no doubt that this is a complete bundle, which can be run directly.

 

The directory structure of helloworldbundle:

 

Content of the activator. Java file:

 Package  Helloworldbundle;  Import  Org. osgi. Framework. bundleactivator;  Import  Org. osgi. Framework. bundlecontext;  Public   Class Activator Implements  Bundleactivator { /*  * (Non-javadoc) * @ see org. osgi. Framework. bundleactivator # Start (Org. osgi. Framework. bundlecontext)  */      Public   Void Start (bundlecontext context) Throws  Exception {system. Out. println ( "Hello world !! " );}  /*  * (Non-javadoc) * @ see org. osgi. Framework. bundleactivator # Stop (Org. osgi. Framework. bundlecontext)  */      Public  Void Stop (bundlecontext context) Throws  Exception {system. Out. println ( "Goodbye World !! " );}} 

 

Content of manifest. MF:

 
Manifest-version: 1.0Bundle-manifestversion:2Bundle-Name: helloworldbundlebundle-symbolicname: helloworldbundlebundle-version:1.0.0. Qualifierbundle-Activator: helloworldbundle. activatorimport-package: org. osgi. Framework;Version = "1.3.0"Bundle-requiredexecutionenvironment: JavaSE-1.6

 

Step 7:Start ()AndStop ()Add two breakpoints to the method:

 

Step 8: Right-click the helloworldbundle project and chooseDebugSelectOsgi framework:

 

Step 9: Everything is OK. Eclipse switches to the debug view and the console window appears.Osgi>Prompt,CodeWe also stopped at the defined start breakpoint.

 

Step 10: enter at the osgi> promptCloseCommand to stop the osgi framework (shutdown and exit ). At this time, the code will stop at the Stop breakpoint.

 

By using the debugging function provided by ECLIPSE, we can become more powerful in the bundle development process.

 

More references:

Coding bundles on the slug demo movie

Remote debugging on the slug demo movie

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.