Class InetAddressResolverProvider
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:
- The
ServiceLoadermechanism is used to locate anInetAddressResolverProviderusing the system class loader. The order in which providers are located is implementation specific. The first provider found will be used to instantiate theInetAddressResolverby invoking theget(InetAddressResolverProvider.Configuration)method. The returnedInetAddressResolverwill be set as the system-wide resolver. - 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:
InetAddresswill use the built-in resolver for any lookup operation that might occur before the VM is fully booted.- Since:
- 18
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceAConfigurationobject is supplied to theget(Configuration)method when setting the system-wide resolver. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new instance ofInetAddressResolverProvider. -
Method Summary
Modifier and TypeMethodDescriptionabstract InetAddressResolverget(InetAddressResolverProvider.Configuration configuration) Initialize and return anInetAddressResolverprovided by this provider.abstract Stringname()Returns the name of this provider, ornullif unnamed.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()Answers a new instance of the same class as the receiver, whose slots have been filled in with the values in the slots of the receiver.booleanCompares the argument to the receiver, and answers true if they represent the same object using a class specific comparison.protected voidfinalize()Deprecated, for removal: This API element is subject to removal in a future version.May cause performance issues, deadlocks and hangs.getClass()Answers the unique instance of java.lang.Class which represents the class of the receiver.inthashCode()Answers an integer hash code for the receiver.final voidnotify()Causes one thread which iswaiting on the receiver to be made ready to run.final voidCauses all threads which arewaiting on the receiver to be made ready to run.toString()Answers a string containing a concise, human-readable description of the receiver.final voidwait()Causes the thread which sent this message to be made not ready to run pending some change in the receiver (as indicated bynotifyornotifyAll).final voidwait(long time) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.final voidwait(long time, int frac) Causes the thread which sent this message to be made not ready to run either pending some change in the receiver (as indicated bynotifyornotifyAll) or the expiration of the timeout.
-
Constructor Details
-
InetAddressResolverProvider
protected InetAddressResolverProvider()Creates a new instance ofInetAddressResolverProvider.- Implementation Note:
- It is recommended that an
InetAddressResolverProviderservice 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.
-
-
Method Details
-
get
Initialize and return anInetAddressResolverprovided by this provider. This method is called byInetAddresswhen installing the system-wide resolver implementation.Any error or exception thrown by this method is considered as a failure of
InetAddressResolverinstantiation and will be propagated to the caller of the method that triggered the lookup operation.- Parameters:
configuration- aInetAddressResolverProvider.Configurationinstance containing platform built-in address resolution configuration.- Returns:
- the resolver provided by this provider
-
name
Returns the name of this provider, ornullif unnamed.- Returns:
- the name of this provider, or
nullif unnamed
-