鏈綆綰︾殑姝ラ:(浠pache Felix涓轟緥)
1. 涓嬭澆Felix 鍙戝竷鍖?br />
http://felix.apache.org/site/downloads.cgi 涓?涓嬭澆 Felix Framework Distribution
3.0.x ,瑙e帇鍒頒竴涓洰褰曚腑
2. 鍦↖ntellij 涓坊鍔?Felix鐩綍
Settings --> OSGI --> IDE Settings --> Framework Defininations: 閫夋嫨 綾誨瀷涓?Felix, 鐒跺悗嫻忚閫変腑Felix 鐨勮В鍘嬬洰褰? 灝辨坊鍔犳垚鍔熶簡.

3. 鍒涘緩涓涓狿roject, 褰撶劧涔熷垱寤轟竴涓狹odule
鍦╩odule灞炴у彸閿坊鍔?OSGI鏀寔
鍦╩odule渚濊禆璁劇疆涓坊鍔?Osmorc鑷姩鐢熸垚鐨凢elix搴?浣滀負鏈ā鍧楃殑渚濊禆.
4. 鍒涘緩涓涓被
1 package com.selftest.osgi;
2
3 import org.osgi.framework.BundleActivator;
4 import org.osgi.framework.BundleContext;
5
6 public class HelloWorldActivator implements BundleActivator
7 {
8 public void start(BundleContext bundleContext) throws Exception
9 {
10 System.out.println("Hello World Bundle started!");
11 }
12
13 public void stop(BundleContext bundleContext) throws Exception
14 {
15 System.out.println("Hello World Bundle stop!");
16 }
17 }
18
4. 鍦╩odule 鐨勫睘鎬SGI涓? 璁劇疆 Bundle Activator涓?HelloWorldActivator , 鍚嶅瓧鑷繁闅忔剰濉啓涓涓?

5. 鏂板緩涓涓?Configuration鏉ユ祴璇?OSGI Bundle
- "ADD" 鍒氬垰鍒涘緩鐨勬ā鍧?
- 閫変腑 "Start OSGI Console"
- Run time directory: recreate each time 鏈綆鍗?/span>
- 鑷姩鍚姩 闅忔剰閫夋嫨

6. 鍚姩嫻嬭瘯
鍚姩, 緇忚繃"婕暱"鐨勭瓑寰? 鐣岄潰鍑烘潵浜? 濡傛灉浣犻夋嫨浜?Start OSGI Console" 鍒欏彲浠ュ懡浠よ浜や簰.
杈撳叆help鍙互鏌ョ湅鎵鏈夊懡浠? 杈撳叆ps鍙互鏌ョ湅鎵鏈夊惎鍔ㄧ殑bundle.
start, stop 鍔犱笂鐩稿簲id鍗沖彲 鍚姩/鍋滄涓涓粍浠?


]]>