public class BootUtil extends Object
Modifier and Type | Class and Description |
---|---|
static class |
BootUtil.NetworkInterfaceWrapper |
static class |
BootUtil.NetworkSnapshot |
static class |
BootUtil.NetworkTuple |
Modifier and Type | Method and Description |
---|---|
static String |
arrayToCommaDelimitedString(Object[] arr)
Convenience method to return a String array as a CSV String.
|
static String |
arrayToDelimitedString(Object[] arr,
String delim)
Convenience method to return a String array as a delimited (e.g.
|
static String |
formatDuration(long duration) |
static String |
getAnonymousPort()
Get an anonymous port
|
static int |
getAvailablePort(String hostname,
String portRange) |
static String |
getCodebase(String[] jars,
String protocol,
String port)
Return the codebase for the provided JAR names and port.
|
static String |
getCodebase(String[] jars,
String protocol,
String address,
String port)
Return the codebase for the provided JAR names, port and address
|
static String |
getHostAddress()
Return the local host address using
java.net.InetAddress.getLocalHost().getHostAddress() |
static NetworkInterface[] |
getNetworkInterfaces() |
static String |
getPortInRange(int minPort,
int maxPort)
Get a free port in supplied port range.
|
static URL |
getResourceURL(String name,
String locatorBaseDir)
Loads the requested resource and returns its URL.
|
static String |
getStackTrace(Throwable t) |
static String[] |
toArray(String arg)
Convert comma delimited and/or space String to array of Strings
|
static LookupLocator[] |
toLookupLocators(String lookupLocatorURLs)
Parse a comma delimited LookupLocator URLs and build array of
LookupLocator out
of it. |
static String |
toLookupLocatorURLs(LookupLocator[] lookupLocators,
boolean removeProtocolPrefix)
Takes an array of LookupLocator builds a comma seperated string of urls out of it.
|
static List<URL> |
toURLs(String element) |
public static String getCodebase(String[] jars, String protocol, String port) throws UnknownHostException
java.net.InetAddress.getLocalHost().getHostAddress()
,
then construct the codebase using the host address and the port for each jar in the array of
jars.jars
- The JAR names to useport
- The port to use when constructing the codebaseUnknownHostException
- if no IP address for the local host could be found.public static String getCodebase(String[] jars, String protocol, String address, String port)
jars
- Array of JAR namesaddress
- The address to use when constructing the codebaseport
- The port to use when constructing the codebasepublic static String getHostAddress() throws UnknownHostException
java.net.InetAddress.getLocalHost().getHostAddress()
UnknownHostException
- if no IP address for the local host could be found.public static String getAnonymousPort() throws IOException
java.net.ServerSocket
with
a port of 0IOException
public static String getPortInRange(int minPort, int maxPort) throws IOException
minPort
- the minimum port number of the port range to scan.maxPort
- the maximum port number of the port range to scan.IOException
public static int getAvailablePort(String hostname, String portRange) throws IOException
IOException
public static List<URL> toURLs(String element) throws MalformedURLException
MalformedURLException
public static String arrayToCommaDelimitedString(Object[] arr)
arr
- array to display. Elements may be of any type (toString will be called on each
element).public static String arrayToDelimitedString(Object[] arr, String delim)
arr
- array to display. Elements may be of any type (toString will be called on each
element).delim
- delimiter to use (probably a ",")public static String[] toArray(String arg)
public static LookupLocator[] toLookupLocators(String lookupLocatorURLs)
LookupLocator
out
of it. For example: "host1:4180,host2:4180,host3:4180"lookupLocatorURLs
- List of LookupLocators urls, separates by ",".LookupLocator
.public static String toLookupLocatorURLs(LookupLocator[] lookupLocators, boolean removeProtocolPrefix)
lookupLocators
- The locatorsremoveProtocolPrefix
- whether the jini:// prefix should be removedpublic static String formatDuration(long duration)
public static NetworkInterface[] getNetworkInterfaces() throws SocketException
SocketException
public static URL getResourceURL(String name, String locatorBaseDir)
name
- name of resource to loadlocatorBaseDir
- if not null we will try to search for the resource in the file system
locatorBaseDir, we will try to recursively search under the
locatorBaseDir as the base search path. By default, false.Copyright © GigaSpaces.