예제 #1
0
 public Prober(JmDNSImpl jmDNSImpl) {
   this.jmDNSImpl = jmDNSImpl;
   // Associate the host name to this, if it needs probing
   if (this.jmDNSImpl.getState() == DNSState.PROBING_1) {
     this.jmDNSImpl.setTask(this);
   }
   // Associate services to this, if they need probing
   synchronized (this.jmDNSImpl) {
     for (Iterator iterator = this.jmDNSImpl.getServices().values().iterator();
         iterator.hasNext(); ) {
       ServiceInfoImpl info = (ServiceInfoImpl) iterator.next();
       if (info.getState() == DNSState.PROBING_1) {
         info.setTask(this);
       }
     }
   }
 }
예제 #2
0
  public boolean cancel() {
    // Remove association from host name to this
    if (this.jmDNSImpl.getTask() == this) {
      this.jmDNSImpl.setTask(null);
    }

    // Remove associations from services to this
    synchronized (this.jmDNSImpl) {
      for (Iterator i = this.jmDNSImpl.getServices().values().iterator(); i.hasNext(); ) {
        ServiceInfoImpl info = (ServiceInfoImpl) i.next();
        if (info.getTask() == this) {
          info.setTask(null);
        }
      }
    }

    return super.cancel();
  }