DESY ACOP Beans Home

com.cosylab.application
Class ConfigurationLoader

java.lang.Object
  extended by com.cosylab.application.ConfigurationLoader

public final class ConfigurationLoader
extends java.lang.Object

This class searches for configuration file in several location in well defined order.

Author:
ikriznar

Method Summary
static java.lang.ClassLoader findClassLoader(java.lang.Class c)
          Tries to return class loader from provided class.
static java.util.Properties loadConfiguration(java.lang.Class c, java.lang.String name)
          Loads the configuration from the file name.properties
static java.util.Properties loadConfiguration(java.lang.String name)
          Loads configuration from the file name.properties using default class loader.
static java.util.Properties loadConfigurationFile(java.lang.Class c, java.lang.String propFileName)
          Loads the configuration from the file with the given name using the supplied class's classloader.
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

findClassLoader

public static java.lang.ClassLoader findClassLoader(java.lang.Class c)
Tries to return class loader from provided class. If not possible, tries to return default class loader. If no usable class loader is found, then null is returned.

Parameters:
c - class for witch class loader is searched
Returns:
class loader instance or null

loadConfiguration

public static java.util.Properties loadConfiguration(java.lang.Class c,
                                                     java.lang.String name)
Loads the configuration from the file name.properties

Parameters:
c - the class loader supplier
name - the name of the file (without extension)
Returns:
properties as read from the file

loadConfiguration

public static java.util.Properties loadConfiguration(java.lang.String name)
Loads configuration from the file name.properties using default class loader.

Parameters:
name - the name of the file (without extension)
Returns:
properties as read from the file

loadConfigurationFile

public static java.util.Properties loadConfigurationFile(java.lang.Class c,
                                                         java.lang.String propFileName)
Loads the configuration from the file with the given name using the supplied class's classloader.

Parameters:
c - class loader source
propFileName - the name of the properties file (with extension)
Returns:
properties as read from the file

main

public static void main(java.lang.String[] args)


Copyright © 2010. All Rights Reserved.