Top Description Inners Fields Constructors Methods
java.net.spi

public abstract Class InetAddressResolverProvider

extends Object
Class Inheritance
Imports
sun.net.ResolverProviderConfiguration, java.net.InetAddress, java.util.ServiceLoader

Service-provider class for InetAddress resolvers.

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:

  1. The 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.
  2. If the previous step fails to find any resolver provider the built-in resolver 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.

Since
18

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
InetAddressResolverProvider.Configuration

A Configuration object is supplied to the InetAddressResolverProvider#get(Configuration) method when setting the system-wide resolver.

Field Summary

Modifier and TypeField and Description
private static final RuntimePermission
INET_ADDRESS_RESOLVER_PERMISSION

The RuntimePermission("inetAddressResolverProvider") is necessary to subclass and instantiate the InetAddressResolverProvider class, as well as to obtain resolver from an instance of that class, and it is also required to obtain the operating system name resolution configurations.

Constructor Summary

AccessConstructor and Description
protected
InetAddressResolverProvider()

Creates a new instance of InetAddressResolverProvider.

private

Method Summary

Modifier and TypeMethod and Description
private static Void
public abstract InetAddressResolver

Returns:

the resolver provided by this provider
get
(InetAddressResolverProvider.Configuration
a Configuration instance containing platform built-in address resolution configuration.
configuration
)

Initialize and return an InetAddressResolver provided by this provider.

public abstract String

Returns:

the name of this provider, or null if unnamed
name
()

Returns the name of this provider, or null if unnamed.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INET_ADDRESS_RESOLVER_PERMISSIONback to summary
private static final RuntimePermission INET_ADDRESS_RESOLVER_PERMISSION

The RuntimePermission("inetAddressResolverProvider") is necessary to subclass and instantiate the InetAddressResolverProvider class, as well as to obtain resolver from an instance of that class, and it is also required to obtain the operating system name resolution configurations.

Constructor Detail

InetAddressResolverProviderback to summary
protected InetAddressResolverProvider()

Creates a new instance of InetAddressResolverProvider.

Implementation Note

It is recommended that an 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.

Exceptions
SecurityException:
if a security manager is present and its checkPermission method doesn't allow the RuntimePermission("inetAddressResolverProvider").
InetAddressResolverProviderback to summary
private InetAddressResolverProvider(Void unused)

Method Detail

checkPermissionback to summary
private static Void checkPermission()
Annotations
@SuppressWarnings:removal
getback to summary
public abstract InetAddressResolver get(InetAddressResolverProvider.Configuration configuration)

Initialize and return an 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.

Parameters
configuration:InetAddressResolverProvider.Configuration

a Configuration instance containing platform built-in address resolution configuration.

Returns:InetAddressResolver

the resolver provided by this provider

nameback to summary
public abstract String name()

Returns the name of this provider, or null if unnamed.

Returns:String

the name of this provider, or null if unnamed

java.net.spi back to summary

public sealed Interface InetAddressResolverProvider.Configuration

Known Direct Implementers
sun.net.ResolverProviderConfiguration

A 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.
Since
18

Method Summary

Modifier and TypeMethod and Description
public InetAddressResolver

Returns:

the JDK built-in resolver.
builtinResolver
()

Returns the built-in resolver.

public String

Returns:

the localhost name.
lookupLocalHostName
()

Reads the localhost name from the system configuration.

Method Detail

builtinResolverback to summary
public InetAddressResolver builtinResolver()

Returns the built-in resolver.

Returns:InetAddressResolver

the JDK built-in resolver.

lookupLocalHostNameback to summary
public String lookupLocalHostName()

Reads the localhost name from the system configuration.

Returns:String

the localhost name.