Skip to content

Commit

Permalink
Replace useless DynamicFeatureResourceInfo class with ResteasyReactiv…
Browse files Browse the repository at this point in the history
…eResourceInfo

Fixes: quarkusio#13981
  • Loading branch information
geoand authored and renegrob committed Dec 23, 2020
1 parent 2fe2960 commit bafedf3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import javax.ws.rs.ext.WriterInterceptor;
import org.jboss.resteasy.reactive.common.jaxrs.ConfigurationImpl;
import org.jboss.resteasy.reactive.common.model.HasPriority;
import org.jboss.resteasy.reactive.common.model.ResourceClass;
import org.jboss.resteasy.reactive.common.model.ResourceDynamicFeature;
import org.jboss.resteasy.reactive.common.model.ResourceInterceptor;
import org.jboss.resteasy.reactive.common.model.ResourceInterceptors;
Expand All @@ -26,8 +25,8 @@
import org.jboss.resteasy.reactive.server.handlers.ResourceRequestFilterHandler;
import org.jboss.resteasy.reactive.server.handlers.ResourceResponseFilterHandler;
import org.jboss.resteasy.reactive.server.jaxrs.DynamicFeatureContext;
import org.jboss.resteasy.reactive.server.jaxrs.DynamicFeatureResourceInfo;
import org.jboss.resteasy.reactive.server.model.DynamicFeatures;
import org.jboss.resteasy.reactive.server.spi.ResteasyReactiveResourceInfo;
import org.jboss.resteasy.reactive.server.spi.ServerRestHandler;
import org.jboss.resteasy.reactive.spi.BeanFactory;

Expand Down Expand Up @@ -158,8 +157,8 @@ private <T> LinkedHashMap<ResourceInterceptor<T>, T> createInterceptorInstances(
return result;
}

public MethodInterceptorContext forMethod(ResourceClass clazz, ResourceMethod method) {
return new MethodInterceptorContext(clazz, method);
public MethodInterceptorContext forMethod(ResourceMethod method, ResteasyReactiveResourceInfo lazyMethod) {
return new MethodInterceptorContext(method, lazyMethod);
}

<T> TreeMap<ResourceInterceptor<T>, T> buildInterceptorMap(
Expand All @@ -185,7 +184,7 @@ public class MethodInterceptorContext {
final Map<ResourceInterceptor<ReaderInterceptor>, ReaderInterceptor> methodSpecificReaderInterceptorsMap;
final Map<ResourceInterceptor<WriterInterceptor>, WriterInterceptor> methodSpecificWriterInterceptorsMap;

MethodInterceptorContext(ResourceClass clazz, ResourceMethod method) {
MethodInterceptorContext(ResourceMethod method, ResteasyReactiveResourceInfo lazyMethod) {
this.method = method;
Map<ResourceInterceptor<ContainerRequestFilter>, ContainerRequestFilter> methodSpecificRequestInterceptorsMap = Collections
.emptyMap();
Expand All @@ -203,12 +202,11 @@ public class MethodInterceptorContext {
// in the global fields
ResourceInterceptors dynamicallyConfiguredInterceptors = new ResourceInterceptors();

DynamicFeatureResourceInfo dynamicFeatureResourceInfo = new DynamicFeatureResourceInfo(clazz, method); // TODO: look into using LazyMethod
DynamicFeatureContext context = new DynamicFeatureContext(
dynamicallyConfiguredInterceptors, configurationImpl, info.getFactoryCreator());
for (ResourceDynamicFeature resourceDynamicFeature : dynamicFeatures.getResourceDynamicFeatures()) {
DynamicFeature feature = resourceDynamicFeature.getFactory().createInstance().getInstance();
feature.configure(dynamicFeatureResourceInfo, context);
feature.configure(lazyMethod, context);
}
dynamicallyConfiguredInterceptors.sort();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ public RuntimeResourceDeployment(DeploymentInfo info, Supplier<Executor> executo

public RuntimeResource buildResourceMethod(ResourceClass clazz,
ServerResourceMethod method, boolean locatableResource, URITemplate classPathTemplate) {
RuntimeInterceptorDeployment.MethodInterceptorContext interceptorDeployment = runtimeInterceptorDeployment
.forMethod(clazz, method);

URITemplate methodPathTemplate = new URITemplate(method.getPath(), false);
List<ServerRestHandler> abortHandlingChain = new ArrayList<>();
MultivaluedMap<ScoreSystem.Category, ScoreSystem.Diagnostic> score = new QuarkusMultivaluedHashMap<>();
Expand All @@ -131,6 +130,17 @@ public RuntimeResource buildResourceMethod(ResourceClass clazz,
}
}

Class<Object> resourceClass = loadClass(clazz.getClassName());
Class<?>[] parameterClasses = new Class[method.getParameters().length];
for (int i = 0; i < method.getParameters().length; ++i) {
parameterClasses[i] = loadClass(method.getParameters()[i].declaredType);
}
ResteasyReactiveResourceInfo lazyMethod = new ResteasyReactiveResourceInfo(method.getName(), resourceClass,
parameterClasses, method.getMethodAnnotationNames());

RuntimeInterceptorDeployment.MethodInterceptorContext interceptorDeployment = runtimeInterceptorDeployment
.forMethod(method, lazyMethod);

//setup reader and writer interceptors first
handlers.addAll(interceptorDeployment.setupInterceptorHandler());
//at this point the handler chain only has interceptors
Expand Down Expand Up @@ -188,14 +198,6 @@ public RuntimeResource buildResourceMethod(ResourceClass clazz,
}
}

Class<Object> resourceClass = loadClass(clazz.getClassName());
Class<?>[] parameterClasses = new Class[method.getParameters().length];
for (int i = 0; i < method.getParameters().length; ++i) {
parameterClasses[i] = loadClass(method.getParameters()[i].declaredType);
}
ResteasyReactiveResourceInfo lazyMethod = new ResteasyReactiveResourceInfo(method.getName(), resourceClass,
parameterClasses, method.getMethodAnnotationNames());

for (int i = 0; i < parameters.length; i++) {
ServerMethodParameter param = (ServerMethodParameter) parameters[i];
boolean single = param.isSingle();
Expand Down

This file was deleted.

0 comments on commit bafedf3

Please sign in to comment.