@Override public Class<?> getResourceClass() { return endpoint instanceof ResourceMethodInvoker ? ((ResourceMethodInvoker) endpoint).getResourceClass() : null; }
@Override public Method getResourceMethod() { return endpoint instanceof ResourceMethodInvoker ? ((ResourceMethodInvoker) endpoint).getResourceMethod() : null; }
return new ResourceMethodInvoker( resourceMethodDispatcherFactory, resourceMethodInvocationHandlerFactory,
protected ResourceInfo getResourceInfo(ResourceMethodInvoker invoker) { return new ResourceInfo(invoker.getResourceClass(), invoker.getResourceMethod(), prefix); }
final Response response = invoke(processingContext, resource); if (method.isSuspendDeclared()) { } else { Response response = invoke(processingContext, resource); completionStage.whenComplete(whenComplete(processingContext));
/** * Get all bound response filters applicable to this request. * This is populated once the right resource method is matched. * * @return All bound (dynamically or by name) response filters applicable to the matched inflector (or an empty * collection if no inflector matched yet). */ Iterable<RankedProvider<ContainerResponseFilter>> getResponseFilters() { final Inflector<RequestProcessingContext, ContainerResponse> inflector = getInflector(); return emptyIfNull(inflector instanceof ResourceMethodInvoker ? ((ResourceMethodInvoker) inflector).getResponseFilters() : null); }
/** * Get all writer interceptors applicable to this request. * * @return All writer interceptors applicable to the matched inflector (or an empty * collection if no inflector matched yet). */ Iterable<WriterInterceptor> getWriterInterceptors() { final Inflector<RequestProcessingContext, ContainerResponse> inflector = getInflector(); return inflector instanceof ResourceMethodInvoker ? ((ResourceMethodInvoker) inflector).getWriterInterceptors() : processingProviders.getSortedGlobalWriterInterceptors(); }
/** * Get all bound request filters applicable to this request. * * @return All bound (dynamically or by name) request filters applicable to the matched inflector (or an empty * collection if no inflector matched yet). */ Iterable<RankedProvider<ContainerRequestFilter>> getRequestFilters() { final Inflector<RequestProcessingContext, ContainerResponse> inflector = getInflector(); return emptyIfNull(inflector instanceof ResourceMethodInvoker ? ((ResourceMethodInvoker) inflector).getRequestFilters() : null); }
/** * Get all reader interceptors applicable to this request. * This is populated once the right resource method is matched. * * @return All reader interceptors applicable to the matched inflector (or an empty * collection if no inflector matched yet). */ @Override protected Iterable<ReaderInterceptor> getReaderInterceptors() { final Inflector<RequestProcessingContext, ContainerResponse> inflector = getInflector(); return inflector instanceof ResourceMethodInvoker ? ((ResourceMethodInvoker) inflector).getReaderInterceptors() : processingProviders.getSortedGlobalReaderInterceptors(); }
private void addNameBoundFiltersAndInterceptors( final ProcessingProviders processingProviders, final Collection<RankedProvider<ContainerRequestFilter>> targetRequestFilters, final Collection<RankedProvider<ContainerResponseFilter>> targetResponseFilters, final Collection<RankedProvider<ReaderInterceptor>> targetReaderInterceptors, final Collection<RankedProvider<WriterInterceptor>> targetWriterInterceptors, final NameBound nameBound ) { addNameBoundProviders(targetRequestFilters, nameBound, processingProviders.getNameBoundRequestFilters(), processingProviders.getNameBoundRequestFiltersInverse()); addNameBoundProviders(targetResponseFilters, nameBound, processingProviders.getNameBoundResponseFilters(), processingProviders.getNameBoundResponseFiltersInverse()); addNameBoundProviders(targetReaderInterceptors, nameBound, processingProviders.getNameBoundReaderInterceptors(), processingProviders.getNameBoundReaderInterceptorsInverse()); addNameBoundProviders(targetWriterInterceptors, nameBound, processingProviders.getNameBoundWriterInterceptors(), processingProviders.getNameBoundWriterInterceptorsInverse()); }
addNameBoundFiltersAndInterceptors( processingProviders, _requestFilters, _responseFilters, _readerInterceptors, _writerInterceptors,
@Override @SuppressWarnings("unchecked") public ContainerResponse apply(final RequestProcessingContext processingContext) { final ContainerRequest request = processingContext.request(); final Object resource = processingContext.routingContext().peekMatchedResource(); if (method.isSuspendDeclared() || method.isManagedAsyncDeclared()) { if (!processingContext.asyncContext().suspend()) { throw new ProcessingException(LocalizationMessages.ERROR_SUSPENDING_ASYNC_REQUEST()); } } if (method.isManagedAsyncDeclared()) { processingContext.asyncContext().invokeManaged(new Producer<Response>() { @Override public Response call() { final Response response = invoke(processingContext, resource); if (method.isSuspendDeclared()) { // we ignore any response returned from a method that injects AsyncResponse return null; } return response; } }); return null; // return null on current thread } else { // TODO replace with processing context factory method. return new ContainerResponse(request, invoke(processingContext, resource)); } }
final Response response = invoke(processingContext, resource); if (method.isSuspendDeclared()) { } else { Response response = invoke(processingContext, resource); completionStage.whenComplete(whenComplete(processingContext));
/** * Get all bound response filters applicable to this request. * This is populated once the right resource method is matched. * * @return All bound (dynamically or by name) response filters applicable to the matched inflector (or an empty * collection if no inflector matched yet). */ Iterable<RankedProvider<ContainerResponseFilter>> getResponseFilters() { final Inflector<RequestProcessingContext, ContainerResponse> inflector = getInflector(); return emptyIfNull(inflector instanceof ResourceMethodInvoker ? ((ResourceMethodInvoker) inflector).getResponseFilters() : null); }
/** * Get all writer interceptors applicable to this request. * * @return All writer interceptors applicable to the matched inflector (or an empty * collection if no inflector matched yet). */ Iterable<WriterInterceptor> getWriterInterceptors() { final Inflector<RequestProcessingContext, ContainerResponse> inflector = getInflector(); return inflector instanceof ResourceMethodInvoker ? ((ResourceMethodInvoker) inflector).getWriterInterceptors() : processingProviders.getSortedGlobalWriterInterceptors(); }
/** * Get all bound request filters applicable to this request. * * @return All bound (dynamically or by name) request filters applicable to the matched inflector (or an empty * collection if no inflector matched yet). */ Iterable<RankedProvider<ContainerRequestFilter>> getRequestFilters() { final Inflector<RequestProcessingContext, ContainerResponse> inflector = getInflector(); return emptyIfNull(inflector instanceof ResourceMethodInvoker ? ((ResourceMethodInvoker) inflector).getRequestFilters() : null); }
/** * Get all reader interceptors applicable to this request. * This is populated once the right resource method is matched. * * @return All reader interceptors applicable to the matched inflector (or an empty * collection if no inflector matched yet). */ @Override protected Iterable<ReaderInterceptor> getReaderInterceptors() { final Inflector<RequestProcessingContext, ContainerResponse> inflector = getInflector(); return inflector instanceof ResourceMethodInvoker ? ((ResourceMethodInvoker) inflector).getReaderInterceptors() : processingProviders.getSortedGlobalReaderInterceptors(); }
private void addNameBoundFiltersAndInterceptors( final ProcessingProviders processingProviders, final Collection<RankedProvider<ContainerRequestFilter>> targetRequestFilters, final Collection<RankedProvider<ContainerResponseFilter>> targetResponseFilters, final Collection<RankedProvider<ReaderInterceptor>> targetReaderInterceptors, final Collection<RankedProvider<WriterInterceptor>> targetWriterInterceptors, final NameBound nameBound ) { addNameBoundProviders(targetRequestFilters, nameBound, processingProviders.getNameBoundRequestFilters(), processingProviders.getNameBoundRequestFiltersInverse()); addNameBoundProviders(targetResponseFilters, nameBound, processingProviders.getNameBoundResponseFilters(), processingProviders.getNameBoundResponseFiltersInverse()); addNameBoundProviders(targetReaderInterceptors, nameBound, processingProviders.getNameBoundReaderInterceptors(), processingProviders.getNameBoundReaderInterceptorsInverse()); addNameBoundProviders(targetWriterInterceptors, nameBound, processingProviders.getNameBoundWriterInterceptors(), processingProviders.getNameBoundWriterInterceptorsInverse()); }
addNameBoundFiltersAndInterceptors( processingProviders, _requestFilters, _responseFilters, _readerInterceptors, _writerInterceptors,
@Override @SuppressWarnings("unchecked") public ContainerResponse apply(final RequestProcessingContext processingContext) { final ContainerRequest request = processingContext.request(); final Object resource = processingContext.routingContext().peekMatchedResource(); if (method.isSuspendDeclared() || method.isManagedAsyncDeclared()) { if (!processingContext.asyncContext().suspend()) { throw new ProcessingException(LocalizationMessages.ERROR_SUSPENDING_ASYNC_REQUEST()); } } if (method.isManagedAsyncDeclared()) { processingContext.asyncContext().invokeManaged(new Producer<Response>() { @Override public Response call() { final Response response = invoke(processingContext, resource); if (method.isSuspendDeclared()) { // we ignore any response returned from a method that injects AsyncResponse return null; } return response; } }); return null; // return null on current thread } else { // TODO replace with processing context factory method. return new ContainerResponse(request, invoke(processingContext, resource)); } }