JBoss AS 7通过cli更新系统属性

ber*_*ami 15 configuration jboss7.x

我可以通过CLI界面读取系统属性

/system-property=propertyname:read-attribute(name="value")

有没有一种简单的方法可以通过CLI界面更新属性?

Jam*_*ins 14

您可以使用该write-attribute操作更改系统属性值.

/system-property=propertyname:write-attribute(name="value", value="newValue")
Run Code Online (Sandbox Code Playgroud)

请参阅下面的答案以获得更好的描述.

  • 取决于如何使用该值。如果您在部署过程中或某种单例中需要它,可以。 (2认同)

ddr*_*dri 14

您只需使用write-attribute操作即可.

管理CLI的健康工作流是公开,读取和写入资源属性.举一个这个工作流程的例子,我们将在JBoss Application Server 7.1.0Beta1的全新默认安装上执行以下步骤.

识别和编写系统资源属性的步骤

  1. 阅读所有系统属性
  2. 更详细地阅读特定的系统属性
  3. 公开示例系统属性属性
  4. 编写示例系统属性属性
  5. 公开更改以确认
  6. 将属性重置为原始值

1.读取所有系统属性

我们并不总是知道我们正在寻找的确切名称.我们可以使用选项卡完成和通配符搜索的混合,以便轻松公开资源和属性.该write-attribute操作是任何工作流程的良好开端,因为它公开了所有当前实体.

[domain@localhost:9999 /] /system-property=*:read-resource
{
    "outcome" => "success",
    "result" => [{
        "address" => [("system-property" => "java.net.preferIPv4Stack")],
        "outcome" => "success",
        "result" => {
            "boot-time" => true,
            "value" => "true"
        }
    }]
}
Run Code Online (Sandbox Code Playgroud)

2.更详细地阅读特定的系统属性

read-resource行动暴露了该read-resource财产.我们可以通过使用该java.net.preferIPv4Stack操作进一步查询.

[domain@localhost:9999 /] /system-property=java.net.preferIPv4Stack:read-resource-description 
{
    "outcome" => "success",
    "result" => {
        "description" => "A system property to set on all servers in the domain.",
        "head-comment-allowed" => true,
        "tail-comment-allowed" => false,
        "attributes" => {
            "value" => {
                "type" => STRING,
                "description" => "The value of the system property.",
                "required" => false,
                "access-type" => "read-write",
                "storage" => "configuration",
                "restart-required" => "no-services"
            },
            "boot-time" => {
                "type" => BOOLEAN,
                "description" => "If true the system property is passed on the command-line to the started server jvm. If false, it will be pushed to the server as part of the startup sequence.",
                "required" => false,
                "default" => true,
                "access-type" => "read-write",
                "storage" => "configuration",
                "restart-required" => "no-services"
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

3.公开示例系统属性属性

read-resource-description操作打印有关资源的信息,包括其属性.我们可以通过read-resource-description操作专门查询这些属性.再次,选项卡完成使您可以在开始键入时轻松编写这些操作字符串,然后单击选项卡以完成字符串或建议可用的添加项.

[domain @ localhost:9999 /] /system-property=java.net.preferIPv4Stack:read-attribute(name=boot-time)
{"outcome"=>"success","result"=> true}

4.编写示例系统属性属性

与我们查询属性的方式相同,我们可以更改它.在这种情况下,我们可以使用该read-attribute操作,记住write-attribute操作报告的预期值类型.此操作声明属性为BOOLEAN,但您应该能够通过查看read-resource-description命令中的现有值(定义它的位置)来解决此问题.

[domain@localhost:9999 /] /system-property=java.net.preferIPv4Stack:write-attribute(name=boot-time, value=false)
{
    "outcome" => "success",
    "result" => {
        "domain-results" => {"step-1" => undefined},
        "server-operations" => undefined
    }
}
Run Code Online (Sandbox Code Playgroud)

5.公开更改以确认

我们可以read-attribute再次运行操作来显示值的变化.

[domain@localhost:9999 /] /system-property=java.net.preferIPv4Stack:read-attribute(name=boot-time)              
{
    "outcome" => "success",
    "result" => false
}
Run Code Online (Sandbox Code Playgroud)

6.将属性重置为原始值

只是为了优雅地结束示例,让我们将值更改回原始状态.

[domain@localhost:9999 /] /system-property=java.net.preferIPv4Stack:write-attribute(name=boot-time, value=true) 
{
    "outcome" => "success",
    "result" => {
        "domain-results" => {"step-1" => undefined},
        "server-operations" => undefined
    }
}
Run Code Online (Sandbox Code Playgroud)

摘要

是的,您可以编写属性值.为了简化过程,暴露属性值和文件类型定义的工作流习惯是一种很好的做法,应该使过程更加清晰.