if (getBundle() == null) { setBundle(config.getBundle()); if (getHandler().equals("org.apache.struts.action.ExceptionHandler")) { setHandler(config.getHandler()); if (getKey() == null) { setKey(config.getKey()); if (getPath() == null) { setPath(config.getPath()); if (getScope().equals("request")) { setScope(config.getScope()); if (getType() == null) { setType(config.getType()); inheritProperties(config);
public DefaultExceptionHandlerConfig(ExceptionHandler exceptionHandler, Class exceptionClass) { this.exceptionHandler = exceptionHandler; this.exceptionClass = exceptionClass; this.exceptionConfig = new ExceptionConfig(); this.exceptionConfig.setHandler(exceptionHandler.getClass().getName()); this.exceptionConfig.setType(exceptionClass.getName()); }
public DefaultExceptionHandlerConfig(ExceptionHandler exceptionHandler, ExceptionConfig exceptionConfig) { this.exceptionHandler = exceptionHandler; this.exceptionConfig = exceptionConfig; this.exceptionConfig.setHandler(exceptionHandler.getClass().getName()); try { exceptionClass = exceptionConfig.getClass().getClassLoader().loadClass(exceptionConfig.getType()); } catch(Exception exc) { throw new NestedApplicationException(exc); } }
/** * <p>Initialize the exception handlers for the specified module.</p> * * @param config ModuleConfig information for this module * @throws ServletException if initialization cannot be performed * @since Struts 1.3 */ protected void initModuleExceptionConfigs(ModuleConfig config) throws ServletException { if (log.isDebugEnabled()) { log.debug("Initializing module path '" + config.getPrefix() + "' forwards"); } // Process exception config extensions. ExceptionConfig[] exceptions = config.findExceptionConfigs(); for (int i = 0; i < exceptions.length; i++) { ExceptionConfig exception = exceptions[i]; processExceptionExtension(exception, config, null); } for (int i = 0; i < exceptions.length; i++) { ExceptionConfig exception = exceptions[i]; // Verify that required fields are all present for the config if (exception.getKey() == null) { handleValueRequiredException("key", exception.getType(), "global exception config"); } } }
/** * <p> Remove the specified exception configuration instance. </p> * * @param config ExceptionConfig instance to be removed * @throws IllegalStateException if this module configuration has been * frozen */ public void removeExceptionConfig(ExceptionConfig config) { if (configured) { throw new IllegalStateException("Configuration is frozen"); } exceptions.remove(config.getType()); }
public DefaultExceptionHandlerConfig(ExceptionConfig exceptionConfig) { this.exceptionConfig = exceptionConfig; try { Class handlerClass = exceptionConfig.getClass().getClassLoader().loadClass(exceptionConfig.getHandler()); exceptionHandler = (ExceptionHandler)handlerClass.newInstance(); exceptionClass = exceptionConfig.getClass().getClassLoader().loadClass(exceptionConfig.getType()); } catch(Exception exc) { throw new NestedApplicationException(exc); } }
String ancestorType = getExtends(); (this != moduleConfig.findExceptionConfig(getType())); checkActionConfig &= !ancestorType.equals(getType()); if (checkCircularInheritance(moduleConfig, actionConfig)) { throw new IllegalArgumentException( "Circular inheritance detected for forward " + getType()); if (!baseConfig.isExtensionProcessed()) { baseConfig.processExtends(moduleConfig, actionConfig); inheritFrom(baseConfig);
throws ServletException { try { if (!exceptionConfig.isExtensionProcessed()) { if (log.isDebugEnabled()) { log.debug("Processing extensions for '" + exceptionConfig.getType() + "'"); actionConfig); exceptionConfig.processExtends(moduleConfig, actionConfig); } catch (Exception e) { handleGeneralExtensionException("Exception", exceptionConfig.getType(), e);
this.findExceptionConfig(baseHandler.getType()); copy.setProperties(baseHandler.copyProperties()); } else { copy.processExtends(getModuleConfig(), this);
String ancestorType = getExtends(); ancestorType = ancestor.getExtends(); if (ancestor.getType().equals(ancestorType)) {
ExceptionHandler handler = (ExceptionHandler) RequestUtils.applicationInstance(config .getHandler());
@Override public ActionForward execute(Exception ex, ExceptionConfig exceptionConfig, ActionMapping mapping, ActionForm actionForm, HttpServletRequest request, HttpServletResponse response) throws ServletException { ActionForward forward = mapping.getInputForward(); if (ex instanceof DomainException) { super.execute(ex, exceptionConfig, mapping, actionForm, request, response); DomainException domainException = (DomainException) ex; String property = domainException.getKey(); ActionMessage error = new ActionMessage(domainException.getKey(), domainException.getArgs()); super.storeException(request, property, error, forward, exceptionConfig.getScope()); } return forward; }
if (ae.getPath() != null) { forward = new ActionForward(ae.getPath()); } else { forward = mapping.getInputForward(); property = ((ModuleException) ex).getProperty(); } else { error = new ActionMessage(ae.getKey(), ex.getMessage()); property = error.getKey(); this.storeException(request, property, error, forward, ae.getScope());
/** * <p> * Initialize the exception handlers for the specified module. * </p> * * @param config * ModuleConfig information for this module * @throws ServletException * if initialization cannot be performed * @since Struts 1.3 */ protected void initModuleExceptionConfigs(ModuleConfig config) throws ServletException { if (log.isDebugEnabled()) { log.debug("Initializing module path '" + config.getPrefix() + "' forwards"); } // Process exception config extensions. ExceptionConfig[] exceptions = config.findExceptionConfigs(); for (int i = 0; i < exceptions.length; i++) { ExceptionConfig exception = exceptions[i]; processExceptionExtension(exception, config); } for (int i = 0; i < exceptions.length; i++) { ExceptionConfig exception = exceptions[i]; // Verify that required fields are all present for the config if (exception.getKey() == null) { handleValueRequiredException("key", exception.getType(), "global exception config"); } } }
/** * Remove the specified exception configuration instance. * * @param config ActionConfig instance to be removed * * @exception IllegalStateException if this module configuration * has been frozen */ public void removeExceptionConfig(ExceptionConfig config) { if (configured) { throw new IllegalStateException("Configuration is frozen"); } exceptions.remove(config.getType()); }
public DefaultExceptionHandlerConfig(ExceptionConfig exceptionConfig) { this.exceptionConfig = exceptionConfig; try { Class handlerClass = exceptionConfig.getClass().getClassLoader().loadClass(exceptionConfig.getHandler()); exceptionHandler = (ExceptionHandler)handlerClass.newInstance(); exceptionClass = exceptionConfig.getClass().getClassLoader().loadClass(exceptionConfig.getType()); } catch(Exception exc) { throw new NestedApplicationException(exc); } }
public DefaultExceptionHandlerConfig(ExceptionHandler exceptionHandler, ExceptionConfig exceptionConfig) { this.exceptionHandler = exceptionHandler; this.exceptionConfig = exceptionConfig; this.exceptionConfig.setHandler(exceptionHandler.getClass().getName()); try { exceptionClass = exceptionConfig.getClass().getClassLoader().loadClass(exceptionConfig.getType()); } catch(Exception exc) { throw new NestedApplicationException(exc); } }
/** * <p> * Extend the exception's configuration as necessary. * </p> * * @param exceptionConfig * the configuration to process. * @param moduleConfig * the module configuration for this module. * @throws ServletException * if initialization cannot be performed. */ protected void processExceptionExtension(ExceptionConfig exceptionConfig, ModuleConfig moduleConfig) throws ServletException { try { if (!exceptionConfig.isExtensionProcessed()) { if (log.isDebugEnabled()) { log.debug("Processing extensions for '" + exceptionConfig.getType() + "'"); } exceptionConfig = processExceptionConfigClass(exceptionConfig, moduleConfig); exceptionConfig.processExtends(moduleConfig, null); } } catch (ServletException e) { throw e; } catch (Exception e) { handleGeneralExtensionException("Exception", exceptionConfig.getType(), e); } }