本主题介绍了 Java CAPS 管理客户机以及将 API 集与基于 JBI 的 Java CAPS 运行时环境和不基于 JBI 的 Java CAPS 运行时环境结合使用的客户机。
脚本客户机 — 使用任何 JSR 223 脚本客户机,如 Groovy、JRuby、Jython 或 JACL。有关其他信息,请参见设置脚本引擎。
Java CAPS 发行版 6 软件包附带提供了一些 Groovy 样例。
CLI 客户机 — 通过您自己的命令行界面客户机来执行这些 API,这些客户机是使用预定义的功能代码(首选 Java 代码)构建的。
其他 Web/GUI 客户机 — 通过自定义 Web/GUI 客户机来执行这些 API。
典型客户机用法示例
try { // Get the Management Client ManagementClient client = ManagementClientFactory.getInstance ("localhost", 4848, "admin", "adminadmin"); // Get the Administration Service AdministrationService administrationService = client.getService(AdministrationService.class); // ... Use the Administration Service ... // Get the Configuration Service ConfigurationService configurationService = client.getService(ConfigurationService.class); // ... Use the Configuration Service ... // Get the Deployment Service DeploymentService deploymentService = client.getService(DeploymentService.class); // ... Use the Deployment Service ... // Get the Installation Service InstallationService installationService = client.getService(InstallationService.class); // ... Use the Installation Service ... // Get the Runtime Management Service RuntimeManagementService runtimeManagementService = client.getService(RuntimeManagementService.class); // ... Use the Runtime Management Service ... // Get the JMS Management Service JmsManagementService jmsManagementService = client.getService(JmsManagementService.class); // ... Use the JMS Management Service ... // Get the Alert Management Service AlertManagementService alertManagementService = client.getService(AlertManagementService.class); // ... Use the Alert Management Service ... // Get the Log Management Service LogManagementService logManagementService = client.getService(LogManagementService.class); // ... Use the Log Management Service ... } catch (ManagementRemoteException exception) { // Format the exception and print it. String formattedExceptionResult= ManagementRemoteExceptionProcessor.processTaskException(exception); System.out.println(formattedExceptionResult); } |
JavaDoc 包含 API 中的所有类的完整列表。Java CAPS 软件包以压缩文件形式附带提供了 JavaDoc。
目标提供了管理操作的范围。通过将命令定向到多个目标,可以有效地扩大该命令的范围。如果指定多个目标,将分别报告每个目标是否成功。也就是说,不会“累积”所有目标上的操作结果以报告摘要状态。下表描述了每种目标类型的范围。
其中的两个目标选项名称为常量:"domain" 和 "server"。它们表示一个运算符实例,可以将其替换为特定于当前模板的名称。
目标名称 |
范围 |
---|---|
domain |
针对域本身执行命令。对于 JBI 目的,这相当于“添加到系统信息库”活动。 |
server |
针对嵌入的 DAS 服务器实例执行命令。 |
群集名称 |
针对群集中的所有实例执行命令。 |
实例名称 |
针对单个独立实例执行命令。 |
群集实例名称 |
针对群集中的特定实例执行命令。 |
此软件包以压缩文件形式附带提供了与该主题有关的样例,例如,AdministrationServiceSample.groovy。