Search in sources :

Example 1 with ServiceInfoImpl

use of javax.jmdns.impl.ServiceInfoImpl in project JAirPort by froks.

the class DNSStateTask method run.

@Override
public void run() {
    DNSOutgoing out = this.createOugoing();
    try {
        if (!this.checkRunCondition()) {
            this.cancel();
            return;
        }
        List<DNSStatefulObject> stateObjects = new ArrayList<DNSStatefulObject>();
        // send probes for JmDNS itself
        synchronized (this.getDns()) {
            if (this.getDns().isAssociatedWithTask(this, this.getTaskState())) {
                logger1.finer(this.getName() + ".run() JmDNS " + this.getTaskDescription() + " " + this.getDns().getName());
                stateObjects.add(this.getDns());
                out = this.buildOutgoingForDNS(out);
            }
        }
        // send probes for services
        for (ServiceInfo serviceInfo : this.getDns().getServices().values()) {
            ServiceInfoImpl info = (ServiceInfoImpl) serviceInfo;
            synchronized (info) {
                if (info.isAssociatedWithTask(this, this.getTaskState())) {
                    logger1.fine(this.getName() + ".run() JmDNS " + this.getTaskDescription() + " " + info.getQualifiedName());
                    stateObjects.add(info);
                    out = this.buildOutgoingForInfo(info, out);
                }
            }
        }
        if (!out.isEmpty()) {
            logger1.finer(this.getName() + ".run() JmDNS " + this.getTaskDescription() + " #" + this.getTaskState());
            this.getDns().send(out);
            // Advance the state of objects.
            this.advanceObjectsState(stateObjects);
        } else {
            // Advance the state of objects.
            this.advanceObjectsState(stateObjects);
            // If we have nothing to send, another timer taskState ahead of us has done the job for us. We can cancel.
            cancel();
            return;
        }
    } catch (Throwable e) {
        logger1.log(Level.WARNING, this.getName() + ".run() exception ", e);
        this.recoverTask(e);
    }
    this.advanceTask();
}
Also used : ServiceInfo(javax.jmdns.ServiceInfo) ServiceInfoImpl(javax.jmdns.impl.ServiceInfoImpl) DNSOutgoing(javax.jmdns.impl.DNSOutgoing) ArrayList(java.util.ArrayList) DNSStatefulObject(javax.jmdns.impl.DNSStatefulObject)

Aggregations

ArrayList (java.util.ArrayList)1 ServiceInfo (javax.jmdns.ServiceInfo)1 DNSOutgoing (javax.jmdns.impl.DNSOutgoing)1 DNSStatefulObject (javax.jmdns.impl.DNSStatefulObject)1 ServiceInfoImpl (javax.jmdns.impl.ServiceInfoImpl)1