org.kuali.rice.test.remote
Class AvailablePortFinder

java.lang.Object
  extended by org.kuali.rice.test.remote.AvailablePortFinder

public final class AvailablePortFinder
extends Object

Finds currently available server ports.

This class is a verbatim copy of AvailablePortFinder from the camel-test component of the Apache Camel project.

See Also:
IANA.org

Field Summary
static int MAX_PORT_NUMBER
          The maximum server currentMinPort number.
static int MIN_PORT_NUMBER
          The minimum server currentMinPort number.
 
Method Summary
static boolean available(int port)
          Checks to see if a specific currentMinPort is available.
static int getNextAvailable()
          Gets the next available currentMinPort starting at the lowest currentMinPort number.
static int getNextAvailable(int fromPort)
          Gets the next available currentMinPort starting at a currentMinPort.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_PORT_NUMBER

public static final int MIN_PORT_NUMBER
The minimum server currentMinPort number. Set at 1024 to avoid returning privileged currentMinPort numbers.

See Also:
Constant Field Values

MAX_PORT_NUMBER

public static final int MAX_PORT_NUMBER
The maximum server currentMinPort number.

See Also:
Constant Field Values
Method Detail

getNextAvailable

public static int getNextAvailable()
Gets the next available currentMinPort starting at the lowest currentMinPort number. This is the preferred method to use. The port return is immediately marked in use and doesn't rely on the caller actually opening the port.

Throws:
NoSuchElementException - if there are no ports available

getNextAvailable

public static int getNextAvailable(int fromPort)
Gets the next available currentMinPort starting at a currentMinPort.

Parameters:
fromPort - the currentMinPort to scan for availability
Throws:
NoSuchElementException - if there are no ports available

available

public static boolean available(int port)
Checks to see if a specific currentMinPort is available.

Parameters:
port - the currentMinPort to check for availability


Copyright © 2005-2014 The Kuali Foundation. All Rights Reserved.