use of org.springframework.beans.BeansException in project leopard by tanhaichao.
the class LeopardHandlerMapping method initApplicationContext.
@Override
protected void initApplicationContext() throws BeansException {
// 修改拦截器排序
try {
Field field = AbstractHandlerMapping.class.getDeclaredField("interceptors");
field.setAccessible(true);
@SuppressWarnings("unchecked") List<Object> interceptors = (List<Object>) field.get(this);
AnnotationAwareOrderComparator.sort(interceptors);
// System.out.println("interceptors:" + interceptors);
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
super.initApplicationContext();
}
use of org.springframework.beans.BeansException in project leopard by tanhaichao.
the class LeopardHandlerMapping method initApplicationContext.
@Override
protected void initApplicationContext(ApplicationContext context) throws BeansException {
try {
Redis redis = (Redis) context.getBean("sessionRedis");
StoreRedisImpl.setRedis(redis);
} catch (NoSuchBeanDefinitionException e) {
logger.warn("没有配置sessionRedis,不启用分布式session.");
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
super.initApplicationContext(context);
requestMappingInfoBuilder = new RequestMappingInfoBuilderImpl(context);
}
use of org.springframework.beans.BeansException in project java by kubernetes-client.
the class KubernetesControllerFactory method buildController.
private Controller buildController(SharedInformerFactory sharedInformerFactory, Reconciler r) throws BeansException {
KubernetesReconciler kubernetesReconciler = r.getClass().getAnnotation(KubernetesReconciler.class);
String reconcilerName = kubernetesReconciler.value();
KubernetesReconcilerWatches watches = kubernetesReconciler.watches();
DefaultControllerBuilder builder = ControllerBuilder.defaultBuilder(sharedInformerFactory);
RateLimitingQueue<Request> workQueue = new DefaultRateLimitingQueue<>();
builder = builder.withWorkQueue(workQueue);
Map<Class, AddFilterAdaptor> addFilters = getAddFilters(watches, r);
Map<Class, UpdateFilterAdaptor> updateFilters = getUpdateFilters(watches, r);
Map<Class, DeleteFilterAdaptor> deleteFilters = getDeleteFilters(watches, r);
List<ReadyFuncAdaptor> readyFuncs = getReadyFuncs(r);
for (KubernetesReconcilerWatch watch : watches.value()) {
try {
Function<? extends KubernetesObject, Request> workQueueKeyFunc;
try {
workQueueKeyFunc = watch.workQueueKeyFunc().getConstructor(WorkQueue.class).newInstance(workQueue);
} catch (NoSuchMethodException e) {
workQueueKeyFunc = watch.workQueueKeyFunc().newInstance();
} catch (InvocationTargetException e) {
throw new BeanCreationException("Failed instantiating controller watch: " + e.getMessage());
}
final Function<? extends KubernetesObject, Request> finalWorkQueueKeyFunc = workQueueKeyFunc;
builder = builder.watch((q) -> {
return ControllerBuilder.controllerWatchBuilder(watch.apiTypeClass(), q).withOnAddFilter(addFilters.get(watch.apiTypeClass())).withOnUpdateFilter(updateFilters.get(watch.apiTypeClass())).withOnDeleteFilter(deleteFilters.get(watch.apiTypeClass())).withWorkQueueKeyFunc(finalWorkQueueKeyFunc).withResyncPeriod(Duration.ofMillis(watch.resyncPeriodMillis())).build();
});
for (Supplier<Boolean> readyFunc : readyFuncs) {
builder = builder.withReadyFunc(readyFunc);
}
} catch (IllegalAccessException | InstantiationException e) {
throw new BeanCreationException("Failed instantiating controller: " + e.getMessage());
}
}
builder = builder.withWorkerCount(kubernetesReconciler.workerCount());
return builder.withReconciler(r).withName(reconcilerName).build();
}
use of org.springframework.beans.BeansException in project pmph by BCSquad.
the class PmphUserServiceImpl method getListByUsernameAndRealname.
@Override
public PageResult<PmphUserManagerVO> getListByUsernameAndRealname(String name, int number, int size) throws CheckedServiceException {
if (null == name || "".equals(name)) {
throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.NULL_PARAM, "模糊查询条件为空");
}
List<PmphUser> pmphUsers = pmphUserDao.getListByUsernameAndRealname(name, (number - 1) * size, size);
PageResult<PmphUserManagerVO> page = new PageResult<>();
page.setFirst(true);
page.setLast(true);
page.setPageNumber(number);
page.setPageSize(size);
if (!pmphUsers.isEmpty()) {
List<PmphUserManagerVO> list = new ArrayList<>();
for (PmphUser user : pmphUsers) {
PmphUserManagerVO userVO = new PmphUserManagerVO();
PmphDepartment department = pmphDepartmentDao.getPmphDepartmentById(user.getDepartmentId());
if (null != department) {
userVO.setDepartmentName(department.getDpName());
}
try {
BeanUtils.copyProperties(userVO, user);
} catch (BeansException ex) {
throw new CheckedServiceException(CheckedExceptionBusiness.USER_MANAGEMENT, CheckedExceptionResult.VO_CONVERSION_FAILED, ex.getMessage());
}
list.add(userVO);
}
page.setRows(list);
}
return page;
}
use of org.springframework.beans.BeansException in project pentaho-platform by pentaho.
the class SystemGwtRpcTest method testResolveTargetThrowsIfBeanResolveThrowsBeansException.
@Test(expected = GwtRpcProxyException.class)
public void testResolveTargetThrowsIfBeanResolveThrowsBeansException() {
String servletPath = "/ws";
String pathInfo = "/gwt/serviceName";
String serviceKey = "ws-gwt-serviceName";
// ---
HttpServletRequest httpRequestMock = setupHttpRequest(servletPath, pathInfo);
// ---
BeansException error = mock(BeansException.class);
ApplicationContext appContext = mock(ApplicationContext.class);
when(appContext.containsBean(serviceKey)).thenReturn(true);
when(appContext.getBean(serviceKey)).thenThrow(error);
// ---
SystemGwtRpc gwtRpc = spy(new SystemGwtRpc(httpRequestMock));
doReturn(appContext).when(gwtRpc).createAppContext();
// ---
gwtRpc.resolveTarget();
}
Aggregations