Package org.jasig.portal.portlet.container.cache

Examples of org.jasig.portal.portlet.container.cache.CachingPortletOutputHandler


        if (cacheState.isUseCachedData()) {
            return doRenderReplayCachedContent(portletWindow, httpServletRequest, cacheState, portletOutputHandler, renderPart, 0);
        }
       
        final int cacheSizeThreshold = this.portletCacheControlService.getCacheSizeThreshold();
        final CachingPortletOutputHandler cachingPortletOutputHandler = new CachingPortletOutputHandler(portletOutputHandler, cacheSizeThreshold);

        final CacheControl cacheControl = cacheState.getCacheControl();
       
        //Setup the request and response
        httpServletRequest = this.setupPortletRequest(httpServletRequest);
        httpServletResponse = new PortletMimeHttpServletResponseWrapper(httpServletResponse, portletWindow, portletOutputHandler, cacheControl);
       
        httpServletRequest.setAttribute(ATTRIBUTE__PORTLET_CACHE_CONTROL, cacheControl);
        httpServletRequest.setAttribute(ATTRIBUTE__PORTLET_OUTPUT_HANDLER, cachingPortletOutputHandler);
       
        logger.debug("Rendering portlet {} for window {}", renderPart.name(), portletWindow);

        final long renderStartTime = System.nanoTime();
        try {
            httpServletRequest.setAttribute(PortletRequest.RENDER_PART, renderPart.getRenderPart());
            this.portletContainer.doRender(portletWindow.getPlutoPortletWindow(), httpServletRequest, httpServletResponse);    
        }
        catch (PortletException pe) {
            throw new PortletDispatchException("The portlet window '" + portletWindow + "' threw an exception while executing renderMarkup.", portletWindow, pe);
        }
        catch (PortletContainerException pce) {
            throw new PortletDispatchException("The portlet container threw an exception while executing renderMarkup on portlet window '" + portletWindow + "'.", portletWindow, pce);
        }
        catch (IOException ioe) {
            throw new PortletDispatchException("The portlet window '" + portletWindow + "' threw an exception while executing renderMarkup.", portletWindow, ioe);
        }
       
        final long executionTime = System.nanoTime() - renderStartTime;
       
        //See if the portlet signaled to use the cached content
        final boolean useCachedContent = cacheControl.useCachedContent();
        if (useCachedContent) {
            final CachedPortletData<PortletRenderResult> cachedPortletData = cacheState.getCachedPortletData();
            if (cachedPortletData == null) {
                throw new PortletDispatchException(
                        "The portlet window '" + portletWindow + "' indicated via CacheControl#useCachedContent " +
                        "that the portal should render cached content, however there is no cached content to return. " +
                        "This is a portlet bug.",
                        portletWindow);
            }
           
            //Update the expiration time and re-store in the cache
            cachedPortletData.updateExpirationTime(cacheControl.getExpirationTime());
           
            renderPart.cachePortletOutput(portletCacheControlService, portletWindowId, httpServletRequest, cacheState, cachedPortletData);
           
            return doRenderReplayCachedContent(portletWindow, httpServletRequest, cacheState, portletOutputHandler, renderPart, executionTime);
        }
       
        publishRenderEvent(portletWindow, httpServletRequest, renderPart, executionTime, false);

        //Build the render result
        final PortletRenderResult portletRenderResult = constructPortletRenderResult(httpServletRequest, executionTime);

        //Check if the portlet's output should be cached
        if (cacheState != null) {
            boolean shouldCache = this.portletCacheControlService.shouldOutputBeCached(cacheControl);

            if (shouldCache) {
                final CachedPortletData<PortletRenderResult> cachedPortletData = cachingPortletOutputHandler
                        .getCachedPortletData(portletRenderResult, cacheControl);

                if (cachedPortletData != null) {
                    renderPart.cachePortletOutput(portletCacheControlService,
                            portletWindowId,
View Full Code Here

TOP

Related Classes of org.jasig.portal.portlet.container.cache.CachingPortletOutputHandler

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.