@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 POJOResourceFactory(final ResourceBuilder resourceBuilder, final ResourceClass resourceClass) { this.resourceBuilder = resourceBuilder; this.scannableClass = resourceClass.getClazz(); this.resourceClass = resourceClass; }
public String traceInfo() { StringBuilder builder = new StringBuilder(); builder.append("[") .append("SINGLETON").append("|") .append(resourceClass.getClazz()).append("|") .append(obj.toString()) .append("]"); return builder.toString(); } }
public Class<?> getResourceClass() { return method.getResourceClass().getClazz(); }
@Override public Class<?> getResourceClass() { return ResourceMethodInvoker.this.method.getResourceClass().getClazz(); } };
public DefaultResourceLocator(final ResourceClass resourceClass, final Method method, final Method annotatedMethod) { this.resourceClass = resourceClass; this.annotatedMethod = annotatedMethod; this.method = method; // we initialize generic types based on the method of the resource class rather than the Method that is actually // annotated. This is so we have the appropriate generic type information. this.genericReturnType = Types.resolveTypeVariables(resourceClass.getClazz(), method.getGenericReturnType()); this.returnType = Types.getRawType(genericReturnType); this.params = new MethodParameter[method.getParameterTypes().length]; Parameter[] reflectionParameters = method.getParameters(); for (int i = 0; i < method.getParameterTypes().length; i++) { this.params[i] = new MethodParameter(this, reflectionParameters[i].getName(), method.getParameterTypes()[i], method.getGenericParameterTypes()[i], annotatedMethod.getParameterAnnotations()[i]); } }
protected Parameter(final ResourceClass resourceClass, final Class<?> type, final Type genericType) { this.resourceClass = resourceClass; this.genericType = Types.resolveTypeVariables(resourceClass.getClazz(), genericType); this.type = Types.getRawType(this.genericType); }
@Override public PropertyInjector createPropertyInjector(ResourceClass resourceClass, ResteasyProviderFactory providerFactory) { return new CdiPropertyInjector(delegate.createPropertyInjector(resourceClass, providerFactory), resourceClass.getClazz(), sessionBeanInterface, manager); }
public void registered(ResteasyProviderFactory factory) { ResourceConstructor constructor = resourceClass.getConstructor(); if (constructor == null) constructor = resourceBuilder.getConstructor(resourceClass.getClazz()); if (constructor == null) { throw new RuntimeException(Messages.MESSAGES.unableToFindPublicConstructorForClass(scannableClass.getName())); } this.constructorInjector = factory.getInjectorFactory().createConstructor(constructor, factory); this.propertyInjector = factory.getInjectorFactory().createPropertyInjector(resourceClass, factory); }
public ResourceClassBuilder buildMethod() { ResteasyUriBuilder builder = (ResteasyUriBuilder) RuntimeDelegate.getInstance().createUriBuilder(); if (locator.resourceClass.getPath() != null) builder.path(locator.resourceClass.getPath()); 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; }
public ResourceClassBuilder buildMethod() { ResteasyUriBuilder builder = (ResteasyUriBuilder) RuntimeDelegate.getInstance().createUriBuilder(); if (method.resourceClass.getPath() != null) builder.path(method.resourceClass.getPath()); if (method.path != null) builder.path(method.path); String pathExpression = builder.getPath(); if (pathExpression == null) pathExpression = ""; method.fullpath = pathExpression; if (method.resourceClass.getClazz().isAnonymousClass()) { method.getMethod().setAccessible(true); } resourceClassBuilder.resourceMethods.add(method); return resourceClassBuilder; } }
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()); } }
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++; } }
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());
@Override public Class<?> getResourceClass() { return ResourceMethodInvoker.this.method.getResourceClass().getClazz(); } };
Class<?> type = parameter.getResourceClass().getClazz();
@Override public PropertyInjector createPropertyInjector(ResourceClass resourceClass, ResteasyProviderFactory providerFactory) { return new CdiPropertyInjector(delegate.createPropertyInjector(resourceClass, providerFactory), resourceClass.getClazz(), sessionBeanInterface, manager); }
@Override public PropertyInjector createPropertyInjector(ResourceClass resourceClass, ResteasyProviderFactory providerFactory) { final PropertyInjector propertyInjector = delegate.createPropertyInjector(resourceClass, providerFactory); return new DdiPropertyInjector(propertyInjector, resourceClass.getClazz()); }
public void registered(ResteasyProviderFactory factory) { ResourceConstructor constructor = resourceClass.getConstructor(); if (constructor == null) constructor = resourceBuilder.getConstructor(resourceClass.getClazz()); if (constructor == null) { throw new RuntimeException(Messages.MESSAGES.unableToFindPublicConstructorForClass(scannableClass.getName())); } this.constructorInjector = factory.getInjectorFactory().createConstructor(constructor, factory); this.propertyInjector = factory.getInjectorFactory().createPropertyInjector(resourceClass, factory); }
return new AsynchronousResponseInjector(); case MESSAGE_BODY: return new MessageBodyParameterInjector(parameter.getResourceClass().getClazz(), parameter.getAccessibleObject(), parameter.getType(), parameter.getGenericType(), parameter.getAnnotations(), providerFactory); default: return null;