• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2014 The gRPC Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package io.grpc;
18 
19 import java.util.Collections;
20 import java.util.List;
21 import javax.annotation.Nullable;
22 import javax.annotation.concurrent.ThreadSafe;
23 
24 /**
25  * Registry of services and their methods used by servers to dispatching incoming calls.
26  */
27 @ThreadSafe
28 public abstract class HandlerRegistry {
29 
30   /**
31    * Returns the {@link ServerServiceDefinition}s provided by the registry, or an empty list if not
32    * supported by the implementation.
33    */
34   @ExperimentalApi("https://github.com/grpc/grpc-java/issues/2222")
getServices()35   public List<ServerServiceDefinition> getServices() {
36     return Collections.emptyList();
37   }
38 
39   /**
40    * Lookup a {@link ServerMethodDefinition} by its fully-qualified name.
41    *
42    * @param methodName to lookup {@link ServerMethodDefinition} for.
43    * @param authority the authority for the desired method (to do virtual hosting). If {@code null}
44    *        the first matching method will be returned.
45    * @return the resolved method or {@code null} if no method for that name exists.
46    */
47   @Nullable
lookupMethod( String methodName, @Nullable String authority)48   public abstract ServerMethodDefinition<?, ?> lookupMethod(
49       String methodName, @Nullable String authority);
50 
51   /**
52    * Lookup a {@link ServerMethodDefinition} by its fully-qualified name.
53    *
54    * @param methodName to lookup {@link ServerMethodDefinition} for.
55    * @return the resolved method or {@code null} if no method for that name exists.
56    */
57   @Nullable
lookupMethod(String methodName)58   public final ServerMethodDefinition<?, ?> lookupMethod(String methodName) {
59     return lookupMethod(methodName, null);
60   }
61 
62 }
63