public void close() { if (jmdns!=null) { // try { jmdns.abort(); jmdns = null; // } catch (final IOException e) { // LOGGER.log(Level.WARNING,"Failed to close down JmDNS instance!",e); // } } }
@Override public void stop() { if (jmdns != null) { try { jmdns.close(); } catch (Exception e) { // Ignore. } } }
public Object call() { try { jmdns = JmDNS.create(); jmdns.registerService(ServiceInfo.create("_hudson._tcp.local.","jenkins", jenkins_port,0,0,props)); // for backward compatibility jmdns.registerService(ServiceInfo.create("_jenkins._tcp.local.","jenkins", jenkins_port,0,0,props)); jmdns.registerService(ServiceInfo.create("_http._tcp.local.","Jenkins", jenkins_port,0,0,props)); } catch (IOException e) {
/** * A service has been added. */ public void serviceAdded(ServiceEvent event) { synchronized (infos) { event.getDNS().requestServiceInfo(event.getType(), event.getName(), 0); } }
@Override public void run() { jmDNS.requestServiceInfo(serviceEvent.getType(), serviceEvent.getName(), SERVICE_RESOLUTION_TIMEOUT); } }.start();
jmdns = new JmDNS(); ServiceInfo clientService = new ServiceInfo("_xmpp-client._tcp.local.", serverName + "._xmpp-client._tcp.local.", clientPortNum, "XMPP Server"); jmdns.registerService(clientService); ServiceInfo componentService = new ServiceInfo("_xmpp-component._tcp.local.", serverName + "._xmpp-component._tcp.local.", componentPortNum, "XMPP Component Server"); jmdns.registerService(componentService);
static synchronized JmDNS create(final InetAddress address) throws IOException { UsageTracker tracker = registry.get(address); if (tracker == null) { tracker = new UsageTracker(); tracker.jmDNS = JmDNS.create(address); registry.put(address, tracker); } tracker.count.incrementAndGet(); return tracker.jmDNS; }
@Override public void registerService(String name) throws IOException { ServiceInfo si = createServiceInfo(name, new HashMap<String, Object>()); serviceInfos.add(si); getJmdns().registerService(si); }
@Override public void serviceAdded(final ServiceEvent event) { if (BuildConfig.DEBUG) { Log.d(TAG, "serviceAdded"); } synchronized (INSTANCE) { if (mDetectionListener != null) { mDNS.requestServiceInfo(SERVICE_TYPE, event.getName(), RESOLVE_TIMEOUT); } } }
protected ServiceInfo createServiceInfo(String name, Map map) { int port = MapHelper.getInt(map, "port", 0); String type = getType(); LOG.debug("Registering service type: {} name: {} details: {}", new Object[]{type, name, map}); return ServiceInfo.create(type, name + "." + type, port, weight, priority, ""); }
@Override public void start() throws Exception { if (group == null) { throw new IOException("You must specify a group to discover"); } String type = getType(); if (!type.endsWith(".")) { LOG.warn("The type '{}' should end with '.' to be a valid Rendezvous type", type); type += "."; } try { // force lazy construction getJmdns(); if (listener != null) { LOG.info("Discovering service of type: {}", type); jmdns.addServiceListener(type, this); } } catch (IOException e) { JMSExceptionSupport.create("Failed to start JmDNS service: " + e, e); } }
public Canceler(ServiceInfo info, Object lock) { this.infos = new ServiceInfo[]{info}; this.lock = lock; addListener(info, new DNSQuestion(info.getQualifiedName(), DNSConstants.TYPE_ANY, DNSConstants.CLASS_IN)); }
@Override public void stop() { if (jmdns != null) { for (Iterator<ServiceInfo> iter = serviceInfos.iterator(); iter.hasNext();) { ServiceInfo si = iter.next(); jmdns.unregisterService(si); } // Close it down async since this could block for a while. final JmDNS closeTarget = jmdns; Thread thread = new Thread() { @Override public void run() { try { if (JmDNSFactory.onClose(getLocalAddress())) { closeTarget.close(); }; } catch (IOException e) { LOG.debug("Error closing JmDNS {}. This exception will be ignored.", getLocalhost(), e); } } }; thread.setDaemon(true); thread.start(); jmdns = null; } }
public void addService(JmDNS jmDNS, String type, String name) { LOG.debug("addService with type: {} name: {}", type, name); if (listener != null) { listener.onServiceAdd(new DiscoveryEvent(name)); } jmDNS.requestServiceInfo(type, name); }
DNSRecord.Address getDNS6AddressRecord() { if ((getAddress() != null) && (getAddress() instanceof Inet6Address)) { return new DNSRecord.Address(getName(), DNSConstants.TYPE_AAAA, DNSConstants.CLASS_IN, DNSConstants.DNS_TTL, getAddress()); } return null; }
@Override public void run() { try { if (JmDNSFactory.onClose(getLocalAddress())) { closeTarget.close(); }; } catch (IOException e) { LOG.debug("Error closing JmDNS {}. This exception will be ignored.", getLocalhost(), e); } } };
public ServiceInfoResolver(ServiceInfo info) { this.info = info; info.dns = JmDNS.this; addListener(info, new DNSQuestion(info.getQualifiedName(), DNSConstants.TYPE_ANY, DNSConstants.CLASS_IN)); }