@Override public MethodInjector createMethodInjector(ResourceLocator method, ResteasyProviderFactory factory) { return new MethodInjectorImpl(method, factory); }
@SuppressWarnings(value = "unchecked") public static Method findInterfaceBasedMethod(Class root, Method method) { if (method.getDeclaringClass().isInterface() || root.isInterface()) return method; for (Class intf : root.getInterfaces()) { try { return intf.getMethod(method.getName(), method.getParameterTypes()); } catch (NoSuchMethodException ignored) {} } if (root.getSuperclass() == null || root.getSuperclass().equals(Object.class)) return method; return findInterfaceBasedMethod(root.getSuperclass(), method); }
public CompletionStage<Object> invoke(HttpRequest request, HttpResponse httpResponse, Object resource) throws Failure, ApplicationException { return injectArguments(request, httpResponse) .thenApply(args -> invoke(request, httpResponse, resource, args)); }
@Override public Object invoke(HttpRequest request, HttpResponse httpResponse, Object resource) throws Failure, ApplicationException { if (!Provider.class.isInstance(resource)) { return super.invoke(request, httpResponse, resource); } Object[] args = injectArguments(request, httpResponse); RestfulContainerRequest req = new RestfulContainerRequest(); req.setInterfaceName(method.getResourceClass().getClazz().getName()); req.setMethodName(method.getMethod().getName()); req.setParamtersDesc(ReflectUtil.getMethodParamDesc(method.getMethod())); req.setArguments(args); req.setHttpRequest(request); req.setAttachments(RestfulUtil.decodeAttachments(request.getMutableHeaders())); try { Response resp = Provider.class.cast(resource).call(req); RestfulUtil.encodeAttachments(httpResponse.getOutputHeaders(), resp.getAttachments()); return resp.getValue(); } catch (Exception e) { if (e != null && e instanceof RuntimeException) { throw (RuntimeException) e; } throw new InternalServerErrorException("provider call process error:" + e.getMessage(), e); } }
public Object invoke(HttpRequest request, HttpResponse httpResponse, Object resource) throws Failure, ApplicationException Object[] args = injectArguments(request, httpResponse); GeneralValidator validator = GeneralValidator.class.cast(request.getAttribute(GeneralValidator.class.getName())); if (validator != null)
public CompletionStage<Object> invoke(HttpRequest request, HttpResponse httpResponse, Object resource) throws Failure, ApplicationException { return injectArguments(request, httpResponse) .thenApply(args -> invoke(request, httpResponse, resource, args)); }
public MethodInjectorImpl(final ResourceLocator resourceMethod, final ResteasyProviderFactory factory) { this.factory = factory; this.method = resourceMethod; this.interfaceBasedMethod = findInterfaceBasedMethod(resourceMethod.getResourceClass().getClazz(), resourceMethod.getMethod()); params = new ValueInjector[resourceMethod.getParams().length]; int i = 0; for (MethodParameter parameter : resourceMethod.getParams()) { params[i] = factory.getInjectorFactory().createParameterExtractor(parameter, factory); if (params[i] instanceof MessageBodyParameterInjector) expectsBody = true; i++; } }
@Override public MethodInjector createMethodInjector(ResourceLocator method, ResteasyProviderFactory factory) { return new MethodInjectorImpl(method, factory); }
@SuppressWarnings(value = "unchecked") public static Method findInterfaceBasedMethod(Class root, Method method) { if (method.getDeclaringClass().isInterface() || root.isInterface()) return method; for (Class intf : root.getInterfaces()) { try { return intf.getMethod(method.getName(), method.getParameterTypes()); } catch (NoSuchMethodException ignored) {} } if (root.getSuperclass() == null || root.getSuperclass().equals(Object.class)) return method; return findInterfaceBasedMethod(root.getSuperclass(), method); }
@Override public MethodInjector createMethodInjector(ResourceLocator method, ResteasyProviderFactory factory) { return new MethodInjectorImpl(method, factory); }
@SuppressWarnings(value = "unchecked") public static Method findInterfaceBasedMethod(Class root, Method method) { if (method.getDeclaringClass().isInterface() || root.isInterface()) return method; for (Class intf : root.getInterfaces()) { try { return intf.getMethod(method.getName(), method.getParameterTypes()); } catch (NoSuchMethodException ignored) {} } if (root.getSuperclass() == null || root.getSuperclass().equals(Object.class)) return method; return findInterfaceBasedMethod(root.getSuperclass(), method); }
public MethodInjectorImpl(final ResourceLocator resourceMethod, final ResteasyProviderFactory factory) { this.factory = factory; this.method = resourceMethod; this.interfaceBasedMethod = findInterfaceBasedMethod(resourceMethod.getResourceClass().getClazz(), resourceMethod.getMethod()); params = new ValueInjector[resourceMethod.getParams().length]; int i = 0; for (MethodParameter parameter : resourceMethod.getParams()) { params[i] = factory.getInjectorFactory().createParameterExtractor(parameter, factory); if (params[i] instanceof MessageBodyParameterInjector) expectsBody = true; i++; } }
public MethodInjectorImpl(ResourceLocator resourceMethod, ResteasyProviderFactory factory) { this.factory = factory; this.method = resourceMethod; this.interfaceBasedMethod = findInterfaceBasedMethod(resourceMethod.getResourceClass().getClazz(), resourceMethod.getMethod()); params = new ValueInjector[resourceMethod.getParams().length]; int i = 0; for (MethodParameter parameter : resourceMethod.getParams()) { params[i] = factory.getInjectorFactory().createParameterExtractor(parameter, factory); if (params[i] instanceof MessageBodyParameterInjector) expectsBody = true; i++; } }