org.nhindirect.stagent.options
Class OptionsManager

java.lang.Object
  extended by org.nhindirect.stagent.options.OptionsManager

public class OptionsManager
extends Object

Manages options tuning and configuration parameters of the agent. Parameters are initialized from JVM parameters or from a properties file if present and can be overridden programmatically.
The following is the order or precedence for applying options:

  1. Programmatic settings
  2. JVM Settings
  3. Properties based settings
  4. Default settings
    1. By default, the manager looks for a properties file named agentSettings.properties in the working directory, but can be overriden using the JVM parameter org.nhindirect.stagent.PropertiesFile providing either the full path and file name or just file name that needs to be located in the working directory.
      Property and JVM setting names are defined in the OptionsParameter class.
      The manager is implemented as a singleton and an instance can be obtained using the getInstance() method.
      Operations on this class are thread safe.

      Since:
      1.4
      Author:
      gm2552

      Method Summary
      static void addInitParameters(Map<String,String> initParams)
                Adds custom init parameters used for options.
      static void destroyInstance()
                Destroys the current manager instance.
      static OptionsManager getInstance()
                Gets the instance of the operations manager.
       OptionsParameter getParameter(String paramName)
                Gets a single option parameter by name.
       Collection<OptionsParameter> getParameters()
                Gets a collection of all set option parameters.
       void setOptionsParameter(OptionsParameter param)
                Sets an options parameter.
       void setOptionsParameters(Collection<OptionsParameter> params)
                Sets a collection of options parameters.
       
      Methods inherited from class java.lang.Object
      equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
       

      Method Detail

      addInitParameters

      public static void addInitParameters(Map<String,String> initParams)
      Adds custom init parameters used for options. Initialization parameters are added as a map of names to JVM parameters/properties. Although not required, names should be name appropriately using the same convention as option parameters. Names are the string used when calling getParameter(String).
      If the OptionsManager has already been initialized with a previous call to getInstance(), the manager immediately searched for JVM parameters in the map's values and loads them into the manager.

      Parameters:
      initParams - A map of option names to JVM parameters.

      destroyInstance

      public static void destroyInstance()
      Destroys the current manager instance. This is mainly intended for testing purposes.


      getInstance

      public static OptionsManager getInstance()
      Gets the instance of the operations manager.

      Returns:
      Instance of the operations manager.

      getParameters

      public Collection<OptionsParameter> getParameters()
      Gets a collection of all set option parameters.

      Returns:
      Collection of all set option parameters.

      getParameter

      public OptionsParameter getParameter(String paramName)
      Gets a single option parameter by name.

      Parameters:
      paramName - The name of the parameter to retrieve.
      Returns:
      The OptionsParameter corresponding to the paremter name. Returns null if a parameter with the name has not be set or loaded from JVM settings.

      setOptionsParameter

      public void setOptionsParameter(OptionsParameter param)
      Sets an options parameter. If an existing setting with the same name already exist, then it will be replaced with this setting.

      Parameters:
      param - The options paremeter to set.

      setOptionsParameters

      public void setOptionsParameters(Collection<OptionsParameter> params)
      Sets a collection of options parameters. If an existing setting with the same name already exist, then it will be replaced with the new setting.

      Parameters:
      params -


      Copyright © 2010-2014 NHIN Direct. All Rights Reserved.