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 社区中所有即将举行的活动。

查看全部