001package jmri.util.zeroconf; 002 003import java.io.IOException; 004import java.net.InetAddress; 005import java.util.EventObject; 006import javax.jmdns.JmDNS; 007import org.slf4j.Logger; 008import org.slf4j.LoggerFactory; 009 010/** 011 * 012 * @author Randall Wood 013 */ 014public class ZeroConfServiceEvent extends EventObject { 015 016 private final ZeroConfService service; 017 private final JmDNS dns; 018 private static final Logger log = LoggerFactory.getLogger(ZeroConfServiceEvent.class); 019 020 protected ZeroConfServiceEvent(ZeroConfService service, JmDNS dns) { 021 super(service); 022 this.dns = dns; 023 this.service = service; 024 } 025 026 /** 027 * @return the service 028 */ 029 public ZeroConfService getService() { 030 return this.service; 031 } 032 033 /** 034 * @return the address or null if there is an IO exception. 035 */ 036 public InetAddress getAddress() { 037 try { 038 return this.dns.getInetAddress(); 039 } catch (IOException ex) { 040 log.error("Unable to get interface address.", ex); 041 return null; 042 } 043 } 044}