Package org.apache.struts.config

Examples of org.apache.struts.config.ExceptionConfig


     * @since Struts 1.1
     */
    public ExceptionConfig findException(Class type) {

        // Check through the entire superclass hierarchy as needed
        ExceptionConfig config = null;
        while (true) {

            // Check for a locally defined handler
            String name = type.getName();
            config = findExceptionConfig(name);
View Full Code Here


                     getExceptionKey() + "'");
            return (true);
        }

        // Look up the local or global exception handler configuration
        ExceptionConfig exceptionConfig = null;
        ActionConfig actionConfig = (ActionConfig)
            context.get(getActionConfigKey());
        ModuleConfig moduleConfig = (ModuleConfig)
            context.get(getModuleConfigKey());
View Full Code Here

                                             ActionForm form,
                                             ActionMapping mapping)
        throws IOException, ServletException {

        // Is there a defined handler for this exception?
        ExceptionConfig config = mapping.findException(exception.getClass());
        if (config == null) {
            log.warn(getInternal().getMessage("unhandledException",
                                              exception.getClass()));
            if (exception instanceof IOException) {
                throw (IOException) exception;
            } else if (exception instanceof ServletException) {
                throw (ServletException) exception;
            } else {
                throw new ServletException(exception);
            }
        }

        // Use the configured exception handling
        try {
            ExceptionHandler handler = (ExceptionHandler)
            RequestUtils.applicationInstance(config.getHandler());
            return (handler.execute(exception, config, mapping, form,
                                    request, response));
        } catch (Exception e) {
            throw new ServletException(e);
        }
View Full Code Here

     * Return the exception configurations for this module.  If there
     * are none, a zero-length array is returned.
     */
    public ExceptionConfig[] findExceptionConfigs() {

        ExceptionConfig results[] = new ExceptionConfig[exceptions.size()];
        return ((ExceptionConfig[]) exceptions.values().toArray(results));

    }
View Full Code Here

   
        //
        // Look up the ExceptionConfig that's associated with this Throwable.
        //
        Class exClass = ex.getClass();
        ExceptionConfig exceptionConfig = null;
        if ( actionMapping != null )
        {
            exceptionConfig = actionMapping.findException( exClass );
        }
        else
        {
            // If the mapping was null (i.e., the exception happened before we got the action mapping), look for the
            // exception only in the module config.
            exceptionConfig = getExceptionConfig(exClass, moduleConfig);
        }
       
        //
        // If there was no applicable exception handler in the current ModuleConfig, look in a shared flow's module.
        //
        if ( exceptionConfig == null )
        {
            FlowController fallbackFC =
                    getFallbackFlowController( flowController, exClass, request, response, getServletContext() );
           
            if ( fallbackFC != null )
            {
                flowController = fallbackFC;
                context = new FlowControllerHandlerContext( request, response, flowController );
                moduleConfig = flowController.getModuleConfig();
                exceptionConfig = getExceptionConfig( exClass, moduleConfig );
               
                if ( exceptionConfig != null )
                {
                    // This is the module that will be handling the exception.  Ensure that its message resources are
                    // initialized.
                    assert request instanceof HttpServletRequest : request.getClass().getName();
                    InternalUtils.selectModule( moduleConfig.getPrefix(), ( HttpServletRequest ) request,
                                                getServletContext() );
                    rw.setCurrentFlowController( flowController );
                }
            }
           
            actionMapping = null;   // This action mapping isn't relevant if we found the exception elsewhere.
        }
       
        if ( exceptionConfig != null )
        {
            if ( _log.isDebugEnabled() )
            {
                _log.debug( "Found exception-config for exception " + exClass.getName()
                            + ": handler=" + exceptionConfig.getHandler() + ", path=" + exceptionConfig.getPath() );
            }

            // If this is a delegating exception handler, use its *delegate's* ModuleConfig.
            if (exceptionConfig instanceof DelegatingExceptionConfig) {
                moduleConfig = ((DelegatingExceptionConfig) exceptionConfig).getDelegateModuleConfig(getServletContext());
View Full Code Here

        context.getRequest().setAttribute( Globals.EXCEPTION_KEY, ex );
    }
   
    protected ExceptionConfig getExceptionConfig( Class exceptionType, ModuleConfig moduleConfig )
    {
        ExceptionConfig config = null;
               
        if ( moduleConfig != null )
        {
            while ( config == null && exceptionType != null )
            {
View Full Code Here

    }
   
    private boolean checkForExceptionConfig( SharedFlowController sf, Class exClass, ServletRequest request )
    {
        ModuleConfig mc = sf.getModuleConfig();
        ExceptionConfig ec = getExceptionConfig( exClass, mc );
       
        if ( ec != null )
        {
            if ( _log.isDebugEnabled() )
            {
View Full Code Here

                ((DelegatingActionMapping) actionConfig).init(servletContext);
            } else {
                // Initialize action-level exception configs.
                ExceptionConfig[] exceptionConfigs = actionConfig.findExceptionConfigs();
                for (int j = 0; j < exceptionConfigs.length; j++) {
                    ExceptionConfig exceptionConfig = exceptionConfigs[j];
                    if (exceptionConfig instanceof DelegatingExceptionConfig) {
                        ((DelegatingExceptionConfig) exceptionConfig).init(servletContext);
                    }
                }
            }
        }
       
        // Initialize module-level exception configs.
        ExceptionConfig[] exceptionConfigs = moduleConfig.findExceptionConfigs();
        for (int i = 0; i < exceptionConfigs.length; i++) {
            ExceptionConfig exceptionConfig = exceptionConfigs[i];
            if (exceptionConfig instanceof DelegatingExceptionConfig) {
                ((DelegatingExceptionConfig) exceptionConfig).init(servletContext);
            }
        }
    }
View Full Code Here

     * Return the exception configurations for this module.  If there
     * are none, a zero-length array is returned.
     */
    public ExceptionConfig[] findExceptionConfigs() {

        ExceptionConfig results[] = new ExceptionConfig[exceptions.size()];
        return ((ExceptionConfig[]) exceptions.values().toArray(results));

    }
View Full Code Here

                                             ActionForm form,
                                             ActionMapping mapping)
        throws IOException, ServletException {

        // Is there a defined handler for this exception?
        ExceptionConfig config = mapping.findException(exception.getClass());
        if (config == null) {
            log.warn(getInternal().getMessage("unhandledException",
                                              exception.getClass()));
            if (exception instanceof IOException) {
                throw (IOException) exception;
            } else if (exception instanceof ServletException) {
                throw (ServletException) exception;
            } else {
                throw new ServletException(exception);
            }
        }

        // Use the configured exception handling
        try {
            ExceptionHandler handler = (ExceptionHandler)
                RequestUtils.applicationInstance(config.getHandler());
            return (handler.execute(exception, config, mapping, form,
                                    request, response));
        } catch (Exception e) {
            throw new ServletException(e);
        }
View Full Code Here

TOP

Related Classes of org.apache.struts.config.ExceptionConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.