brooklyn.location
Interface PortSupplier


public interface PortSupplier

Mixin interface for location which allows it to supply ports from a given range


Method Summary
 int obtainPort(PortRange range)
          Reserve a port for your application, with a port number in a specific range.
 boolean obtainSpecificPort(int portNumber)
          Reserve a specific port for an application.
 void releasePort(int portNumber)
          Release a previously reserved port.
 

Method Detail

obtainSpecificPort

boolean obtainSpecificPort(int portNumber)
Reserve a specific port for an application. If your application requires a specific port - for example, port 80 for a web server - you should reserve this port before starting your application. Using this method, you will be able to detect if another application has already claimed this port number.

Parameters:
portNumber - the required port number.
Returns:
true if the port was successfully reserved; false if it has been previously reserved.

obtainPort

int obtainPort(PortRange range)
Reserve a port for your application, with a port number in a specific range. If your application requires a port, but it does not mind exactly which port number - for example, a port for internal JMX monitoring - call this method.

Parameters:
range - the range of acceptable port numbers.
Returns:
the port number that has been reserved, or -1 if there was no available port in the acceptable range.

releasePort

void releasePort(int portNumber)
Release a previously reserved port.

Parameters:
portNumber - the port number from a call to obtainPort(PortRange) or obtainSpecificPort(int)


Copyright © 2013. All Rights Reserved.