@Provides @Named(Constants.AppFabric.SERVER_ADDRESS) public final InetAddress providesHostname(CConfiguration cConf) { return Networks.resolve( cConf.get(Constants.AppFabric.SERVER_ADDRESS), new InetSocketAddress("localhost", 0).getAddress()); }
private Discoverable createDiscoverable(final String serviceName) { InetSocketAddress address; // NOTE: at this moment we are not using port anywhere int port = Networks.getRandomPort(); try { address = new InetSocketAddress(InetAddress.getLocalHost(), port); } catch (UnknownHostException e) { address = new InetSocketAddress(port); } final InetSocketAddress finalAddress = address; return new Discoverable() { @Override public String getName() { return serviceName; } @Override public InetSocketAddress getSocketAddress() { return finalAddress; } }; }