<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Extreme Pattern: eclipse and OSGi</title>
    <link>http://blog.extremepattern.com/articles/2006/09/20/eclipse-and-osgi</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>enjoy</description>
    <item>
      <title>eclipse and OSGi</title>
      <description>&lt;h3&gt;源起&lt;/h3&gt;


	&lt;p&gt;想開發基於 &lt;span class="caps"&gt;RCP&lt;/span&gt; 之上的應用，就需要了解其底層使用的 OSGi 運作機制。OSGi 基本上希望軟體可以像現在 &lt;span class="caps"&gt;USB&lt;/span&gt; 一樣熱插拔，既然 &lt;span class="caps"&gt;USB&lt;/span&gt; 需要 OS 支援，應用程式就需要 OSGi 來做這個事，讓符合規格的應用程式可以直接熱插拔，甚至可以挑版本插拔，聽起來好像不錯。&lt;/p&gt;


	&lt;p&gt;&lt;img src="/files/my_osgi.png" alt="" /&gt;&lt;/p&gt;


	&lt;h3&gt;What&amp;#8217;s New&lt;/h3&gt;


	&lt;ol&gt;
	&lt;li&gt;2006-09-23 新增螢幕展示 screencast&lt;/li&gt;
	&lt;/ol&gt;


	&lt;h3&gt;Open Services Gateway in Eclipse&lt;/h3&gt;


	&lt;p&gt;大部分的 Java 開發者都直接用 &lt;span class="caps"&gt;IDE&lt;/span&gt;，並不太會去動到 eclipse 的內部，eclispe &lt;span class="caps"&gt;IDE&lt;/span&gt; 本身由一堆 plug-ins 組成，同時提供一個 OSGi 的環境供 plug-ins 運作，提供整個開發所需的功能。&lt;/p&gt;


	&lt;p&gt;慢慢地有人覺得 minimum eclipse plug-ins 可以方便再利用來開發 eclipse &lt;span class="caps"&gt;IDE&lt;/span&gt; 類似桌面型軟體，所以 Eclipse Rich Client Platform (RCP) 慢慢成形，RCP 牽涉到 plug-ins 取捨，選哪些 eclipse  plug-ins 可以方便以後大家使用，當然 OSGi 也要一起包起來帶走。&lt;/p&gt;


	&lt;p&gt;在 &lt;span class="caps"&gt;RCP&lt;/span&gt; 包起來的環境中都可以找到這個實作 rcp/plugins/org.eclipse.osgi_3.x.x.jar。&lt;/p&gt;


	&lt;h3&gt; osgi console&lt;/h3&gt;


	&lt;p&gt;先進入 console 狀態&lt;/p&gt;


&lt;pre&gt;
C:\Downloads\EclipseInstall\OSGi&amp;gt;java -Dosgi.install.area=file://c:/downloads/ 
-cp org.eclipse.osgi_3.2.0.v20060601.jar
org.eclipse.osgi.framework.launcher.Launcher -console
&lt;/pre&gt;

	&lt;p&gt;launch 後到 http://www.knopflerfish.org/repo/index.html 找一些下載。&lt;/p&gt;


&lt;pre&gt;
osgi&amp;gt; ss

Framework is shutdown.

id      State       Bundle
0       RESOLVED    system.bundle_3.2.0.v20060601

osgi&amp;gt; launch

osgi&amp;gt; ss

Framework is launched.

id      State       Bundle
0       ACTIVE      system.bundle_3.2.0.v20060601

osgi&amp;gt; install http://www.knopflerfish.org/repo/jars/log/log_all-2.0.0.jar
Bundle id is 1

osgi&amp;gt; ss

Framework is launched.

id      State       Bundle
0       ACTIVE      system.bundle_3.2.0.v20060601
1       INSTALLED   org.knopflerfish.log_2.0.0

osgi&amp;gt; start 1
&lt;/pre&gt;

	&lt;p&gt;啟動失敗，會告知缺少 org.osgi.service.cm，換一個不相依commons-logging_all-2.0.0.jar 試過，可以啟動。&lt;/p&gt;


&lt;pre&gt;
osgi&amp;gt; install http://www.knopflerfish.org/repo/jars/commons-logging/commons-logging_all-2.0.0.jar
Bundle id is 2

osgi&amp;gt; ss

Framework is launched.

id      State       Bundle
0       ACTIVE      system.bundle_3.2.0.v20060601
1       INSTALLED   org.knopflerfish.log_2.0.0
2       INSTALLED   org.knopflerfish.bundle.commons-logging_2.0.0

osgi&amp;gt; start 2

osgi&amp;gt; ss

Framework is launched.

id      State       Bundle
0       ACTIVE      system.bundle_3.2.0.v20060601
1       INSTALLED   org.knopflerfish.log_2.0.0
2       ACTIVE      org.knopflerfish.bundle.commons-logging_2.0.0
&lt;/pre&gt;

	&lt;p&gt;加上 cm 看看。&lt;/p&gt;


&lt;pre&gt;
osgi&amp;gt; install http://www.knopflerfish.org/repo/jars/cm/cm_all-2.0.0.jar
Bundle id is 4

osgi&amp;gt; ss

Framework is launched.

id      State       Bundle
0       ACTIVE      system.bundle_3.2.0.v20060601
1       INSTALLED   org.knopflerfish.log_2.0.0
2       ACTIVE      org.knopflerfish.bundle.commons-logging_2.0.0
4       INSTALLED   org.knopflerfish.bundle.cm_2.0.0

osgi&amp;gt; start 4

osgi&amp;gt; ss

Framework is launched.

id      State       Bundle
0       ACTIVE      system.bundle_3.2.0.v20060601
1       RESOLVED    org.knopflerfish.log_2.0.0
2       ACTIVE      org.knopflerfish.bundle.commons-logging_2.0.0
4       ACTIVE      org.knopflerfish.bundle.cm_2.0.0

osgi&amp;gt; start 1

osgi&amp;gt; ss

Framework is launched.

id      State       Bundle
0       ACTIVE      system.bundle_3.2.0.v20060601
1       ACTIVE      org.knopflerfish.log_2.0.0
2       ACTIVE      org.knopflerfish.bundle.commons-logging_2.0.0
4       ACTIVE      org.knopflerfish.bundle.cm_2.0.0

&lt;/pre&gt;

	&lt;h3&gt;screencast 螢幕展示&lt;/h3&gt;


	&lt;p&gt;覺得手動太麻煩 ? 可以用 eclipse 來玩，非常簡單，幾分鐘就可以。&lt;/p&gt;


	&lt;p&gt;&lt;img src="/files/screencast.png" alt="" /&gt; &lt;a href="/showswf/osgi_1/843/617"&gt;screencast&lt;/a&gt;&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;用 3.2 版&lt;/li&gt;
		&lt;li&gt;只有選 plug-in 專案，沒有 Bundle 專案，以後也許會改比較 OSGi 的說法。&lt;/li&gt;
		&lt;li&gt;用 Equinox 當底層&lt;/li&gt;
		&lt;li&gt;都幫你出好了，雖然應該用 Bundle 比較適合&lt;/li&gt;
		&lt;li&gt;直接用範本，連程式碼都不用打&lt;/li&gt;
		&lt;li&gt;直接就可以跑&lt;/li&gt;
		&lt;li&gt;檢視一下&lt;/li&gt;
		&lt;li&gt;匯出 jar&lt;/li&gt;
		&lt;li&gt;順便匯出  ant 的 build.xml 參考&lt;/li&gt;
		&lt;li&gt;看一下成果&lt;/li&gt;
		&lt;li&gt;建立一個純的 osgi 環境，只取 org.eclipse.osgi 一個 jar&lt;/li&gt;
		&lt;li&gt;直接吃剛才編出的 jar 看看。&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;產出的 ant build.xml 可是好東西，對於需要 &lt;a href="http://www.eclipse.org/articles/Article-PDE-Automation/automation.html"&gt;自動化產出 Bundle&lt;/a&gt; 的人來說，用起來會很方便。&lt;/p&gt;


	&lt;h3&gt;small osgi 螢幕展示&lt;/h3&gt;


	&lt;p&gt;關於 eclipse 開發的螢幕展示還可以參考下面連結，將 OSGi 環境建立在改造過小型 &lt;span class="caps"&gt;NAS&lt;/span&gt; 裝置上面，在遠端用 eclipse 開發。&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www.eclipse.org/equinox/documents/osgicongress2005/coding.html"&gt;Coding bundles on the Slug demo movie&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www.eclipse.org/equinox/documents/osgicongress2005/debugging.html"&gt;Remote debugging on the Slug demo movie&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;OSGi 移植到小裝置上的做法，也許 gcj 也是一種可以考慮的做法。&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://osgifun.blogspot.com/2005/10/openslug-gateway-installation-osgi-on.html"&gt;OpenSlug Gateway Installation &amp;#8211; OSGi on the &lt;span class="caps"&gt;NSLU2&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www.aqute.biz/2005/10/osgi-on-slug.html"&gt;OSGi on the Slug&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;將 OSGi 真的變成 Open Services Gateway 似乎需要一點時間，目前 &lt;span class="caps"&gt;IBM&lt;/span&gt; 在這個領域推蠻久的。&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www-128.ibm.com/developerworks/wireless/library/wi-osgi/index.html"&gt;Managed mobile clients with OSGi: Managed smart clients&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www-128.ibm.com/developerworks/websphere/library/techarticles/0606_salkosuo/0606_salkosuo.html" title="OSGi"&gt;&lt;span class="caps"&gt;IBM&lt;/span&gt; Workplace Client Technology, Micro Edition and Open Services Gateway Initiative&lt;/a&gt;&lt;/p&gt;


	&lt;h3&gt;links 參考&lt;/h3&gt;


	&lt;p&gt;&lt;a href="http://www.eclipsezone.com/eclipse/forums/t64096.html"&gt;Developing Eclipse/OSGi Web Applications&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www.eclipsezone.com/nl/archives/eznews_20060810.html"&gt;OSGi Everywhere&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www.eclipsezone.com/eclipse/forums/t78442.rhtml"&gt;Spring and OSGi, A Perfect Match?&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://opensource.atlassian.com/projects/spring/secure/attachment/11934/spring_and_osgi-64.html"&gt;Spring and OSGi&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www-128.ibm.com/developerworks/library/os-ecl-osgi/index.html"&gt;Understanding how Eclipse plug-ins work with OSGi&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://jmesnil.net/weblog/2004/12/launching-eclipse-osgi-framework-from.html"&gt;Launching Eclipse OSGi Framework from the command line&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://osgi.org/markets/opensource.asp?section=3"&gt;OSGi Open Source Market&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www.knopflerfish.org"&gt;Knopflerfish &amp;#8211; Open Source OSGi&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://nettrace.blogspirit.com/archive/2004/10/10/java_%E6%B7%BA%E8%AB%87_osgi_%E6%A8%99%E6%BA%96.html"&gt;Java: 淺談 OSGi 標準&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 20 Sep 2006 03:25:00 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:75dfd29a-0ee9-4dd0-85a1-af1d98e2b650</guid>
      <author>LIN</author>
      <link>http://blog.extremepattern.com/articles/2006/09/20/eclipse-and-osgi</link>
      <category>screencast</category>
      <category>eclipse</category>
      <category>java</category>
    </item>
  </channel>
</rss>
