public List getActionInterceptors()

in ti/phase2/jars/core/src/java/org/apache/ti/pageflow/interceptor/action/ActionInterceptorContext.java [125:220]


    public List /*< Interceptor >*/ getActionInterceptors() {
        PageFlowActionContext actionContext = PageFlowActionContext.get();
        InternalConcurrentHashMap /*< String, HashMap< String, ArrayList< Interceptor > > >*/ cache = (InternalConcurrentHashMap) actionContext.getApplication()
                                                                                                                                               .get(CACHE_ATTR);

        if (cache == null) {
            //
            // Don't have to synchronize here.  If by some chance two initial requests come in at the same time,
            // one of the caches will get overwritten in the ServletContext, but it will just get recreated the
            // next time.
            //
            cache = new InternalConcurrentHashMap /*< String, HashMap< String, ArrayList< Interceptor > > >*/();
            actionContext.getApplication().put(CACHE_ATTR, cache);
        }

        String namespace = getPageFlow().getNamespace();
        String actionName = getActionName();
        HashMap /*< String, ArrayList< Interceptor > >*/ cacheByPageFlow = (HashMap) cache.get(namespace);

        if (cacheByPageFlow != null) {
            List /*< Interceptor >*/ interceptors = (List) cacheByPageFlow.get(actionName);

            if (interceptors != null) {
                return interceptors;
            }
        }

        //
        // We didn't find it in the cache -- build it.
        //
        if (cacheByPageFlow == null) {
            cacheByPageFlow = new HashMap /*< String, ArrayList< Interceptor > >*/();
        }

        PageFlowActionInterceptorsConfig config = ConfigUtil.getConfig().getPageFlowActionInterceptors();
        ArrayList /*< Interceptor >*/ interceptorsList = new ArrayList /*< Interceptor >*/();

        if (config == null) {
            cacheByPageFlow.put(actionName, interceptorsList);
            cache.put(namespace, cacheByPageFlow);

            return interceptorsList;
        }

        //
        // Global interceptors.
        //
        GlobalPageFlowActionInterceptorConfig globalInterceptors = config.getGlobalPageFlowActionInterceptors();

        if (globalInterceptors != null) {
            addInterceptors(globalInterceptors.getActionInterceptors(), interceptorsList, ActionInterceptor.class);
            addSimpleInterceptors(globalInterceptors.getSimpleActionInterceptors(), interceptorsList);
        }

        //
        // Per-pageflow and per-action interceptors.
        //
        String pageFlowURI = getPageFlow().getPath();
        PerPageFlowActionInterceptorConfig[] perPageFlowInterceptorsConfig = config.getPerPageFlowActionInterceptors();

        if (perPageFlowInterceptorsConfig != null) {
            for (int i = 0; i < perPageFlowInterceptorsConfig.length; i++) {
                PerPageFlowActionInterceptorConfig ppfi = perPageFlowInterceptorsConfig[i];

                if ((ppfi != null) && pageFlowURI.equals(ppfi.getPageFlowUri())) {
                    //
                    // This is a matching page flow -- add per-pageflow interceptors.
                    //
                    addInterceptors(perPageFlowInterceptorsConfig[i].getActionInterceptors(), interceptorsList,
                                    ActionInterceptor.class);
                    addSimpleInterceptors(perPageFlowInterceptorsConfig[i].getSimpleActionInterceptors(), interceptorsList);

                    PerActionInterceptorConfig[] perActionConfigs = perPageFlowInterceptorsConfig[i].getPerActionInterceptors();

                    if (perActionConfigs != null) {
                        for (int j = 0; j < perActionConfigs.length; j++) {
                            PerActionInterceptorConfig perActionConfig = perActionConfigs[j];

                            if ((perActionConfig != null) && actionName.equals(perActionConfig.getActionName())) {
                                //
                                // This is a matching action -- add per-action interceptors.
                                //
                                addInterceptors(perActionConfig.getActionInterceptors(), interceptorsList, ActionInterceptor.class);
                                addSimpleInterceptors(perActionConfig.getSimpleActionInterceptors(), interceptorsList);
                            }
                        }
                    }
                }
            }
        }

        cacheByPageFlow.put(actionName, interceptorsList);
        cache.put(namespace, cacheByPageFlow);

        return interceptorsList;
    }