for (String httpMethod : rm.getHttpMethods()) else if (httpMethod.equals("HEAD")) method = new HeadResourceMethod(); method.setClazz(rm.getResourceClass().getName()); method.setMethod(rm.getMethod().getName()); AtomicLong stat = rm.getStats().get(httpMethod); if (stat != null) method.setInvocations(stat.longValue()); else method.setInvocations(0); if (rm.getProduces() != null) for (MediaType mediaType : rm.getProduces()) if (rm.getConsumes() != null) for (MediaType mediaType : rm.getConsumes())
hasProduces |= method != null && method.getProduces() != null && method.getProduces().length > 0; hasProduces |= method != null && method.getMethod().getClass().getAnnotation(Produces.class) != null; if (method.getProduces().length > 0) produces = method.getProduces(); String[] producesValues = method.getMethod().getClass().getAnnotation(Produces.class).value(); produces = new MediaType[producesValues.length]; for (int i = 0; i < producesValues.length; i++) if (generic == null) if (method != null && !Response.class.isAssignableFrom(method.getMethod().getReturnType())) generic = method.getGenericReturnType(); else generic = type; if (annotations == null && method != null) annotations = method.getMethodAnnotations();
try object = methodInvoker.invokeDryRun(request, response).toCompletableFuture().getNow(null); ByteArrayOutputStream tmpOutputStream = new ByteArrayOutputStream(); MessageBodyWriter msgBodyWriter = ResteasyProviderFactory.getInstance().getMessageBodyWriter( object.getClass(), object.getClass(), methodInvoker.getMethodAnnotations(), MediaType.APPLICATION_JSON_TYPE); msgBodyWriter.writeTo(object, object.getClass(), object.getClass(), methodInvoker.getMethodAnnotations(), MediaType.APPLICATION_JSON_TYPE, new MultivaluedTreeMap<String, Object>(), tmpOutputStream); ObjectMapper mapper = new ObjectMapper();
public ResteasyWadlMethodMetaData(final ResteasyWadlServiceRegistry serviceRegistry, final ResourceMethodInvoker resourceInvoker) { this.registry = serviceRegistry; this.resourceInvoker = resourceInvoker; this.method = resourceInvoker.getMethod(); this.klass = resourceInvoker.getResourceClass(); Path methodPath = method.getAnnotation(Path.class); methodUri = methodPath == null ? null : methodPath.value(); this.functionPrefix = serviceRegistry.getFunctionPrefix(); this.functionName = this.functionPrefix + "." + method.getName(); httpMethods = resourceInvoker.getHttpMethods();
public static AsyncResponseConsumer makeAsyncResponseConsumer(ResourceMethodInvoker method, AsyncStreamProvider<?> asyncStreamProvider) { if(method.isSse()) { return new AsyncGeneralStreamingSseResponseConsumer(method, asyncStreamProvider); } Stream stream = method.getMethod().getAnnotation(Stream.class); if (stream != null) { if (Stream.MODE.RAW.equals(stream.value())) { return new AsyncRawStreamingResponseConsumer(method, asyncStreamProvider); } else { return new AsyncGeneralStreamingSseResponseConsumer(method, asyncStreamProvider); } } return new AsyncStreamCollectorResponseConsumer(method, asyncStreamProvider); }
Headers<Object> metadata = new Headers<Object>(); metadata.putAll(r.getMetadata()); builtResponse = new BuiltResponse(r.getStatus(), r.getStatusInfo().getReasonPhrase(), metadata, r.getEntity(), method.getMethodAnnotations()); Type unwrappedType = ((ParameterizedType)method.getGenericReturnType()).getActualTypeArguments()[0]; Type newType = adaptGenericType(unwrappedType); jaxrsResponse.addMethodAnnotations(method.getMethodAnnotations()); builtResponse = jaxrsResponse;
if (invoker.getHttpMethods().contains(httpMethod.toUpperCase())) if (invoker.doesConsume(contentType)) if (invoker.doesProduce(weightedAccepts)) for (Match match : matches) allowed.addAll(((ResourceMethodInvoker) match.expression.getInvoker()).getHttpMethods()); for (Match match : matches) if (((ResourceMethodInvoker) match.expression.getInvoker()).getHttpMethods().contains("PATCH")) .getConsumes())); if (contentType == null) contentType = MediaType.WILDCARD_TYPE; MediaType[] consumes = invoker.getConsumes(); if (consumes.length == 0) MediaType[] produces = invoker.getProduces(); if (produces.length == 0)
public static List<Method> getServiceMethods(ResourceMethodRegistry registry){ ArrayList<Method> results = new ArrayList<Method>(); for (Entry<String, List<ResourceInvoker>> entry : registry.getBounded().entrySet()) { List<ResourceInvoker> invokers = entry.getValue(); for (ResourceInvoker invoker : invokers) { if (invoker instanceof ResourceMethodInvoker) { ResourceMethodInvoker resourceMethod = (ResourceMethodInvoker)invoker; Method method = resourceMethod.getMethod(); results.add(method); } else { // TODO: fix this? } } } return results; }
ResourceMethodInvoker method = (ResourceMethodInvoker) request.getProperty(ResourceMethodInvoker.class.getName()); GenerateQuerySessionId annotation = FindAnnotation.findAnnotation(method.getMethodAnnotations(), GenerateQuerySessionId.class); log.error(method.getResourceClass() + "." + method.getMethod().getName() + " did not set QUERY_ID threadlocal."); } else { id = QUERY_ID.get();
private String formatMethod(ResourceMethodInvoker resource, String servletMapping, String path, String contextRootPath) { StringBuilder builder = new StringBuilder(); builder.append("%1$s "); String servletPath = servletMapping.replaceAll("\\*", ""); if(servletPath.charAt(0) == '/') { servletPath = servletPath.substring(1); } builder.append(contextRootPath).append('/').append(servletPath).append(path); builder.append(" - ").append(resource.getResourceClass().getCanonicalName()).append('.').append(resource.getMethod().getName()).append('('); if (resource.getMethod().getParameterTypes().length > 0) { builder.append("..."); } builder.append(')'); return builder.toString().replaceAll("//", "/"); }
return null; initializeAsync(request.getAsyncContext().getAsyncResponse()); request.getAsyncContext().getAsyncResponse().resume(rtn); return null; build.addMethodAnnotations(getMethodAnnotations()); return build; rtn1.addMethodAnnotations(getMethodAnnotations()); if (rtn1.getGenericType() == null) if (getMethod().getReturnType().equals(Response.class)) if (jaxrsResponse.getGenericType() == null) if (getMethod().getReturnType().equals(Response.class)) jaxrsResponse.addMethodAnnotations(getMethodAnnotations()); return jaxrsResponse;
isValidatable = GeneralValidatorCDI.class.cast(validator).isValidatable(getMethod().getDeclaringClass(), injector); isValidatable = validator.isValidatable(getMethod().getDeclaringClass()); methodIsValidatable = validator.isMethodValidatable(getMethod()); if (isSseResourceMethod(method))
void handle(ModelNode response, String contextRootPath, Collection<String> servletMappings, String mapping, List<ResourceInvoker> resources) { for (ResourceInvoker resourceInvoker : resources) { if (ResourceMethodInvoker.class.isAssignableFrom(resourceInvoker.getClass())) { ResourceMethodInvoker resource = (ResourceMethodInvoker) resourceInvoker; final ModelNode node = new ModelNode(); node.get(CLASSNAME.getName()).set(resource.getResourceClass().getCanonicalName()); node.get(PATH.getName()).set(mapping); for (String servletMapping : servletMappings) { String method = formatMethod(resource, servletMapping, mapping, contextRootPath); for (final String httpMethod : resource.getHttpMethods()) { node.get(METHODS.getName()).add(String.format(method, httpMethod)); } } response.add(node); } } }
try rtn = internalInvokeOnTarget(request, response, target); build.addMethodAnnotations(getMethodAnnotations()); return build; rtn1.addMethodAnnotations(getMethodAnnotations()); if (rtn1.getGenericType() == null) if (getMethod().getReturnType().equals(Response.class)) if (jaxrsResponse.getGenericType() == null) if (getMethod().getReturnType().equals(Response.class)) jaxrsResponse.addMethodAnnotations(getMethodAnnotations()); return jaxrsResponse;
MediaType type = method.resolveContentType(request, entity); BuiltResponse jaxrsResponse = (BuiltResponse)Response.ok(entity, type).build(); jaxrsResponse.setGenericType(method.getGenericReturnType()); jaxrsResponse.addMethodAnnotations(method.getMethodAnnotations()); response = jaxrsResponse;
public void filter(ContainerRequestContext requestContext) { UriRoutingContext routingContext = (UriRoutingContext) requestContext.getUriInfo(); ResourceMethodInvoker invoker = (ResourceMethodInvoker) routingContext.getInflector(); Class<?> className = invoker.getResourceClass(); Method methodName = invoker.getResourceMethod(); }
public static AsyncResponseConsumer makeAsyncResponseConsumer(ResourceMethodInvoker method, AsyncStreamProvider<?> asyncStreamProvider) { if(method.isSse()) { return new AsyncStreamSseResponseConsumer(method, asyncStreamProvider); } for (Annotation annotation : method.getMethodAnnotations()) { if(annotation.annotationType() == Stream.class) { return new AsyncStreamingResponseConsumer(method, asyncStreamProvider); } } return new AsyncStreamCollectorResponseConsumer(method, asyncStreamProvider); }
public CompletionStage<Object> invokeDryRun(HttpRequest request, HttpResponse response) { return resource.createResource(request, response, resourceMethodProviderFactory) .thenCompose(target -> invokeDryRun(request, response, target)); }
public MethodMetaData(final ServiceRegistry serviceRegistry, final ResourceMethodInvoker invoker) throws Exception { this.registry = serviceRegistry; this.invoker = invoker; this.method = invoker.getMethod(); this.klass = invoker.getResourceClass(); this.functionPrefix = serviceRegistry.getFunctionPrefix(); this.functionName = this.functionPrefix + "." + method.getName(); httpMethods = invoker.getHttpMethods();
if (invoker.getHttpMethods().contains(httpMethod.toUpperCase())) if (invoker.doesConsume(contentType)) if (invoker.doesProduce(weightedAccepts)) for (Match match : matches) allowed.addAll(((ResourceMethodInvoker) match.expression.getInvoker()).getHttpMethods()); for (Match match : matches) if (((ResourceMethodInvoker) match.expression.getInvoker()).getHttpMethods().contains("PATCH")) .getConsumes())); if (contentType == null) contentType = MediaType.WILDCARD_TYPE; MediaType[] consumes = invoker.getConsumes(); if (consumes.length == 0) MediaType[] produces = invoker.getProduces(); if (produces.length == 0)