A resolver provider is a factory for custom implementations of InetAddress resolvers. A resolver defines operations for looking up (resolving) host names and IP addresses.
A resolver provider is a concrete subclass of this class that has a zero-argument constructor and implements the abstract methods specified below.
A given invocation of the Java virtual machine maintains a single
system-wide resolver instance, which is used by
InetAddress. It is set after the VM is fully initialized and when an
invocation of a method in InetAddress class triggers the first lookup
operation.
A resolver provider is located and loaded by
InetAddress to create the system-wide resolver as follows:
ServiceLoader mechanism is used to locate an
InetAddressResolverProvider using the
system class loader. The order in which providers are located is
implementation specific.
The first provider found will be used to instantiate the
InetAddressResolver by invoking the
InetAddressResolverProvider#get(InetAddressResolverProvider.Configuration)
method. The returned InetAddressResolver will be set as the
system-wide resolver.
If instantiating a custom resolver from a provider discovered in step 1 throws an error or exception, the system-wide resolver will not be set and the error or exception will be propagated to the caller of the method that triggered the lookup operation. Otherwise, any lookup operation will be performed using the system-wide resolver.
Implementation Note
InetAddress will use the built-in resolver for any lookup operation
that might occur before the VM is fully booted.
| Modifier and Type | Class and Description |
|---|---|
| public static interface | InetAddressResolverProvider.
A |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public abstract InetAddressResolver | Returns: the resolver provided by this providera configurationConfiguration instance containing platform built-in address
resolution configuration.Initialize and return an |
| public abstract String | Returns: the name of this provider, ornull if unnamedReturns the name of this provider, or |
| InetAddressResolverProvider | back to summary |
|---|---|
| protected InetAddressResolverProvider() Creates a new instance of Implementation Note It is recommended that an | |
| get | back to summary |
|---|---|
| public abstract InetAddressResolver get(InetAddressResolverProvider. Initialize and return an Any error or exception thrown by this method is considered as
a failure of
| |
| name | back to summary |
|---|---|
| public abstract String name() Returns the name of this provider, or
| |
Configuration object is supplied to the
InetAddressResolverProvider#get(Configuration) method when
setting the system-wide resolver.
A resolver implementation can then delegate to the built-in resolver
provided by this interface if it needs to.
| Modifier and Type | Method and Description |
|---|---|
| public InetAddressResolver | |
| public String | Returns: the localhost name.Reads the localhost name from the system configuration. |
| builtinResolver | back to summary |
|---|---|
| public InetAddressResolver builtinResolver() Returns the built-in resolver.
| |
| lookupLocalHostName | back to summary |
|---|---|
| public String lookupLocalHostName() Reads the localhost name from the system configuration.
| |