Package net.sf.ehcache.constructs.web

Examples of net.sf.ehcache.constructs.web.PageInfo


  @Override
  protected PageInfo buildPageInfo(HttpServletRequest request,
      HttpServletResponse response, FilterChain chain) throws Exception {
     // Look up the cached page
        final String key = prepareCache(request);
        PageInfo pageInfo = null;
        try {
          // check clear cache
          clearCache(request);
          //
            Element element = blockingCache.get(key);
            if (element == null || element.getObjectValue() == null) {
                try {
                    // Page is not cached - build the response, cache it, and
                    // send to client
                    pageInfo = buildPage(request, response, chain);
                    if (pageInfo.isOk() && pageInfo.getTimeToLiveSeconds()>=0) {
                        blockingCache.put(new Element(key, pageInfo, false,
                            (int)pageInfo.getTimeToLiveSeconds(), (int)pageInfo.getTimeToLiveSeconds()));
                        logger.debug("Cache widget {} {} seconds ",
                            getWidgetConfig(request).getName(), getWidgetConfig(request).getCache());
                    } else {
                      blockingCache.put(new Element(key, null));
                    }
View Full Code Here


        //
        WidgetConfig widgetConfig = (WidgetConfig) request
        .getAttribute(WidgetConfig.KEY);
        Long timeToLiveSeconds = parseTimeToLiveSeconds(widgetConfig.getCache());
        // Return the page info
        return new PageInfo(wrapper.getStatus(), wrapper.getContentType(),
                wrapper.getCookies(),
                outstr.toByteArray(), false, timeToLiveSeconds, wrapper.getAllHeaders());
  }
View Full Code Here

     * Performs the filtering for a request.
     */
    protected void doFilter(final HttpServletRequest request, final HttpServletResponse response,
                            final FilterChain chain) throws Exception {

        PageInfo pageInfo = buildPageInfo(request, response, chain);

        // Send the page to the client
        writeResponse(response, pageInfo);
    }
View Full Code Here

        final GenericResponseWrapper wrapper = new GenericResponseWrapper(response, outstr);
        chain.doFilter(request, wrapper);
        wrapper.flush();

        // Return the page info
        return new PageInfo(wrapper.getStatus(), wrapper.getContentType(), wrapper.getHeaders(), wrapper.getCookies(),
                outstr.toByteArray(), false);
    }
View Full Code Here

            Exception {
        if (response.isCommitted()) {
            throw new AlreadyCommittedException("Response already committed before doing buildPage.");
        }
        logRequestHeaders(request);
        PageInfo pageInfo = buildPageInfo(request, response, chain);

        //return on error or redirect code
        int statusCode = pageInfo.getStatusCode();
        if (statusCode != HttpServletResponse.SC_OK) {
            return;
        }

        if (response.isCommitted()) {
View Full Code Here

     */
    protected PageInfo buildPageInfo(final HttpServletRequest request, final HttpServletResponse response,
                                     final FilterChain chain) throws Exception {
        // Look up the cached page
        final String key = calculateKey(request);
        PageInfo pageInfo = null;
        String originalThreadName = Thread.currentThread().getName();
        try {
            checkNoReentry(request);
            Element element = blockingCache.get(key);
            if (element == null || element.getObjectValue() == null) {
                try {
                    // Page is not cached - build the response, cache it, and send to client
                    pageInfo = buildPage(request, response, chain);
                    if (pageInfo.isOk()) {
                        if (LOG.isLoggable(Level.FINEST)) {
                            LOG.finest("PageInfo ok. Adding to cache " + blockingCache.getName() + " with key " + key);
                        }
                        blockingCache.put(new Element(key, pageInfo));
                    } else {
View Full Code Here

        final GenericResponseWrapper wrapper = new GenericResponseWrapper(response, outstr);
        chain.doFilter(request, wrapper);
        wrapper.flush();

        // Return the page info
        return new PageInfo(wrapper.getStatus(), wrapper.getContentType(), wrapper.getHeaders(), wrapper.getCookies(),
                outstr.toByteArray(), true);
    }
View Full Code Here

     */
    @Override
    protected PageInfo buildPageInfo(final HttpServletRequest request,
            final HttpServletResponse response, final FilterChain chain)
            throws Exception {
      PageInfo pageInfo = super.buildPageInfo(request, response, chain);
      verifyCaching(request);
        return pageInfo;
    }
View Full Code Here

TOP

Related Classes of net.sf.ehcache.constructs.web.PageInfo

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.