Rio Project 4.2 API Documentation



org.rioproject.boot
Class BootUtil

java.lang.Object
  extended by org.rioproject.boot.BootUtil

public class BootUtil
extends Object

Provides static convenience methods for use in configuration files. This class cannot be instantiated.

Author:
Dennis Reedy

Method Summary
static int getAnonymousPort()
          Get an anonymous port
static String getCodebase(String[] jars, String port)
          Return the codebase for the provided JAR names and port.
static String getCodebase(String[] jars, String address, String port)
          Return the codebase for the provided JAR names, port and address
static String getCodebase(String jar, String port)
          Return the codebase for the provided JAR name and port.
static String getCodebase(String jar, String address, String port)
          Return the codebase for the provided JAR name, port and address
static String getHostAddress()
          Return the local host address using java.net.InetAddress.getLocalHost().getHostAddress()
static String getHostAddress(String name)
          Return the local host address for a passed in host using InetAddress.getByName(String)
static String getHostAddressFromProperty(String property)
          Return the local host address based on the value of a system property.
static String getHostName()
          Return the local host name java.net.InetAddress.getLocalHost().getHostName()
static int getPortFromRange(int start, int end)
          Get a port from a range of ports
static int getPortFromRange(String portRange)
          Get a port from a range of ports
static URL[] scanDirectory(String dirPath)
          Will return an array of URLs for all .jar and .zip files in the directory, including the directory itself
static String[] toArray(String arg)
          Convert a comma, space and/or File.pathSeparator delimited String to array of Strings
static String[] toArray(String arg, String delim)
          Convert a delimited String to array of Strings
static URL[] toURLs(String[] elements)
          Will return an array of URLs based on the input String array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getCodebase

public static String getCodebase(String jar,
                                 String port)
                          throws UnknownHostException
Return the codebase for the provided JAR name and port. This method will first get the IP Address of the machine using java.net.InetAddress.getLocalHost().getHostAddress(), then construct the codebase using the host address and the port for the provided jar.

Parameters:
jar - The JAR to use
port - The port to use when constructing the codebase
Returns:
the codebase for the JAR
Throws:
UnknownHostException - if no IP address for the local host could be found.

getCodebase

public static String getCodebase(String[] jars,
                                 String port)
                          throws UnknownHostException
Return the codebase for the provided JAR names and port. This method will first get the IP Address of the machine using java.net.InetAddress.getLocalHost().getHostAddress(), then construct the codebase using the host address and the port for each jar in the array of jars.

Parameters:
jars - The JAR names to use
port - The port to use when constructing the codebase
Returns:
The codebase as a space-delimited String for the provided JARs
Throws:
UnknownHostException - if no IP address for the local host could be found.

getCodebase

public static String getCodebase(String jar,
                                 String address,
                                 String port)
Return the codebase for the provided JAR name, port and address

Parameters:
jar - The JAR to use
address - The address to use when constructing the codebase
port - The port to use when constructing the codebase
Returns:
the codebase for the JAR

getCodebase

public static String getCodebase(String[] jars,
                                 String address,
                                 String port)
Return the codebase for the provided JAR names, port and address

Parameters:
jars - Array of JAR names
address - The address to use when constructing the codebase
port - The port to use when constructing the codebase
Returns:
the codebase for the JAR

getHostAddress

public static String getHostAddress()
                             throws UnknownHostException
Return the local host address using java.net.InetAddress.getLocalHost().getHostAddress()

Returns:
The local host address
Throws:
UnknownHostException - if no IP address for the local host could be found.

getHostAddress

public static String getHostAddress(String name)
                             throws UnknownHostException
Return the local host address for a passed in host using InetAddress.getByName(String)

Parameters:
name - The name of the host to return
Returns:
The local host address
Throws:
UnknownHostException - if no IP address for the host name could be found.

getHostAddressFromProperty

public static String getHostAddressFromProperty(String property)
                                         throws UnknownHostException
Return the local host address based on the value of a system property. using InetAddress.getByName(String). If the system property is not resolvable, return the default host address obtained from InetAddress.getLocalHost()

Parameters:
property - The property name to use
Returns:
The local host address
Throws:
UnknownHostException - if no IP address for the host name could be found.

getHostName

public static String getHostName()
                          throws UnknownHostException
Return the local host name java.net.InetAddress.getLocalHost().getHostName()

Returns:
The local host name
Throws:
UnknownHostException - if no hostname for the local host could be found.

getAnonymousPort

public static int getAnonymousPort()
                            throws IOException
Get an anonymous port

Returns:
An anonymous port created by instantiating a java.net.ServerSocket with a port of 0
Throws:
IOException - If an anonymous port cannot be obtained

getPortFromRange

public static int getPortFromRange(String portRange)
                            throws IOException
Get a port from a range of ports

Parameters:
portRange - A range of ports. The port range is specified as "-" delimited string, startRange-endRange, where startRange and endRange are inclusive.
Returns:
An port created by instantiating a org.rioproject.net.PortRangeServerSocketFactory with provided range
Throws:
IOException - If a port cannot be obtained
IllegalArgumentException - is either bound is not between 0 and 65535, or if end is < than low.

getPortFromRange

public static int getPortFromRange(int start,
                                   int end)
                            throws IOException
Get a port from a range of ports

Parameters:
start - The range to start from (inclusive)
end - The end of the range (inclusive)
Returns:
A port created by instantiating a org.rioproject.net.PortRangeServerSocketFactory with provided range
Throws:
IOException - If a port cannot be obtained
IllegalArgumentException - is either bound is not between 0 and 65535, or if end is < than low.

toURLs

public static URL[] toURLs(String[] elements)
                    throws MalformedURLException
Will return an array of URLs based on the input String array. If the array element is a file, the fully qualified file path must be provided. If the array element is a directory, a fully qualified directory path must be provided, and the directory will be searched for all .jar and .zip files

Parameters:
elements - A String array of fully qualified directory path
Returns:
An URL[] elements
Throws:
MalformedURLException - if any of the elements cannot be converted

scanDirectory

public static URL[] scanDirectory(String dirPath)
                           throws MalformedURLException
Will return an array of URLs for all .jar and .zip files in the directory, including the directory itself

Parameters:
dirPath - A fully qualified directory path
Returns:
A URL[] for all .jar and .zip files in the directory, including the directory itself
Throws:
MalformedURLException - If elements in the directory cannot be created into a URL

toArray

public static String[] toArray(String arg)
Convert a comma, space and/or File.pathSeparator delimited String to array of Strings

Parameters:
arg - The String to convert
Returns:
An array of Strings

toArray

public static String[] toArray(String arg,
                               String delim)
Convert a delimited String to array of Strings

Parameters:
arg - The String to convert
delim - the delimiters to use
Returns:
An array of Strings

Copyright © Rio Project.

Copyright © 2006-2011 Rio Project. All Rights Reserved.