public abstract class InetAddressResolverProvider extends Object
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 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.
InetAddress
will use the built-in resolver for any lookup operation that might occur before the VM is fully booted.Modifier and Type | Class | Description |
---|---|---|
static interface |
InetAddressResolverProvider.Configuration |
A Configuration object is supplied to the get(Configuration) method when setting the system-wide resolver. |
Modifier | Constructor | Description |
---|---|---|
protected |
Creates a new instance of InetAddressResolverProvider . |
Modifier and Type | Method | Description |
---|---|---|
abstract InetAddressResolver |
get |
Initialize and return an InetAddressResolver provided by this provider. |
abstract String |
name() |
Returns the name of this provider, or null if unnamed. |
protected InetAddressResolverProvider()
InetAddressResolverProvider
.InetAddressResolverProvider
service implementation initialization should be as simple as possible, in order to avoid possible risks of deadlock or class loading cycles during the instantiation of the service provider.SecurityException
- if a security manager is present and its checkPermission
method doesn't allow the RuntimePermission("inetAddressResolverProvider")
.public abstract InetAddressResolver get(InetAddressResolverProvider.Configuration configuration)
InetAddressResolver
provided by this provider. This method is called by InetAddress
when installing the system-wide resolver implementation. Any error or exception thrown by this method is considered as a failure of InetAddressResolver
instantiation and will be propagated to the caller of the method that triggered the lookup operation.
configuration
- a InetAddressResolverProvider.Configuration
instance containing platform built-in address resolution configuration.public abstract String name()
null
if unnamed.null
if unnamed
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/net/spi/InetAddressResolverProvider.html