use of eu.okaeri.platform.web.meta.PathParamMeta in project okaeri-platform by OkaeriPoland.
the class RequestHandlerComponentResolver method getCall.
private Object[] getCall(@NonNull Map<Integer, Object[]> prefilledCallCache, @NonNull RequestHandlerMeta handlerMeta, @NonNull Context context, @NonNull Injector injector) {
Object[] prefilledCall = prefilledCallCache.computeIfAbsent(Thread.currentThread().hashCode(), (hash) -> {
OkaeriInjector okaeriInjector = (OkaeriInjector) injector;
Parameter[] parameters = handlerMeta.getMethod().getParameters();
return okaeriInjector.fillParameters(parameters, false);
});
int[] contextIndexes = handlerMeta.getContextIndexes();
for (int contextIndex : contextIndexes) {
prefilledCall[contextIndex] = context;
}
Map<Integer, PathParamMeta> pathParams = handlerMeta.getPathParams();
for (PathParamMeta pathParam : pathParams.values()) {
Object paramValue;
String paramName = pathParam.getName();
Class<?> paramType = pathParam.getType();
try {
paramValue = context.pathParamAsClass(paramName, paramType).get();
} catch (Exception exception) {
throw new RuntimeException("Failed resolving path parameter (" + paramName + ") of type " + paramType, exception);
}
prefilledCall[pathParam.getIndex()] = paramValue;
}
return prefilledCall;
}
Aggregations