更進一步
VMware 提供培訓和認證,以加速您的進展。
了解更多dm Server 有了一個新的命令列介面。它目前與現有的 Equinox shell 一起提供,並將在 2.0 版本中取代它。相較於 Equinox shell 的改進包括基本的 Tab 鍵自動完成和命令歷史記錄。
dm Shell 可以本地和遠端通過 ssh 訪問。當本地使用時,通過使用 './startup.sh -shell' 選項啟動伺服器,一旦 dm Kernel 啟動,它將接管主控台輸出。主控台輸出仍然可以在事件日誌中查看。無論哪種方式,首先產生的是 ASCII 藝術啟動畫面,然後是命令提示符 ':> '。
[13:36:54 ~]: ssh -p 2402 admin@localhost
admin@localhost's password:
@@@ ***
@@@ ***** .__. .__. .__. .__.
@@@@ ****** __| | _____ _____.| |__ ____ | | | |
@@@@@@ **** / __ | / \ / ___/| | \ ./ __ \ | | | |
@@@@@ *** / /_/ || Y Y \ \___ \ | Y \\ ___/ | |__| |__
@@@ *** \______||__|_|__/ /_____/ |___|__/ \____/ |____/|____/
Type 'help' to see the available commands.
:>
當遠端訪問 dm Shell 時,需要密碼,安全性由 JAAS 身份驗證提供,並且與 dm Console 使用相同的帳號/密碼。預設值為 'admin/springsource'。這可以從 'config' 目錄中的 'com.springsource.kernel.users.properties' 檔案中配置。
進入 shell 後,輸入 'help' 以查看可用命令的列表。當命令輸入到一半時,只需按下 'TAB' 鍵即可查看命令的可能完成列表,而不是返回並再次輸入 'help'。
從 'bundles' 命令開始,這將顯示系統中 使用者區域 的 bundles。將顯示它們的狀態、名稱、版本以及是否由 Spring 驅動。除了少數用於管理使用者區域的核心 bundles 及其服務外,核心的任何部分對於使用者安裝的工件都是不可見的。這使得它更清晰,因為可見的系統 bundles 和服務少得多。
:> bundles
Id State Name-Version
0 Active org.eclipse.osgi-3.5.1.R35x_v20090827
1 Active com.springsource.region.user-0.0.0
2 Resolved org.springframework.aop-3.0.0.CI-395
3 Resolved org.springframework.asm-3.0.0.CI-395
....
46 Active S com.springsource.server.admin.web-2.0.0.M5
47 Active com.springsource.javax.servlet.jsp.jstl-1.1.2
48 Active com.springsource.org.apache.taglibs.standard-1.1.2
49 Active org.springframework.context.support-3.0.0.CI-395
50 Active org.springframework.jdbc-3.0.0.CI-395
51 Active org.springframework.js-2.0.8.RELEASE
52 Active org.springframework.transaction-3.0.0.CI-395
53 Active org.springframework.web.servlet-3.0.0.CI-395
54 Active S com.springsource.server.repository.hosted-2.0.0.M5-com.springsource.server.repository.hosted.core-2.0.0.M5
55 Active com.springsource.server.repository.hosted-2.0.0.M5-com.springsource.server.repository.hosted.web-2.0.0.M5
56 Active com.springsource.server.repository.hosted-2.0.0.M5-com.springsource.server.repository.hosted-synthetic.context-2.0.0.M5
57 Active com.springsource.server.splash-2.0.0.M5
執行操作也很容易,例如安裝 bundle。輸入 'install file:/path.to.bundle.jar'。
:> install file:/Users/chrisfrost/Desktop/com.bar.import-1.0.0.jar
60 Installed com.bar.importer-1.0.0
Bundle 已安裝,但是當我們嘗試 'start' 它時,出現錯誤。當嘗試啟動 bundle 時,顯示了 bundle 缺少必要的依賴項。
:> start 60
Error occured while starting bundle '[60] com.bar.importer-1.0.0' : The bundle could not be resolved. Reason: Missing Constraint: Import-Package: com.foo; version="[1.0.0,2.0.0)"
:>
隨時可以使用 'diag' 命令輕鬆獲取此資訊。呈現的資訊將與嘗試啟動 bundle 時在日誌檔案中顯示的資訊相同。
:> diag 60
Resolution report for bundel 60 Installed com.bar.importer-1.0.0
Cannot resolve: com.bar.importer
Resolver report:
An Import-Package could not be resolved. Caused missing constraint <Import-Package: com.foo; version="[1.0.0,2.0.0)"> in bundle <com.bar.importer_1.0.0>
:>
我們可以安裝一個滿足依賴項的 bundle,然後再次 'start' 我們原始的 bundle,這次一切順利。
這是一個非常簡單的 bundle,可以通過輸入 'bundle 60' 來查看詳細資訊。請記住,有 Tab 鍵自動完成功能,所以只需輸入 'bu TAB 60' 即可完成命令。這裡顯示了此 bundle 導入和導出的所有套件。bundle 名稱前的 'S' 表示該 bundle 具有 Spring context。
:> bundle 60
Bundle report for 60 Active S com.bar.importer-1.0.0
Imported packages:
com.foo-[1.0.0, 2.0.0)
Exported packages:
:> bundle 61
Bundle report for 61 Resolved com.foo.exporter-1.0.0
Imported packages:
Exported packages:
com.foo-1.0.0
:>
我們可以看到它現在正在導入之前導致錯誤的套件。顯示的第二個 bundle 是導出該套件的 bundle。
其他可用的命令包括 'config' 和 'configs',這些命令將顯示已安裝的配置及其屬性。
:> configs
Pid
com.springsource.kernel
com.springsource.repository
com.springsource.server.repository.hosted
com.springsource.osgi.medic
com.springsource.kernel.users
com.springsource.kernel.jmxremote.access
:> config com.springsource.osgi.medic
Pid = com.springsource.osgi.medic
Factory pid = null
Bundle location = null
dump.root.directory = serviceability/dump
log.wrapSysErr = true
log.wrapSysOut = true
service.pid = com.springsource.osgi.medic
:>
顯示的是可用配置的列表以及 medic 配置的屬性。當完成 dm Shell 後,有兩種方法可以離開它。'exit' 將簡單地退出 shell,而 'shutdown' 將調用伺服器上的關閉,shell 會話將作為關閉過程的一部分終止。
:> exit
Goodbye.
Connection to localhost closed.
[14:24:03 ~]:
在 2.0 版本發佈之前,shell 方面正在進行更多工作,屆時將會有完整的用戶指南,我猜測還會有另一篇部落格或螢幕錄影。因此,如果有您想看到的殺手級功能,請大聲說出來。