コード例 #1
0
  @Override
  public void begin(InterpretationContext ec, String name, Attributes attributes)
      throws ActionException {

    inError = false;

    String className = attributes.getValue(CLASS_ATTRIBUTE);
    if (OptionHelper.isEmpty(className)) {
      addError(
          "Mandatory \""
              + CLASS_ATTRIBUTE
              + "\" attribute not set for <loggerContextListener> element");
      inError = true;
      return;
    }

    try {
      lcl =
          (LoggerContextListener)
              OptionHelper.instantiateByClassName(className, LoggerContextListener.class, context);

      if (lcl instanceof ContextAware) {
        ((ContextAware) lcl).setContext(context);
      }

      ec.pushObject(lcl);
      addInfo("Adding LoggerContextListener of type [" + className + "] to the object stack");

    } catch (Exception oops) {
      inError = true;
      addError("Could not create LoggerContextListener of type " + className + "].", oops);
    }
  }
コード例 #2
0
  public void begin(InterpretationContext ec, String name, Attributes attributes)
      throws ActionException {
    inError = false;
    String className = attributes.getValue(CLASS_ATTRIBUTE);
    if (OptionHelper.isEmpty(className)) {
      addError(
          "Missing class name for statusListener. Near [" + name + "] line " + getLineNumber(ec));
      inError = true;
      return;
    }

    try {
      statusListener =
          (StatusListener)
              OptionHelper.instantiateByClassName(className, StatusListener.class, context);
      addInfo("Adding status listener of type [" + className + "]");
      ec.getContext().getStatusManager().add(statusListener);
      if (statusListener instanceof ContextAware) {
        ((ContextAware) statusListener).setContext(context);
      }
      ec.pushObject(statusListener);
    } catch (Exception e) {
      inError = true;
      addError("Could not create an StatusListener of type [" + className + "].", e);
      throw new ActionException(e);
    }
  }