sb.append(this.getName()).append('.'); sb.append(this.getTypeWithSubtype()); sb.append("' address: '"); InetAddress[] addresses = this.getInetAddresses();
buf.append("[" + this.getClass().getSimpleName() + "@" + System.identityHashCode(this) + " "); buf.append("name: '"); buf.append((this.getName().length() > 0 ? this.getName() + "." : "") + this.getTypeWithSubtype()); buf.append("' address: '"); InetAddress[] addresses = this.getInetAddresses();
buf.append("[" + this.getClass().getSimpleName() + "@" + System.identityHashCode(this) + " "); buf.append("name: '"); buf.append((this.getName().length() > 0 ? this.getName() + "." : "") + this.getTypeWithSubtype()); buf.append("' address: '"); InetAddress[] addresses = this.getInetAddresses();
buf.append("[" + this.getClass().getSimpleName() + "@" + System.identityHashCode(this) + " "); buf.append("name: '"); buf.append((this.getName().length() > 0 ? this.getName() + "." : "") + this.getTypeWithSubtype()); buf.append("' address: '"); InetAddress[] addresses = this.getInetAddresses();
public Collection<DNSRecord> answers(boolean unique, int ttl, HostInfo localHost) { List<DNSRecord> list = new ArrayList<DNSRecord>(); if (this.getSubtype().length() > 0) { list.add(new Pointer(this.getTypeWithSubtype(), DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, ttl, this.getQualifiedName())); } list.add(new Pointer(this.getType(), DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, ttl, this.getQualifiedName())); list.add(new Service(this.getQualifiedName(), DNSRecordClass.CLASS_IN, unique, ttl, _priority, _weight, _port, localHost.getName())); list.add(new Text(this.getQualifiedName(), DNSRecordClass.CLASS_IN, unique, ttl, this.getTextBytes())); return list; }
public Collection<DNSRecord> answers(boolean unique, int ttl, HostInfo localHost) { List<DNSRecord> list = new ArrayList<DNSRecord>(); if (this.getSubtype().length() > 0) { list.add(new Pointer(this.getTypeWithSubtype(), DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, ttl, this.getQualifiedName())); } list.add(new Pointer(this.getType(), DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, ttl, this.getQualifiedName())); list.add(new Service(this.getQualifiedName(), DNSRecordClass.CLASS_IN, unique, ttl, _priority, _weight, _port, localHost.getName())); list.add(new Text(this.getQualifiedName(), DNSRecordClass.CLASS_IN, unique, ttl, this.getTextBytes())); return list; }
public Collection<DNSRecord> answers(boolean unique, int ttl, HostInfo localHost) { List<DNSRecord> list = new ArrayList<DNSRecord>(); if (this.getSubtype().length() > 0) { list.add(new Pointer(this.getTypeWithSubtype(), DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, ttl, this.getQualifiedName())); } list.add(new Pointer(this.getType(), DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, ttl, this.getQualifiedName())); list.add(new Service(this.getQualifiedName(), DNSRecordClass.CLASS_IN, unique, ttl, _priority, _weight, _port, localHost.getName())); list.add(new Text(this.getQualifiedName(), DNSRecordClass.CLASS_IN, unique, ttl, this.getTextBytes())); return list; }
protected void addAnswersForServiceInfo(JmDNSImpl jmDNSImpl, Set<DNSRecord> answers, ServiceInfoImpl info) { if ((info != null) && info.isAnnounced()) { if (this.getName().equalsIgnoreCase(info.getQualifiedName()) || this.getName().equalsIgnoreCase(info.getType()) || this.getName().equalsIgnoreCase(info.getTypeWithSubtype())) { answers.addAll(jmDNSImpl.getLocalHost().answers(this.getRecordClass(), DNSRecordClass.UNIQUE, DNSConstants.DNS_TTL)); answers.addAll(info.answers(this.getRecordClass(), DNSRecordClass.UNIQUE, DNSConstants.DNS_TTL, jmDNSImpl.getLocalHost())); } logger.debug("{} DNSQuestion({}).addAnswersForServiceInfo(): info: {}\n{}", jmDNSImpl.getName(), this.getName(), info, answers); } }
/** * Create a series of answer that correspond with the give service info. * * @param recordClass * record class of the query * @param unique * @param ttl * @param localHost * @return collection of answers */ public Collection<DNSRecord> answers(DNSRecordClass recordClass, boolean unique, int ttl, HostInfo localHost) { List<DNSRecord> list = new ArrayList<DNSRecord>(); // [PJYF Dec 6 2011] This is bad hack as I don't know what the spec should really means in this case. i.e. what is the class of our registered services. if ((recordClass == DNSRecordClass.CLASS_ANY) || (recordClass == DNSRecordClass.CLASS_IN)) { if (this.getSubtype().length() > 0) { list.add(new Pointer(this.getTypeWithSubtype(), DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, ttl, this.getQualifiedName())); } list.add(new Pointer(this.getType(), DNSRecordClass.CLASS_IN, DNSRecordClass.NOT_UNIQUE, ttl, this.getQualifiedName())); list.add(new Service(this.getQualifiedName(), DNSRecordClass.CLASS_IN, unique, ttl, _priority, _weight, _port, localHost.getName())); list.add(new Text(this.getQualifiedName(), DNSRecordClass.CLASS_IN, unique, ttl, this.getTextBytes())); } return list; }
/** * {@inheritDoc} */ @Override public void registerService(ServiceInfo infoAbstract) throws IOException { if (this.isClosing() || this.isClosed()) { throw new IllegalStateException("This DNS is closed."); } final ServiceInfoImpl info = (ServiceInfoImpl) infoAbstract; if (info.getDns() != null) { if (info.getDns() != this) { throw new IllegalStateException("A service information can only be registered with a single instamce of JmDNS."); } else if (_services.get(info.getKey()) != null) { throw new IllegalStateException("A service information can only be registered once."); } } info.setDns(this); this.registerServiceType(info.getTypeWithSubtype()); // bind the service to this address info.recoverState(); info.setServer(_localHost.getName()); info.addAddress(_localHost.getInet4Address()); info.addAddress(_localHost.getInet6Address()); this.makeServiceNameUnique(info); while (_services.putIfAbsent(info.getKey(), info) != null) { this.makeServiceNameUnique(info); } this.startProber(); logger.debug("registerService() JmDNS registered service as {}", info); }
this.registerServiceType(info.getTypeWithSubtype());
this.registerServiceType(info.getTypeWithSubtype());
/** * {@inheritDoc} */ @Override public void registerService(ServiceInfo infoAbstract) throws IOException { if (this.isClosing() || this.isClosed()) { throw new IllegalStateException("This DNS is closed."); } final ServiceInfoImpl info = (ServiceInfoImpl) infoAbstract; if ((info.getDns() != null) && (info.getDns() != this)) { throw new IllegalStateException("This service information is already registered with another DNS."); } info.setDns(this); this.registerServiceType(info.getTypeWithSubtype()); // bind the service to this address info.setServer(_localHost.getName()); info.addAddress(_localHost.getInet4Address()); info.addAddress(_localHost.getInet6Address()); this.waitForAnnounced(DNSConstants.SERVICE_INFO_TIMEOUT); this.makeServiceNameUnique(info); while (_services.putIfAbsent(info.getKey(), info) != null) { this.makeServiceNameUnique(info); } this.startProber(); info.waitForAnnounced(DNSConstants.SERVICE_INFO_TIMEOUT); if (logger.isLoggable(Level.FINE)) { logger.fine("registerService() JmDNS registered service as " + info); } }