From 28d51c5e3e30a837275ed7f0e304e13786e8c41e Mon Sep 17 00:00:00 2001 From: Carl Mastrangelo Date: Wed, 2 Sep 2015 15:29:21 -0700 Subject: [PATCH] Add an authority header to HandlerRegistry.lookupMethod --- core/src/main/java/io/grpc/HandlerRegistry.java | 16 +++++++++++++++- .../java/io/grpc/MutableHandlerRegistryImpl.java | 5 ++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/io/grpc/HandlerRegistry.java b/core/src/main/java/io/grpc/HandlerRegistry.java index f7a79db814..7aad4f65a7 100644 --- a/core/src/main/java/io/grpc/HandlerRegistry.java +++ b/core/src/main/java/io/grpc/HandlerRegistry.java @@ -45,9 +45,23 @@ public abstract class HandlerRegistry { * Lookup a {@link ServerMethodDefinition} by its fully-qualified name. * * @param methodName to lookup {@link ServerMethodDefinition} for. + * @param authority the authority for the desired method (to do virtual hosting). If {@code null} + * the first matching method will be returned. * @return the resolved method or {@code null} if no method for that name exists. */ @Nullable - public abstract ServerMethodDefinition lookupMethod(String methodName); + public abstract ServerMethodDefinition lookupMethod( + String methodName, @Nullable String authority); + + /** + * Lookup a {@link ServerMethodDefinition} by its fully-qualified name. + * + * @param methodName to lookup {@link ServerMethodDefinition} for. + * @return the resolved method or {@code null} if no method for that name exists. + */ + @Nullable + public final ServerMethodDefinition lookupMethod(String methodName) { + return lookupMethod(methodName, null); + } } diff --git a/core/src/main/java/io/grpc/MutableHandlerRegistryImpl.java b/core/src/main/java/io/grpc/MutableHandlerRegistryImpl.java index 78bc8f0a8e..f578e99a28 100644 --- a/core/src/main/java/io/grpc/MutableHandlerRegistryImpl.java +++ b/core/src/main/java/io/grpc/MutableHandlerRegistryImpl.java @@ -60,9 +60,12 @@ public final class MutableHandlerRegistryImpl extends MutableHandlerRegistry { return services.remove(service.getName(), service); } + /** + * Note: This does not actually honor the authority provided. It will, eventually in the future. + */ @Override @Nullable - public ServerMethodDefinition lookupMethod(String methodName) { + public ServerMethodDefinition lookupMethod(String methodName, @Nullable String authority) { String serviceName = MethodDescriptor.extractFullServiceName(methodName); if (serviceName == null) { return null;