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

Properly serialise output of endpoint command

parent b7607222
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
}
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