[jboss-cvs] jboss-portal/wsrp/src/main/org/jboss/portal/wsrp/consumer ...

Chris Laprun chris.laprun at jboss.com
Wed Aug 2 19:48:23 EDT 2006


  User: claprun 
  Date: 06/08/02 19:48:23

  Modified:    wsrp/src/main/org/jboss/portal/wsrp/consumer  
                        RenderHandler.java WSRPConsumerImpl.java
  Log:
  - Implemented producer-side support for sending caching information to consumers.
  - Added caching support tests.
  - Improved tests.
  
  Revision  Changes    Path
  1.8       +23 -19    jboss-portal/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: RenderHandler.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-portal/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -b -r1.7 -r1.8
  --- RenderHandler.java	1 Aug 2006 13:57:45 -0000	1.7
  +++ RenderHandler.java	2 Aug 2006 23:48:23 -0000	1.8
  @@ -43,7 +43,7 @@
   
   /**
    * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
  - * @version $Revision: 1.7 $
  + * @version $Revision: 1.8 $
    * @since 2.4 (May 31, 2006)
    */
   public class RenderHandler extends InvocationHandler
  @@ -57,6 +57,12 @@
         super(consumer);
      }
   
  +   public MarkupResponse performRenderRequest(GetMarkup markupRequest, PortletInvocation invocation, int retryCount)
  +      throws ServiceDescriptionUnavailableException
  +   {
  +      return (MarkupResponse)performRequest(markupRequest, invocation, retryCount);
  +   }
  +
      void processRenderRequest(RequestPrecursor requestPrecursor, PortletInvocation invocation)
         throws InvokerUnavailableException
      {
  @@ -110,21 +116,7 @@
         result.setTitle(markupContext.getPreferredTitle());
   
         // cache markup if possible
  -      CacheControl cacheControl = markupContext.getCacheControl();
  -      int expires;
  -      if (cacheControl != null)
  -      {
  -         expires = cacheControl.getExpires();
  -         String userScope = cacheControl.getUserScope();
  -         log.debug("RenderHandler.processRenderRequest: trying to cache markup " + userScope + " for " + expires + " seconds.");
  -      }
  -      else
  -      {
  -         //use default value based on consumer cache expiration time
  -         Integer expirationCacheSeconds = consumer.getExpirationCacheSeconds();
  -         expires = (expirationCacheSeconds != null ? expirationCacheSeconds.intValue() : 0);
  -      }
  -      result.setExpirationSecs(expires);
  +      cacheMarkupIfNeeded(markupContext, result);
   
         PrintWriter writer = result.getWriter();
         writer.write(markup);
  @@ -186,10 +178,22 @@
         }
      }
   
  -   public MarkupResponse performRenderRequest(GetMarkup markupRequest, PortletInvocation invocation, int retryCount)
  -      throws ServiceDescriptionUnavailableException
  +   private void cacheMarkupIfNeeded(MarkupContext markupContext, FragmentResult result)
      {
  -      return (MarkupResponse)performRequest(markupRequest, invocation, retryCount);
  +      CacheControl cacheControl = markupContext.getCacheControl();
  +      int expires;
  +      if (cacheControl != null)
  +      {
  +         expires = cacheControl.getExpires();
  +         String userScope = cacheControl.getUserScope();
  +
  +         // check that we support the user scope...
  +         if (consumer.supportsUserScope(userScope))
  +         {
  +            log.debug("RenderHandler.processRenderRequest: trying to cache markup " + userScope + " for " + expires + " seconds.");
  +            result.setExpirationSecs(expires);
  +         }
  +      }
      }
   
      private static class WSRPURLRewriter extends URLTools.URLReplacementGenerator
  
  
  
  1.50      +29 -2     jboss-portal/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: WSRPConsumerImpl.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-portal/wsrp/src/main/org/jboss/portal/wsrp/consumer/WSRPConsumerImpl.java,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -b -r1.49 -r1.50
  --- WSRPConsumerImpl.java	30 Jun 2006 21:05:03 -0000	1.49
  +++ WSRPConsumerImpl.java	2 Aug 2006 23:48:23 -0000	1.50
  @@ -68,12 +68,11 @@
   /**
    * @author <a href="mailto:boleslaw.dawidowicz at jboss.org">Boleslaw Dawidowicz</a>
    * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
  - * @version $Revision: 1.49 $
  + * @version $Revision: 1.50 $
    * @since 2.4
    */
   public class WSRPConsumerImpl extends AbstractJBossService implements WSRPConsumer
   {
  -
      private static final String SERVICE_DESCRIPTION = "service description";
      private static final String MARKUP = "markup";
      private static final String PORTLET_MANAGEMENT = "portlet management";
  @@ -113,6 +112,18 @@
      /** The registration data used to register this consumer with the associated producer */
      private RegistrationData registrationData;
   
  +   /** The default user scopes as per the specification (6.1.4) */
  +   private static final Set WSRP_DEFAULT_USER_SCOPE = new HashSet(2);
  +
  +   static
  +   {
  +      WSRP_DEFAULT_USER_SCOPE.add(WSRPConstants.CACHE_FOR_ALL);
  +      WSRP_DEFAULT_USER_SCOPE.add(WSRPConstants.CACHE_PER_USER);
  +   }
  +
  +   /** The set of supported user scopes */
  +   private Set supportedUserScopes = WSRP_DEFAULT_USER_SCOPE; // todo: make it possible to support different user scopes
  +
      public WSRPConsumerImpl()
      {
         unregisteredServiceDescriptionRequest = initUnregisteredServiceDescriptionRequest();
  @@ -364,6 +375,22 @@
         this.expirationCacheSeconds = expirationCacheSeconds;
      }
   
  +   public Set getSupportedUserScopes()
  +   {
  +      return Collections.unmodifiableSet(supportedUserScopes);
  +   }
  +
  +   /**
  +    * Determines whether the specified user scope (for markup caching) is supported.
  +    *
  +    * @param userScope the user scope which support is to be determined
  +    * @return <code>true</code> if the given user scope is supported, <code>false</code> otherwise
  +    */
  +   public boolean supportsUserScope(String userScope)
  +   {
  +      return supportedUserScopes.contains(userScope);
  +   }
  +
      // Registration *****************************************************************************************************
   
      void handleInvalidRegistrationFault()
  
  
  



More information about the jboss-cvs-commits mailing list