Package net.paoding.rose.web

Examples of net.paoding.rose.web.ControllerInterceptor


        List<InterceptorDelegate> interceptors = module.getInterceptors();
        List<InterceptorDelegate> registeredInterceptors = new ArrayList<InterceptorDelegate>(
                interceptors.size());
        for (InterceptorDelegate interceptor : interceptors) {

            ControllerInterceptor most = InterceptorDelegate.getMostInnerInterceptor(interceptor);

            if (!most.getClass().getName().startsWith("net.paoding.rose.web")) {

                // 获取@Intercepted注解 (@Intercepted注解配置于控制器或其方法中,决定一个拦截器是否应该拦截之。没有配置按“需要”处理)
                Intercepted intercepted = method.getAnnotation(Intercepted.class);
                if (intercepted == null) {
                    // 对于标注@Inherited的annotation,class.getAnnotation可以保证:如果本类没有,自动会从父类判断是否具有
                    intercepted = this.controllerClass.getAnnotation(Intercepted.class);
                }
                // 通过@Intercepted注解的allow和deny排除拦截器
                if (intercepted != null) {
                    // 3.1 先排除deny禁止的
                    if (RoseStringUtil.matches(intercepted.deny(), interceptor.getName())) {
                        if (logger.isDebugEnabled()) {
                            logger.debug("action '" + controllerClass.getName() + "#"
                                    + method.getName()
                                    + "': remove interceptor by @Intercepted.deny: "
                                    + most.getClass().getName());
                        }
                        continue;
                    }
                    // 3.2 确认最大的allow允许
                    if (!RoseStringUtil.matches(intercepted.allow(), interceptor.getName())) {
                        if (logger.isDebugEnabled()) {
                            logger.debug("action '" + controllerClass.getName() + "#"
                                    + method.getName()
                                    + "': remove interceptor by @Intercepted.allow: "
                                    + most.getClass().getName());
                        }
                        continue;
                    }
                }
            }
            // 取得拦截器同意后,注册到这个控制器方法中
            if (interceptor.isForAction(controllerClass, method)) {
                registeredInterceptors.add(interceptor);
            } else {
                if (logger.isDebugEnabled()) {
                    logger.debug("action '" + controllerClass.getName() + "#" + method.getName()
                            + "': remove interceptor by interceptor.isForAction: "
                            + most.getClass().getName());
                }
            }
        }
        //
View Full Code Here


            // 将拦截器设置到module中
            List<InterceptorDelegate> interceptors = findInterceptors(moduleContext);
            for (Iterator<InterceptorDelegate> iter = interceptors.iterator(); iter.hasNext();) {
                InterceptorDelegate interceptor = iter.next();

                ControllerInterceptor most = InterceptorDelegate
                        .getMostInnerInterceptor(interceptor);

                if (!most.getClass().getName().startsWith("net.paoding.rose.web")) {

                    // 先排除deny禁止的
                    if (moduleResource.getInterceptedDeny() != null) {
                        if (RoseStringUtil.matches(moduleResource.getInterceptedDeny(), interceptor
                                .getName())) {
                            iter.remove();
                            if (logger.isDebugEnabled()) {
                                logger.debug("module '" + module.getMappingPath()
                                        + "': remove interceptor by rose.properties: "
                                        + most.getClass().getName());
                            }
                            continue;
                        }
                    }
                    //  确认最大的allow允许
                    if (moduleResource.getInterceptedAllow() != null) {
                        if (!RoseStringUtil.matches(moduleResource.getInterceptedAllow(),
                                interceptor.getName())) {
                            iter.remove();
                            if (logger.isDebugEnabled()) {
                                logger.debug("module '" + module.getMappingPath()
                                        + "': remove interceptor by rose.properties: "
                                        + most.getClass().getName());
                            }
                            continue;
                        }
                    }
                }
View Full Code Here

                InterceptorDelegate position = interceptors.get(j);
                if (position.getName().equals(interceptor.getName())) {
                    // rose内部要求interceptor要有一个唯一的标识
                    // 请这两个类的提供者商量改类名,不能同时取一样的类名
                    // 如果是通过@Component等设置名字的,则不要设置一样
                    ControllerInterceptor duplicated1 = InterceptorDelegate
                            .getMostInnerInterceptor(position);
                    ControllerInterceptor duplicated2 = InterceptorDelegate
                            .getMostInnerInterceptor(interceptor);

                    throw new IllegalArgumentException(
                            "duplicated interceptor name for these two interceptors: '"
                                    + duplicated1.getClass() + "' and '" + duplicated2.getClass()
                                    + "'");
                }
            }
        }
    }
View Full Code Here

        String[] interceptorNames = SpringUtils.getBeanNames(context.getBeanFactory(),
                ControllerInterceptor.class);
        ArrayList<InterceptorDelegate> interceptors = new ArrayList<InterceptorDelegate>(
                interceptorNames.length);
        for (String beanName : interceptorNames) {
            ControllerInterceptor interceptor = (ControllerInterceptor) context.getBean(beanName);
            Class<?> userClass = ClassUtils.getUserClass(interceptor);
            if (userClass.isAnnotationPresent(Ignored.class)) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Ignored interceptor (Ignored):" + interceptor);
                }
View Full Code Here

            this.oncePerRequest = oncePerRequest;
            return this;
        }

        public InterceptorDelegate build() {
            ControllerInterceptor interceptor = this.interceptor;
            if (oncePerRequest) {
                interceptor = new OncePerRequestInterceptorDelegate(interceptor);
            }
            InterceptorDelegate wrapper = new InterceptorDelegate(interceptor);
            if (StringUtils.isBlank(wrapper.getName())) {
View Full Code Here

TOP

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

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.