InitializationParameters.java

This class provides accessor methods for obtaining Sybase connection parameters. Other methods can be added in the future when there is a need for more parameters. Also using methods in this class allows us to change how we get parameters in the future without having to make changes in other applications that use those parameters.


package cpa.app.vip;

import java.util.*;


/**************************************************************
 * This class provides methods for obtaining initialization
 * parameter values.  If the property does not exist
 * in System properties then the the parameter is obtained
 * through reading an XML file.  Once the property is read
 * from an XML file the property is stored to System
 * properties where in can be referenced subsequently without
 * having to perform disk access.
 *
 * @author Paul McKinney
 **************************************************************/
public class InitializationParameters
{

   InitParamsParser ipp = new InitParamsParser();

   public String getSybaseUser1()
   {
      String id = null;

      id = System.getProperty("cpa.app.vip.SybaseDbms1.id");
      if (id == null)
      {
         Properties props = new Properties();
         id = ipp.getInitParam("SybaseDbms1", "id");
         props.put("cpa.app.vip.SybaseDbms1.id", id);
         System.setProperties(props);
      }

      return id;
   }


   public String getSybasePassword1()
   {
      String password = null;

      password = System.getProperty("cpa.app.vip.SybaseDbms1.password");
      if (password == null)
      {
         Properties props = new Properties();
         password = ipp.getInitParam("SybaseDbms1", "password");
         props.put("cpa.app.vip.SybaseDbms1.password", password);
         System.setProperties(props);
      }

      return password;
   }


   public String getSybaseUrl1()
   {
      String url = null;

      url = System.getProperty("cpa.app.vip.SybaseDbms1.url");
      if (url == null)
      {
         Properties props = new Properties();
         url = ipp.getInitParam("SybaseDbms1", "url");
         props.put("cpa.app.vip.SybaseDbms1.url", url);
         System.setProperties(props);
      }

      return url;
   }

}