Package org.apache.beehive.netui.util.internal.concurrent

Examples of org.apache.beehive.netui.util.internal.concurrent.InternalConcurrentHashMap


    }
   
    public List/*< Interceptor >*/ getActionInterceptors()
    {
        ServletContext servletContext = getServletContext();
        InternalConcurrentHashMap/*< String, HashMap< String, ArrayList< Interceptor > > >*/ cache =
                ( InternalConcurrentHashMap ) servletContext.getAttribute( 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 > > >*/();
            servletContext.setAttribute( CACHE_ATTR, cache );
        }
       
        String modulePath = getPageFlow().getModulePath();
        String actionName = getActionName();
        HashMap/*< String, ArrayList< Interceptor > >*/ cacheByPageFlow = ( HashMap ) cache.get( modulePath );
        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 > >*/();
        PageflowActionInterceptors config = ConfigUtil.getConfig().getPageflowActionInterceptors();
        ArrayList/*< Interceptor >*/ interceptorsList = new ArrayList/*< Interceptor >*/();
       
        if ( config == null )
        {
            cacheByPageFlow.put( actionName, interceptorsList );
            cache.put( modulePath, cacheByPageFlow );
            return interceptorsList;
        }
       
        //
        // Global interceptors.
        //
        PageflowActionInterceptors.Global globalInterceptors = config.getGlobal();
       
        if ( globalInterceptors != null )
        {
            addInterceptors( globalInterceptors.getActionInterceptorArray(), interceptorsList, ActionInterceptor.class );
            addSimpleInterceptors( globalInterceptors.getSimpleActionInterceptorArray(), interceptorsList );
        }
       
        //
        // Per-pageflow and per-action interceptors.
        //
        String pageFlowURI = getPageFlow().getURI();
        PageflowActionInterceptors.PerPageflow[] perPageFlowInterceptorsConfig = config.getPerPageflowArray();
       
        if ( perPageFlowInterceptorsConfig != null )
        {
            for ( int i = 0; i < perPageFlowInterceptorsConfig.length; i++ )
            {
                PageflowActionInterceptors.PerPageflow ppfi = perPageFlowInterceptorsConfig[i];
               
                if ( ppfi != null && pageFlowURI.equals( ppfi.getPageflowUri() ) )
                {
                    //
                    // This is a matching page flow -- add per-pageflow interceptors.
                    //
                    addInterceptors( perPageFlowInterceptorsConfig[i].getActionInterceptorArray(), interceptorsList,
                                     ActionInterceptor.class );
                    addSimpleInterceptors( perPageFlowInterceptorsConfig[i].getSimpleActionInterceptorArray(),
                                           interceptorsList );
                   
                    PageflowActionInterceptors.PerPageflow.PerAction[] perActionConfigs =
                            perPageFlowInterceptorsConfig[i].getPerActionArray();
                   
                    if ( perActionConfigs != null )
                    {
                        for ( int j = 0; j < perActionConfigs.length; j++ )
                        {
                            PageflowActionInterceptors.PerPageflow.PerAction perActionConfig = perActionConfigs[j];
                           
                            if ( perActionConfig != null && actionName.equals( perActionConfig.getActionName() ) )
                            {
                                //
                                // This is a matching action -- add per-action interceptors.
                                //
                                addInterceptors( perActionConfig.getActionInterceptorArray(), interceptorsList,
                                                 ActionInterceptor.class );
                                addSimpleInterceptors( perActionConfig.getSimpleActionInterceptorArray(),
                                                       interceptorsList );
                            }
                        }
                    }
                }
            }
        }
       
        cacheByPageFlow.put( actionName, interceptorsList );
        cache.put( modulePath, cacheByPageFlow );
        return interceptorsList;
    }
View Full Code Here


   
    private ProcessedAnnotationsDocument.ProcessedAnnotations _annotations;
   
    public static AnnotationReader getAnnotationReader( Class type, ServletContext servletContext )
    {
        InternalConcurrentHashMap cache = ( InternalConcurrentHashMap ) servletContext.getAttribute( CACHE_ATTR );
       
        if ( cache == null )
        {
            cache = new InternalConcurrentHashMap();
            servletContext.setAttribute( CACHE_ATTR, cache );
        }
       
        AnnotationReader reader = ( AnnotationReader ) cache.get( type );
       
        if ( reader == null )
        {
            reader = new AnnotationReader( type, servletContext );
            cache.put( type, reader );
        }
       
        return reader;
    }
View Full Code Here

    private static final Logger LOGGER = Logger.getInstance(PropertyCache.class);

    private final InternalConcurrentHashMap _classCache;

    public PropertyCache() {
        _classCache = new InternalConcurrentHashMap();
    }
View Full Code Here

    /**
     *
     */
    public MethodCache() {
        _methodCache = new InternalConcurrentHashMap();
    }
View Full Code Here

    private final InternalConcurrentHashMap _fieldCache;
    private final InternalConcurrentHashMap _declaredFieldCache;

    public FieldCache()
    {
        _fieldCache = new InternalConcurrentHashMap();
        _declaredFieldCache = new InternalConcurrentHashMap();
    }
View Full Code Here

    protected ClassLevelCache() {
    }

    public Object get(String majorKey, String minorKey) {
        InternalConcurrentHashMap cache = (InternalConcurrentHashMap)_caches.get(majorKey);
        return cache != null ? cache.get(minorKey) : null;
    }
View Full Code Here

    public Map getCacheMap(String cacheID) {
        return getCacheMap(cacheID, true);
    }

    public Map getCacheMap(String cacheID, boolean createIfMissing) {
        InternalConcurrentHashMap cache = (InternalConcurrentHashMap)_caches.get(cacheID);

        if(cache == null && createIfMissing) {
            cache = new InternalConcurrentHashMap();
            _caches.put(cacheID, cache);
        }

        return cache;
    }
View Full Code Here


    public List/*< Interceptor >*/ getActionInterceptors()
    {
        ServletContext servletContext = getServletContext();
        InternalConcurrentHashMap/*< String, HashMap< String, ArrayList< Interceptor > > >*/ cache =
                ( InternalConcurrentHashMap ) servletContext.getAttribute( 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 > > >*/();
            servletContext.setAttribute( CACHE_ATTR, cache );
        }

        String modulePath = getPageFlow().getModulePath();
        String actionName = getActionName();
        HashMap/*< String, ArrayList< Interceptor > >*/ cacheByPageFlow = ( HashMap ) cache.get( modulePath );
        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( modulePath, 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().getURI();
        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( modulePath, cacheByPageFlow );
        return interceptorsList;
    }
View Full Code Here

    private ProcessedAnnotations _annotations;

    public static AnnotationReader getAnnotationReader( Class type, ServletContext servletContext )
    {
        InternalConcurrentHashMap cache = ( InternalConcurrentHashMap ) servletContext.getAttribute( CACHE_ATTR );

        if ( cache == null )
        {
            cache = new InternalConcurrentHashMap();
            servletContext.setAttribute( CACHE_ATTR, cache );
        }

        AnnotationReader reader = ( AnnotationReader ) cache.get( type );

        if ( reader == null )
        {
            reader = new AnnotationReader( type, servletContext );
            cache.put( type, reader );
        }

        return reader;
    }
View Full Code Here

    /**
     *
     */
    public MethodCache() {
        _methodCache = new InternalConcurrentHashMap();
    }
View Full Code Here

TOP

Related Classes of org.apache.beehive.netui.util.internal.concurrent.InternalConcurrentHashMap

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.