[OSGI] Felix Basic Environment Construction and operation

Source: Internet
Author: User

Felix is an Apache-owned framework for implementing OSG specification I. Access Address: http://felix.apache.org/


Building the basic OSGi framework only requires downloading the Felix framework.


Unzip to any directory (for example: D:\felix-framework-4.4.1), open cmd Command window in felix-framework-4.4.1 directory, execute launch Felix framework command

Java-jar Bin/felix.jar

Enter the LB command to view the current launch of Felix's bundle after completion of startup

G! LB
START Level 1
   id| State      | level| Name
    0| Active     |    0| System Bundle (4.4.1)
    1| Active     |    1| Apache Felix Bundle Repository (2.0.2)
    2| Active     |    1| Apache Felix Gogo Command (0.14.0)
    3| Active     |    1| Apache Felix Gogo Runtime (0.12.1)
    4| Active     |    1| Apache Felix Gogo Shell (0.10.0)
g!

Stop Felix Frame is input stop 0


Installing Felix's Bundle (Helloworld.jar) is the absolute path that requires the bundle, execute the command install File:/file_path

<pre name= "code" class= "plain" >g! LB
START Level 1
   id| State      | level| Name
    0| Active     |    0| System Bundle (4.4.1)
    1| Active     |    1| Apache Felix Bundle Repository (2.0.2)
    2| Active     |    1| Apache Felix Gogo Command (0.14.0)
    3| Active     |    1| Apache Felix Gogo Runtime (0.12.1)
    4| Active     |    1| Apache Felix Gogo Shell (0.10.0)
g! Install File:/d:/felix-framework-4.4.1/myplugins/helloworld_ 1.0.0.201501121409.jar
Bundle id:5 
g!

Execute LB View Installation results

G! LB
START Level 1
   id| State      | level| Name
    0| Active     |    0| System Bundle (4.4.1)
    1| Active     |    1| Apache Felix Bundle Repository (2.0.2)
    2| Active     |    1| Apache Felix Gogo Command (0.14.0)
    3| Active     |    1| Apache Felix Gogo Runtime (0.12.1)
    4| Active     |    1| Apache Felix Gogo Shell (0.10.0)
    5| Installed  |    1| Helloworld (1.0.0.201501121409)
g!
You can see that the status of the newly installed Helloworld.jar is installed


Start bundle command Start Bundleid

G! Start 5
Hello world!
G!

View bundle Status LB

G! LB
START Level 1
   id| State      | level| Name
    0| Active     |    0| System Bundle (4.4.1)
    1| Active     |    1| Apache Felix Bundle Repository (2.0.2)
    2| Active     |    1| Apache Felix Gogo Command (0.14.0)
    3| Active     |    1| Apache Felix Gogo Runtime (0.12.1)
    4| Active     |    1| Apache Felix Gogo Shell (0.10.0)
    5| Active     |    1| Helloworld (1.0.0.201501121409)
g!
HelloWorld Bundle Status Active indicates plug-in is activated


Stop bundle command for Stop Bundleid

G! Stop 5
g! lb
START level 1
   id| State      | level| Name
    0| Active     |    0| System Bundle (4.4.1)
    1| Active     |    1| Apache Felix Bundle Repository (2.0.2)
    2| Active     |    1| Apache Felix Gogo Command (0.14.0)
    3| Active     |    1| Apache Felix Gogo Runtime (0.12.1)
    4| Active     |    1| Apache Felix Gogo Shell (0.10.0)
    5| Resolved   |    1| Helloworld (1.0.0.201501121409)
g!
HelloWorld bundle status changed to Resolved


Update the HelloWorld source, the output statement into Hello World, OSGI!

There are two ways to update an operation


When replacing the modified bundle with the original bundle, perform the update Bundleid

G! Update 5
g! lb
START level 1
   id| State      | level| Name
    0| Active     |    0| System Bundle (4.4.1)
    1| Active     |    1| Apache Felix Bundle Repository (2.0.2)
    2| Active     |    1| Apache Felix Gogo Command (0.14.0)
    3| Active     |    1| Apache Felix Gogo Runtime (0.12.1)
    4| Active     |    1| Apache Felix Gogo Shell (0.10.0)
    5| Installed  |    1| Helloworld (1.0.0.201501121422)
g! start 5
Hello world, OSGI!
G!

Perform update Bundleid File:/fiel_path the existing bundle with the stored bundle to another location

G! LB
START Level 1
   id| State      | level| Name
    0| Active     |    0| System Bundle (4.4.1)
    1| Active     |    1| Apache Felix Bundle Repository (2.0.2)
    2| Active     |    1| Apache Felix Gogo Command (0.14.0)
    3| Active     |    1| Apache Felix Gogo Runtime (0.12.1)
    4| Active     |    1| Apache Felix Gogo Shell (0.10.0)
    5| Active     |    1| Helloworld (1.0.0.201501121409)
g! Update 5 File:/d:/felix-framework-4.4.1/myplugins/helloworld_ 1.0.0.201501121409_new.jar
Hello World, OSGI!
G!

Unload Bundle Command Uninstall Bundleid

G! Uninstall 5
g! lb
START level 1
   id| State      | level| Name
    0| Active     |    0| System Bundle (4.4.1)
    1| Active     |    1| Apache Felix Bundle Repository (2.0.2)
    2| Active     |    1| Apache Felix Gogo Command (0.14.0)
    3| Active     |    1| Apache Felix Gogo Runtime (0.12.1)
    4| Active     |    1| Apache Felix Gogo Shell (0.10.0)
g!


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.