use of cn.taketoday.context.loader.BeanDefinitionRegistrar in project today-framework by TAKETODAY.
the class HandlerMethodRegistry method getInterceptors.
/**
* Get {@link HandlerInterceptor} objects
*
* @param interceptors
* {@link HandlerInterceptor} class
* @return Array of {@link HandlerInterceptor} objects
*/
public HandlerInterceptor[] getInterceptors(Class<? extends HandlerInterceptor>[] interceptors) {
if (ObjectUtils.isEmpty(interceptors)) {
return HandlerInterceptor.EMPTY_ARRAY;
}
int i = 0;
HandlerInterceptor[] ret = new HandlerInterceptor[interceptors.length];
BeanDefinitionRegistrar registrar = obtainApplicationContext().unwrap(BeanDefinitionRegistrar.class);
for (Class<? extends HandlerInterceptor> interceptor : interceptors) {
if (!registry.containsBeanDefinition(interceptor, true)) {
try {
registrar.registerBean(interceptor);
} catch (BeanDefinitionStoreException e) {
throw new ConfigurationException("Interceptor: [" + interceptor.getName() + "] register error", e);
}
}
HandlerInterceptor instance = this.beanFactory.getBean(interceptor);
Assert.state(instance != null, "Can't get target interceptor bean");
ret[i++] = instance;
}
return ret;
}
Aggregations