Package net.paoding.rose.web

Examples of net.paoding.rose.web.ControllerErrorHandler


    @Override
    public Object onError(Invocation inv, Throwable ex) throws Throwable {
        InvocationBean invb = (InvocationBean) inv;
        Module module = invb.getModule();
        while ((module = module.getParent()) != null) {
            ControllerErrorHandler handler;
            if ((handler = module.getErrorHandler()) != null) {
                return handler.onError(invb, ex);
            }
        }
        throw ex;
    }
View Full Code Here


            while (cause instanceof InvocationTargetException) {
                cause = ((InvocationTargetException) cause).getTargetException();
            }
            //
            Module errorHandlerModule = module;
            ControllerErrorHandler errorHandler = errorHandlerModule.getErrorHandler();
            while (errorHandler == null && errorHandlerModule != null) {
                errorHandlerModule = errorHandlerModule.getParent();
                if (errorHandlerModule != null) {
                    errorHandler = errorHandlerModule.getErrorHandler();
                    if (errorHandler != null) {
                        if (errorHandler.getClass().isAnnotationPresent(NotForSubModules.class)) {
                            errorHandler = null;
                            continue;
                        }
                    }
                } else {
                    errorHandler = null;
                    break;
                }
            }
            Object instruction = null;
            if (errorHandler != null) {
                if (logger.isDebugEnabled()) {
                    logger.debug("exception happended; " + errorHandler.getClass().getName()
                            + " will handle the exception: " //
                            + cause.getClass().getName() + ":" + cause.getMessage());
                }
                rose.getInvocation().setViewModule(errorHandlerModule);
                //
                HttpServletRequest request = rose.getInvocation().getRequest();
                WebUtils.exposeErrorRequestAttributes(request, cause, null);
                StackTraceSimplifier.simplify(cause)//对栈进行简化
                instruction = errorHandler.onError(rose.getInvocation(), cause);
            }

            // onError方法返回null,表示需要重新throw出去
            // rethrow出去的不是cause而是invException,目的要把整个异常抛出来,以让知道整个异常的来由
            if ((errorHandler == null) || (instruction == null)) {
View Full Code Here

                logger.debug("module '" + module.getMappingPath() + "': apply global validators "
                        + validators);
            }

            // errorhandler
            ControllerErrorHandler errorHandler = getContextErrorHandler(moduleContext);
            if (errorHandler != null) {
                if (Proxy.isProxyClass(errorHandler.getClass())) {
                    module.setErrorHandler(errorHandler);
                } else {
                    ErrorHandlerDispatcher dispatcher = new ErrorHandlerDispatcher(errorHandler);
                    module.setErrorHandler(dispatcher);
                }
View Full Code Here

        return true;
    }

    /** 错误处理器,只从本容器找,不从父容器找 */
    private ControllerErrorHandler getContextErrorHandler(XmlWebApplicationContext context) {
        ControllerErrorHandler errorHandler = null;
        String[] names = context.getBeanNamesForType(ControllerErrorHandler.class);
        for (int i = 0; errorHandler == null && i < names.length; i++) {
            errorHandler = (ControllerErrorHandler) context.getBean(names[i]);
            Class<?> userClass = ClassUtils.getUserClass(errorHandler);
            if (userClass.isAnnotationPresent(Ignored.class)) {
View Full Code Here

TOP

Related Classes of net.paoding.rose.web.ControllerErrorHandler

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.