org.edg.security.voms.service
Class Configuration

java.lang.Object
  |
  +--org.edg.security.voms.service.Configuration

public class Configuration
extends java.lang.Object

Provides comfortable access to configuration parameters.
First it tries to locate the configuration directory through JNDI using the "java:comp/env/configDir" environmental variable, which can be set in a servlet context the following way:

  <Context path="/edg-voms-admin" docBase=".../edg-voms-admin.war">
    <Environment name="configDir" value=".../etc/edg-voms-admin"
                   type="java.lang.String" override="false"/>
  </Context>
  

The second guess is through the system property called "voms.configuration.directory", which can be set on the command line:
    java ... -Dvoms.configuration.directory=.../etc/edg-voms-admin
  

The third guess is the default or central configuration directory, which comes with the original installation. But this is only a guess, based on the assumption that the configuration directory is something like .../var/etc/edg-voms-admin/.... This string will be replaced by .../etc/edg-voms-admin.
If none of the above are set, then it will try to load the configuration files from the classpath.

Version:
$Name: v0_7_0 $
Author:
Karoly Lorentey

Field Summary
private static Configuration conf
          The single Configuration object.
private  java.lang.String configDir
          The location of the configuration files.
private  java.lang.String defaultConfigDir
          The location of the default configuration files.
private  boolean loaded
          Indicates that the configuration file was successfully loaded.
private static org.apache.log4j.Logger log
           
static java.lang.String[] propertiesFiles
          The name of the configurations file for VOMS services.
private  java.util.Properties props
          The standard Java Properties object that holds our properties.
 
Constructor Summary
protected Configuration()
          Loads service parameters from the above configuration files.
 
Method Summary
protected  java.io.InputStream getConfigResource(java.lang.String resource)
          Finds a file with the given name in the configuration directories.
static java.io.InputStream getConfigResourceAsStream(java.lang.String resource)
          Finds a file with the given name in the configuration directories or returns null.
static boolean getFlag(java.lang.String key)
          Returns the value of a boolean flag (convenience method).
static boolean getFlag(java.lang.String key, boolean defaultValue)
          Returns the value of a boolean flag (convenience method).
static int getInt(java.lang.String key, int defaultValue)
          Returns the value of an integer value (convenience method).
static long getLong(java.lang.String key, long defaultValue)
          Returns the value of an long value (convenience method).
static java.util.Properties getProperties()
          Returns the whole properties table.
static java.lang.String getProperty(java.lang.String key)
          Returns the value of the given property, or null if there is no such property.
static java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)
          Returns the value of the given property, or default if there is no such property.
protected  java.io.InputStream getResource(java.lang.String resource)
          Finds a file with the given name in the configuration directories.
static boolean isLoaded()
          Returns true if the configuration file was successfully loaded.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

conf

private static Configuration conf
The single Configuration object.


props

private java.util.Properties props
The standard Java Properties object that holds our properties.


propertiesFiles

public static final java.lang.String[] propertiesFiles
The name of the configurations file for VOMS services.


configDir

private java.lang.String configDir
The location of the configuration files. In the case we don't use the classloader to pick them up, because we cannot store them in a war file. The location is retrieved through JNDI.


defaultConfigDir

private java.lang.String defaultConfigDir
The location of the default configuration files. These can be usually overwritten by the files in the VO specific configuration directory.


loaded

private boolean loaded
Indicates that the configuration file was successfully loaded.


log

private static org.apache.log4j.Logger log
Constructor Detail

Configuration

protected Configuration()
Loads service parameters from the above configuration files.

Method Detail

getResource

protected java.io.InputStream getResource(java.lang.String resource)
                                   throws java.io.IOException
Finds a file with the given name in the configuration directories.

java.io.IOException

getConfigResource

protected java.io.InputStream getConfigResource(java.lang.String resource)
Finds a file with the given name in the configuration directories.


getConfigResourceAsStream

public static java.io.InputStream getConfigResourceAsStream(java.lang.String resource)
Finds a file with the given name in the configuration directories or returns null.


getProperty

public static java.lang.String getProperty(java.lang.String key)
Returns the value of the given property, or null if there is no such property.


getProperty

public static java.lang.String getProperty(java.lang.String key,
                                           java.lang.String defaultValue)
Returns the value of the given property, or default if there is no such property.


getProperties

public static java.util.Properties getProperties()
Returns the whole properties table.

It is not a wise idea to return the whole table, however the mail session object requires its settings in a Properties object. Unless we copy everything one-by-one, this is the easiest way to export it.

Returning a javax.mail.Session object from this class is not a great idea, because that would introduce unnecessary dependencies.

The ideal solution would be making EmailNotification a friend class...

See Also:
org.edg.security.voms.notificateion.EmailNotification

getFlag

public static boolean getFlag(java.lang.String key)
Returns the value of a boolean flag (convenience method). Returns false if the value of the given property is one of "false", "off", or "no"; otherwise returns true.


getFlag

public static boolean getFlag(java.lang.String key,
                              boolean defaultValue)
Returns the value of a boolean flag (convenience method). Returns false if the value of the given property is one of "false", "off", or "no"; otherwise returns true.


getInt

public static int getInt(java.lang.String key,
                         int defaultValue)
Returns the value of an integer value (convenience method).


getLong

public static long getLong(java.lang.String key,
                           long defaultValue)
Returns the value of an long value (convenience method).


isLoaded

public static boolean isLoaded()
Returns true if the configuration file was successfully loaded.