예제 #1
1
  private void loop() {
    while (thread == Thread.currentThread()) {
      try {
        Request key = peekKey();
        if (key == null) throw new IOException("end of stream");
        synchronized (response_map) {
          Response response = (Response) response_map.get(key);
          if (response == null) {
            if (log.level >= 4) log.println("Invalid key, skipping message");
            doSkip();
          } else {
            doRecv(response);
            response.isReceived = true;
            response_map.notifyAll();
          }
        }
      } catch (Exception ex) {
        String msg = ex.getMessage();
        boolean timeout = msg != null && msg.equals("Read timed out");
        /* If just a timeout, try to disconnect gracefully
         */
        boolean hard = timeout == false;

        if (!timeout && log.level >= 3) ex.printStackTrace(log);

        try {
          disconnect(hard);
        } catch (IOException ioe) {
          ioe.printStackTrace(log);
        }
      }
    }
  }
예제 #2
0
 public void run() {
   String line;
   String id = null;
   seqs = new HashMap<String, StringBuffer>();
   try {
     //      System.err.println("quality read start");  // debug
     while (true) {
       line = br.readLine();
       // FIX ME: update to use reader...
       if (line == null) break;
       // EOF
       if (line.indexOf(">") == 0) {
         String[] stuff = line.substring(1).split("\\s+");
         id = new String(stuff[0]);
         // HACK, WRONG if line contains comments...
       } else {
         // sequence
         StringBuffer sb = seqs.get(id);
         if (sb == null) seqs.put(id, sb = new StringBuffer());
         sb.append(line);
       }
     }
     data_loaded = true;
     //      System.err.println("quality read end");  // debug
   } catch (Exception e) {
     System.err.println("FASTASequenceReader load error: " + e); // debug
     System.exit(1);
   }
 }
예제 #3
0
 /**
  * Returns the index of the given relation in the relation sort order, or the index of "*" if the
  * relation is not explicitly listed.
  */
 public Integer getRelationSortIndex(String rel) {
   Integer retval = _relationIndexMap.get(rel);
   if (retval != null) return retval;
   retval = _relationIndexMap.get("*");
   if (retval != null) return retval;
   return new Integer(-1);
 }
예제 #4
0
  /**
   * Returns an icon for the specified file.
   *
   * @param file file reference
   * @return icon
   */
  public static Icon file(final IOFile file) {
    if (file == null) return UNKNOWN;

    // fallback code for displaying icons
    final String path = file.path();
    final MediaType type = MediaType.get(path);
    if (type.isXML()) return XML;
    if (type.isXQuery()) return XQUERY;
    if (path.contains(IO.BASEXSUFFIX)) return BASEX;

    // only works with standard dpi (https://bugs.openjdk.java.net/browse/JDK-6817929)
    if (Prop.WIN && !GUIConstants.large()) {
      // retrieve system icons (only supported on Windows)
      final int p = path.lastIndexOf(path, '.');
      final String suffix = p == -1 ? null : path.substring(p + 1);
      Icon icon = null;
      if (suffix != null) icon = FILES.get(suffix);
      if (icon == null) {
        icon = FS.getSystemIcon(file.file());
        if (suffix != null) FILES.put(suffix, icon);
      }
      return icon;
    }
    // default icon chooser
    return type.isText() ? TEXT : UNKNOWN;
  }
예제 #5
0
  public void save() {
    for (String key : fields.keySet()) {
      JComponent comp = fields.get(key);

      if (comp instanceof JTextField) {
        JTextField c = (JTextField) comp;

        if (c.getText().trim().equals("")) {
          sketch.configFile.unset(key);
        } else {
          sketch.configFile.set(key, c.getText());
        }
      } else if (comp instanceof JTextArea) {
        JTextArea c = (JTextArea) comp;

        if (c.getText().trim().equals("")) {
          sketch.configFile.unset(key);
        } else {
          sketch.configFile.set(key, c.getText());
        }
      }
    }

    sketch.saveConfig();
  }
예제 #6
0
 public void setObjectValues() {
   ((JTextField) (fields.get("board"))).setText(sketch.getBoard().getName());
   ((JTextField) (fields.get("core"))).setText(sketch.getCore().getName());
   ((JTextField) (fields.get("compiler"))).setText(sketch.getCompiler().getName());
   ((JTextField) (fields.get("port"))).setText(sketch.getDevice().toString());
   ((JTextField) (fields.get("programmer"))).setText(sketch.getProgrammer());
 }
예제 #7
0
  /**
   * Returns the specified image as icon.
   *
   * @param name name of icon
   * @return icon
   */
  public static ImageIcon icon(final String name) {
    ImageIcon ii = ICONS.get(name);
    if (ii != null) return ii;

    Image img;
    if (GUIConstants.scale > 1) {
      // choose large image or none
      final URL url =
          GUIConstants.large() ? BaseXImages.class.getResource("/img/" + name + "_32.png") : null;

      if (url == null) {
        // resize low-res image if no hi-res image exists
        img = get(url(name));
        final int w = (int) (img.getWidth(null) * GUIConstants.scale);
        final int h = (int) (img.getHeight(null) * GUIConstants.scale);
        final BufferedImage tmp = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
        final Graphics2D g2 = tmp.createGraphics();
        g2.setRenderingHint(
            RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
        g2.drawImage(img, 0, 0, w, h, null);
        g2.dispose();
        img = tmp;
      } else {
        img = get(url);
      }
    } else {
      img = get(name);
    }
    ii = new ImageIcon(img);
    ICONS.put(name, ii);
    return ii;
  }
  JarFile get(URL url, boolean useCaches) throws IOException {

    JarFile result = null;
    JarFile local_result = null;

    if (useCaches) {
      synchronized (this) {
        result = getCachedJarFile(url);
      }
      if (result == null) {
        local_result = URLJarFile.getJarFile(url);
        synchronized (this) {
          result = getCachedJarFile(url);
          if (result == null) {
            fileCache.put(url, local_result);
            urlCache.put(local_result, url);
            result = local_result;
          } else {
            if (local_result != null) {
              local_result.close();
            }
          }
        }
      }
    } else {
      result = URLJarFile.getJarFile(url);
    }
    if (result == null) throw new FileNotFoundException(url.toString());

    return result;
  }
예제 #9
0
 public void sendrecv(Request request, Response response, long timeout) throws IOException {
   synchronized (response_map) {
     makeKey(request);
     response.isReceived = false;
     try {
       response_map.put(request, response);
       doSend(request);
       response.expiration = System.currentTimeMillis() + timeout;
       while (!response.isReceived) {
         response_map.wait(timeout);
         timeout = response.expiration - System.currentTimeMillis();
         if (timeout <= 0) {
           throw new TransportException(name + " timedout waiting for response to " + request);
         }
       }
     } catch (IOException ioe) {
       if (log.level > 2) ioe.printStackTrace(log);
       try {
         disconnect(true);
       } catch (IOException ioe2) {
         ioe2.printStackTrace(log);
       }
       throw ioe;
     } catch (InterruptedException ie) {
       throw new TransportException(ie);
     } finally {
       response_map.remove(request);
     }
   }
 }
예제 #10
0
  public synchronized void messageReceived(int to, Message m) {

    DrainMsg mhMsg = (DrainMsg) m;

    log.debug(
        "incoming: localDest: "
            + to
            + " type:"
            + mhMsg.get_type()
            + " hops:"
            + (16 - mhMsg.get_ttl())
            + " seqNo:"
            + mhMsg.get_seqNo()
            + " source:"
            + mhMsg.get_source()
            + " finalDest:"
            + mhMsg.get_dest());

    // lets assume that the network cannot buffer more than 25 drain msgs from a single source at a
    // time (should be more than reasonable)
    if (seqNos.containsKey(new Integer(mhMsg.get_source()))) {
      int oldSeqNo = ((Integer) seqNos.get(new Integer(mhMsg.get_source()))).intValue();
      int upperBound = mhMsg.get_seqNo() + 25;
      int wrappedUpperBound = 25 - (255 - mhMsg.get_seqNo());
      if ((oldSeqNo >= mhMsg.get_seqNo() && oldSeqNo < upperBound)
          || (oldSeqNo >= 0 && oldSeqNo < wrappedUpperBound)) {
        log.debug(
            "Dropping message from "
                + mhMsg.get_source()
                + " with duplicate seqNo: "
                + mhMsg.get_seqNo());
        return;
      }
    }
    seqNos.put(new Integer(mhMsg.get_source()), new Integer(mhMsg.get_seqNo()));

    if (to != spAddr && to != MoteIF.TOS_BCAST_ADDR && to != TOS_UART_ADDR) {
      log.debug("Dropping message not for me.");
      return;
    }

    HashSet promiscuousSet = (HashSet) idTable.get(new Integer(BCAST_ID));
    HashSet listenerSet = (HashSet) idTable.get(new Integer(mhMsg.get_type()));

    if (listenerSet != null && promiscuousSet != null) {
      listenerSet.addAll(promiscuousSet);
    } else if (listenerSet == null && promiscuousSet != null) {
      listenerSet = promiscuousSet;
    }

    if (listenerSet == null) {
      log.debug("No Listener for type: " + mhMsg.get_type());
      return;
    }

    for (Iterator it = listenerSet.iterator(); it.hasNext(); ) {
      MessageListener ml = (MessageListener) it.next();
      ml.messageReceived(to, mhMsg);
    }
  }
  /** Looks up the local database, creating if necessary. */
  private DataSource findDatabaseImpl(String url, String driverName) throws SQLException {
    try {
      synchronized (_databaseMap) {
        DBPool db = _databaseMap.get(url);

        if (db == null) {
          db = new DBPool();

          db.setVar(url + "-" + _gId++);

          DriverConfig driver = db.createDriver();

          ClassLoader loader = Thread.currentThread().getContextClassLoader();

          Class driverClass = Class.forName(driverName, false, loader);

          driver.setType(driverClass);
          driver.setURL(url);

          db.init();

          _databaseMap.put(url, db);
        }

        return db;
      }
    } catch (RuntimeException e) {
      throw e;
    } catch (SQLException e) {
      throw e;
    } catch (Exception e) {
      throw ConfigException.create(e);
    }
  }
 public ArrayList getPointList(long handId) {
   ArrayList curList;
   if (_pointLists.containsKey(handId)) curList = (ArrayList) _pointLists.get(handId);
   else {
     curList = new ArrayList(_maxPoints);
     _pointLists.put(handId, curList);
   }
   return curList;
 }
예제 #13
0
 /**
  * Add a ServiceMonitorFilter to this MonitorFilter
  *
  * @param serviceMonitorFilter Service Specific Filter
  * @exception MonitorFilterException
  * @return ServiceMonitorFilter Modified Filter to the capabilities of the service
  */
 public ServiceMonitorFilter addServiceMonitorFilter(ServiceMonitorFilter serviceMonitorFilter)
     throws MonitorFilterException {
   ModuleClassID moduleClassID = serviceMonitorFilter.getModuleClassID();
   if (serviceMonitorFilters.get(moduleClassID) != null)
     throw new MonitorFilterException(
         "Attempt to add a second Monitor Filter for: " + moduleClassID);
   serviceMonitorFilters.put(moduleClassID, serviceMonitorFilter);
   return serviceMonitorFilter;
 }
예제 #14
0
 /**
  * Obtient le socket enregistré correspondant à l'addresse IP donnée.
  *
  * @return le socket correspondant à l'IP source donnée s'il a été enregistré null sinon.
  */
 public Socket popSocket(InetAddress addr) {
   String addrname = toId(addr);
   if (acceptedSockets.containsKey(addrname)) {
     Socket sock = acceptedSockets.get(addrname);
     acceptedSockets.remove(addrname);
     return sock;
   }
   return null;
 }
예제 #15
0
  public void registerListener(int id, MessageListener m) {
    HashSet listenerSet = (HashSet) idTable.get(new Integer(id));

    if (listenerSet == null) {
      listenerSet = new HashSet();
      idTable.put(new Integer(id), listenerSet);
    }
    listenerSet.add(m);
    log.info("New Listener for id=" + id);
  }
예제 #16
0
  void send(String msg) {
    Iterator it = clients.keySet().iterator();

    while (it.hasNext()) {
      try {
        DataOutputStream out = (DataOutputStream) clients.get(it.next());
        out.writeUTF(msg);
      } catch (IOException e) {
      }
    }
  }
예제 #17
0
파일: Main.java 프로젝트: damacode/MyTumblr
 private static void writeDuplicates() {
   Main.status("Writing duplicates.");
   if (!dup_post_list.isEmpty()) {
     Main.status(String.format("%s\t%s", "older_post", "newer_post"));
     for (Post post : dup_post_list.keySet()) {
       Main.status(String.format("%s\t%s", post.post_id, dup_post_list.get(post).post_id));
     }
   } else {
     Main.status("There are no duplicates.");
   }
   Main.status("Writing duplicates done.");
 }
예제 #18
0
 public boolean startProxy(long from, long to) {
   // lazy init for proxy support check quickly in isReadable
   if (ProxyConnections == null) {
     ProxyConnections = new HashMap<Long, EventableChannel>();
   }
   EventableChannel target = Connections.get(to);
   if (target != null) {
     ProxyConnections.put(from, target);
     return true;
   } else {
     return false;
   }
 }
예제 #19
0
  private void addMenuToTray() {
    HashMap categories = new HashMap();

    // create menu list
    Iterator plugins = PluginManager.getInstance().getAvailablePlugins();
    plugins = PluginComparator.sortPlugins(plugins);

    while (plugins.hasNext()) {
      Plugin p = (Plugin) plugins.next();

      JMenu category = (JMenu) categories.get(p.getCategory());
      if (category == null) {
        category = new JMenu(p.getCategory());
        categories.put(p.getCategory(), category);

        // copy menu to real one
        if (!p.getCategory().equals("Invisible")) this.trayIcon.add(category);
      }

      ImageIcon icon = new ImageIcon();
      try {
        icon = new ImageIcon(new URL(p.getDirectory() + p.getIcon()));
        icon = new ImageIcon(icon.getImage().getScaledInstance(16, 16, Image.SCALE_SMOOTH));
      } catch (Exception e) {
        // error at icon loading
      }

      JMenuItem menu = new JMenuItem(p.getTitle(), icon);
      menu.setName(p.getName());
      menu.setToolTipText(p.getToolTip());
      menu.addActionListener(this);
      category.add(menu);
    }

    this.trayIcon.addSeparator();

    // windows
    this.trayIcon.add(new WindowMenu(this));

    // open main interface
    JMenuItem menu = new JMenuItem(tr("open"));
    menu.setName("org.lucane.applications.maininterface");
    menu.addActionListener(this);
    this.trayIcon.add(menu);

    // exit
    menu = new JMenuItem(tr("exit"));
    menu.setName("exit");
    menu.addActionListener(this);
    this.trayIcon.add(menu);
  }
예제 #20
0
 // get relation sort order, or use defaults
 private void loadRelationSortOrder(Element relationSortingElt) {
   // use defaults if no order specified
   if (relationSortingElt == null) {
     for (int i = 0; i < defaultRelationSortOrder.length; i++) {
       _relationIndexMap.put(defaultRelationSortOrder[i], new Integer(i));
     }
     return;
   }
   // otherwise load from 'order' attribute
   String orderAttr = relationSortingElt.getAttributeValue("order");
   String[] relSortOrder = orderAttr.split("\\s+");
   for (int i = 0; i < relSortOrder.length; i++) {
     _relationIndexMap.put(relSortOrder[i], new Integer(i));
   }
 }
예제 #21
0
  void close() {
    try {
      if (mySelector != null) mySelector.close();
    } catch (IOException e) {
    }
    mySelector = null;

    // run down open connections and sockets.
    Iterator<ServerSocketChannel> i = Acceptors.values().iterator();
    while (i.hasNext()) {
      try {
        i.next().close();
      } catch (IOException e) {
      }
    }

    // 29Sep09: We create an ArrayList of the existing connections, then iterate over
    // that to call unbind on them. This is because an unbind can trigger a reconnect,
    // which will add to the Connections HashMap, causing a ConcurrentModificationException.
    // XXX: The correct behavior here would be to latch the various reactor methods to return
    // immediately if the reactor is shutting down.
    ArrayList<EventableChannel> conns = new ArrayList<EventableChannel>();
    Iterator<EventableChannel> i2 = Connections.values().iterator();
    while (i2.hasNext()) {
      EventableChannel ec = i2.next();
      if (ec != null) {
        conns.add(ec);
      }
    }
    Connections.clear();

    ListIterator<EventableChannel> i3 = conns.listIterator(0);
    while (i3.hasNext()) {
      EventableChannel ec = i3.next();
      eventCallback(ec.getBinding(), EM_CONNECTION_UNBOUND, null);
      ec.close();

      EventableSocketChannel sc = (EventableSocketChannel) ec;
      if (sc != null && sc.isAttached()) DetachedConnections.add(sc);
    }

    ListIterator<EventableSocketChannel> i4 = DetachedConnections.listIterator(0);
    while (i4.hasNext()) {
      EventableSocketChannel ec = i4.next();
      ec.cleanup();
    }
    DetachedConnections.clear();
  }
  private JarFile getCachedJarFile(URL url) {
    JarFile result = (JarFile) fileCache.get(url);

    /* if the JAR file is cached, the permission will always be there */
    if (result != null) {
      Permission perm = getPermission(result);
      if (perm != null) {
        SecurityManager sm = System.getSecurityManager();
        if (sm != null) {
          try {
            sm.checkPermission(perm);
          } catch (SecurityException se) {
            // fallback to checkRead/checkConnect for pre 1.2
            // security managers
            if ((perm instanceof java.io.FilePermission)
                && perm.getActions().indexOf("read") != -1) {
              sm.checkRead(perm.getName());
            } else if ((perm instanceof java.net.SocketPermission)
                && perm.getActions().indexOf("connect") != -1) {
              sm.checkConnect(url.getHost(), url.getPort());
            } else {
              throw se;
            }
          }
        }
      }
    }
    return result;
  }
예제 #23
0
  /** {@inheritDoc} */
  public void initializeFrom(Element element) throws DocumentSerializationException {
    for (Enumeration e = element.getChildren(); e.hasMoreElements(); ) {
      Element serviceElement = (TextElement) e.nextElement();
      String tagName = (String) serviceElement.getKey();

      if (tagName.equals("service")) {
        try {
          ModuleClassID moduleClassID =
              (ModuleClassID)
                  IDFactory.fromURI(
                      new URI(
                          DocumentSerializableUtilities.getString(
                              serviceElement, "moduleClassID", "ERROR")));

          try {
            ServiceMonitorFilter serviceMonitorFilter =
                MonitorResources.createServiceMonitorFilter(moduleClassID);
            serviceMonitorFilter.init(moduleClassID);
            Element serviceMonitorFilterElement =
                DocumentSerializableUtilities.getChildElement(serviceElement, "serviceFilter");
            serviceMonitorFilter.initializeFrom(serviceMonitorFilterElement);
            serviceMonitorFilters.put(moduleClassID, serviceMonitorFilter);
          } catch (Exception ex) {
            if (unknownModuleClassIDs == null) unknownModuleClassIDs = new LinkedList();

            unknownModuleClassIDs.add(moduleClassID);
          }
        } catch (URISyntaxException jex) {
          throw new DocumentSerializationException("Can't get ModuleClassID", jex);
        }
      }
    }
  }
예제 #24
0
 public void disconnect(boolean hard) throws IOException {
   synchronized (setupDiscoLock) {
     synchronized (this) {
       switch (state) {
         case 0: /* not connected - just return */
           return;
         case 2:
           hard = true;
         case 3: /* connected - go ahead and disconnect */
           if (response_map.size() != 0 && !hard) {
             break; /* outstanding requests */
           }
           doDisconnect(hard);
         case 4: /* in error - reset the transport */
           thread = null;
           state = 0;
           break;
         default:
           if (log.level >= 1) log.println("Invalid state: " + state);
           thread = null;
           state = 0;
           break;
       }
     }
   }
 }
예제 #25
0
  // returns a macro adder for the given morph item
  private MacroAdder getMacAdder(MorphItem mi) {

    // check map
    MacroAdder retval = macAdderMap.get(mi);
    if (retval != null) return retval;

    // set up macro adder
    IntHashSetMap macrosFromLex = new IntHashSetMap();
    String[] newMacroNames = mi.getMacros();
    List<MacroItem> macroItems = new ArrayList<MacroItem>();
    for (int i = 0; i < newMacroNames.length; i++) {
      Set<FeatureStructure> featStrucs = (Set<FeatureStructure>) _macros.get(newMacroNames[i]);
      if (featStrucs != null) {
        for (Iterator<FeatureStructure> fsIt = featStrucs.iterator(); fsIt.hasNext(); ) {
          FeatureStructure fs = fsIt.next();
          macrosFromLex.put(fs.getIndex(), fs);
        }
      }
      MacroItem macroItem = _macroItems.get(newMacroNames[i]);
      if (macroItem != null) {
        macroItems.add(macroItem);
      } else {
        // should be checked earlier too
        System.err.println(
            "Warning: macro " + newMacroNames[i] + " not found for word '" + mi.getWord() + "'");
      }
    }
    retval = new MacroAdder(macrosFromLex, macroItems);

    // update map and return
    macAdderMap.put(mi, retval);
    return retval;
  }
예제 #26
0
  void isReadable(SelectionKey k) {
    EventableChannel ec = (EventableChannel) k.attachment();
    long b = ec.getBinding();

    if (ec.isWatchOnly()) {
      if (ec.isNotifyReadable()) eventCallback(b, EM_CONNECTION_NOTIFY_READABLE, null);
    } else {
      myReadBuffer.clear();

      try {
        ec.readInboundData(myReadBuffer);
        myReadBuffer.flip();
        if (myReadBuffer.limit() > 0) {
          if (ProxyConnections != null) {
            EventableChannel target = ProxyConnections.get(b);
            if (target != null) {
              ByteBuffer myWriteBuffer = ByteBuffer.allocate(myReadBuffer.limit());
              myWriteBuffer.put(myReadBuffer);
              myWriteBuffer.flip();
              target.scheduleOutboundData(myWriteBuffer);
            } else {
              eventCallback(b, EM_CONNECTION_READ, myReadBuffer);
            }
          } else {
            eventCallback(b, EM_CONNECTION_READ, myReadBuffer);
          }
        }
      } catch (IOException e) {
        UnboundConnections.add(b);
      }
    }
  }
 /**
  * @param key
  * @param options
  */
 private void addSuffixPluralPattern(String key, HashMap<String, String> options) {
   String option = options.get(key);
   if (option != null) {
     patternMap.put(
         key, Pattern.compile("\\b(\\w{" + minPrefixLength + ",})(" + option + ")s?\\b"));
   }
 }
예제 #28
0
파일: UDP.java 프로젝트: NZDIS/jgroups
    void bundleAndSend() {
      Map.Entry entry;
      IpAddress dest;
      ObjectOutputStream out;
      InetAddress addr;
      int port;
      byte[] data;
      List l;

      if (Trace.trace) {
        Trace.info(
            "UDP.BundlingOutgoingPacketHandler.bundleAndSend()",
            "\nsending msgs:\n" + dumpMessages(msgs));
      }
      synchronized (msgs) {
        stopTimer();

        if (msgs.size() == 0) {
          return;
        }

        for (Iterator it = msgs.entrySet().iterator(); it.hasNext(); ) {
          entry = (Map.Entry) it.next();
          dest = (IpAddress) entry.getKey();
          addr = dest.getIpAddress();
          port = dest.getPort();
          l = (List) entry.getValue();
          try {
            out_stream.reset();
            // BufferedOutputStream bos=new BufferedOutputStream(out_stream);
            out_stream.write(Version.version_id, 0, Version.version_id.length); // write the version
            // bos.write(Version.version_id, 0, Version.version_id.length); // write the version
            out = new ObjectOutputStream(out_stream);
            // out=new ObjectOutputStream(bos);
            l.writeExternal(out);
            out.close(); // needed if out buffers its output to out_stream
            data = out_stream.toByteArray();
            doSend(data, addr, port);
          } catch (IOException e) {
            Trace.error(
                "UDP.BundlingOutgoingPacketHandle.bundleAndSend()",
                "exception sending msg (to dest=" + dest + "): " + e);
          }
        }
        msgs.clear();
      }
    }
예제 #29
0
  public void deregisterListener(int id, MessageListener m) {
    HashSet listenerSet = (HashSet) idTable.get(new Integer(id));

    if (listenerSet == null) {
      throw new IllegalArgumentException("No listeners registered for message type " + id);
    }
    listenerSet.remove(m);
  }
예제 #30
0
 public SocketChannel detachChannel(long sig) {
   EventableSocketChannel ec = (EventableSocketChannel) Connections.get(sig);
   if (ec != null) {
     UnboundConnections.add(sig);
     return ec.getChannel();
   } else {
     return null;
   }
 }