Skip to content

Commit

Permalink
ref #175
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Furer committed Oct 28, 2021
1 parent 0ffec28 commit a0a6583
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.springframework.util.ReflectionUtils;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.AbstractMap;
Expand Down Expand Up @@ -113,12 +114,17 @@ public void setGRpcServicesRegistry(GRpcServicesRegistry registry) {
final Map<GrpcServiceMethodKey, Map.Entry<Object, Method>> map = new HashMap<>();

Function<String, ReflectionUtils.MethodFilter> filterFactory = name ->
method -> method.getName().equalsIgnoreCase(name);
method -> method.getName().equalsIgnoreCase(name) ;

for (BindableService service : registry.getBeanNameToServiceBeanMap().values()) {
for (MethodDescriptor<?, ?> d : service.bindService().getServiceDescriptor().getMethods()) {
Class<?> abstractBaseClass = service.getClass();
while (!Modifier.isAbstract(abstractBaseClass.getModifiers())){
abstractBaseClass = abstractBaseClass.getSuperclass();
}

final Method method = MethodIntrospector
.selectMethods(service.getClass(), filterFactory.apply(d.getBareMethodName()))
.selectMethods(abstractBaseClass, filterFactory.apply(d.getBareMethodName()))
.iterator().next();
map.put(new GrpcServiceMethodKey(d),
new AbstractMap.SimpleImmutableEntry<>(service, method));
Expand Down

0 comments on commit a0a6583

Please sign in to comment.