int index = 0;
for( Connector connector : connectors )
{
if( connector instanceof NetworkConnector )
{
NetworkConnector netConnector = (NetworkConnector) connector;
String host = configuration().hostName().get();
if( host == null )
{
host = netConnector.getHost();
if( host == null ) // If serving all interfaces.
{
try
{
host = InetAddress.getLocalHost().getHostAddress();
}
catch( UnknownHostException e )
{
InternalError error = new InternalError( "UnknownHost for local interface." );
error.initCause( e );
throw error;
}
}
}
result[ index++] = new InterfaceImpl( host, netConnector.getPort(), servedProtocol() );
}
}
return result;
}