use of org.glassfish.jersey.server.model.ResourceMethod in project brave by openzipkin.
the class EventParser method requestMatched.
/**
* Invoked prior to request invocation during {@link RequestEventListener#onEvent(RequestEvent)}
* where the event type is {@link RequestEvent.Type#REQUEST_MATCHED}
*
* <p>Adds the tags {@link #RESOURCE_CLASS} and {@link #RESOURCE_METHOD}. Override or use {@link
* #NOOP} to change this behavior.
*/
protected void requestMatched(RequestEvent event, SpanCustomizer customizer) {
ResourceMethod method = event.getContainerRequest().getUriInfo().getMatchedResourceMethod();
// This case is extremely odd as this is called on REQUEST_MATCHED!
if (method == null)
return;
Invocable i = method.getInvocable();
customizer.tag(RESOURCE_CLASS, i.getHandler().getHandlerClass().getSimpleName());
customizer.tag(RESOURCE_METHOD, i.getHandlingMethod().getName());
}
use of org.glassfish.jersey.server.model.ResourceMethod in project graylog2-server by Graylog2.
the class AuditEventModelProcessor method checkResources.
private void checkResources(List<Resource> resources) {
for (Resource resource : resources) {
for (ResourceMethod method : resource.getResourceMethods()) {
final Method m = method.getInvocable().getDefinitionMethod();
if (m.isAnnotationPresent(POST.class) || m.isAnnotationPresent(PUT.class) || m.isAnnotationPresent(DELETE.class)) {
if (!m.isAnnotationPresent(AuditEvent.class) && !m.isAnnotationPresent(NoAuditEvent.class)) {
LOG.warn("REST endpoint not included in audit trail: {}", String.format(Locale.US, "%6s %s", method.getHttpMethod(), getPathFromResource(resource)));
LOG.debug("Missing @AuditEvent or @NoAuditEvent annotation: {}#{}", m.getDeclaringClass().getCanonicalName(), m.getName());
} else {
if (m.isAnnotationPresent(AuditEvent.class)) {
final AuditEvent annotation = m.getAnnotation(AuditEvent.class);
if (!auditEventTypes.contains(annotation.type())) {
LOG.warn("REST endpoint does not use a registered audit type: {} (type: \"{}\")", String.format(Locale.US, "%6s %s", method.getHttpMethod(), getPathFromResource(resource)), annotation.type());
LOG.debug("Make sure the audit event types are registered in a class that implements PluginAuditEventTypes: {}#{}", m.getDeclaringClass().getCanonicalName(), m.getName());
}
} else if (m.isAnnotationPresent(NoAuditEvent.class)) {
final NoAuditEvent annotation = m.getAnnotation(NoAuditEvent.class);
if (isNullOrEmpty(annotation.value())) {
LOG.warn("REST endpoint uses @NoAuditEvent annotation with an empty value: {}", String.format(Locale.US, "%6s %s", method.getHttpMethod(), getPathFromResource(resource)));
}
}
}
}
}
// Make sure to also check all child resources! Otherwise some resources will not be checked.
checkResources(resource.getChildResources());
}
}
Aggregations