下面列出了org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint#org.springframework.boot.actuate.endpoint.annotation.Endpoint 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Autowired
EndpointCommand(ApplicationContext appCtx) {
appCtx.getBeansWithAnnotation(Endpoint.class).entrySet().stream()
.sorted(Comparator.comparing(e -> e.getKey()))
.forEachOrdered(entry -> {
log.debug("{} : {}", entry.getKey(), entry.getValue().getClass().getName());
for (Method m : entry.getValue().getClass().getDeclaredMethods()) {
if (m.isAnnotationPresent(ReadOperation.class) || m.isAnnotationPresent(WriteOperation.class)) {
log.debug("\tOp: {}", m.getName());
for (Parameter p : m.getParameters()) {
log.debug("\t\tParameter {}, {}", p.getName(), p.getType().getName());
}
}
}
});
}
/**
* 自定义网关监控端点
*
* @param context
* @param bus
* @return
*/
@Bean
@ConditionalOnEnabledEndpoint
@ConditionalOnClass({Endpoint.class})
public ApiEndpoint apiEndpoint(ApplicationContext context, BusProperties bus) {
ApiEndpoint endpoint = new ApiEndpoint(context, bus.getId());
log.info("ApiEndpoint [{}]", endpoint);
return endpoint;
}
/**
* 网关bus端点
*
* @param context
* @param bus
* @return
*/
@Bean
@ConditionalOnEnabledEndpoint
@ConditionalOnClass({Endpoint.class})
public ApiEndpoint apiEndpoint(ApplicationContext context, BusProperties bus) {
ApiEndpoint endpoint = new ApiEndpoint(context, bus.getId());
log.info("ApiEndpoint [{}]", endpoint);
return endpoint;
}