[b]1.File → new → project[/b]
[img]http://dl.iteye.com/upload/attachment/542357/4d843341-e7d4-3491-9a4a-628d74a15d9b.jpg[/img]
[b]2.選擇 Plug-in project[/b]
[img]http://dl.iteye.com/upload/attachment/542359/29001686-87c5-3446-9647-e643c25acca6.jpg[/img]
[b]3.打入project name:com.puf.osgi.test
Target Platform選擇 an OSGi framework:Equinox
按下Next後選擇Finish[/b]
[img]http://dl.iteye.com/upload/attachment/542463/64009bf9-a8de-3a09-87ab-61fcfa97d9b7.jpg[/img]
[b]4.至MANIFEST 內點選 Dependencies
並至Required Plug-ins內選擇相依的Bundle[/b]
[img]http://dl.iteye.com/upload/attachment/542365/50606d38-63d9-3e63-a611-81dd1ed1ba7d.jpg[/img]
5.至com.puf.osgi.test下新增web-files資料夾,並在資料夾下新增一個index.html檔
[img]http://dl.iteye.com/upload/attachment/542371/d58980e6-a719-38b8-9129-9b5818af9066.jpg[/img]
[img]http://dl.iteye.com/upload/attachment/542369/06821d78-00cc-3ecd-9107-802765d67b12.jpg[/img]
[img]http://dl.iteye.com/upload/attachment/542367/c0feaf80-a091-31bd-b44c-43d18821180d.jpg[/img]
[img]http://dl.iteye.com/upload/attachment/542373/2f3f3ac4-43c9-3514-8b64-a72ec731044f.jpg[/img]
6.在com.puf.osgi.test下新增一個plugin.xml檔案,檔案內容為
[img]http://dl.iteye.com/upload/attachment/542375/d2ff2100-e3ad-37ff-b9bd-b1e79050657d.jpg[/img]
7.發現MANIFEST.MF內Bundle-SymbolicName出現錯誤,在後面加上singleton:=true即可
8.至Run → Run configurations 選擇OSGi Framework 右鍵點選 New
選擇 Deselect All 將 com.puf.osgi.test 打勾,在點選Add Required Bundles
按下 Run
[img]http://dl.iteye.com/upload/attachment/542377/3a84844a-410c-39f6-9889-98372869372a.jpg[/img]
[img]http://dl.iteye.com/upload/attachment/542379/ea37ebdd-f71f-3dda-9550-b628e6b0bd5b.jpg[/img]
9.在至Run → Debug 後,開啟瀏覽器打入 http://localhost/web/index.html 即可
[img]http://dl.iteye.com/upload/attachment/542381/29c2a202-9bea-3cee-b77f-f370ae998394.jpg[/img]
參考網址:http://developer.51cto.com/art/200906/126290.htm
[img]http://dl.iteye.com/upload/attachment/542357/4d843341-e7d4-3491-9a4a-628d74a15d9b.jpg[/img]
[b]2.選擇 Plug-in project[/b]
[img]http://dl.iteye.com/upload/attachment/542359/29001686-87c5-3446-9647-e643c25acca6.jpg[/img]
[b]3.打入project name:com.puf.osgi.test
Target Platform選擇 an OSGi framework:Equinox
按下Next後選擇Finish[/b]
[img]http://dl.iteye.com/upload/attachment/542463/64009bf9-a8de-3a09-87ab-61fcfa97d9b7.jpg[/img]
[b]4.至MANIFEST 內點選 Dependencies
並至Required Plug-ins內選擇相依的Bundle[/b]
[img]http://dl.iteye.com/upload/attachment/542365/50606d38-63d9-3e63-a611-81dd1ed1ba7d.jpg[/img]
5.至com.puf.osgi.test下新增web-files資料夾,並在資料夾下新增一個index.html檔
[img]http://dl.iteye.com/upload/attachment/542371/d58980e6-a719-38b8-9129-9b5818af9066.jpg[/img]
[img]http://dl.iteye.com/upload/attachment/542369/06821d78-00cc-3ecd-9107-802765d67b12.jpg[/img]
[img]http://dl.iteye.com/upload/attachment/542367/c0feaf80-a091-31bd-b44c-43d18821180d.jpg[/img]
[img]http://dl.iteye.com/upload/attachment/542373/2f3f3ac4-43c9-3514-8b64-a72ec731044f.jpg[/img]
6.在com.puf.osgi.test下新增一個plugin.xml檔案,檔案內容為
<plugin>
<extension point="org.eclipse.equinox.http.registry.resources">
<resource alias="/web" base-name="/web_files" />
</extension>
</plugin>
[img]http://dl.iteye.com/upload/attachment/542375/d2ff2100-e3ad-37ff-b9bd-b1e79050657d.jpg[/img]
7.發現MANIFEST.MF內Bundle-SymbolicName出現錯誤,在後面加上singleton:=true即可
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Test
Bundle-SymbolicName: com.puf.osgi.test;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.puf.osgi.test.Activator
Bundle-Vendor: PUF
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Import-Package: org.osgi.framework;version="1.3.0"
Require-Bundle: org.eclipse.equinox.http.jetty;bundle-version="2.0.100",
org.eclipse.equinox.http.servlet;bundle-version="1.1.200",
org.mortbay.jetty.server;bundle-version="6.1.23",
org.apache.commons.logging;bundle-version="1.0.4",
javax.servlet;bundle-version="2.5.0",
org.eclipse.equinox.http.registry;bundle-version="1.1.100"
8.至Run → Run configurations 選擇OSGi Framework 右鍵點選 New
選擇 Deselect All 將 com.puf.osgi.test 打勾,在點選Add Required Bundles
按下 Run
[img]http://dl.iteye.com/upload/attachment/542377/3a84844a-410c-39f6-9889-98372869372a.jpg[/img]
[img]http://dl.iteye.com/upload/attachment/542379/ea37ebdd-f71f-3dda-9550-b628e6b0bd5b.jpg[/img]
9.在至Run → Debug 後,開啟瀏覽器打入 http://localhost/web/index.html 即可
[img]http://dl.iteye.com/upload/attachment/542381/29c2a202-9bea-3cee-b77f-f370ae998394.jpg[/img]
參考網址:http://developer.51cto.com/art/200906/126290.htm