builder.path(base); builder.path(method.getFullpath()); String fullpath = builder.getPath(); if (fullpath == null) { builder.path(base); builder.path(method.getResourceClass().getPath()); String classExpression = builder.getPath(); if (classExpression == null) {
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 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 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 AccessibleObject getAccessibleObject() { return locator.getMethod(); }
protected MethodParameter(final ResourceLocator locator, final String name, final Class<?> type, final Type genericType, final Annotation[] annotations) { super(locator.getResourceClass(), type, genericType); this.annotations = annotations; this.locator = locator; this.paramName = name; }
public ServiceRegistry(final ServiceRegistry parent, final ResourceMethodRegistry registry, final ResteasyProviderFactory providerFactory, final ResourceLocatorInvoker invoker) throws Exception { this.parent = parent; this.registry = registry; this.providerFactory = providerFactory; this.invoker = invoker; if(invoker != null){ Method method = invoker.getMethod(); ResourceLocator resourceLocator = MethodMetaData.getResourceLocator(invoker); String methodPathVal = resourceLocator.getPath(); String classPathVal = resourceLocator.getResourceClass().getPath(); this.uri = MethodMetaData.appendURIFragments(parent, classPathVal, methodPathVal); if(parent.isRoot()) this.functionPrefix = method.getDeclaringClass().getSimpleName() + "." + method.getName(); else this.functionPrefix = parent.getFunctionPrefix() + "." + method.getName(); } scanRegistry(); }
Class<?> clz = resLocator.getReturnType(); if (clz.equals(resClass.getClazz())) { break; String subMapping = new StringBuilder(mapping).append("/").append(resLocator.getFullpath()).toString().replace("//", "/"); JaxrsResourceLocatorDescription inner = resLocatorDescription(subResClass, contextPath, subMapping, servletMappings, resolvedCls); if (inner.containsMethodResources()) {
protected void processMethod(ResourceLocator method) { String fullpath = method.getFullpath() == null ? "" : method.getFullpath(); InjectorFactory injectorFactory = providerFactory.getInjectorFactory(); if (method instanceof ResourceMethod) { ResourceMethodInvoker invoker = new ResourceMethodInvoker((ResourceMethod)method, injectorFactory, null, providerFactory); root.addInvoker(fullpath, invoker); } else { ResourceLocatorInvoker locator = new ResourceLocatorInvoker(null, injectorFactory, providerFactory, method); root.addInvoker(fullpath, locator); } }
if (validator != null) validator.validateAllParameters(request, resource, method.getMethod(), args); Method invokedMethod = method.getMethod(); if (!invokedMethod.getDeclaringClass().isAssignableFrom(resource.getClass())) throw new InternalServerErrorException(Messages.MESSAGES.notAllowedToReflectOnMethod(method.toString()), e); String msg = Messages.MESSAGES.badArguments(method.toString() + " ("); if (args != null) validator.validateReturnValue(request, resource, method.getMethod(), result);
public LocatorMethodParameterBuilder param(int i) { return new LocatorMethodParameterBuilder(this, locator.getParams()[i]); }
@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 Method getMethod() { return method.getMethod(); }
protected MethodParameter(final ResourceLocator locator, final String name, final Class<?> type, final Type genericType, final Annotation[] annotations) { super(locator.getResourceClass(), type, genericType); this.annotations = annotations; this.locator = locator; this.paramName = name; }
public ServiceRegistry(ServiceRegistry parent, ResourceMethodRegistry registry, ResteasyProviderFactory providerFactory, ResourceLocatorInvoker invoker) throws Exception { this.parent = parent; this.registry = registry; this.providerFactory = providerFactory; this.invoker = invoker; if(invoker != null){ Method method = invoker.getMethod(); ResourceLocator resourceLocator = MethodMetaData.getResourceLocator(invoker); String methodPathVal = resourceLocator.getPath(); String classPathVal = resourceLocator.getResourceClass().getPath(); this.uri = MethodMetaData.appendURIFragments(parent, classPathVal, methodPathVal); if(parent.isRoot()) this.functionPrefix = method.getDeclaringClass().getSimpleName() + "." + method.getName(); else this.functionPrefix = parent.getFunctionPrefix() + "." + method.getName(); } scanRegistry(); }
Class<?> clz = resLocator.getReturnType(); if (clz.equals(resClass.getClazz())) { break; String subMapping = new StringBuilder(mapping).append("/").append(resLocator.getFullpath()).toString().replace("//", "/"); JaxrsResourceLocatorDescription inner = resLocatorDescription(subResClass, contextPath, subMapping, servletMappings, resolvedCls); if (inner.containsMethodResources()) {
protected void processMethod(ResourceLocator method) { String fullpath = method.getFullpath() == null ? "" : method.getFullpath(); InjectorFactory injectorFactory = providerFactory.getInjectorFactory(); if (method instanceof ResourceMethod) { ResourceMethodInvoker invoker = new ResourceMethodInvoker((ResourceMethod)method, injectorFactory, null, providerFactory); root.addInvoker(fullpath, invoker); } else { ResourceLocatorInvoker locator = new ResourceLocatorInvoker(null, injectorFactory, providerFactory, method); root.addInvoker(fullpath, locator); } }
public ResourceMethodParameterBuilder param(int i) { return new ResourceMethodParameterBuilder(this, locator.getParams()[i]); }
builder.path(base); builder.path(method.getFullpath()); String fullpath = builder.getPath(); if (fullpath == null) { builder.path(base); builder.path(method.getResourceClass().getPath()); String classExpression = builder.getPath(); if (classExpression == null) {
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++; } }