Browse Source

Add endpoint command to shell

fixex #461
pull/535/merge
Christian Dupuis 12 years ago
parent
commit
b760722234
  1. 2
      spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ShellProperties.java
  2. 13
      spring-boot-docs/src/main/asciidoc/production-ready-features.adoc
  3. 33
      spring-boot-starters/spring-boot-starter-shell/src/main/resources/commands/crash/endpoint.groovy

2
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ShellProperties.java

@ -167,6 +167,8 @@ public class ShellProperties { @@ -167,6 +167,8 @@ public class ShellProperties {
+ "configured method '%s'. Please check your classpath.",
finalAuth, this.auth));
}
// Make sure we keep track of final authentication method
this.auth = finalAuth;
}
/**

13
spring-boot-docs/src/main/asciidoc/production-ready-features.adoc

@ -467,13 +467,8 @@ download and install http://www.putty.org/[PuTTY]. @@ -467,13 +467,8 @@ download and install http://www.putty.org/[PuTTY].
:: Spring Boot :: (v{spring-boot-version}) on myhost
----
Type `help` for a list of commands. Spring boot provides `metrics`, `beans` and
`autoconfig` commands. You can also use the `jmx` command to query endpoint data:
[indent=0]
----
jmx find -p org.springframework.boot:type=Endpoint,name=healthEndpoint | jmx get Data
----
Type `help` for a list of commands. Spring boot provides `metrics`, `beans`, `autoconfig`
and `endpoint` commands.
@ -502,10 +497,10 @@ for details). By default Spring Boot will search for commands in the following l @@ -502,10 +497,10 @@ for details). By default Spring Boot will search for commands in the following l
* `classpath*:/commands/**`
* `classpath*:/crash/commands/**`
TIP: You can change the search path by settings a `shell.commandpathpatterns` property.
TIP: You can change the search path by settings a `shell.commandPathPatterns` property.
Here is a simple ``hello world'' command that could be loaded from
`src/main/resources/commands/Hello.groovy`
`src/main/resources/commands/hello.groovy`
[source,groovy,indent=0]
----

33
spring-boot-starters/spring-boot-starter-shell/src/main/resources/commands/crash/endpoint.groovy

@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
package commands
import org.springframework.boot.actuate.endpoint.Endpoint;
@Usage("Invoke actuator endpoints")
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
}
}
""
}
@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()
}
}
""
}
}
Loading…
Cancel
Save