public class TransportUtils extends Object
Modifier and Type | Field and Description |
---|---|
static int |
MAX_PORT_NUMBER |
static int |
MIN_PORT_NUMBER |
Constructor and Description |
---|
TransportUtils() |
Modifier and Type | Method and Description |
---|---|
static int |
getAvailablePort(int randomAttempts)
Attempts to find a free port between the MIN_PORT_NUMBER(9000) and MAX_PORT_NUMBER(11000).
|
static Map<String,String> |
getHostAndPort(String ipString)
Given a server endpoint as a String, this method splits it into Protocol, Host and Port
|
static HttpURLConnection |
getHttpConnection(String urlString)
This is a utility method that creates and returns a HTTP connection object.
|
static Map<String,String> |
getInterfaceIPMap() |
static String |
readResponseFromHttpRequest(HttpURLConnection httpConnection)
This is a utility method that reads and returns the response from a HTTP connection
|
static boolean |
validateIPv4(String ipAddress)
This method validates whether a specific IP Address is of IPv4 type
|
public static final int MIN_PORT_NUMBER
public static final int MAX_PORT_NUMBER
public static Map<String,String> getHostAndPort(String ipString) throws TransportHandlerException
ipString
- a network endpoint in the format - 'TransportHandlerException
public static boolean validateIPv4(String ipAddress)
ipAddress
- the IP Address which needs to be validatedpublic static Map<String,String> getInterfaceIPMap() throws TransportHandlerException
TransportHandlerException
public static int getAvailablePort(int randomAttempts)
randomAttempts
- no of times to TEST port numbers picked randomly over the given rangepublic static HttpURLConnection getHttpConnection(String urlString) throws TransportHandlerException
urlString
- the URL pattern to which the connection needs to be createdTransportHandlerException
- if errors occur when creating the HTTP connection with
the given URL stringpublic static String readResponseFromHttpRequest(HttpURLConnection httpConnection) throws TransportHandlerException
httpConnection
- the connection from which a response is expectedTransportHandlerException
- if any errors occur whilst reading the response from
the connection streamCopyright © 2017 WSO2. All rights reserved.