ejona | ba71ee9 | 2014-08-14 14:17:13 -0700 | [diff] [blame] | 1 | package com.google.net.stubby; |
| 2 | |
ejona | 34aede3 | 2014-08-18 14:30:24 -0700 | [diff] [blame] | 3 | import com.google.net.stubby.ServerMethodDefinition; |
| 4 | import com.google.net.stubby.ServerServiceDefinition; |
ejona | ba71ee9 | 2014-08-14 14:17:13 -0700 | [diff] [blame] | 5 | |
| 6 | import javax.annotation.Nullable; |
| 7 | import javax.annotation.concurrent.ThreadSafe; |
| 8 | |
| 9 | /** Registry of services and their methods for dispatching incoming calls. */ |
| 10 | @ThreadSafe |
| 11 | public abstract class HandlerRegistry { |
| 12 | /** Lookup full method name, starting with '/'. Returns {@code null} if method not found. */ |
| 13 | @Nullable |
| 14 | public abstract Method lookupMethod(String methodName); |
| 15 | |
| 16 | /** A method definition and its parent's service definition. */ |
| 17 | public static final class Method { |
ejona | 34aede3 | 2014-08-18 14:30:24 -0700 | [diff] [blame] | 18 | private final ServerServiceDefinition serviceDef; |
| 19 | private final ServerMethodDefinition methodDef; |
ejona | ba71ee9 | 2014-08-14 14:17:13 -0700 | [diff] [blame] | 20 | |
ejona | 34aede3 | 2014-08-18 14:30:24 -0700 | [diff] [blame] | 21 | public Method(ServerServiceDefinition serviceDef, ServerMethodDefinition methodDef) { |
ejona | ba71ee9 | 2014-08-14 14:17:13 -0700 | [diff] [blame] | 22 | this.serviceDef = serviceDef; |
| 23 | this.methodDef = methodDef; |
| 24 | } |
| 25 | |
ejona | 34aede3 | 2014-08-18 14:30:24 -0700 | [diff] [blame] | 26 | public ServerServiceDefinition getServiceDefinition() { |
ejona | ba71ee9 | 2014-08-14 14:17:13 -0700 | [diff] [blame] | 27 | return serviceDef; |
| 28 | } |
| 29 | |
ejona | 34aede3 | 2014-08-18 14:30:24 -0700 | [diff] [blame] | 30 | public ServerMethodDefinition getMethodDefinition() { |
ejona | ba71ee9 | 2014-08-14 14:17:13 -0700 | [diff] [blame] | 31 | return methodDef; |
| 32 | } |
| 33 | } |
| 34 | } |