So digging into this more, the issue cannot be resolved without an api
change because there are interface criteria that aggregate other
criteria. For example, the
NetworkServiceInterface.OverallInterfaceCriteria, NotInterfaceCriteria,
AnyInterfaceCriteria, etc. The current issue I have is that the
LoopbackInterfaceCriteriaWithAddress is wrapped in a
NetworkServiceInterface.OverallInterfaceCriteria instance, and therefore
I cannot determine that it provides a InterfaceCriteriaWithAddress
implementation. The proper change would require a change to the
InterfaceCriteria to return the bindAddress to use when the criteria is
accepted, with the default implementation simply returning the input
address:
public interface InterfaceCriteria extends Serializable {
/**
* Gets whether the given network interface and address are
acceptable for
* use. Acceptance is indicated by returning the address which
should be used for binding against
* the network interface, typically this is the input address. For
those criteria which override the
* bind address, the overriden address should be returned.
*
* @param networkInterface the network interface. Cannot be
<code>null</code>
* @param address an address that is associated with
<code>networkInterface</code>. Cannot be <code>null</code>
* @return <code>InetAddress</code> the non-null address to bind to
if the criteria is met, null if the criteria does not apply
*
* @throws SocketException
*/
InetAddress isAcceptable(NetworkInterface networkInterface,
InetAddress address) throws SocketException;
}
Show replies by date