Wanted to override a base interceptor with another one, had tried adding ConditionalOnMissingBean but its not working and both the interceptors are registered.
@GrpcGlobalServerInterceptor
@Order(1100)
**@ConditionalOnMissingBean**(GrpcResponseServerInterceptor.class)
class BaseInterceptor extends ServerInterceptor # This is common interceptor (Usually in other modules this is fine)
@GrpcGlobalServerInterceptor
@Order(1100)
class CustomServiceInterceptor extends BaseInterceptor implements GrpcResponseServerInterceptor
Also tried Bean aware approach but got error while adding to HashBiMap (value already present)
beanFactoryAwareOrderComparator(final ApplicationContext context,
final Class<?> beanType) {
final Map<?, String> beans = HashBiMap.create(context.getBeansOfType(beanType)).inverse();
@GrpcGlobalServerInterceptor
@Order(999)
ServerInterceptor serverInterceptor() {
if (null != applicationContext.getBean(GrpcResponseServerInterceptor.class)) {
return applicationContext.getBean(GrpcResponseServerInterceptor.class);
}
return new BaseInterceptor();
}
Wanted to override a base interceptor with another one, had tried adding ConditionalOnMissingBean but its not working and both the interceptors are registered.
Also tried Bean aware approach but got error while adding to HashBiMap (value already present)