use of de.fraunhofer.iosb.ilt.faaast.service.endpoint.http.request.mapper.RequestMapper in project FAAAST-Service by FraunhoferIOSB.
the class RequestMappingManager method init.
private void init() {
try (ScanResult scanResult = new ClassGraph().enableAllInfo().acceptPackages(getClass().getPackageName()).scan()) {
mappers = scanResult.getSubclasses(RequestMapper.class.getName()).filter(x -> !x.isAbstract() && !x.isInterface()).loadClasses(RequestMapper.class).stream().map(x -> {
try {
Constructor<RequestMapper> constructor = x.getConstructor(ServiceContext.class);
return constructor.newInstance(serviceContext);
} catch (NoSuchMethodException | SecurityException e) {
LOGGER.warn("request mapper implementation could not be loaded, " + "reason: missing constructor (implementation class: {}, required constructor signature: {})", x.getName(), ServiceContext.class.getName(), e);
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
LOGGER.warn("request mapper implementation could not be loaded, " + "reason: calling constructor failed (implementation class: {}, constructor arguments: {})", x.getName(), ServiceContext.class.getName(), e);
}
LOGGER.debug("unable to instantiate class {}", x.getName());
return null;
}).filter(x -> x != null).collect(Collectors.toList());
mappers.stream().filter(x -> x == null).collect(Collectors.toList());
}
}
Aggregations