安装运行

安装之前首先需要:

  1. 克隆编译打包生成安装文件

  2. 安装 WildFly

克隆编译打包生成安装文件:

Maven 3.xJava 1.7 或以后版本git 客户端 安装配置完成后执行如下命令

$ git clone git@github.com:kylinsoong/wildfly-samples.git
$ cd wildfly-samples/subsystem/acme-subsystem/
$ mvn clean install

如上命令执行完成会生成 acme-subsystem-dist.zip 文件,位于 target 目录下.

安装 WildFly:

下载 WildFly,解压完成安装

$ unzip wildfly-10.0.0.Final.zip

安装 acme-subsystem:

解压 acme-subsystem-dist.zip 到 WildFly 主目录

$ unzip acme-subsystem-dist.zip -d wildfly-10.0.0.Final

启动 acme-subsystem:

$ ./bin/standalone.sh -c standalone-wildfly10.xml

测试 acme-subsystem:

部署 example.war, cool.war, test.warWildFly,查看 console 端日志输出:

16:20:23,007 INFO  [stdout] (tracker-sar-thread) Current deployments deployed while sar tracking active:[], Cool: 0
16:20:23,011 INFO  [stdout] (tracker-war-thread) Current deployments deployed while war tracking active:[example.war, test.war, cool.war], Cool: 1

更多管理层面的测试参照如下使用 CLI 测试部分。

使用 CLI 测试

查看所有 resource 定义:

[standalone@localhost:9990 /] /subsystem=tracker:read-resource(include-defaults=true,recursive=true)
{
    "outcome" => "success",
    "result" => {
        "show-cool-deployments" => true,
        "type" => {
            "sar" => {"tick" => 10000L},
            "war" => {"tick" => 10000L}
        }
    }
}

添加新type:

[standalone@localhost:9990 /] /subsystem=tracker/type=jar:add(tick=10000)
{"outcome" => "success"}

移除type:

[standalone@localhost:9990 /] /subsystem=tracker/type=jar:remove()
{"outcome" => "success"}

修改tick默认值:

[standalone@localhost:9990 /] /subsystem=tracker/type=sar:write-attribute(name=tick,value=20000)
{"outcome" => "success"}

读取tick值:

[standalone@localhost:9990 /] /subsystem=tracker/type=sar:read-attribute(name=tick)
{
    "outcome" => "success",
    "result" => 20000L
}

修改show-cool-deployments值:

[standalone@localhost:9990 /] /subsystem=tracker:write-attribute(name=show-cool-deployments,value=false)
{
    "outcome" => "success",
    "result" => true
}

读取show-cool-deployments值:

[standalone@localhost:9990 /] /subsystem=tracker:read-attribute(name=show-cool-deployments)
{
    "outcome" => "success",
    "result" => false
}

停止所有 Tracker:

[standalone@localhost:9990 /] /subsystem=tracker:disable-all-tracker()
{
    "outcome" => "success",
    "result" => true
}

停止一个 Tracker:

[standalone@localhost:9990 /] /subsystem=tracker/type=sar:disable-tracker()
{
    "outcome" => "success",
    "result" => true
}

查看部署列表:

[standalone@localhost:9990 /] /subsystem=tracker:list-deployments()
{
    "outcome" => "success",
    "result" => [
        "example.war",
        "test.war",
        "cool.war"
    ]
}

查看Cool部署列表:

[standalone@localhost:9990 /] /subsystem=tracker:list-cool-deployments()
{
    "outcome" => "success",
    "result" => ["cool.war"]
}