*/
public static ServiceRegistrar createServiceRegistrar(final Path path,
final String address,
final String domain) {
// Get a registrar factory
final ServiceRegistrarFactory factory;
if (path == null) {
factory = createFactory();
} else {
factory = createFactory(path);
}
// Create the registrar
if (address != null) {
log.info("Creating service registrar with address: {}", address);
return factory.create(address);
} else if (!Strings.isNullOrEmpty(domain)) {
log.info("Creating service registrar for domain: {}", domain);
// TODO: localhost:4999 is pretty specific to Spotify's registrar, this should be
// handled in createForDomain there, rather than here. Localhost should just pass through.
return domain.equals("localhost")
? factory.create("tcp://localhost:4999")
: factory.createForDomain(domain);
} else {
log.info("No address nor domain configured, not creating service registrar.");
return new NopServiceRegistrar();
}
}