コード例 #1
0
  private ActionConfig buildActionConfig(String path) {
    ActionMapping mapping = new ActionMapping();

    mapping.setName("name,{1}");
    mapping.setPath(path);
    mapping.setScope("request");
    mapping.setUnknown(false);
    mapping.setValidate(true);

    mapping.setPrefix("foo,{1}");
    mapping.setSuffix("bar,{1}");

    mapping.setType("foo.bar.{1}Action");
    mapping.setRoles("public,{1}");
    mapping.setParameter("param,{1}");
    mapping.setAttribute("attrib,{1}");
    mapping.setForward("fwd,{1}");
    mapping.setInclude("include,{1}");
    mapping.setInput("input,{1}");

    ForwardConfig cfg = new ActionForward();

    cfg.setName("name");
    cfg.setPath("path,{1}");
    cfg.setModule("mod{1}");
    cfg.setProperty("foo", "bar,{1}");
    mapping.addForwardConfig(cfg);

    cfg = new ActionForward();
    cfg.setName("name2");
    cfg.setPath("path2");
    cfg.setModule("mod{1}");
    mapping.addForwardConfig(cfg);

    ExceptionConfig excfg = new ExceptionConfig();

    excfg.setKey("foo");
    excfg.setType("foo.Bar");
    excfg.setPath("path");
    mapping.addExceptionConfig(excfg);

    excfg = new ExceptionConfig();
    excfg.setKey("foo2");
    excfg.setType("foo.Bar2");
    excfg.setPath("path2");
    mapping.addExceptionConfig(excfg);

    mapping.setProperty("testprop", "testval");
    mapping.setProperty("testprop2", "test{1}");

    mapping.freeze();

    return mapping;
  }
コード例 #2
0
  private static void registerExceptionHandling(
      final ActionMapping actionMapping, Exceptions exceptions) {
    for (final ExceptionHandling exception : exceptions.value()) {
      final ExceptionConfig exceptionConfig = new ExceptionConfig();

      Class<? extends Exception> exClass = exception.type();
      Class<? extends ExceptionHandler> handlerClass = exception.handler();

      String exceptionHandler = (handlerClass == null ? null : handlerClass.getName());
      if (exceptionHandler == null) {
        final Config appConfig = FenixWebFramework.getConfig();
        exceptionHandler =
            (appConfig.getExceptionHandlerClassname() == null
                ? ExceptionHandler.class.getName()
                : appConfig.getExceptionHandlerClassname());
      }

      String key =
          (exception.key() == null
              ? EXCEPTION_KEY_DEFAULT_PREFIX + exClass.getSimpleName()
              : exception.key());

      exceptionConfig.setKey(key);
      exceptionConfig.setHandler(exceptionHandler);
      exceptionConfig.setType(exClass.getName());

      if (!StringUtils.isEmpty(exception.path())) {
        exceptionConfig.setPath(exception.path());
      }

      if (!StringUtils.isEmpty(exception.scope())) {
        exceptionConfig.setScope(exception.scope());
      }

      actionMapping.addExceptionConfig(exceptionConfig);
    }
  }