@Override public void removeRegistrations(ResourceClass resourceClass) { for (ResourceMethod method : resourceClass.getResourceMethods()) { if (widerMatching) rootNode.removeBinding(method.getFullpath(), method.getMethod()); else root.removeBinding(resourceClass.getPath(), method.getFullpath(), method.getMethod()); } for (ResourceLocator method : resourceClass.getResourceLocators()) { if (widerMatching) rootNode.removeBinding(method.getFullpath(), method.getMethod()); else root.removeBinding(resourceClass.getPath(), method.getFullpath(), method.getMethod()); } }
public MediaType[] getConsumes() { return method.getConsumes(); }
public Set<String> getHttpMethods() { return method.getHttpMethods(); }
@SuppressWarnings(value = "unchecked") protected MediaType resolveContentTypeByAccept(List<MediaType> accepts, Object entity) { if (accepts == null || accepts.size() == 0 || entity == null) { return MediaType.WILDCARD_TYPE; } Class clazz = entity.getClass(); Type type = this.method.getGenericReturnType(); if (entity instanceof GenericEntity) { GenericEntity gen = (GenericEntity) entity; clazz = gen.getRawType(); type = gen.getType(); } for (MediaType accept : accepts) { if (resourceMethodProviderFactory.getMessageBodyWriter(clazz, type, method.getAnnotatedMethod().getAnnotations(), accept) != null) { return accept; } } return MediaType.WILDCARD_TYPE; }
MediaType[] producedMediaTypes = resourceMethod.getProduces(); boolean onlyProduceServerSentEventsMediaType = producedMediaTypes != null && producedMediaTypes.length == 1 && MediaType.SERVER_SENT_EVENTS_TYPE.isCompatible(producedMediaTypes[0]); MethodParameter[] resourceMethodParameters = resourceMethod.getParams(); if (resourceMethodParameters != null) for (Annotation annotation : resourceMethod.getAnnotatedMethod().getAnnotations())
public void registryUpdated(JaxrsInterceptorRegistry registry) { this.resourceMethodProviderFactory = new ResteasyProviderFactoryImpl(parentProviderFactory); for (DynamicFeature feature : parentProviderFactory.getServerDynamicFeatures()) { feature.configure(resourceInfo, new FeatureContextDelegate(resourceMethodProviderFactory)); } if (registry.getIntf().equals(WriterInterceptor.class)) { writerInterceptors = resourceMethodProviderFactory.getServerWriterInterceptorRegistry().postMatch(method.getResourceClass().getClazz(), method.getAnnotatedMethod()); } else if (registry.getIntf().equals(ContainerRequestFilter.class)) { requestFilters = resourceMethodProviderFactory.getContainerRequestFilterRegistry().postMatch(method.getResourceClass().getClazz(), method.getAnnotatedMethod()); } else if (registry.getIntf().equals(ContainerResponseFilter.class)) { responseFilters = resourceMethodProviderFactory.getContainerResponseFilterRegistry().postMatch(method.getResourceClass().getClazz(), method.getAnnotatedMethod()); } }
for (ResourceMethod resMethod : resClass.getResourceMethods()) { JaxrsResourceMethodDescription jaxrsRes = new JaxrsResourceMethodDescription(); jaxrsRes.consumeTypes = resMethod.getConsumes(); jaxrsRes.contextPath = contextPath; jaxrsRes.httpMethods = resMethod.getHttpMethods(); jaxrsRes.method = resMethod.getMethod(); jaxrsRes.produceTypes = resMethod.getProduces(); jaxrsRes.resourceClass = resClass.getClazz(); String resPath = new StringBuilder(mapping).append("/").append(resMethod.getFullpath()).toString().replace("//", "/"); jaxrsRes.resourcePath = resPath; jaxrsRes.servletMappings = servletMappings; addMethodParameters(jaxrsRes, resMethod.getMethod()); locatorRes.methodsDescriptions.add(jaxrsRes);
this.parentProviderFactory = providerFactory; this.method = method; this.methodAnnotations = this.method.getAnnotatedMethod().getAnnotations(); requestFilters = resourceMethodProviderFactory.getContainerRequestFilterRegistry().postMatch(method.getResourceClass().getClazz(), method.getAnnotatedMethod()); responseFilters = resourceMethodProviderFactory.getContainerResponseFilterRegistry().postMatch(method.getResourceClass().getClazz(), method.getAnnotatedMethod()); writerInterceptors = resourceMethodProviderFactory.getServerWriterInterceptorRegistry().postMatch(method.getResourceClass().getClazz(), method.getAnnotatedMethod()); asyncResponseProvider = resourceMethodProviderFactory.getAsyncResponseProvider(method.getReturnType()); if(asyncResponseProvider == null){ asyncStreamProvider = resourceMethodProviderFactory.getAsyncStreamProvider(method.getReturnType()); method.markAsynchronous();
@Override public Method getMethod() { return method.getMethod(); }
public MediaType[] getProduces() { return method.getProduces(); }
if(method.isAsynchronous()) return null; if (rtn == null || method.getReturnType().equals(void.class)) return build; if (Response.class.isAssignableFrom(method.getReturnType()) || rtn instanceof Response) rtn1.setGenericType(method.getGenericReturnType()); jaxrsResponse.setGenericType(method.getGenericReturnType());
this.klass = invoker.getResourceClass(); String methodPath = resourceMethod.getPath(); String klassPath = resourceMethod.getResourceClass().getPath(); Produces produces = method.getAnnotation(Produces.class);
public CompletionStage<BuiltResponse> invoke(HttpRequest request, HttpResponse response, Object target) { request.setAttribute(ResourceMethodInvoker.class.getName(), this); incrementMethodCount(request.getHttpMethod()); ResteasyUriInfo uriInfo = (ResteasyUriInfo) request.getUri(); if (method.getPath() != null) { uriInfo.pushMatchedURI(uriInfo.getMatchingPath()); } uriInfo.pushCurrentResource(target); BuiltResponse rtn = invokeOnTarget(request, response, target); // FIXME: async return CompletableFuture.completedFuture(rtn); }
public Class<?> getResourceClass() { return method.getResourceClass().getClazz(); }
Field field = ResourceMethodInvoker.class.getDeclaredField("method"); field.setAccessible(true); ResourceMethod method = (ResourceMethod) field.get(methodInvoker); String path = method.getFullpath();
@Override public Method getResourceMethod() { return ResourceMethodInvoker.this.method.getAnnotatedMethod(); }
public Type getGenericReturnType() { return method.getGenericReturnType(); }
for (ResourceMethod resMethod : resClass.getResourceMethods()) { JaxrsResourceMethodDescription jaxrsRes = new JaxrsResourceMethodDescription(); jaxrsRes.consumeTypes = resMethod.getConsumes(); jaxrsRes.contextPath = contextPath; jaxrsRes.httpMethods = resMethod.getHttpMethods(); jaxrsRes.method = resMethod.getMethod(); jaxrsRes.produceTypes = resMethod.getProduces(); jaxrsRes.resourceClass = resClass.getClazz(); String resPath = new StringBuilder(mapping).append("/").append(resMethod.getFullpath()).toString().replace("//", "/"); jaxrsRes.resourcePath = resPath; jaxrsRes.servletMappings = servletMappings; addMethodParameters(jaxrsRes, resMethod.getMethod()); locatorRes.methodsDescriptions.add(jaxrsRes);
this.parentProviderFactory = providerFactory; this.method = method; this.methodAnnotations = this.method.getAnnotatedMethod().getAnnotations(); requestFilters = resourceMethodProviderFactory.getContainerRequestFilterRegistry().postMatch(method.getResourceClass().getClazz(), method.getAnnotatedMethod()); responseFilters = resourceMethodProviderFactory.getContainerResponseFilterRegistry().postMatch(method.getResourceClass().getClazz(), method.getAnnotatedMethod()); writerInterceptors = resourceMethodProviderFactory.getServerWriterInterceptorRegistry().postMatch(method.getResourceClass().getClazz(), method.getAnnotatedMethod()); asyncResponseProvider = resourceMethodProviderFactory.getAsyncResponseProvider(method.getReturnType()); if(asyncResponseProvider == null){ asyncStreamProvider = resourceMethodProviderFactory.getAsyncStreamProvider(method.getReturnType()); method.markAsynchronous();
protected BuiltResponse invokeOnTarget(HttpRequest request, HttpResponse response, Object target) { final RESTEasyTracingLogger tracingLogger = RESTEasyTracingLogger.getInstance(request); final long timestamp = tracingLogger.timestamp("METHOD_INVOKE"); try { ResteasyContext.pushContext(ResourceInfo.class, resourceInfo); // we don't pop so writer interceptors can get at this PostMatchContainerRequestContext requestContext = new PostMatchContainerRequestContext(request, this, requestFilters, () -> invokeOnTargetAfterFilter(request, response, target)); // let it handle the continuation return requestContext.filter(); } finally { if (resource instanceof SingletonResource) { tracingLogger.logDuration("METHOD_INVOKE", timestamp, ((SingletonResource) resource).traceInfo(), method.getMethod()); } else { tracingLogger.logDuration("METHOD_INVOKE", timestamp, resource, method.getMethod()); } } }