View Javadoc
1   /*
2    * Copyright 2014 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. 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, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  
17  package io.netty.resolver;
18  
19  import io.netty.util.concurrent.Future;
20  import io.netty.util.concurrent.Promise;
21  import io.netty.util.internal.UnstableApi;
22  
23  import java.io.Closeable;
24  import java.util.List;
25  
26  /**
27   * Resolves an arbitrary string that represents the name of an endpoint into an address.
28   */
29  @UnstableApi
30  public interface NameResolver<T> extends Closeable {
31  
32      /**
33       * Resolves the specified name into an address.
34       *
35       * @param inetHost the name to resolve
36       *
37       * @return the address as the result of the resolution
38       */
39      Future<T> resolve(String inetHost);
40  
41      /**
42       * Resolves the specified name into an address.
43       *
44       * @param inetHost the name to resolve
45       * @param promise the {@link Promise} which will be fulfilled when the name resolution is finished
46       *
47       * @return the address as the result of the resolution
48       */
49      Future<T> resolve(String inetHost, Promise<T> promise);
50  
51      /**
52       * Resolves the specified host name and port into a list of address.
53       *
54       * @param inetHost the name to resolve
55       *
56       * @return the list of the address as the result of the resolution
57       */
58      Future<List<T>> resolveAll(String inetHost);
59  
60      /**
61       * Resolves the specified host name and port into a list of address.
62       *
63       * @param inetHost the name to resolve
64       * @param promise the {@link Promise} which will be fulfilled when the name resolution is finished
65       *
66       * @return the list of the address as the result of the resolution
67       */
68      Future<List<T>> resolveAll(String inetHost, Promise<List<T>> promise);
69  
70      /**
71       * Closes all the resources allocated and used by this resolver.
72       */
73      @Override
74      void close();
75  }