Example #1
0
  /**
   * Initializes this object loading the initialization parameters. Does nothing if this method has
   * already been called, even if the previous call threw any exception.
   *
   * @throws Exception If any required parameter is undefined.
   */
  public void init(ServletConfig sc, Log log) throws Exception {
    if (!initCalled) {
      initCalled = true;
      // Read in the required properties:
      for (Prop prop : Prop.values()) {
        String value = sc.getInitParameter(prop.getName());
        if (value != null && value.trim().length() > 0) {
          prop.setValue(value);
        } else if (prop.getValue() == null) {
          throw new Exception("Required init parameter not defined: " + prop.getName());
        }
      }

      if (log != null && log.isDebugEnabled()) {
        for (Prop prop : Prop.values()) {
          log.debug(prop.getName() + " = " + prop.getValue());
        }
      }
    }
  }