/*
 * Copyright (c) 2015-2016, Index Data
 * All rights reserved.
 * See the file LICENSE for details.
 */
package okapi.bean;

public class Ports {

  private final int port_start;
  private final int port_end;
  private final Boolean[] ports;

  public Ports(int port_start, int port_end) {
    this.port_start = port_start;
    this.port_end = port_end;
    this.ports = new Boolean[port_end - port_start];
    for (int i = 0; i < ports.length; i++) {
      ports[i] = false;
    }
  }

  public int get() {
    for (int i = 0; i < ports.length; i++) {
      if (ports[i] == false) {
        ports[i] = true;
        return i + port_start;
      }
    }
    return -1;
  }

  public void free(int p) {
    if (p > 0) {
      ports[p - port_start] = false;
    }
  }
}

@@ -121,16 +121,98 @@
 .bean;%0A%0A
+import io.vertx.core.logging.Logger;%0Aimport io.vertx.core.logging.LoggerFactory;%0A%0A
 public c
@@ -321,16 +321,83 @@
 ports;%0A%0A
+  private final Logger logger = LoggerFactory.getLogger(%22Ports%22);%0A%0A
   public
@@ -762,22 +762,29 @@
         
-return
+final int p =
  i + por
@@ -788,24 +788,86 @@
 port_start;%0A
+        logger.debug(%22allocate port %22 + p);%0A        return p;%0A
       %7D%0A    
@@ -912,24 +912,24 @@
 ee(int p) %7B%0A
-
     if (p %3E 
@@ -929,24 +929,62 @@
 f (p %3E 0) %7B%0A
+      logger.debug(%22free port %22 + p);%0A
       ports%5B

Add some logging to Ports