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

Chris Laprun chris.laprun at jboss.com
Mon Aug 21 19:07:20 EDT 2006


  User: claprun 
  Date: 06/08/21 19:07:20

  Modified:    wsrp/src/main/org/jboss/portal/wsrp/consumer       Tag:
                        JBoss_Portal_Branch_2_4 ActionHandler.java
                        ProducerSessionInformation.java RenderHandler.java
                        InvocationHandler.java SessionHandler.java
                        WSRPConsumerImpl.java
  Log:
  - Backported recent changes.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.4.2.1   +12 -35    jboss-portal/wsrp/src/main/org/jboss/portal/wsrp/consumer/ActionHandler.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ActionHandler.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-portal/wsrp/src/main/org/jboss/portal/wsrp/consumer/ActionHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.4.2.1
  diff -u -b -r1.4 -r1.4.2.1
  --- ActionHandler.java	31 Jul 2006 00:20:52 -0000	1.4
  +++ ActionHandler.java	21 Aug 2006 23:07:20 -0000	1.4.2.1
  @@ -23,7 +23,7 @@
   package org.jboss.portal.wsrp.consumer;
   
   import org.jboss.portal.common.util.ParameterValidation;
  -import org.jboss.portal.portlet.InvokerUnavailableException;
  +import org.jboss.portal.portlet.Parameters;
   import org.jboss.portal.portlet.ParametersStateString;
   import org.jboss.portal.portlet.StateString;
   import org.jboss.portal.portlet.invocation.PortletInvocation;
  @@ -33,7 +33,6 @@
   import org.jboss.portal.portlet.spi.ActionContext;
   import org.jboss.portal.portlet.spi.InstanceContext;
   import org.jboss.portal.portlet.state.AccessMode;
  -import org.jboss.portal.portlet.Parameters;
   import org.jboss.portal.wsrp.WSRPTypeFactory;
   import org.jboss.portal.wsrp.WSRPUtils;
   import org.jboss.portal.wsrp.core.BlockingInteractionResponse;
  @@ -52,7 +51,7 @@
   
   /**
    * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.4.2.1 $
    * @since 2.4 (May 31, 2006)
    */
   public class ActionHandler extends InvocationHandler
  @@ -62,8 +61,7 @@
         super(consumer);
      }
   
  -   void processActionRequest(PortletInvocation invocation, RequestPrecursor requestPrecursor)
  -      throws InvokerUnavailableException
  +   protected Object prepareRequest(RequestPrecursor requestPrecursor, PortletInvocation invocation)
      {
         // access mode
         InstanceContext instanceContext = invocation.getInstanceContext();
  @@ -111,31 +109,17 @@
         // todo: need to deal with GET method in forms
   
         // Create the blocking action request
  -      PerformBlockingInteraction actionRequest = WSRPTypeFactory.createPerformBlockingInteraction(
  +      return WSRPTypeFactory.createPerformBlockingInteraction(
            requestPrecursor.portletHandle, requestPrecursor.runtimeContext, requestPrecursor.markupParams,
            interactionParams);
  -      actionRequest.setRegistrationContext(consumer.getRegistrationContext());
  -
  -      // User context
  -      actionRequest.setUserContext(consumer.getUserContextFrom(invocation, requestPrecursor.runtimeContext));
  -
  -      BlockingInteractionResponse response;
  -      try
  -      {
  -         response = performActionRequest(actionRequest, invocation, 0);
  -      }
  -      catch (ServiceDescriptionUnavailableException e)
  -      {
  -         throw new InvokerUnavailableException(e.getMessage(), e);
         }
  -      if (response == null)
  +
  +   protected void processResponse(Object response, PortletInvocation invocation, RequestPrecursor requestPrecursor)
         {
  -         unwrapWSRPError(invocation);
  -         return;
  -      }
  +      BlockingInteractionResponse blockingInteractionResponse = (BlockingInteractionResponse)response;
   
  -      String redirectURL = response.getRedirectURL();
  -      UpdateResponse updateResponse = response.getUpdateResponse();
  +      String redirectURL = blockingInteractionResponse.getRedirectURL();
  +      UpdateResponse updateResponse = blockingInteractionResponse.getUpdateResponse();
         if (redirectURL != null && updateResponse != null)
         {
            invocation.setResult(new ErrorResult(
  @@ -177,14 +161,14 @@
            if (portletContext != null && !requestPrecursor.portletHandle.equals(portletContext.getPortletHandle()))
            {
               // fix-me: we don't currently handle clones
  -            log.warn("Producer '");
  +            log.warn("Implicit clone operation not currently supported: producer '" + consumer.getProducerId()
  +               + "' updated the portlet handle.");
            }
   
            invocation.setResult(result);
         }
      }
   
  -
      protected void updateUserContext(Object request, UserContext userContext)
      {
         getActionRequest(request).setUserContext(userContext);
  @@ -215,11 +199,4 @@
   
         throw new IllegalArgumentException("ActionHandler: request is not a PerformBlockingInteraction request!");
      }
  -
  -   public BlockingInteractionResponse performActionRequest(PerformBlockingInteraction actionRequest,
  -                                                           PortletInvocation invocation, int retryCount)
  -      throws ServiceDescriptionUnavailableException
  -   {
  -      return (BlockingInteractionResponse)performRequest(actionRequest, invocation, retryCount);
  -   }
   }
  
  
  
  1.2.2.1   +78 -13    jboss-portal/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerSessionInformation.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ProducerSessionInformation.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-portal/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerSessionInformation.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -b -r1.2 -r1.2.2.1
  --- ProducerSessionInformation.java	30 Jun 2006 21:05:03 -0000	1.2
  +++ ProducerSessionInformation.java	21 Aug 2006 23:07:20 -0000	1.2.2.1
  @@ -22,6 +22,11 @@
   
   package org.jboss.portal.wsrp.consumer;
   
  +import org.jboss.logging.Logger;
  +import org.jboss.portal.common.util.ParameterValidation;
  +import org.jboss.portal.wsrp.WSRPConstants;
  +import org.jboss.portal.wsrp.core.SessionContext;
  +
   import java.util.HashMap;
   import java.util.Map;
   
  @@ -29,15 +34,22 @@
    * Records session and cookie information for a producer.
    *
    * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.2.2.1 $
    * @since 2.4 (May 30, 2006)
    */
   public class ProducerSessionInformation
   {
  +   private Logger log = Logger.getLogger(ProducerSessionInformation.class);
  +
      private boolean userCookiesInitialized = false;
      private boolean perGroupCookies = false;
  +
  +   /** group id -> cookie */
      private Map groupCookies;
  +
  +   /** portlet handle -> SessionInfo */
      private Map portletSessions;
  +
      private String userCookie;
   
      public String getUserCookie()
  @@ -125,35 +137,41 @@
         groupCookies = null;
      }
   
  -   public void addSessionIdForPortlet(String portletHandle, String sessionId)
  +   public void addSessionForPortlet(String portletHandle, SessionContext sessionContext)
      {
  -      if (portletHandle == null || sessionId == null)
  -      {
  -         throw new IllegalArgumentException("Cannot add sessionId: '" + sessionId + "' for portlet id: '"
  -            + portletHandle + "'");
  -      }
  +      ParameterValidation.throwIllegalArgExceptionIfNull(portletHandle, "portlet handle");
   
         if (portletSessions == null)
         {
            portletSessions = new HashMap();
         }
   
  -      portletSessions.put(portletHandle, sessionId);
  +      portletSessions.put(portletHandle, new SessionInfo(sessionContext));
      }
   
  +   /**
  +    * Retrieves the session id for the portlet with the specified handle. Note that this will "touch" the session, hence
  +    * resetting the time since the last use of the session.
  +    *
  +    * @param portletHandle the handle of the portlet for which the session id is to be retrieved
  +    * @return the session id for the specified portlet, <code>null</code> if there is no session associated with the
  +    *         portlet or if the session has expired.
  +    */
      public String getSessionIdForPortlet(String portletHandle)
      {
  -      if (portletHandle == null)
  -      {
  -         throw new IllegalArgumentException("Cannot get sessionId for null portlet handle");
  -      }
  +      ParameterValidation.throwIllegalArgExceptionIfNull(portletHandle, "portlet handle");
   
         if (portletSessions == null)
         {
            return null;
         }
   
  -      return (String)portletSessions.get(portletHandle);
  +      SessionInfo session = (SessionInfo)portletSessions.get(portletHandle);
  +      if (session != null)
  +      {
  +         return session.getSessionId();
  +      }
  +      return null;
      }
   
      public void removeSessionIdForPortlet(String portletHandle)
  @@ -163,4 +181,51 @@
            portletSessions.remove(portletHandle);
         }
      }
  +
  +   private class SessionInfo
  +   {
  +      private SessionContext sessionContext;
  +      private long lastInvocationTime;
  +
  +      public SessionInfo(SessionContext sessionContext)
  +      {
  +         ParameterValidation.throwIllegalArgExceptionIfNull(sessionContext, "SessionContext");
  +         ParameterValidation.throwIllegalArgExceptionIfNull(sessionContext.getSessionID(), "session id");
  +
  +         this.sessionContext = sessionContext;
  +         lastInvocationTime = System.currentTimeMillis();
  +      }
  +
  +      /**
  +       * Checks that the session associated with the session context hasn't expired and update the last invocation time
  +       *
  +       * @return
  +       */
  +      private boolean isStillValid()
  +      {
  +         int expires = sessionContext.getExpires();
  +         if (expires == WSRPConstants.SESSION_NEVER_EXPIRES)
  +         {
  +            return true;
  +         }
  +
  +         long now = System.currentTimeMillis();
  +         long secondsSinceLastInvocation = (now - lastInvocationTime) / 1000;
  +         lastInvocationTime = now;
  +
  +         long diff = expires - secondsSinceLastInvocation;
  +         log.debug("Session ID '" + sessionContext.getSessionID() + "' is " + ((diff > 0) ? "" : "not")
  +            + " valid (time since last invocation: " + diff + ")");
  +         return diff > 0;
  +      }
  +
  +      public String getSessionId()
  +      {
  +         if (isStillValid())
  +         {
  +            return sessionContext.getSessionID();
  +         }
  +         return null;
  +      }
  +   }
   }
  
  
  
  1.8.2.1   +9 -32     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.8
  retrieving revision 1.8.2.1
  diff -u -b -r1.8 -r1.8.2.1
  --- RenderHandler.java	2 Aug 2006 23:48:23 -0000	1.8
  +++ RenderHandler.java	21 Aug 2006 23:07:20 -0000	1.8.2.1
  @@ -24,7 +24,6 @@
   
   import org.jboss.portal.common.util.Tools;
   import org.jboss.portal.common.util.URLTools;
  -import org.jboss.portal.portlet.InvokerUnavailableException;
   import org.jboss.portal.portlet.invocation.PortletInvocation;
   import org.jboss.portal.portlet.result.ErrorResult;
   import org.jboss.portal.portlet.result.FragmentResult;
  @@ -43,7 +42,7 @@
   
   /**
    * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
  - * @version $Revision: 1.8 $
  + * @version $Revision: 1.8.2.1 $
    * @since 2.4 (May 31, 2006)
    */
   public class RenderHandler extends InvocationHandler
  @@ -57,43 +56,21 @@
         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
  +   protected Object prepareRequest(RequestPrecursor requestPrecursor, PortletInvocation invocation)
      {
         // Create the markup request
  -      GetMarkup markupRequest = WSRPTypeFactory.createMarkupRequest(requestPrecursor.portletHandle,
  +      return WSRPTypeFactory.createMarkupRequest(requestPrecursor.portletHandle,
            requestPrecursor.runtimeContext, requestPrecursor.markupParams);
  -      markupRequest.setRegistrationContext(consumer.getRegistrationContext());
  -
  -      // User context
  -      markupRequest.setUserContext(consumer.getUserContextFrom(invocation, requestPrecursor.runtimeContext));
  -
  -      // Perform the request
  -      MarkupResponse response;
  -      try
  -      {
  -         response = performRenderRequest(markupRequest, invocation, 0);
  -      }
  -      catch (ServiceDescriptionUnavailableException e)
  -      {
  -         throw new InvokerUnavailableException(e.getMessage(), e);
         }
  -      if (response == null)
  +
  +   protected void processResponse(Object response, PortletInvocation invocation, RequestPrecursor requestPrecursor)
         {
  -         unwrapWSRPError(invocation);
  -         return;
  -      }
  +      MarkupResponse markupResponse = (MarkupResponse)response;
   
         // process the response
  -      consumer.getSessionHandler().updateSessionIfNeeded(response.getSessionContext(), invocation);
  +      consumer.getSessionHandler().updateSessionIfNeeded(markupResponse.getSessionContext(), invocation);
   
  -      MarkupContext markupContext = response.getMarkupContext();
  +      MarkupContext markupContext = markupResponse.getMarkupContext();
         String markup = markupContext.getMarkupString();
         byte[] binary = markupContext.getMarkupBinary();
         if (markup != null && binary != null)
  
  
  
  1.2.2.1   +58 -26    jboss-portal/wsrp/src/main/org/jboss/portal/wsrp/consumer/InvocationHandler.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: InvocationHandler.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-portal/wsrp/src/main/org/jboss/portal/wsrp/consumer/InvocationHandler.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -b -r1.2 -r1.2.2.1
  --- InvocationHandler.java	10 Aug 2006 19:56:47 -0000	1.2
  +++ InvocationHandler.java	21 Aug 2006 23:07:20 -0000	1.2.2.1
  @@ -23,6 +23,8 @@
   package org.jboss.portal.wsrp.consumer;
   
   import org.jboss.logging.Logger;
  +import org.jboss.portal.portlet.InvokerUnavailableException;
  +import org.jboss.portal.portlet.PortletInvokerException;
   import org.jboss.portal.portlet.invocation.PortletInvocation;
   import org.jboss.portal.portlet.result.ErrorResult;
   import org.jboss.portal.wsrp.core.InvalidCookieFault;
  @@ -38,13 +40,12 @@
   
   /**
    * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
  - * @version $Revision: 1.2 $
  + * @version $Revision: 1.2.2.1 $
    * @since 2.4 (May 31, 2006)
    */
   public abstract class InvocationHandler
   {
      protected WSRPConsumerImpl consumer;
  -//   protected SessionHandler sessionHandler;
   
      protected Logger log = Logger.getLogger(getClass());
      /**
  @@ -62,42 +63,67 @@
         this.consumer = consumer;
      }
   
  -   protected Object performRequest(Object request, PortletInvocation invocation, int retryCount)
  +   void handle(PortletInvocation invocation) throws PortletInvokerException
  +   {
  +      // Extracts basic required information from invocation
  +      RequestPrecursor requestPrecursor = new RequestPrecursor(consumer, invocation);
  +
  +      // create the specific request
  +      Object request = prepareRequest(requestPrecursor, invocation);
  +
  +      // Perform the request
  +      Object response;
  +      try
  +      {
  +         response = performRequest(request, invocation);
  +      }
  +      catch (ServiceDescriptionUnavailableException e)
  +      {
  +         throw new InvokerUnavailableException(e.getMessage(), e);
  +      }
  +      if (response == null)
  +      {
  +         unwrapWSRPError(invocation);
  +         return;
  +      }
  +
  +      processResponse(response, invocation, requestPrecursor);
  +   }
  +
  +   protected Object performRequest(Object request, PortletInvocation invocation)
         throws ServiceDescriptionUnavailableException
      {
  +      int retryCount = 0;
  +      Object response = null;
  +
  +      // as long as we don't get a non-null response and we're allowed to try again, try to perform the request
  +      while (response == null && retryCount != DO_NOT_RETRY && retryCount < MAXIMUM_RETRY_NUMBER)
  +      {
  +         // prepare everything for the request
         SessionHandler sessionHandler = consumer.getSessionHandler();
         sessionHandler.initCookieIfNeeded(invocation);
  +         updateRegistrationContext(request);
  +         RuntimeContext runtimeContext = getRuntimeContextFrom(request);
  +         updateUserContext(request, consumer.getUserContextFrom(invocation, runtimeContext));
  +         consumer.setTemplatesIfNeeded(invocation, runtimeContext);
   
  -      Object response = null;
         try
         {
            // if we need cookies, set the current group id
            sessionHandler.initPortletGroupIdIfNeeded(invocation);
   
            response = performRequest(request);
  -
         }
         catch (Exception e)
         {
  -         RuntimeContext runtimeContext = getRuntimeContextFrom(request);
            retryCount = dealWithError(e, invocation, runtimeContext, retryCount);
  -
  -         if (retryCount != DO_NOT_RETRY && retryCount < MAXIMUM_RETRY_NUMBER)
  -         {
  -            // update the different parameters since they may have been modified
  -            updateRegistrationContext(request);
  -            updateUserContext(request, consumer.getUserContextFrom(invocation, runtimeContext));
  -            consumer.setTemplatesIfNeeded(invocation, runtimeContext);
  -
  -            response = performRequest(request, invocation, retryCount);
  -         }
         }
         finally
         {
            // we're done: reset current group id
            sessionHandler.resetPortletGroupIdIfNeeded();
         }
  -
  +      }
         return response;
      }
   
  @@ -120,12 +146,13 @@
         // recoverable errors
         if (error instanceof InvalidCookieFault)
         {
  -         log.info("Re-initializing cookies after InvalidCookieFault");
  +         log.debug("Re-initializing cookies after InvalidCookieFault.");
            // we need to re-init the cookies
            sessionHandler.initCookieIfNeeded(invocation);
         }
         else if (error instanceof InvalidSessionFault)
         {
  +         log.debug("Session invalidated afet InvalidSessionFault, will re-send session-stored information.");
            sessionHandler.handleInvalidSessionFault(invocation, runtimeContext);
         }
         else if (error instanceof InvalidRegistrationFault)
  @@ -199,4 +226,9 @@
      protected abstract RuntimeContext getRuntimeContextFrom(Object request);
   
      protected abstract Object performRequest(Object request) throws Exception;
  +
  +   protected abstract Object prepareRequest(RequestPrecursor requestPrecursor, PortletInvocation invocation);
  +
  +   protected abstract void processResponse(Object response, PortletInvocation invocation, RequestPrecursor requestPrecursor);
  +
   }
  
  
  
  1.5.2.1   +6 -9      jboss-portal/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SessionHandler.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-portal/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.5.2.1
  diff -u -b -r1.5 -r1.5.2.1
  --- SessionHandler.java	10 Aug 2006 19:56:47 -0000	1.5
  +++ SessionHandler.java	21 Aug 2006 23:07:20 -0000	1.5.2.1
  @@ -44,7 +44,7 @@
    * Manages session informations on behalf of a consumer.
    *
    * @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a>
  - * @version $Revision: 1.5 $
  + * @version $Revision: 1.5.2.1 $
    * @since 2.4 (May 31, 2006)
    */
   public class SessionHandler
  @@ -54,9 +54,9 @@
   
      /** Cookie protocol required by the producer with the consumer */
      private CookieProtocol requiresInitCookie;
  +
      /** The prefix used to isolate WSRP-related session information in the actual session object. */
      private static final String SESSION_ID_PREFIX = "org.jboss.portal.wsrp.session.";
  -   private static final String SESSION_ID = "session id";
   
      /**
       * Constructs a new SessionHandler.
  @@ -83,12 +83,12 @@
         this.requiresInitCookie = requiresInitCookie;
      }
   
  -   public void initPortletGroupIdIfNeeded(PortletInvocation invocation)
  +   void initPortletGroupIdIfNeeded(PortletInvocation invocation)
      {
         // if we need cookies, set the current group id
         if (requiresGroupInitCookie())
         {
  -         WSRPPortletInfo info = consumer.getPortletInfo(WSRPConsumerImpl.getPortletHandle(invocation));
  +         WSRPPortletInfo info = consumer.getPortletInfo(invocation);
            RequestHeaderClientHandler.setCurrentGroupId(info.getGroupId());
         }
      }
  @@ -204,11 +204,8 @@
      {
         if (sessionContext != null)
         {
  -         String sessionId = sessionContext.getSessionID();
  -         ParameterValidation.throwIllegalArgExceptionIfNull(sessionId, SESSION_ID);
            ProducerSessionInformation sessionInfo = getProducerSessionInformation(invocation);
  -         sessionInfo.addSessionIdForPortlet(WSRPConsumerImpl.getPortletHandle(invocation), sessionId);
  -         // sessionContext.getExpires(); // todo: manage expiration
  +         sessionInfo.addSessionForPortlet(WSRPConsumerImpl.getPortletHandle(invocation), sessionContext);
         }
      }
   
  @@ -252,7 +249,7 @@
         // invalidate current session
         invalidateSession(invocation);
   
  -      // fix the request todo: there is more to do here, check the spec!
  +      // set the session id to null
         runtimeContext.setSessionID(null);
      }
   
  
  
  
  1.51.2.1  +19 -11    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.51
  retrieving revision 1.51.2.1
  diff -u -b -r1.51 -r1.51.2.1
  --- WSRPConsumerImpl.java	10 Aug 2006 19:56:47 -0000	1.51
  +++ WSRPConsumerImpl.java	21 Aug 2006 23:07:20 -0000	1.51.2.1
  @@ -68,7 +68,7 @@
   /**
    * @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.51 $
  + * @version $Revision: 1.51.2.1 $
    * @since 2.4
    */
   public class WSRPConsumerImpl extends AbstractJBossService implements WSRPConsumer
  @@ -174,21 +174,22 @@
   
      public void invoke(PortletInvocation invocation) throws PortletInvokerException
      {
  -      // Extracts basic required information from invocation
  -      RequestPrecursor requestPrecursor = new RequestPrecursor(this, invocation);
  +      InvocationHandler handler;
   
         if (invocation instanceof RenderInvocation)
         {
  -         renderHandler.processRenderRequest(requestPrecursor, invocation);
  +         handler = renderHandler;
         }
         else if (invocation instanceof ActionInvocation)
         {
  -         actionHandler.processActionRequest(invocation, requestPrecursor);
  +         handler = actionHandler;
         }
         else
         {
            throw new InvocationException("Unknown invocation type: " + invocation);
         }
  +
  +      handler.handle(invocation);
      }
   
      public String createClone(String portletId)
  @@ -249,15 +250,15 @@
         return (String)invocation.getAttribute(PortletInvocation.PORTLET_ID_ATTRIBUTE);
      }
   
  -   WSRPPortletInfo getPortletInfo(String portletHandle)
  +   WSRPPortletInfo getPortletInfo(PortletInvocation invocation)
      {
         try
         {
  -         return (WSRPPortletInfo)getWSRPPortlet(portletHandle).getInfo();
  +         return (WSRPPortletInfo)getWSRPPortlet(getPortletHandle(invocation)).getInfo();
         }
         catch (PortletInvokerException e)
         {
  -         log.debug("Couldn't retrieve portlet info for portlet: '" + portletHandle + "'", e);
  +         log.debug("Couldn't retrieve portlet info for portlet: '" + getPortletHandle(invocation) + "'", e);
            return null;
         }
      }
  @@ -317,6 +318,13 @@
                     + "' uses the GET method in forms. Since we don't handle this, this portlet will be excluded from " +
                     "the list of offered portlets for producer " + getProducerId());
               }
  +            else if (info.isHasUserSpecificState())
  +            {
  +               log.warn("Portlet '" + portletHandle
  +                  + "' will store persistent state for each user. To be handled properly, this would require " +
  +                  "supporting portlet cloning, which we don't currently do. This portlet will be excluded from the " +
  +                  "list of offered portlets for producer " + getProducerId());
  +            }
               else
               {
                  WSRPPortlet wsrpPortlet = new WSRPPortlet(portletHandle, info);
  @@ -396,7 +404,7 @@
      void handleInvalidRegistrationFault()
         throws ServiceDescriptionUnavailableException
      {
  -      log.info("Trying to re-register after InvalidRegistrationFault");
  +      log.debug("Trying to re-register after InvalidRegistrationFault");
         // get the service description again and try to register
         getServiceDescriptionAndRegisterIfNeeded();
      }
  @@ -615,7 +623,7 @@
      org.jboss.portal.wsrp.core.UserContext getUserContextFrom(PortletInvocation invocation, RuntimeContext runtimeContext)
      {
         // first decide if we need to pass the user context...
  -      WSRPPortletInfo info = getPortletInfo(getPortletHandle(invocation));
  +      WSRPPortletInfo info = getPortletInfo(invocation);
   
         if (info != null && info.isUserContextStoredInSession() && runtimeContext.getSessionID() != null)
         {
  @@ -640,7 +648,7 @@
      void setTemplatesIfNeeded(PortletInvocation invocation, RuntimeContext runtimeContext)
      {
         // todo: could store templates in producer session info to avoid to re-generate them all the time?
  -      WSRPPortletInfo info = getPortletInfo(getPortletHandle(invocation));
  +      WSRPPortletInfo info = getPortletInfo(invocation);
   
         if (info != null && info.isDoesUrlTemplateProcessing()
            && (!info.isTemplatesStoredInSession() || runtimeContext.getSessionID() == null))
  
  
  



More information about the jboss-cvs-commits mailing list