Package mfinder.annotation

Examples of mfinder.annotation.Action


        //trim empay and '/'
        String namespace = ns == null ? PATH_SEPARATOR + "" : PATH_SEPARATOR + StringUtil.trim(ns.name(), PATH_SEPARATOR);

        String path = null;
        //not nullable Action
        Action action = method.getAnnotation(Action.class);
        //Action名称可能为空字符串
        String aname = action.name().trim();
        if ("".equals(aname)) {
            //Action名称为空字符串时取其方法的名称(区分大小写)
            aname = method.getName();
            //if namespace is '/' or not
            path = namespace.length() == 1 ? PATH_SEPARATOR + aname : namespace + PATH_SEPARATOR + aname;
        } else {
            //action's name can't be null by annotation
            String name = StringUtil.trim(aname, PATH_SEPARATOR);
            //if action's name is trim as empty
            if (name.isEmpty()) {
                path = namespace;
            } else if (PATH_SEPARATOR == aname.charAt(0)) {
                path = PATH_SEPARATOR + name;
            } else {
                //if namespace is '/' or not
                path = namespace.length() == 1 ? PATH_SEPARATOR + name : namespace + PATH_SEPARATOR + name;
            }
        }

        //包含特别属性注入的Action需重新生成对象
        if (obj != null && Injector.actionInjection.containsKey(path)) {
            obj = objectFactory.newInstance(obj.getClass());
            Injector.injectAction(path, obj);
        }

        //Action中不记录路径的后缀名称
        ActionProxy ap = new ActionProxy(this, namespace, path, action, method, obj);

        //interceptorStack
        String stackName = action.interceptorStack().trim();
        //not not nullable action's interceptors
        String[] interceptorNames = action.interceptors();

        List<InterceptorProxy> inters = new ArrayList<InterceptorProxy>();
        //action interceptors
        if (interceptorNames.length != 0) {
            ////action interceptorStack
            if (StringUtil.isNotNull(stackName)) {
                addActionInterceptors(inters, stackName, ap);
            }
            //action中申明的interceptors
            for (String name : action.interceptors()) {
                InterceptorProxy ip = interceptors.get(name);
                if (ip == null) {
                    LOG.warn("No such Interceptor [" + name + "] defined in : " + ap.getMethodInfo());
                } else {
                    inters.add(ip);
                }
            }
        } //action interceptorStack
        else if (StringUtil.isNotNull(stackName)) {
            addActionInterceptors(inters, stackName, ap);
        } else {
            //是否已设置action的拦截器集合
            boolean setInterceptors = false;
            //namespace interceptorStack & interceptors
            if (ns != null) {
                //namespace interceptorStack
                if (StringUtil.isNotNull(stackName = ns.interceptorStack().trim())) {
                    setInterceptors = true;
                    addActionInterceptors(inters, stackName, ap);
                }
                //namespace interceptors
                if (ns.interceptors().length != 0) {
                    setInterceptors = true;
                    for (String name : ns.interceptors()) {
                        InterceptorProxy ip = interceptors.get(name);
                        if (ip == null) {
                            LOG.warn("No such Interceptor [" + name + "] defined in : " + ap.getMethodInfo());
                        } else {
                            inters.add(ip);
                        }
                    }
                }
            }
            //defaultInterceptorStack
            if (!setInterceptors) {
                if (StringUtil.isNotNull(stackName = defaultInterceptorStack)) {
                    addActionInterceptors(inters, stackName, ap);
                }
            }
        }
        //trim
        ((ArrayList) inters).trimToSize();
        ap.setInterceptors(inters);

        //set results
        Result[] rs = action.results();
        Map<String, Result> res = new HashMap<String, Result>(rs.length);
        for (Result r : rs) {
            res.put(r.name(), r);
        }
        ap.setResults(res);
View Full Code Here

TOP

Related Classes of mfinder.annotation.Action

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.