diff --git a/spring-boot-starters/spring-boot-starter-shell/src/main/resources/commands/crash/endpoint.groovy b/spring-boot-starters/spring-boot-starter-shell/src/main/resources/commands/crash/endpoint.groovy index f918f69ec8e..b817343a996 100644 --- a/spring-boot-starters/spring-boot-starter-shell/src/main/resources/commands/crash/endpoint.groovy +++ b/spring-boot-starters/spring-boot-starter-shell/src/main/resources/commands/crash/endpoint.groovy @@ -1,6 +1,7 @@ package commands -import org.springframework.boot.actuate.endpoint.Endpoint; +import org.springframework.boot.actuate.endpoint.Endpoint +import org.springframework.boot.actuate.endpoint.jmx.* @Usage("Invoke actuator endpoints") class endpoint { @@ -8,7 +9,7 @@ class endpoint { @Usage("List all available and enabled actuator endpoints") @Command def list(InvocationContext context) { - + context.attributes['spring.beanfactory'].getBeansOfType(Endpoint.class).each { name, endpoint -> if (endpoint.isEnabled()) { out.println name @@ -20,14 +21,22 @@ class endpoint { @Usage("Invoke provided actuator endpoint") @Command def invoke(InvocationContext context, @Usage("The object name pattern") @Required @Argument String name) { - + context.attributes['spring.beanfactory'].getBeansOfType(Endpoint.class).each { n, endpoint -> if (n.equals(name) && endpoint.isEnabled()) { - out.println endpoint.invoke() + + EndpointMBean mbean = context.attributes['spring.beanfactory'].getBean(EndpointMBeanExporter.class).getEndpointMBean(name, endpoint) + if (mbean instanceof DataEndpointMBean) { + out.println mbean.getData() + } + else { + out.println mbean.invoke() + } + } } "" } - -} \ No newline at end of file + +}