Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Project Rio
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jini.rio.boot
Class BootUtil

    java.lang.Object
      org.jini.rio.boot.BootUtil

    public class BootUtil

extends Object

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

Method Summary
`static String[]` | `createConfigArgs(String configFile, String[] overrides)` Assemble a String array suitable for use as Jini configuration options.
`static URL` | `fileToURL(String filePath)` Get an URL from a fully qualified file path
`static String` | `getAnonymousPort()` Get an anonymous port
`static String` | `getClasspath(String[] jars)` Return the classpath for the provided JAR names.
`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 String[]` | `parseOverrides(String propertiesFile)` Read the properties file and return an array of String instances which can be used as Jini configuration overrides
`static String[]` | `parseOverrides(String propertiesFile, String[] components)` Read the properties file and return an array of String instances which can be used as Jini configuration overrides
`static URL[]` | `scanDirectory(String dirPath)` Will return an array of URLs for all .jar and .zip files in the directory
`static String[]` | `toArray(String arg)` Convert comma delimited and/or space String to array of Strings
`static URL[]` | `toURLs(String[] elements)` Will return an array of URLs base 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

### getClasspath

    public static String getClasspath(String[] jars)

  Return the classpath for the provided JAR names.

  Parameters:
    `jars` - Array of JAR names
  Returns:
    The classpath with system dependant path delimeters

### 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 String 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

### fileToURL

    public static URL fileToURL(String filePath)
                         throws MalformedURLException

  Get an URL from a fully qualified file path

  Parameters:
    `filePath` - A fully qualified file path
  Returns:
    The URL from the file if the file exists
  Throws:
    `MalformedURLException` - If the filePath cannot be converted

### toURLs

    public static URL[] toURLs(String[] elements)
                        throws MalformedURLException

  Will return an array of URLs base 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 aray 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

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

### toArray

    public static String[] toArray(String arg)

  Convert comma delimited and/or space String to array of Strings

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

### parseOverrides

    public static String[] parseOverrides(String propertiesFile)
                                   throws IOException

  Read the properties file and return an array of String instances which can be used as Jini configuration overrides

  Parameters:
    `propertiesFile` - A Properties file containig override declarations
  Returns:
    An array of String values suitable for use as Jini configuration overrides. If the propeties file is empty return a zero-length array
  Throws:
    `NullPointerException` - if propertiesFile is null
    `IOException` - if the Properties file cannot be read

### parseOverrides

    public static String[] parseOverrides(String propertiesFile,
                                          String[] components)
                                   throws IOException

  Read the properties file and return an array of String instances which can be used as Jini configuration overrides

  Parameters:
    `propertiesFile` - A Properties file containig override declarations
    `components` - An array of components to match, maty be null. If not null, then if a ket starts with an element in the provided components array it will be p[art of the array of overrides returned. If this parameter is null or zero-length, all property components are returned
  Returns:
    An array of String values suitable for use as Jini configuration overrides. If there are no matching components or the propeties file is empty return a zero-length array
  Throws:
    `NullPointerException` - if propertiesFile is null
    `IOException` - if the Properties file cannot be read

### createConfigArgs

    public static String[] createConfigArgs(String configFile,
                                            String[] overrides)

  Assemble a String array suitable for use as Jini configuration options. The String array whose first element is the configuration source and remaining elements specify override values for entries

  Parameters:
    `configFile` - The location of the configuration file, must not be null
    `overrides` - Array of elements specifying override values for entries, mat be null
  Returns:
    A String array suitable for use as a Jini configuration
  Throws:
    `NullPointerException` - if configFile is null

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Project Rio
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © Project Rio.