Java Globus API: Class PortRange
org.globus.net
Class PortRange
java.lang.Object
|
+--org.globus.net.PortRange
- public class PortRange
- extends java.lang.Object
This class manages the port ranges. It keeps track of which
ports are used and which ones are open.
|
Field Summary |
protected static byte |
UNUSED
|
protected static byte |
USED
|
|
Method Summary |
void |
free(int portNumber)
Releases or frees the port number. |
int |
getFreePort(int lastPortNumber)
Returns first available port. |
static PortRange |
getInstance()
Returns the default instance of this class. |
boolean |
isEnabled()
Checks if the port range is set. |
void |
setUsed(int portNumber)
Sets the port number as used. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
UNUSED
protected static final byte UNUSED
USED
protected static final byte USED
PortRange
protected PortRange()
getInstance
public static PortRange getInstance()
- Returns the default instance of this class.
If the tcp.port.range property is set, the class
will be initialized with the specified port ranges.
- Returns:
- PortRange the default instace of this class.
isEnabled
public boolean isEnabled()
- Checks if the port range is set.
- Returns:
- true if the port range is set, false otherwise.
getFreePort
public int getFreePort(int lastPortNumber)
throws java.io.IOException
- Returns first available port.
- Parameters:
lastPortNumber - port number to start finding the next
available port from. Set it to 0 if
called initialy.- Returns:
- the next available port number from the lastPortNumber.
setUsed
public void setUsed(int portNumber)
- Sets the port number as used.
- Parameters:
portNumber - port number
free
public void free(int portNumber)
- Releases or frees the port number.
(Mark it as unused)
- Parameters:
portNumber - port number