10/30/2009

Websphere sMASH Getting Started

官方下載
請先安裝好JDK, 並設好JAVA環境變數
下載zero.zip, 解壓縮到(e.g C:\zero), 並且將c:\zero\加到環境變數。

第一次安裝
1. 進到c:\zero\找到zero.bat 執行它, 會從官方網站的repository下載一些zip檔,
要稍等一陣子等他跑完
2. 再執行appbuilder.bat, 一樣會下載一些東西等他跑完(更久)

第一次執行
1. 開啟windows command.exe
2. 輸入appbuilder open (如果你的環境變數有設對,就會work)
他會開啟你的browser來到 http://localhost:8070/
如果沒有自動開啟, 請手動開啟

影片
接下來如何開始你的第一個應用程式可看影片(從2:38秒開始看)
http://www.youtube.com/watch?v=l_dqIi9MTf8&feature=player_embedded#

文件
如果你喜歡top-down開發(從UI往data model實作), 請參考:
http://www.projectzero.org/zero/monza.dev/latest/docs/zero.gettingstarted.doc/zero.appbuilder.formeditor/UserInterfaceFirst.html
如果你喜歡bottom-up開發(從data model往UI實作), 請參考:
http://www.projectzero.org/zero/monza.dev/latest/docs/zero.gettingstarted.doc/zero.appbuilder.formeditor/DataFirst.html

Connection.demo
瀏覽http://localhost:8070/
左手邊Create from repository> module group 選stable
輸入demo以搜尋相關sample
找到connection.demo > Create
稍等片刻
畫面上出現zero.connection.demo 點進去
右上角執行START
開啟網址http://localhost:8080/

10/29/2009

Java Library to OSGi bundle Wrapping


事先請安裝好Eclipse+Knopflerfish開發環境



開始一個Bundle project
Eclipse>File>New>Project>OSGi>Bundle Project
產生一個新的bundle project用來包所需的library

取名叫做e.g. xxxAPIBundle
Next>uncheck Create Activator>Finish
不需要activator

workspace/xxxAPIBundle目錄下建lib目錄, 將所需要的library JAR檔都放在這
回到Eclipse, xxxAPIBundle project目錄上右鍵重新整理(F5), 會看到lib目錄出現


設定Build path
xxxAPIBundle>Build Path>Configure Build Path, 切換到Libraries分頁
Add JARs, 不要用Add External JARs > 展開xxxAPIBundle目錄, lib底下所有的JAR檔加入

修改manifest
點兩下Bundle.manifest找到Export Packages
Add…>選擇所有packages> OK

----------到這邊已完成, 底下是optional------------


畢竟包好的API bundle是要給OSGi環境的其他bundle使用, 
如果你開發的主程式有需要額外Import package, 你也可以手動編輯bundle.manifest頁面。
Eclipse下方的分頁選到bundle.manifest進入純文字編輯模式

手動加入export packagemanifest
Export –Package: 一堆敘述的最後加上你所需要的package
Ctrl+S儲存, 此時project explorer內的bundle.manifest出現紅色的x可以不理會.

輸出bundle
xxxAPIBundle專案目錄上右鍵>Export>Java>JAR file>Next
展開畫面xxxAPIBundle目錄> 確認lib目錄有打勾
Select export destination選擇輸出位置 Browse>選擇檔名e.g. xxxAPIBundle.jar
Next>Next (不要急著按Finish)
Use existing manifest from workspace
選擇Manifest file: /xxxAPIBundle/bundle.manifest


Finish
輸出的JAR檔已可以加入到Knopflerfish供其他bundle使用。