たとえば、DNS構成で次のSRVレコードが定義されている場合
_dev._tcp IN SRV 0 0 8400 dev.server.com.
次のコマンドを実行できます
host -lt SRV server.com
そしてそれは私にdnsサーバー(server.com)のSRVレコードの完全なリストを与えます。JNDIルックアップを使用して同じことをしたい場合
Hashtable<String, String> env = new Hashtable<String, String>();
env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
DirContext ctx = new InitialDirContext(env);
Attributes attributes = ctx.getAttributes("server.com", new String [] { "SRV" });
return attributes;
上記のコードは属性を返していません。上記のコードの最後から2行目をこれに変更すると、
Attributes attributes = ctx.getAttributes("_dev._tcp.server.com", new String [] { "SRV" });
できます。
しかし、問題は、以前は完全なドメイン名がわからないため、SRVレコードを検索して完全なドメイン名を見つける必要があることです。
これを行う方法として何かアイデアはありますか?