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

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


            logger.trace("doServeResource-Reusing cached data");
            return doResourceReplayCachedContent(portletWindow, httpServletRequest, cacheState, portletOutputHandler, 0);
        }
       
        final int cacheSizeThreshold = this.portletCacheControlService.getCacheSizeThreshold();
        final CachingPortletResourceOutputHandler cachingPortletOutputHandler = new CachingPortletResourceOutputHandler(portletOutputHandler, cacheSizeThreshold);

        CacheControl cacheControl = cacheState.getCacheControl();
        //Wrap the cache control so it immediately sets the caching related response headers
        cacheControl = new HeaderSettingCacheControl(cacheControl, cachingPortletOutputHandler);
       
        //Setup the request and response
        httpServletRequest = this.setupPortletRequest(httpServletRequest);
        httpServletResponse = new PortletResourceHttpServletResponseWrapper(httpServletResponse, portletWindow, portletOutputHandler, cacheControl);
       
        httpServletRequest.setAttribute(ATTRIBUTE__PORTLET_CACHE_CONTROL, cacheControl);
        httpServletRequest.setAttribute(ATTRIBUTE__PORTLET_OUTPUT_HANDLER, cachingPortletOutputHandler);
       
        this.logger.debug("Executing resource request for window {}", portletWindow);

        final long start = System.nanoTime();
        try {
            this.portletContainer.doServeResource(portletWindow.getPlutoPortletWindow(), httpServletRequest, httpServletResponse);
        }
        catch (PortletException pe) {
            throw new PortletDispatchException("The portlet window '" + portletWindow + "' threw an exception while executing serveResource.", portletWindow, pe);
        }
        catch (PortletContainerException pce) {
            throw new PortletDispatchException("The portlet container threw an exception while executing serveResource on portlet window '" + portletWindow + "'.", portletWindow, pce);
        }
        catch (IOException ioe) {
            throw new PortletDispatchException("The portlet window '" + portletWindow + "' threw an exception while executing serveResource.", portletWindow, ioe);
        }
        final long executionTime = System.nanoTime() - start;
       
        //See if the portlet signaled to use the cached content
        final boolean useCachedContent = cacheControl.useCachedContent();
        if (useCachedContent) {
            final CachedPortletResourceData<Long> cachedPortletResourceData = cacheState.getCachedPortletData();
           
            if (cachedPortletResourceData != null) {
                //Update the expiration time and re-store in the cache
                final CachedPortletData<Long> cachedPortletData = cachedPortletResourceData.getCachedPortletData();
                cachedPortletData.updateExpirationTime(cacheControl.getExpirationTime());
                this.portletCacheControlService.cachePortletResourceOutput(portletWindowId, httpServletRequest, cacheState, cachedPortletResourceData);
            }
           
            if (cacheState.isBrowserSetEtag()) {
                logger.trace("doServeResource-useCachedContent, Reusing browser data");
                //Browser-side content matches, send a 304
                return doResourceReplayBrowserContent(portletWindow, httpServletRequest, cacheState, portletOutputHandler);
            }
            logger.trace("doServeResource-useCachedContent, Reusing cached data");

            return doResourceReplayCachedContent(portletWindow, httpServletRequest, cacheState, cachingPortletOutputHandler, executionTime);
        }
       
        publishResourceEvent(portletWindow, httpServletRequest, executionTime, false, false);
       
        if (cacheState != null) {
            boolean shouldCache = this.portletCacheControlService.shouldOutputBeCached(cacheControl);

            if (shouldCache) {
                final CachedPortletResourceData<Long> cachedPortletResourceData = cachingPortletOutputHandler
                        .getCachedPortletResourceData(executionTime, cacheControl);

                if (cachedPortletResourceData != null) {
                    this.portletCacheControlService.cachePortletResourceOutput(portletWindowId,
                            httpServletRequest,
View Full Code Here

TOP

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

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.