dm Shell

工程 | Christopher Frost | 2009 年 10 月 15 日 | ...

dm Server 有了一個新的命令列 Shell。它目前與現有的 Equinox shell 一起提供,並將取代 2.0 版本的 Equinox shell。與 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 的 ID/密碼相同。預設值為 'admin/springsource'。這可以在 'config' 目錄中的 'com.springsource.kernel.users.properties' 檔案中配置。

列出包

進入 shell 後,鍵入 'help' 以檢視可用命令的列表。當命令輸入到一半時,只需按 'TAB' 鍵即可檢視該命令可能的補全列表,而無需返回並再次鍵入 'help'

'bundles' 命令開始,這將顯示系統中使用者區域的 bundles。顯示它們的狀態、名稱、版本以及它們是否由 Spring 提供支援。除了少數用於管理使用者區域的核心包及其服務之外,核心的任何部分對於使用者安裝的工件都是不可見的。這使得它更加清晰,因為可見的系統包和服務要少得多。

:> 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,可以透過鍵入 'bundle 60' 來詳細檢視。記住有 Tab 鍵補全,所以只需 'bu TAB 60' 即可完成命令。這裡顯示了該 bundle 匯入和匯出的所有包。bundle 名稱之前的 'S' 表示該 bundle 具有 Spring 上下文。

:> 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' 將呼叫伺服器上的 shutdown,並且 shell 會話將作為 shutdown 的一部分終止。

:> exit
Goodbye.
Connection to localhost closed.
[14:24:03 ~]: 

即將推出...

在 2.0 版本釋出之前,還在對 shell 進行更多的工作,到時將有一個完整的使用者指南,並且我懷疑還會有一個部落格或截圖影片。因此,如果有一些您希望看到的殺手級功能,請大聲說出來。

獲取 Spring 新聞簡報

透過 Spring 新聞簡報保持聯絡

訂閱

遙遙領先

VMware 提供培訓和認證,以加速您的進步。

瞭解更多

獲取支援

Tanzu Spring 在一個簡單的訂閱中提供對 OpenJDK™、Spring 和 Apache Tomcat® 的支援和二進位制檔案。

瞭解更多

即將舉行的活動

檢視 Spring 社群中所有即將舉行的活動。

檢視全部