本文整理汇总了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);
}
示例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());
}
示例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);
}
}
示例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"));
}
示例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);
}
}
}
}