use of org.summerb.easycrud.api.EasyCrudExceptionStrategy in project summerb by skarpushin.
the class EasyCrudScaffoldImpl method initService.
@SuppressWarnings({ "rawtypes", "unchecked" })
protected <TId, TDto extends HasId<TId>> void initService(EasyCrudServicePluggableImpl<TId, TDto, EasyCrudDao<TId, TDto>> service, Class<TDto> dtoClass, String messageCode, String tableName, EasyCrudDao<TId, TDto> dao, Object... injections) throws Exception {
service.setDtoClass(dtoClass);
service.setDao(dao);
service.setEntityTypeMessageCode(messageCode);
beanFactory.autowireBean(service);
if (injections == null || injections.length == 0) {
service.afterPropertiesSet();
return;
}
// NOTE: Ok. This thing around EasyCrudExceptionStrategy tells me this code is
// begging to be refactored. Screamign about OCP... I'll do it later.
List<EasyCrudWireTap<TId, TDto>> wireTaps = Arrays.stream(injections).filter(x -> !(x instanceof EasyCrudExceptionStrategy)).map(injectionToWireTapMapper(dtoClass, messageCode, tableName)).collect(Collectors.toList());
if (wireTaps.size() > 0) {
service.setWireTap(new EasyCrudWireTapDelegatingImpl<>(wireTaps));
}
EasyCrudExceptionStrategy exceptionStrategy = Arrays.stream(injections).filter(x -> x instanceof EasyCrudExceptionStrategy).map(x -> (EasyCrudExceptionStrategy) x).findFirst().orElse(null);
if (exceptionStrategy != null) {
service.setGenericExceptionStrategy(exceptionStrategy);
}
// x.
service.afterPropertiesSet();
}
Aggregations