@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); } }
@Override public AccessibleObject getAccessibleObject() { return locator.getMethod(); }
public Method getMethod() { return method.getMethod(); }
public void collectResourceMethodsUntilRoot(List<Method> methods) { if (isRoot()) return; methods.add(locator.getMethod()); parent.collectResourceMethodsUntilRoot(methods); }
public ResteasyWadlServiceRegistry(final ResteasyWadlServiceRegistry parent, final ResourceMethodRegistry registry, final ResteasyProviderFactory providerFactory, final ResourceLocator locator) { this.parent = parent; this.registry = registry; this.providerFactory = providerFactory; this.locator = locator; if (locator != null) { Method method = locator.getMethod(); Path methodPath = method.getAnnotation(Path.class); Class<?> declaringClass = method.getDeclaringClass(); Path classPath = declaringClass.getAnnotation(Path.class); this.uri = ResteasyWadlMethodMetaData.appendURIFragments(parent, classPath, methodPath); if (parent.isRoot()) this.functionPrefix = declaringClass.getSimpleName() + "." + method.getName(); else this.functionPrefix = parent.getFunctionPrefix() + "." + method.getName(); } scanRegistry(); }
} else if (invoker instanceof ResourceLocator) { ResourceLocator locator = (ResourceLocator) invoker; Method method = locator.getMethod(); Class<?> locatorType = method.getReturnType(); Class<?>[] locatorResourceTypes = GetRestful.getSubResourceClasses(locatorType);
@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 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++; } }
Object subResource = method.getMethod().invoke(locator, args); if (subResource instanceof Class)
@Override public AccessibleObject getAccessibleObject() { return locator.getMethod(); }
public Method getMethod() { return method.getMethod(); }
public Method getMethod() { return method.getMethod(); }
public ResourceClassBuilder buildMethod() { ResteasyUriBuilder builder = new ResteasyUriBuilder(); if (locator.resourceClass.path != null) builder.path(locator.resourceClass.path); if (locator.path != null) builder.path(locator.path); String pathExpression = builder.getPath(); if (pathExpression == null) pathExpression = ""; locator.fullpath = pathExpression; if (locator.resourceClass.getClazz().isAnonymousClass()) { locator.getMethod().setAccessible(true); } resourceClassBuilder.resourceLocators.add(locator); return resourceClassBuilder; }
@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()); } }
@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 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++; } }
Object subResource = method.getMethod().invoke(locator, args); if (subResource instanceof Class)
Object subResource = method.getMethod().invoke(locator, args); if (subResource instanceof Class)