Skip to content

Commit 6641cf8

Browse files
committed
Remove ControlBusController.getCommandsForBean
The extra REST API to get commands for specific bean does not make sense. Exactly same data can be extracted from the JSON returned by the `getCommands` REST API
1 parent 7c42402 commit 6641cf8

File tree

3 files changed

+18
-41
lines changed

3 files changed

+18
-41
lines changed

spring-integration-http/src/main/java/org/springframework/integration/http/management/ControlBusController.java

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -82,33 +82,6 @@ public List<ControlBusBean> getCommands() {
8282
.toList();
8383
}
8484

85-
@GetMapping(name = "getCommandsForBean", path = "/{beanName}")
86-
public ControlBusBean getCommandsForBean(@PathVariable String beanName) {
87-
Map<ControlBusCommandRegistry.CommandMethod, String> commandsForBean =
88-
this.controlBusCommandRegistry.getCommands()
89-
.get(beanName);
90-
91-
return createControlBusBean(beanName, commandsForBean);
92-
}
93-
94-
private ControlBusBean createControlBusBean(String beanName,
95-
Map<ControlBusCommandRegistry.CommandMethod, String> commandsForBean) {
96-
97-
List<ControlBusCommand> commands =
98-
commandsForBean.keySet()
99-
.stream()
100-
.map(this::converControlBusCommand)
101-
.toList();
102-
103-
return new ControlBusBean(beanName, commands);
104-
}
105-
106-
private ControlBusCommand converControlBusCommand(ControlBusCommandRegistry.CommandMethod commandMethod) {
107-
return new ControlBusCommand(commandMethod.getBeanName() + '.' + commandMethod.getMethodName(),
108-
commandMethod.getDescription(),
109-
Arrays.asList(commandMethod.getParameterTypes()));
110-
}
111-
11285
@PostMapping(name = "invokeCommand", path = "/{command}")
11386
public Object invokeCommand(@PathVariable String command,
11487
@RequestBody(required = false) List<CommandArgument> arguments) {
@@ -133,6 +106,24 @@ public Object invokeCommand(@PathVariable String command,
133106
return commandExpression.getValue(this.evaluationContext, parameterValues);
134107
}
135108

109+
private static ControlBusBean createControlBusBean(String beanName,
110+
Map<ControlBusCommandRegistry.CommandMethod, String> commandsForBean) {
111+
112+
List<ControlBusCommand> commands =
113+
commandsForBean.keySet()
114+
.stream()
115+
.map(ControlBusController::converControlBusCommand)
116+
.toList();
117+
118+
return new ControlBusBean(beanName, commands);
119+
}
120+
121+
private static ControlBusCommand converControlBusCommand(ControlBusCommandRegistry.CommandMethod commandMethod) {
122+
return new ControlBusCommand(commandMethod.getBeanName() + '.' + commandMethod.getMethodName(),
123+
commandMethod.getDescription(),
124+
Arrays.asList(commandMethod.getParameterTypes()));
125+
}
126+
136127
public record ControlBusBean(String beanName, List<ControlBusCommand> commands) {
137128

138129
}

spring-integration-http/src/test/java/org/springframework/integration/http/management/ControlBusControllerTests.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,6 @@ void allCommandsAreRegistered() throws Exception {
8383
.andExpect(content().string(Matchers.containsString("The overloaded operation with two arguments")));
8484
}
8585

86-
@Test
87-
void commandsForBean() throws Exception {
88-
this.mockMvc.perform(get("/control-bus/testManagementComponent")
89-
.accept(MediaType.APPLICATION_JSON))
90-
.andExpect(status().isOk())
91-
.andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
92-
.andExpect(handler().handlerType(ControlBusController.class))
93-
.andExpect(handler().methodName("getCommandsForBean"))
94-
.andExpect(content().string(Matchers.containsString("testManagementComponent.operation")))
95-
.andExpect(content().string(Matchers.containsString("testManagementComponent.operation2")));
96-
}
97-
9886
@Test
9987
void controlBusCommandIsPerformedOverRestCall() throws Exception {
10088
this.mockMvc.perform(post("/control-bus/testManagementComponent.operation")

src/reference/antora/modules/ROOT/pages/http/control-bus-controller.adoc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ The `/control-bus` GET request returns all the control bus commands for the appl
6969
Essentially, a JSON-serialized list of `ControlBusController.ControlBusBean` instances.
7070
Each entry is a bean with a list of control bus eligible methods (see `ControlBusMethodFilter` for more information) with their parameter types and description from the `@ManagedOperation` or `@ManagedAttribute` (falls back to method name otherwise).
7171

72-
The GET method of this REST controller for `/control-bus/\{beanName}` returns commands for specific bean.
73-
7472
The POST method to `/control-bus/{beanName.methodName}` invokes the command.
7573
The body of the request may contain a list of values and their types for command to execute.
7674
For example, the `operation` command with `int` argument for the class:

0 commit comments

Comments
 (0)