
cn.aradin.spring.actuator.starter.actuate.StateEndpoint Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aradin-spring-actuator-starter Show documentation
Show all versions of aradin-spring-actuator-starter Show documentation
Actuator And Customized HealthCheck
The newest version!
package cn.aradin.spring.actuator.starter.actuate;
import java.util.Collections;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import cn.aradin.spring.actuator.starter.context.DeployContext;
@Endpoint(id = "state", enableByDefault = true)
public class StateEndpoint {
private final static Logger log = LoggerFactory.getLogger(StateEndpoint.class);
private static final Map CONTEXT_MESSAGE = Collections
.unmodifiableMap(Collections.singletonMap("message", "Context OK."));
public StateEndpoint() {
// TODO Auto-generated constructor stub
}
@ReadOperation
public Map state() {
if (DeployContext.isStopped()||DeployContext.isStopping()) {
log.error("Context is stopping or already stopped");
throw new RuntimeException("Context is stopping or already stopped");
}
if (log.isDebugEnabled()) {
log.debug("Context is checking");
}
return CONTEXT_MESSAGE;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy