Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GrpcGlobalServerInterceptor override in case of another bean of some type. #951

Open
313hemant313 opened this issue Aug 28, 2023 · 0 comments
Labels
enhancement A feature request or improvement

Comments

@313hemant313
Copy link
Contributor

313hemant313 commented Aug 28, 2023

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();
    }
@313hemant313 313hemant313 added the enhancement A feature request or improvement label Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A feature request or improvement
Projects
None yet
Development

No branches or pull requests

1 participant