Author: chris.laprun(a)jboss.com
Date: 2007-05-20 16:33:53 -0400 (Sun, 20 May 2007)
New Revision: 7276
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ActionHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/InvocationHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerSessionInformation.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java
Log:
- Update session information in case a portlet was cloned.
- Cache CCPs.
- Improved logging.
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ActionHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ActionHandler.java 2007-05-20
18:40:25 UTC (rev 7275)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ActionHandler.java 2007-05-20
20:33:53 UTC (rev 7276)
@@ -24,9 +24,9 @@
package org.jboss.portal.wsrp.consumer;
import org.jboss.portal.common.util.ParameterValidation;
+import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.portlet.PortletParametersStateString;
-import org.jboss.portal.portlet.PortletInvokerException;
import org.jboss.portal.portlet.StateEvent;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.invocation.PortletInvocation;
@@ -69,7 +69,7 @@
protected Object prepareRequest(RequestPrecursor requestPrecursor, PortletInvocation
invocation)
{
PortletContext portletContext = requestPrecursor.getPortletContext();
- log.debug("Consumer about to attempt rendering portlet '" +
portletContext.getPortletHandle() + "'");
+ log.debug("Consumer about to attempt action on portlet '" +
portletContext.getPortletHandle() + "'");
// access mode
InstanceContext instanceContext = invocation.getInstanceContext();
@@ -120,6 +120,7 @@
protected PortletInvocationResponse processResponse(Object response, PortletInvocation
invocation, RequestPrecursor requestPrecursor) throws PortletInvokerException
{
BlockingInteractionResponse blockingInteractionResponse =
(BlockingInteractionResponse)response;
+ log.debug("Starting processing response");
String redirectURL = blockingInteractionResponse.getRedirectURL();
UpdateResponse updateResponse = blockingInteractionResponse.getUpdateResponse();
@@ -165,10 +166,11 @@
PortletContext originalContext = requestPrecursor.getPortletContext();
InstanceContext context = invocation.getInstanceContext();
- if
(!originalContext.getPortletHandle().equals(portletContext.getPortletHandle()))
+ String handle = portletContext.getPortletHandle();
+ if (!originalContext.getPortletHandle().equals(handle))
{
log.debug("Portlet '" + requestPrecursor.getPortletHandle()
+ "' was implicitely cloned. New handle is '"
- + portletContext.getPortletHandle() + "'");
+ + handle + "'");
StateEvent event = new
StateEvent(WSRPUtils.convertToPortalPortletContext(portletContext),
StateEvent.PORTLET_CLONED_EVENT);
context.onStateEvent(event);
}
@@ -183,9 +185,12 @@
context.onStateEvent(event);
}
}
+
+ // update the session information associated with the portlet handle
+
consumer.getSessionHandler().updateSessionInfoFor(originalContext.getPortletHandle(),
handle, invocation);
}
-
+ log.debug("Response processed");
return result;
}
}
@@ -208,7 +213,9 @@
protected Object performRequest(Object request)
throws Exception
{
- return
consumer.getMarkupService().performBlockingInteraction(getActionRequest(request));
+ PerformBlockingInteraction interaction = getActionRequest(request);
+ log.debug("performBlockingInteraction on '" +
interaction.getPortletContext().getPortletHandle() + "'");
+ return consumer.getMarkupService().performBlockingInteraction(interaction);
}
private PerformBlockingInteraction getActionRequest(Object request)
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java 2007-05-20
18:40:25 UTC (rev 7275)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/EndpointConfigurationInfo.java 2007-05-20
20:33:53 UTC (rev 7276)
@@ -23,6 +23,7 @@
package org.jboss.portal.wsrp.consumer;
+import org.jboss.logging.Logger;
import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.portlet.InvokerUnavailableException;
import org.jboss.portal.wsrp.core.WSRP_v1_Markup_PortType;
@@ -42,6 +43,8 @@
*/
public class EndpointConfigurationInfo
{
+ private final static Logger log = Logger.getLogger(EndpointConfigurationInfo.class);
+
/** DB primary key */
private Long key;
@@ -377,7 +380,12 @@
public boolean isRefreshNeeded()
{
- return !isAvailable() || areURLsDirty();
+ boolean result = !isAvailable() || areURLsDirty();
+ if (result)
+ {
+ log.debug("Refresh needed");
+ }
+ return result;
}
private boolean areURLsDirty()
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/InvocationHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/InvocationHandler.java 2007-05-20
18:40:25 UTC (rev 7275)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/InvocationHandler.java 2007-05-20
20:33:53 UTC (rev 7276)
@@ -139,6 +139,7 @@
sessionHandler.resetCurrentlyHeldInformation();
}
}
+ log.debug("performRequest finished. Response is " + (response != null ?
response.getClass().getName() : null));
return response;
}
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-05-20
18:40:25 UTC (rev 7275)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerInfo.java 2007-05-20
20:33:53 UTC (rev 7276)
@@ -63,7 +63,7 @@
*/
public class ProducerInfo
{
- private final Logger log = Logger.getLogger(getClass());
+ private final static Logger log = Logger.getLogger(ProducerInfo.class);
// Persistent information
@@ -93,6 +93,9 @@
/** The Producer-Offered Portlets (handle -> WSRPPortlet) */
private Map popsMap;
+ /** A cache for Consumer-Configured Portlets (handle -> WSRPPortlet) */
+ private Map ccpsMap;
+
/** Portlet groups. */
private Map portletGroups;
@@ -254,7 +257,7 @@
// POPs and rest of producer info separetely...
if (forceRefresh || isRefreshNeeded(true))
{
- log.debug("ProducerInfo refresh needed for producer '" +
persistentId + "'");
+ log.debug("Refreshing...");
RefreshResult result = new RefreshResult(true, REFRESH_MEANING);
try
{
@@ -418,29 +421,37 @@
public Portlet getPortlet(PortletContext portletContext) throws
PortletInvokerException
{
- boolean justRefreshed = refresh(false);
-
String portletHandle = portletContext.getId();
ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(portletHandle,
"Portlet handle", "getPortlet");
+ log.debug("Retrieving portlet '" + portletHandle +
"'");
+ // check if we need to refresh
+ boolean justRefreshed = refresh(false);
+
Portlet portlet = null;
- // First try POP cache if cache is still valid or we just refreshed
+ // First try caches if caches are still valid or we just refreshed
if (justRefreshed || (useCache() && !isCacheExpired()))
{
- log.debug("Trying to retrieve portlet '" + portletHandle +
"' from cached service description");
+ log.debug("Trying cached POPs");
portlet = (Portlet)popsMap.get(portletHandle);
+
+ if (portlet == null)
+ {
+ log.debug("Trying cached CCPs");
+ portlet = (Portlet)ccpsMap.get(portletHandle);
+ }
}
- if (portlet != null) // we had a match on a POP, return it
+ if (portlet != null) // we had a match in cache, return it
{
- log.debug("Portlet '" + portletHandle + "' was in cached
service description");
+ log.debug("Portlet was cached");
return portlet;
}
else // otherwise, retrieve just the information for the appropriate portlet
{
- log.debug("Retrieving portlet '" + portletHandle + "' via
getPortletDescription");
+ log.debug("Retrieving portlet via getPortletDescription");
GetPortletDescription gpd =
WSRPTypeFactory.createGetPortletDescription(getRegistrationContext(), portletContext);
gpd.setUserContext(UserAccess.getUserContext());
@@ -449,7 +460,16 @@
{
PortletDescriptionResponse response =
persistentEndpointInfo.getPortletManagementService().getPortletDescription(gpd);
ParameterValidation.throwIllegalArgExceptionIfNull(response,
"PortletDescriptionResponse");
- return
createWSRPPortletFromPortletDescription(response.getPortletDescription());
+ portlet =
createWSRPPortletFromPortletDescription(response.getPortletDescription());
+
+ // add the portlet to the CCP cache
+ if (ccpsMap == null)
+ {
+ ccpsMap = new HashMap();
+ }
+ ccpsMap.put(portletHandle, portlet);
+
+ return portlet;
}
catch (InvalidHandleFault invalidHandleFault)
{
@@ -496,7 +516,13 @@
*/
private boolean isCacheExpired()
{
- return !useCache() || System.currentTimeMillis() > expirationTimeMillis ||
popsMap == null || portletGroups == null;
+ boolean result = !useCache() || System.currentTimeMillis() >
expirationTimeMillis || popsMap == null
+ || portletGroups == null;
+ if (result)
+ {
+ log.debug("Cache expired or not used");
+ }
+ return result;
}
public Integer getExpirationCacheSeconds()
@@ -773,9 +799,14 @@
public boolean isRefreshNeeded(boolean considerCache)
{
- return (considerCache && isCacheExpired())
+ boolean result = (considerCache && isCacheExpired())
|| persistentRegistrationInfo == null
|| persistentRegistrationInfo.isRefreshNeeded()
|| persistentEndpointInfo.isRefreshNeeded();
+ if (result)
+ {
+ log.debug("Refresh needed for producer '" + persistentId +
"'");
+ }
+ return result;
}
}
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerSessionInformation.java
===================================================================
---
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerSessionInformation.java 2007-05-20
18:40:25 UTC (rev 7275)
+++
trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/ProducerSessionInformation.java 2007-05-20
20:33:53 UTC (rev 7276)
@@ -431,6 +431,36 @@
parent = sessionHandler;
}
+ /**
+ * Update the mappings that were associated with the specified original portlet handle
after it has been modified as
+ * a result of a clone operation to the specified new handle.
+ *
+ * @param originalHandle
+ * @param newHandle
+ * @since 2.6
+ */
+ public void updateHandleAssociatedInfo(String originalHandle, String newHandle)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(originalHandle,
"original handle",
+ "Updating information associated with a portlet handle");
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(newHandle, "new
handle",
+ "Updating information associated with a portlet handle");
+
+ String sessionId = getSessionIdForPortlet(originalHandle);
+ ProducerSessionInformation.SessionInfo info = getSessionInfoFor(originalHandle);
+ if (sessionId != null && info != null)
+ {
+ portletSessions.put(newHandle, info);
+ portletSessions.remove(originalHandle);
+ sessionId2PortletHandle.put(sessionId, newHandle);
+ log.debug("Updated mapping information for '" + originalHandle +
"' to reference '" + newHandle + "' instead.");
+ }
+ else
+ {
+ throw new IllegalArgumentException("Cannot update information for unknown
handle '" + originalHandle + "'");
+ }
+ }
+
private class SessionInfo
{
private SessionContext sessionContext;
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2007-05-20
18:40:25 UTC (rev 7275)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RegistrationInfo.java 2007-05-20
20:33:53 UTC (rev 7276)
@@ -53,7 +53,7 @@
*/
public class RegistrationInfo
{
- private final Logger log = Logger.getLogger(getClass());
+ private static final Logger log = Logger.getLogger(RegistrationInfo.class);
private Long key;
private String persistentConsumerName;
@@ -116,7 +116,12 @@
public boolean isRefreshNeeded()
{
- return dirty || requiresRegistration == null;
+ boolean result = dirty || requiresRegistration == null;
+ if (result)
+ {
+ log.debug("Refresh needed");
+ }
+ return result;
}
public Boolean isRegistrationValid()
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java 2007-05-20
18:40:25 UTC (rev 7275)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/RenderHandler.java 2007-05-20
20:33:53 UTC (rev 7276)
@@ -89,6 +89,7 @@
protected PortletInvocationResponse processResponse(Object response, PortletInvocation
invocation, RequestPrecursor requestPrecursor)
{
MarkupResponse markupResponse = (MarkupResponse)response;
+ log.debug("Starting processing response");
// process the response
consumer.getSessionHandler().updateSessionIfNeeded(markupResponse.getSessionContext(),
invocation);
@@ -120,6 +121,7 @@
PrintWriter writer = result.getWriter();
writer.write(markup);
+ log.debug("Response processed");
return result;
}
@@ -140,7 +142,9 @@
protected Object performRequest(Object request) throws Exception
{
- return consumer.getMarkupService().getMarkup(getRenderRequest(request));
+ GetMarkup renderRequest = getRenderRequest(request);
+ log.debug("getMarkup on '" +
renderRequest.getPortletContext().getPortletHandle() + "'");
+ return consumer.getMarkupService().getMarkup(renderRequest);
}
private GetMarkup getRenderRequest(Object request)
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java 2007-05-20
18:40:25 UTC (rev 7275)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/consumer/SessionHandler.java 2007-05-20
20:33:53 UTC (rev 7276)
@@ -25,8 +25,8 @@
import org.jboss.logging.Logger;
import org.jboss.portal.api.event.PortalEvent;
+import org.jboss.portal.api.event.PortalEventContext;
import org.jboss.portal.api.event.PortalEventListener;
-import org.jboss.portal.api.event.PortalEventContext;
import org.jboss.portal.api.session.event.PortalSessionEvent;
import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.portlet.InvokerUnavailableException;
@@ -438,4 +438,19 @@
}
}
}
+
+ /**
+ * @param originalHandle
+ * @param newHandle
+ * @param invocation
+ * @since 2.6
+ */
+ public void updateSessionInfoFor(String originalHandle, String newHandle,
PortletInvocation invocation)
+ {
+ ProducerSessionInformation info = getProducerSessionInformation(invocation,
false);
+ if (info != null)
+ {
+ info.updateHandleAssociatedInfo(originalHandle, newHandle);
+ }
+ }
}