Commit 99d6af6c authored by Christian Dupuis's avatar Christian Dupuis

Properly serialise output of endpoint command

parent b7607222
package commands 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") @Usage("Invoke actuator endpoints")
class endpoint { class endpoint {
...@@ -8,7 +9,7 @@ class endpoint { ...@@ -8,7 +9,7 @@ class endpoint {
@Usage("List all available and enabled actuator endpoints") @Usage("List all available and enabled actuator endpoints")
@Command @Command
def list(InvocationContext context) { def list(InvocationContext context) {
context.attributes['spring.beanfactory'].getBeansOfType(Endpoint.class).each { name, endpoint -> context.attributes['spring.beanfactory'].getBeansOfType(Endpoint.class).each { name, endpoint ->
if (endpoint.isEnabled()) { if (endpoint.isEnabled()) {
out.println name out.println name
...@@ -20,14 +21,22 @@ class endpoint { ...@@ -20,14 +21,22 @@ class endpoint {
@Usage("Invoke provided actuator endpoint") @Usage("Invoke provided actuator endpoint")
@Command @Command
def invoke(InvocationContext context, @Usage("The object name pattern") @Required @Argument String name) { def invoke(InvocationContext context, @Usage("The object name pattern") @Required @Argument String name) {
context.attributes['spring.beanfactory'].getBeansOfType(Endpoint.class).each { n, endpoint -> context.attributes['spring.beanfactory'].getBeansOfType(Endpoint.class).each { n, endpoint ->
if (n.equals(name) && endpoint.isEnabled()) { 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 }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment