当前位置: 首页>>代码示例>>Java>>正文


Java ExceptionConfig.setType方法代码示例

本文整理汇总了Java中org.apache.struts.config.ExceptionConfig.setType方法的典型用法代码示例。如果您正苦于以下问题:Java ExceptionConfig.setType方法的具体用法?Java ExceptionConfig.setType怎么用?Java ExceptionConfig.setType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.struts.config.ExceptionConfig的用法示例。


在下文中一共展示了ExceptionConfig.setType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testProcessExceptionConfigClassSubConfigCustomClass

import org.apache.struts.config.ExceptionConfig; //导入方法依赖的package包/类
/**
 * Make sure processExceptionConfigClass() returns the same class instance
 * if the base config isn't using a custom class.
 */
public void testProcessExceptionConfigClassSubConfigCustomClass()
    throws Exception {
    moduleConfig.addExceptionConfig(baseException);

    ExceptionConfig customSub = new ExceptionConfig();

    customSub.setType("java.lang.IllegalStateException");
    customSub.setExtends("java.lang.NullPointerException");
    moduleConfig.addExceptionConfig(customSub);

    ExceptionConfig result =
        actionServlet.processExceptionConfigClass(customSub, moduleConfig,
            null);

    assertSame("The instance returned should be the param given it.",
        customSub, result);
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:22,代码来源:TestActionServlet.java

示例2: testProcessActionExtensionWithExceptionConfig

import org.apache.struts.config.ExceptionConfig; //导入方法依赖的package包/类
/**
 * Test that an ActionConfig's ExceptionConfig can inherit from a
 * global ExceptionConfig.
 */
public void testProcessActionExtensionWithExceptionConfig()
    throws ServletException {
    ExceptionConfig exceptionConfig = new ExceptionConfig();
    exceptionConfig.setType("SomeException");
    exceptionConfig.setExtends("java.lang.NullPointerException");
    baseAction.addExceptionConfig(exceptionConfig);

    moduleConfig.addActionConfig(baseAction);
    moduleConfig.addExceptionConfig(baseException);
    actionServlet.processActionConfigExtension(baseAction, moduleConfig);

    exceptionConfig = baseAction.findExceptionConfig("SomeException");

    assertEquals("SomeException's inheritance was not processed.",
        baseException.getKey(), exceptionConfig.getKey());
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:21,代码来源:TestActionServlet.java

示例3: registerExceptionHandling

import org.apache.struts.config.ExceptionConfig; //导入方法依赖的package包/类
private static void registerExceptionHandling(final ActionMapping actionMapping, Class<?> actionClass) {
    for (final ExceptionHandling exception : actionClass.getAnnotationsByType(ExceptionHandling.class)) {
        final ExceptionConfig exceptionConfig = new ExceptionConfig();

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

        exceptionConfig.setKey(Strings.emptyToNull(exception.key()));
        exceptionConfig.setHandler(handlerClass.getName());
        exceptionConfig.setType(exClass.getName());

        if (!Strings.isNullOrEmpty(exception.path())) {
            exceptionConfig.setPath(exception.path());
        }

        if (!Strings.isNullOrEmpty(exception.scope())) {
            exceptionConfig.setScope(exception.scope());
        }

        actionMapping.addExceptionConfig(exceptionConfig);
    }
}
 
开发者ID:FenixEdu,项目名称:bennu-renderers,代码行数:23,代码来源:StrutsAnnotationsPlugIn.java

示例4: testProcessExceptionConfigClass

import org.apache.struts.config.ExceptionConfig; //导入方法依赖的package包/类
/**
 * Make sure processExceptionConfigClass() returns an instance of the
 * correct class if the base config is using a custom class.
 */
public void testProcessExceptionConfigClass()
    throws Exception {
    CustomExceptionConfig customBase = new CustomExceptionConfig();

    customBase.setType("java.lang.NullPointerException");
    customBase.setKey("msg.exception.npe");
    moduleConfig.addExceptionConfig(customBase);

    ExceptionConfig customSub = new ExceptionConfig();

    customSub.setType("java.lang.IllegalStateException");
    customSub.setExtends("java.lang.NullPointerException");
    moduleConfig.addExceptionConfig(customSub);

    ExceptionConfig result =
        actionServlet.processExceptionConfigClass(customSub, moduleConfig,
            null);

    assertTrue("Incorrect class of exception config",
        result instanceof CustomExceptionConfig);
    assertEquals("Incorrect type", customSub.getType(), result.getType());
    assertEquals("Incorrect key", customSub.getKey(), result.getKey());
    assertEquals("Incorrect extends", customSub.getExtends(),
        result.getExtends());

    assertSame("Result was not registered in the module config", result,
        moduleConfig.findExceptionConfig("java.lang.IllegalStateException"));
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:33,代码来源:TestActionServlet.java

示例5: initializeExceptionHandlerConfigurations

import org.apache.struts.config.ExceptionConfig; //导入方法依赖的package包/类
private void initializeExceptionHandlerConfigurations(Collection<ExceptionHandler> exceptionHandlers) {
    if (exceptionHandlers != null) {
        for (ExceptionHandler handler : exceptionHandlers) {
            for (ExceptionHandlerMapping mapping : handler.mappings) {
                ExceptionConfig config = new ExceptionConfig();
                config.setHandler(handler.handler);
                config.setKey(mapping.key);
                config.setType(mapping.type);
                logger.debug("Adding exception config {}", config);
                exceptionConfigs.add(config);
            }
        }
    }
}
 
开发者ID:FenixEdu,项目名称:bennu-renderers,代码行数:15,代码来源:ActionServletWrapper.java


注:本文中的org.apache.struts.config.ExceptionConfig.setType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。