下面列出了怎么用org.springframework.boot.actuate.env.EnvironmentEndpoint的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public EnvironmentDescriptor currentValue() {
EnvironmentEndpoint.EnvironmentDescriptor result = endpoint.environment(null);
//
// Consider of dependency design, we do not use an actuator model directly.
// We choose to define a serializable model in core module,
// which can also be used by other extension modules(storage, for example)
//
String jsonString = JsonUtils.toJsonString(result);
return JsonUtils.parseObject(jsonString, EnvironmentDescriptor.class);
}
public ActuatorCommand(ApplicationContext applicationContext, Environment environment,
SshShellProperties properties, SshShellHelper helper,
@Lazy AuditEventsEndpoint audit, @Lazy BeansEndpoint beans,
@Lazy ConditionsReportEndpoint conditions,
@Lazy ConfigurationPropertiesReportEndpoint configprops, @Lazy EnvironmentEndpoint env,
@Lazy HealthEndpoint health,
@Lazy HttpTraceEndpoint httptrace, @Lazy InfoEndpoint info, @Lazy LoggersEndpoint loggers,
@Lazy MetricsEndpoint metrics,
@Lazy MappingsEndpoint mappings, @Lazy ScheduledTasksEndpoint scheduledtasks,
@Lazy ShutdownEndpoint shutdown,
@Lazy ThreadDumpEndpoint threaddump) {
this.applicationContext = applicationContext;
this.environment = environment;
this.properties = properties;
this.helper = helper;
this.audit = audit;
this.beans = beans;
this.conditions = conditions;
this.configprops = configprops;
this.env = env;
this.health = health;
this.httptrace = httptrace;
this.info = info;
this.loggers = loggers;
this.metrics = metrics;
this.mappings = mappings;
this.scheduledtasks = scheduledtasks;
this.shutdown = shutdown;
this.threaddump = threaddump;
}
/**
* Environment method
*
* @param pattern pattern to filter with
* @return env
*/
@ShellMethod(key = "env", value = "Display env endpoint.")
@ShellMethodAvailability("envAvailability")
public EnvironmentEndpoint.EnvironmentDescriptor env(
@ShellOption(value = {"-p", "--pattern"}, defaultValue = ShellOption.NULL, help = "Pattern " +
"to filter on") String pattern) {
return env.environment(pattern);
}
@Test
public void environmentBeansConfiguredCorrectly() {
Map<String, EnvironmentEndpoint> envbeans = this.context
.getBeansOfType(EnvironmentEndpoint.class);
then(envbeans).hasSize(1).containsKey("writableEnvironmentEndpoint");
then(envbeans.get("writableEnvironmentEndpoint"))
.isInstanceOf(WritableEnvironmentEndpoint.class);
Map<String, EnvironmentEndpointWebExtension> extbeans = this.context
.getBeansOfType(EnvironmentEndpointWebExtension.class);
then(extbeans).hasSize(1).containsKey("writableEnvironmentEndpointWebExtension");
then(extbeans.get("writableEnvironmentEndpointWebExtension"))
.isInstanceOf(WritableEnvironmentEndpointWebExtension.class);
}
@Bean
@ConditionalOnMissingBean
public ActuatorEnvironmentDimension createEnvironmentDimension(EnvironmentEndpoint endpoint) {
return new ActuatorEnvironmentDimension(endpoint);
}
public ActuatorEnvironmentDimension(EnvironmentEndpoint endpoint) {
this.endpoint = endpoint;
}
@Bean
public ActuatorEnvironmentDimension createEnvironmentDimension(EnvironmentEndpoint endpoint) {
return new ActuatorEnvironmentDimension(endpoint);
}
/**
* @return whether `env` command is available
*/
public Availability envAvailability() {
return availability("env", EnvironmentEndpoint.class);
}
EnvironmentCommand(@Value("${sshd.system.command.roles.environment}") String[] systemRoles,
EnvironmentEndpoint envEndpoint) {
super(systemRoles);
this.envEndpoint = envEndpoint;
}