Example #1
0
  /**
   * Called at initialization. Reads in config properties.
   *
   * @param arg0
   */
  @Override
  public void contextInitialized(ServletContextEvent arg0) {

    try {
      String configFileLocation =
          arg0.getServletContext().getInitParameter(FILE_LOCATION_PARAM_NAME);

      System.out.println(
          "Reading from web.xml file the context-param name "
              + FILE_LOCATION_PARAM_NAME
              + " from the web.xml file to "
              + "determine the name of the Java properties configuration "
              + "file.");

      // If not params file configured in web.xml complain
      if (configFileLocation == null) {
        System.err.println(
            "Should set the context-param "
                + FILE_LOCATION_PARAM_NAME
                + " in the web.xml file to specify Transitime "
                + "config file to read in.");
        return;
      }

      // Process the params file
      ConfigFileReader.processConfig(configFileLocation);
    } catch (Exception e) {
      // Output error if params file could not be read in
      e.printStackTrace();
    }
  }