Package net.paoding.rose.web

Examples of net.paoding.rose.web.InterceptorDelegate


        }

        @Override
        public Object doNext() throws Exception {
            if (++index < interceptors.length) { // ++index 用于将-1转化为0
                InterceptorDelegate interceptor = interceptors[index];
                //
                rose.addAfterCompletion(interceptor);
                Object instruction = interceptor.roundInvocation(rose.getInvocation(), this);
                //
                if (debugEnabled) {
                    logger.debug("interceptor[" + interceptor.getName() + "] do round and return '"
                            + instruction + "'");
                }

                // 拦截器返回null的,要恢复为原instruction
                // 这个功能非常有用!!
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());
View Full Code Here

        return modules;
    }

    private void throwExceptionIfDuplicatedNames(List<InterceptorDelegate> interceptors) {
        for (int i = 0; i < interceptors.size(); i++) {
            InterceptorDelegate interceptor = interceptors.get(i);
            for (int j = i + 1; j < interceptors.size(); j++) {
                // 先判断是否有"名字"一样的拦截器
                InterceptorDelegate position = interceptors.get(j);
                if (position.getName().equals(interceptor.getName())) {
                    // rose内部要求interceptor要有一个唯一的标识
                    // 请这两个类的提供者商量改类名,不能同时取一样的类名
                    // 如果是通过@Component等设置名字的,则不要设置一样
                    ControllerInterceptor duplicated1 = InterceptorDelegate
                            .getMostInnerInterceptor(position);
View Full Code Here

                        + ": don't starts with 'rose', it's reserved");
            }

            builder.name(interceporName);

            InterceptorDelegate wrapper = builder.build();
            interceptors.add(wrapper);
            if (logger.isDebugEnabled()) {
                int priority = 0;
                if (interceptor instanceof Ordered) {
                    priority = ((Ordered) interceptor).getPriority();
                }
                logger.debug("recognized interceptor[priority=" + priority + "]: " // \r\n
                        + wrapper.getName() + "=" + userClass.getName());
            }
        }
        Collections.sort(interceptors);
        throwExceptionIfDuplicatedNames(interceptors);
        return interceptors;
View Full Code Here

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

TOP

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

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.