package org.cidrz.webapp.dynasite.utils.admin; import org.cidrz.webapp.dynasite.struts.action.admin.PoolAction; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import javax.jmdns.JmDNS; import javax.jmdns.ServiceEvent; import javax.jmdns.ServiceInfo; import javax.jmdns.ServiceListener; import java.io.IOException; /** * @author Chris Kelley * Date: Jun 1, 2006 * Time: 1:14:08 PM */ public class JmDmsListener implements ServiceListener { /** * Commons Logging instance. */ private static Log log = LogFactory.getFactory().getInstance(JmDmsListener.class); public void addService(JmDNS jmdns, String type, String name) { System.out.println("ADD: " + jmdns.getServiceInfo(type, name)); } public void removeService(JmDNS jmdns, String type, String name) { System.out.println("REMOVE: " + name); } public void resolveService(JmDNS jmdns, String type, String name, ServiceInfo info) { System.out.println("RESOLVED: " + info); } public void serviceAdded(ServiceEvent serviceEvent) { } public void serviceRemoved(ServiceEvent serviceEvent) { } public void serviceResolved(ServiceEvent serviceEvent) { } public static void jmdnsListen() throws IOException { JmDNS jmdns = new JmDNS(); jmdns.addServiceListener("_http._tcp.local.", new JmDmsListener()); ServiceInfo si = jmdns.getServiceInfo("_http._tcp.local.", "zeprs"); if (si != null) { log.debug("si: " + si.getURL()); } else { log.debug("si is null"); } } }