控制总线控制器
从版本 6.4 开始,HTTP 模块提供了一个@EnableControlBusController
configuration 类注解来公开ControlBusController
作为 REST 服务在/control-bus
路径。
这ControlBusControllerConfiguration
为ControlBusCommandRegistry
公开上述 REST 服务的所有可用 Control Bus 命令。
这/control-bus
GET 请求以如下格式返回应用程序的所有控制总线命令:
[
{
"beanName": "errorChannel",
"commands": [
{
"command": "errorChannel.setShouldTrack",
"description": "setShouldTrack",
"parameterTypes": [
"boolean"
]
},
{
"command": "errorChannel.setLoggingEnabled",
"description": "Use to disable debug logging during normal message flow",
"parameterTypes": [
"boolean"
]
},
{
"command": "errorChannel.isLoggingEnabled",
"description": "isLoggingEnabled",
"parameterTypes": []
}
]
},
{
"beanName": "testManagementComponent",
"commands": [
{
"command": "testManagementComponent.operation2",
"description": "operation2",
"parameterTypes": []
},
{
"command": "testManagementComponent.operation",
"description": "operation",
"parameterTypes": []
},
{
"command": "testManagementComponent.operation",
"description": "operation",
"parameterTypes": [
"int",
"java.lang.String"
]
},
{
"command": "testManagementComponent.operation",
"description": "operation",
"parameterTypes": [
"int"
]
}
]
}
]
本质上,JSON 序列化的ControlBusController.ControlBusBean
实例。
每个条目都是一个 Bean,其中包含一个符合控制总线条件的方法列表(参见ControlBusMethodFilter
)及其参数类型和描述,以及@ManagedOperation
或@ManagedAttribute
(否则回退到方法名称)。
POST 方法用于/control-bus/{beanName.methodName}
调用命令。
请求正文可能包含一个值及其类型列表,供命令执行。
例如,operation
command 替换为int
类的参数:
@ManagedResource
class TestManagementComponent {
@ManagedOperation
public void operation() {
}
@ManagedOperation(description = "The overloaded operation with int argument")
public void operation(int input) {
}
@ManagedOperation(description = "The overloaded operation with two arguments")
public void operation(int input1, String input2) {
}
@ManagedOperation
public int operation2() {
return 123;
}
}
可以称为/testManagementComponent.operation
使用带有 body 的 mention POST 方法:
[
{
"value": "1",
"parameterType": "int"
}
]
请参阅 Control Bus 了解更多信息。