Package org.gatein.pc.api.cache

Examples of org.gatein.pc.api.cache.CacheControl


            // Invoke
            PortletInvocationResponse response = super.invoke(invocation);

            // Try to cache any fragment result
            CacheControl control = null;
            if (response instanceof ContentResponse)
            {
               fragment = (ContentResponse)response;
               control = fragment.getCacheControl();
            }
            else if (response instanceof RevalidateMarkupResponse)
            {
               RevalidateMarkupResponse revalidate = (RevalidateMarkupResponse)response;
               control = revalidate.getCacheControl();
            }

            // Compute expiration time, i.e when it will expire
            long expirationTimeMillis = 0;
            String validationToken = null;
            if (control != null)
            {
               if (control.getExpirationSecs() == -1)
               {
                  expirationTimeMillis = Long.MAX_VALUE;
               }
               else if (control.getExpirationSecs() > 0)
               {
                  expirationTimeMillis = System.currentTimeMillis() + control.getExpirationSecs() * 1000;
               }
               if (control.getValidationToken() != null)
               {
                  validationToken = control.getValidationToken();
               }
               else if (cachedEntry != null)
               {
                  validationToken = cachedEntry.validationToken;
               }
View Full Code Here


            if (response instanceof RevalidateMarkupResponse && cachedContent != null)
            {
               // Normally we receive such response when the validation token was set which implies we have an existing content
               // We substitute with the appropriate content response
               RevalidateMarkupResponse revalidate = (RevalidateMarkupResponse)response;
               CacheControl control = revalidate.getCacheControl();
               if (cachedContent instanceof FragmentResponse)
               {
                  response = new FragmentResponse((FragmentResponse)cachedContent, control);
               }
               else
               {
                  response = new ContentResponse(cachedContent, control);
               }
            }

            // If we have a content cache it whenever it is possible
            if (response instanceof ContentResponse)
            {
               ContentResponse contentResponse = (ContentResponse)response;
               CacheControl control = contentResponse.getCacheControl();

               //
               if (control != null)
               {
                  // Compute expiration time, i.e when it will expire
                  long expirationTimeMillis = 0;
                  if (control.getExpirationSecs() == -1)
                  {
                     expirationTimeMillis = Long.MAX_VALUE;
                  }
                  else if (control.getExpirationSecs() > 0)
                  {
                     expirationTimeMillis = System.currentTimeMillis() + control.getExpirationSecs() * 1000;
                  }

                  // Cache if we can
                  if (expirationTimeMillis > 0)
                  {
                     // Use validation token if any
                     String validationToken = null;
                     if (control.getValidationToken() != null)
                     {
                        validationToken = control.getValidationToken();
                     }
                     else if (cachedEntry != null)
                     {
                        validationToken = cachedEntry.validationToken;
                     }
View Full Code Here

TOP

Related Classes of org.gatein.pc.api.cache.CacheControl

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.