Use eclipse to install and develop your own boundle

Source: Internet
Author: User

1. Write the Java file that inherits bundleactivator. The start () function is the entry to the osgi platform call start.

Package com. javaworld. sample. helloworld;

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 !! ");
}

}
2. Create a new directory and test the org. Eclipse. osgi_3.5.1.r35x_v20090827.jar (osgi package of eclipse) and Java file under this directory. Go to the directory and compile and modify the class.
Javac-classpath org. Eclipse. osgi_3.5.1.r35x_v20090827.jar COM/javaworld/sample/helloworld/Activator. Java
3. Create a manifest. MF file in the META-INF directory, specify bundle-activator and other settings.

Manifest-version: 1.0
Bundle-vendor: javaworld
Bundle-version: 1.0.0.qualifier
Bundle-Name: helloworld
Created-by: 1.6.0 _ 14 (Sun Microsystems Inc .)
Bundle-Activator: COM. javaworld. sample. helloworld. Activator
Bundle-manifestversion: 2
Import-package: org. osgi. Framework; version = "1.3.0"
Bundle-symbolicname: COM. javaworld. sample. helloworld
4. Package
Jar-CFM com. javaworld. sample. helloworld. activator. Jar helloworld. mf com/javaworld/sample/helloworld/Activator. Class
5. Enter the directory at the DOS prompt and start osgi
Java-jar org. Eclipse. osgi_3.5.1.r35x_v20090827.jar-Console
6. Install and create a bundle
Osgi> Install file: COM. javaworld. sample. helloworld. activator. Jar
7. Start bundle according to the ID. If the ID is 1
Osgi> Start 1
8. Stop bundle
Osgi> stop 1
9. Uninstall bundle
Osgi> uninstall file: COM. javaworld. sample. helloworld. activator. Jar

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.