Rio Project 4.2 API Documentation



org.rioproject.config
Class ConfigHelper

java.lang.Object
  extended by org.rioproject.config.ConfigHelper

public class ConfigHelper
extends Object

Utility for accessing configuration arguments

Author:
Dennis Reedy

Field Summary
static String CLASSPATH_RESOURCE
           
static String FILE_RESOURCE
           
 
Constructor Summary
ConfigHelper()
           
 
Method Summary
static String[] getConfigArgs(String... args)
          Get configuration arguments to create a Configuration object
static String[] getConfigArgs(String[] args, ClassLoader cl)
          Get configuration arguments to create a Configuration object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASSPATH_RESOURCE

public static final String CLASSPATH_RESOURCE
See Also:
Constant Field Values

FILE_RESOURCE

public static final String FILE_RESOURCE
See Also:
Constant Field Values
Constructor Detail

ConfigHelper

public ConfigHelper()
Method Detail

getConfigArgs

public static String[] getConfigArgs(String... args)
                              throws IOException
Get configuration arguments to create a Configuration object

Parameters:
args - Arguments to be used by a ConfigurationProvider to create a Configuration
Returns:
  • If the first parameter of the args parameters is a "-", return the args parameter intact.
  • If the first element of the args parameter begins with classpath:, load the URL of the configuration file as a resource using the current context classloader, and return the URL.toString() of the loaded resource. Only the first element of the args parameter is used to construct the configuration argument.
  • If the first element of the args parameter begins with file:, return the canonical path of the file. If the parameter does not include a leading File.separator, the file location will be considered relative to the current working directory. If there are any system property elements defined in the args element, they will be translated to the corresponding system properties of the running JVM.
  • If the first element of the args parameter ends with .config, return the args parameter intact. If there are any system property elements defined in the args element, they will be translated to the corresponding system properties of the running JVM.
  • Otherwise, create a temporary file containing the contents of the args value and return the canonical path of the created file as the configuration argument
Throws:
IllegalArgumentException - if the args parameter is null or of zero length
IOException - if there are errors accessing the file system

getConfigArgs

public static String[] getConfigArgs(String[] args,
                                     ClassLoader cl)
                              throws IOException
Get configuration arguments to create a Configuration object

Parameters:
args - Arguments to be used by a ConfigurationProvider to create a Configuration
cl - The ClassLoader to use if resources need to be loaded. If null, the threads current context classloader is used
Returns:
  • If the first parameter of the args parameters is a "-", return the args parameter intact.
  • If the first element of the args parameter begins with classpath:, load the URL of the configuration file as a resource using the current context classloader, and return the URL.toString() of the loaded resource. Only the first element of the args parameter is used to construct the configuration argument.
  • If the first element of the args parameter begins with file:, return the canonical path of the file. If the parameter does not include a leading File.separator, the file location will be considered relative to the current working directory. If there are any system property elements defined in the args element, they will be translated to the corresponding system properties of the running JVM.
  • If the first element of the args parameter ends with .config or .groovy, return the args parameter intact. If there are any system property elements defined in the args element, they will be translated to the corresponding system properties of the running JVM.
  • Otherwise, create a temporary file containing the contents of the args value and return the canonical path of the created file as the configuration argument
Throws:
IllegalArgumentException - if the args parameter is null or of zero length
IOException - if there are errors accessing the file system

Copyright © Rio Project.

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