Skip to content

Commit 025368f

Browse files
committed
Add method to define grpc client`s bean-name
1 parent 97b7d0d commit 025368f

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

grpc-client-spring-boot-autoconfigure/src/main/java/net/devh/boot/grpc/client/inject/GrpcClientBeanPostProcessor.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ public Object postProcessBeforeInitialization(final Object bean, final String be
103103
}
104104

105105
for (final GrpcClientBean beanClientIterator : clazz.getAnnotationsByType(GrpcClientBean.class)) {
106-
final String beanNameToCreate = beanClientIterator.beanName().isEmpty()
107-
? beanClientIterator.client().value() + beanClientIterator.clazz().getSimpleName()
108-
: beanClientIterator.beanName();
106+
final String beanNameToCreate = getBeanName(beanClientIterator);
109107
try {
110108
final ConfigurableListableBeanFactory beanFactory =
111109
((ConfigurableApplicationContext) this.applicationContext).getBeanFactory();
@@ -291,4 +289,18 @@ private List<StubFactory> getStubFactories() {
291289
return this.stubFactories;
292290
}
293291

292+
/**
293+
* The method is used to determine with which name the bean should be registered in the context
294+
*
295+
* @param grpcClientBean annotation value
296+
* @return name
297+
*/
298+
private String getBeanName(final GrpcClientBean grpcClientBean) {
299+
if (!grpcClientBean.beanName().isEmpty()) {
300+
return grpcClientBean.beanName();
301+
} else {
302+
return grpcClientBean.client().value() + grpcClientBean.clazz().getSimpleName();
303+
}
304+
}
305+
294306
}

0 commit comments

Comments
 (0)