@GetMapping @Override public Object invoke() { return super.invoke(); } }
import java.util.Collection; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.PublicMetricsAutoConfiguration; import org.springframework.boot.actuate.endpoint.MetricsEndpoint; import org.springframework.boot.actuate.endpoint.mvc.EndpointHandlerMapping; import org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter; import org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; @Configuration @Import({ EndpointAutoConfiguration.class, PublicMetricsAutoConfiguration.class }) public class SpringBootActuatorConfig { @Bean @Autowired public EndpointHandlerMapping endpointHandlerMapping(Collection<? extends MvcEndpoint> endpoints) { return new EndpointHandlerMapping(endpoints); } @Bean @Autowired public EndpointMvcAdapter metricsEndPoint(MetricsEndpoint delegate) { return new EndpointMvcAdapter(delegate); } }
/** * Find a given counter, taking care of name conversion between the Spring Boot domain and our domain. * @throws MetricsMvcEndpoint.NoSuchMetricException if the counter does not exist */ private Metric<Double> findCounter(@PathVariable("name") String name) { @SuppressWarnings("unchecked") Metric<Double> c = (Metric<Double>) metricRepository.findOne(COUNTER_PREFIX + name); if (c == null) { throw new MetricsMvcEndpoint.NoSuchMetricException(name); } return c; }
@RequestMapping @ResponseBody public List<Map<String, Object>> invoke() { List<Map<String, Object>> result = new ArrayList<Map<String, Object>>(); MvcEndpoints mvcEndpoints = context.getBean(MvcEndpoints.class); if (mvcEndpoints != null) { for (MvcEndpoint endpoint : mvcEndpoints.getEndpoints()) { Map<String, Object> endpointInfo = new HashMap<String, Object>(); endpointInfo.put("sensitive", endpoint.isSensitive()); endpointInfo.put("path", endpoint.getPath()); if (endpoint.getEndpointType() != null) { endpointInfo.put("endpointType", endpoint.getEndpointType().getName()); } else { endpointInfo.put("endpointType", endpoint.getClass().getName()); } result.add(endpointInfo); } } return result; }
@Bean public FilterRegistrationBean authenticationFilter(final Optional<JolokiaMvcEndpoint> jolokiaEndpoint) { final FilterRegistrationBean filter = new FilterRegistrationBean(); filter.setFilter(new AuthenticationFilter()); if (jolokiaEndpoint.isPresent() && !jolokiaEndpoint.get().getPath().isEmpty()) { filter.addUrlPatterns( Strings.webContextPath(managementContextPath, jolokiaEndpoint.get().getPath(), "*")); } return filter; }
@Override protected HeapDumper createHeapDumper() throws HeapDumperUnavailableException { try { Class<?> ibmDumpClass = ClassUtils.forName(DUMP_CLASS_NAME, null); Method ibmDumpMethod = ReflectionUtils.findMethod(ibmDumpClass, DUMP_METHOD_NAME, String.class); logger.debug("Initializing J9 HeapDumper"); return new J9JvmHeapDumper(ibmDumpMethod); } catch (ClassNotFoundException e) { logger.debug("Initializing default HeapDumper"); return super.createHeapDumper(); } }
@RequestMapping(method = RequestMethod.GET) @ResponseBody @Override public Object invoke() { if (!getDelegate().isEnabled()) { return new ResponseEntity<Map<String, String>>(Collections.singletonMap( "message", "This endpoint is disabled"), HttpStatus.NOT_FOUND); } return super.invoke(); }
Collection<? extends MvcEndpoint> endpoints ){ return new EndpointHandlerMapping(endpoints);
@Bean @ConditionalOnBean(JolokiaMvcEndpoint.class) public SimpleUrlHandlerMapping hawtioUrlMapping( final ManagementServerProperties managementServerProperties, final HawtioEndpoint hawtioEndpoint, final JolokiaMvcEndpoint jolokiaEndpoint) { final String hawtioPath = Strings.webContextPath(hawtioEndpoint.getPath()); final String jolokiaPath = Strings.webContextPath(jolokiaEndpoint.getPath()); final SilentSimpleUrlHandlerMapping mapping = new SilentSimpleUrlHandlerMapping(); final Map<String, Object> urlMap = new HashMap<>(); if (!hawtioPath.isEmpty() || !"/jolokia".equals(jolokiaPath)) { final String hawtioJolokiaPath = Strings.webContextPath( managementServerProperties.getContextPath(), hawtioPath, "jolokia", "**"); urlMap.put(hawtioJolokiaPath, new JolokiaForwardingController(jolokiaEndpoint.getPath())); mapping.setOrder(Ordered.HIGHEST_PRECEDENCE); } else { urlMap.put(SilentSimpleUrlHandlerMapping.DUMMY, null); } mapping.setUrlMap(urlMap); return mapping; }
/** * Invoke the graceful shutdown. * @return the response entity */ @GetMapping @ResponseBody @Override public Object invoke() { if (!getDelegate().isEnabled()) { return new ResponseEntity<Map<String, String>>( Collections.singletonMap("message", "This endpoint is disabled"), HttpStatus.NOT_FOUND); } return super.invoke(); } }