OpenNMS API 1.2.9

## org.opennms.core.resource
Class Vault

    java.lang.Object
      org.opennms.core.resource.Vault

public class Vault
extends java.lang.Object

The Vault handles policies for allocating/deallocating scarce resources and stores application configuration properties.

Since our code might be deployed in different environments, this class provides a deployment-neutral way of retrieving scarce resources and configuration properties. Our application code may be deployed as a daemon, command-line interface, graphical user interface, applet, or servlet. Some of the scarce resources we might like to have allocation policies for are database connections, socket connections, RMI connections, CORBA connections, or open temporary files.

Author:
  Lawrence Karnowski , Brian Weaver , OpenNMS

Field Summary
`protected static DbConnectionFactory` `dbConnectionFactory` A delegate object that encapsulates the JDBC database connection allocation management.
`protected static java.lang.String` `homeDir` Stores the directory where the OpenNMS configuration files can be found.
`protected static java.util.Properties` `properties` Holds all the application configuration properties.

Constructor Summary
`private` `Vault()` Private, empty constructor so that this class cannot be instantiated.

Method Summary
`static EventProxy` `createEventProxy()`
`static java.sql.Connection` `getDbConnection()` Retrieve a database connection from the database connection factory.
`static java.lang.String` `getHomeDir()` Get the directory that holds the OpenNMS configuration files.
`static java.util.Properties` `getProperties()` Return the entire set of application configuration properties.
`static java.lang.String` `getProperty(java.lang.String key)` Return property from the configuration parameter list.
`static void` `releaseDbConnection(java.sql.Connection connection)` Replace a database connection from the database connection factory.
`static void` `setDbConnectionFactory(DbConnectionFactory factory)` Set the delegate class for managing JDBC database connection pools.
`static void` `setHomeDir(java.lang.String homeDir)` Set the directory so we will know where we can get the OpenNMS configuration files.
`static void` `setProperties(java.util.Properties properties)` Set the application configuration properties.
`static boolean` `supplementSystemPropertiesFromKey(java.lang.String key)` Adds new keys to the system properties using the passed key name a the properties location instance.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### properties

    protected static java.util.Properties properties

  Holds all the application configuration properties.

### homeDir

    protected static java.lang.String homeDir

  Stores the directory where the OpenNMS configuration files can be found. The default is /opt/OpenNMS.

### dbConnectionFactory

    protected static DbConnectionFactory dbConnectionFactory

  A delegate object that encapsulates the JDBC database connection allocation management. For example, some factories might preallocate connections into pools, or some might allocate connections only when requested.

Constructor Detail

### Vault

    private Vault()

  Private, empty constructor so that this class cannot be instantiated.

Method Detail

### setDbConnectionFactory

    public static void setDbConnectionFactory(DbConnectionFactory factory)

  Set the delegate class for managing JDBC database connection pools. This interface allows us to deploy `Vault` in different environments and using different database connection pooling models.

### getDbConnection

    public static java.sql.Connection getDbConnection()
                                               throws java.sql.SQLException

  Retrieve a database connection from the database connection factory. Depending on the implementation of the delegate `DbConnectionFactory`, this method may wait until a connection is available.

  Returns:
    A database connection.
  Throws:
    `java.sql.SQLException` - If a SQL error occurs while requesting or allocating the connection. This depends on the implementation of `DbConnectionFactory`being used.
    `java.lang.IllegalStateException` - If no `DbConnectionFactory` has been specified.

### releaseDbConnection

    public static void releaseDbConnection(java.sql.Connection connection)
                                    throws java.sql.SQLException

  Replace a database connection from the database connection factory.

  Parameters:
    `connection` - the connection to release
  Throws:
    `java.sql.SQLException` - If a SQL error occurs while replacing or deallocating the connection. This depends on the implementation of `DbConnectionFactory`being used.
    `java.lang.IllegalStateException` - If no `DbConnectionFactory` has been specified.

### setProperties

    public static void setProperties(java.util.Properties properties)

  Set the application configuration properties.

### getProperties

    public static java.util.Properties getProperties()

  Return the entire set of application configuration properties.

### getProperty

    public static java.lang.String getProperty(java.lang.String key)

  Return property from the configuration parameter list.

### setHomeDir

    public static void setHomeDir(java.lang.String homeDir)

  Set the directory so we will know where we can get the OpenNMS configuration files.

### getHomeDir

    public static java.lang.String getHomeDir()

  Get the directory that holds the OpenNMS configuration files.

### supplementSystemPropertiesFromKey

    public static boolean supplementSystemPropertiesFromKey(java.lang.String key)

  Adds new keys to the system properties using the passed key name a the properties location instance. The passed key is used as a key to the system `property` to find the supplementary property information. The returned value should be in the form of a list of file names, each separated by the system `separator` character.

  Once the list of files is recovered, each file is visited and loaded into the system properties. If any file cannot be loaded due to an I/O error then it is skipped as a whole. No partial key sets are laoded into the system properties. Also, this method will not overwrite an existing key in the currently loaded properties.

  Parameters:
    `key` - The key name used to lookup the property path values.
  Returns:
    True if all properties loaded correctly, false if any property file failed to load.

### createEventProxy

    public static EventProxy createEventProxy()

OpenNMS API 1.2.9

Generated by ranger on May 19 2007 2335.