Rename spring-boot-starter-shell -> remote-shell

Fixes gh-462
This commit is contained in:
Phillip Webb
2014-03-21 09:05:56 -07:00
parent 8c0703ad9c
commit 47eb8180b3
14 changed files with 9 additions and 9 deletions

View File

@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starters</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version>
</parent>
<artifactId>spring-boot-starter-remote-shell</artifactId>
<packaging>jar</packaging>
<properties>
<main.basedir>${basedir}/../..</main.basedir>
</properties>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.crashub</groupId>
<artifactId>crash.cli</artifactId>
</dependency>
<dependency>
<groupId>org.crashub</groupId>
<artifactId>crash.connectors.ssh</artifactId>
</dependency>
<dependency>
<groupId>org.crashub</groupId>
<artifactId>crash.connectors.telnet</artifactId>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.crashub</groupId>
<artifactId>crash.embed.spring</artifactId>
<exclusions>
<exclusion>
<artifactId>spring-web</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.crashub</groupId>
<artifactId>crash.plugins.cron</artifactId>
</dependency>
<dependency>
<groupId>org.crashub</groupId>
<artifactId>crash.plugins.mail</artifactId>
</dependency>
<dependency>
<groupId>org.crashub</groupId>
<artifactId>crash.shell</artifactId>
<exclusions>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1 @@
provides: crash.cli,crash.shell,crash.plugins.cron,crash.embed.spring,crash.connectors.telnet,crash.connectors.ssh

View File

@@ -0,0 +1,29 @@
package commands
import org.springframework.boot.actuate.endpoint.AutoConfigurationReportEndpoint
class autoconfig {
@Usage("Display auto configuration report from ApplicationContext")
@Command
void main(InvocationContext context) {
context.attributes['spring.beanfactory'].getBeansOfType(AutoConfigurationReportEndpoint.class).each { name, endpoint ->
def report = endpoint.invoke()
out.println "Endpoint: " + name + "\n\nPositive Matches:\n================\n"
report.positiveMatches.each { key, list ->
out.println key + ":"
list.each { mandc ->
out.println " " + mandc.condition + ": " + mandc.message
}
}
out.println "\nNegative Matches\n================\n"
report.negativeMatches.each { key, list ->
out.println key + ":"
list.each { mandc ->
out.println " " + mandc.condition + ": " + mandc.message
}
}
}
}
}

View File

@@ -0,0 +1,17 @@
package commands
import org.springframework.boot.actuate.endpoint.BeansEndpoint
class beans {
@Usage("Display beans in ApplicationContext")
@Command
def main(InvocationContext context) {
def result = [:]
context.attributes['spring.beanfactory'].getBeansOfType(BeansEndpoint.class).each { name, endpoint ->
result.put(name, endpoint.invoke())
}
result.size() == 1 ? result.values()[0] : result
}
}

View File

@@ -0,0 +1,46 @@
package commands
import org.springframework.boot.actuate.endpoint.Endpoint
import org.springframework.boot.actuate.endpoint.jmx.*
@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 name of the Endpoint to invoke") @Required @Argument String name) {
// Don't require passed argument to end with 'Endpoint'
if (!name.endsWith("Endpoint")) {
name = name + "Endpoint"
}
context.attributes['spring.beanfactory'].getBeansOfType(Endpoint.class).each { n, endpoint ->
if (n.equals(name) && endpoint.isEnabled()) {
EndpointMBean mbean = context.attributes['spring.beanfactory'].getBean(EndpointMBeanExporter.class).getEndpointMBean(name, endpoint)
if (mbean instanceof DataEndpointMBean) {
out.println mbean.getData()
}
else {
out.println mbean.endpoint.invoke()
}
}
}
""
}
}

View File

@@ -0,0 +1,31 @@
welcome = { ->
if (!crash.context.attributes['spring.environment'].getProperty("spring.main.show_banner", Boolean.class, Boolean.TRUE)) {
return ""
}
// Resolve hostname
def hostName;
try {
hostName = java.net.InetAddress.getLocalHost().getHostName();
}
catch (java.net.UnknownHostException ignore) {
hostName = "localhost";
}
// Get Spring Boot version from context
def version = crash.context.attributes.get("spring.boot.version")
return """\
. ____ _ __ _ _
/\\\\ / ___'_ __ _ _(_)_ __ __ _ \\ \\ \\ \\
( ( )\\___ | '_ | '_| | '_ \\/ _` | \\ \\ \\ \\
\\\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v$version) on $hostName
""";
}
prompt = { ->
return "> ";
}

View File

@@ -0,0 +1,49 @@
package commands
import org.crsh.text.ui.UIBuilder
import org.springframework.boot.actuate.endpoint.MetricsEndpoint
class metrics {
@Usage("Display metrics provided by Spring Boot")
@Command
public void main(InvocationContext context) {
context.takeAlternateBuffer();
try {
while (!Thread.interrupted()) {
out.cls()
out.show(new UIBuilder().table(columns:[1]) {
header {
table(columns:[1], separator: dashed) {
header(bold: true, fg: black, bg: white) { label("metrics"); }
}
}
row {
table(columns:[1, 1]) {
header(bold: true, fg: black, bg: white) {
label("NAME")
label("VALUE")
}
context.attributes['spring.beanfactory'].getBeansOfType(MetricsEndpoint.class).each { name, metrics ->
metrics.invoke().each { k, v ->
row {
label(k)
label(v)
}
}
}
}
}
}
);
out.flush();
Thread.sleep(1000);
}
}
finally {
context.releaseAlternateBuffer();
}
}
}