Author: chris.laprun(a)jboss.com
Date: 2011-01-06 07:11:44 -0500 (Thu, 06 Jan 2011)
New Revision: 5682
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/InvocationHandler.java
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/spi/WSRPConsumerSPI.java
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockWSRPConsumer.java
Log:
- GTNWSRP-194:
+ Made RequestPrecursor deal with templates as well so that we only need to retrieve the
PortletInfo once.
+ Made getUserContextFrom and setTemplatesIfNeeded use a provided PortletInfo.
+ Added getPortletInfo(PortletInvovation) to WSRPConsumerSPI.
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java 2011-01-06
11:56:39 UTC (rev 5681)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/WSRPConsumerImpl.java 2011-01-06
12:11:44 UTC (rev 5682)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, Red Hat Middleware, LLC, and individual
* contributors as indicated by the @authors tag. See the
* copyright.txt in the distribution for a full listing of
* individual contributors.
@@ -694,11 +694,9 @@
// fix-me!
- public org.oasis.wsrp.v2.UserContext getUserContextFrom(PortletInvocation invocation,
RuntimeContext runtimeContext) throws PortletInvokerException
+ public org.oasis.wsrp.v2.UserContext getUserContextFrom(WSRPPortletInfo info,
PortletInvocation invocation, RuntimeContext runtimeContext) throws
PortletInvokerException
{
// first decide if we need to pass the user context...
- WSRPPortletInfo info = getPortletInfo(invocation);
-
SessionParams sessionParams = runtimeContext.getSessionParams();
if (info != null && info.isUserContextStoredInSession() &&
sessionParams != null && sessionParams.getSessionID() != null)
{
@@ -720,11 +718,9 @@
return null;
}
- public void setTemplatesIfNeeded(PortletInvocation invocation, RuntimeContext
runtimeContext) throws PortletInvokerException
+ public void setTemplatesIfNeeded(WSRPPortletInfo info, PortletInvocation invocation,
RuntimeContext runtimeContext) throws PortletInvokerException
{
// todo: could store templates in producer session info to avoid to re-generate
them all the time?
- WSRPPortletInfo info = getPortletInfo(invocation);
-
SessionParams sessionParams = runtimeContext.getSessionParams();
if (info != null && info.isDoesUrlTemplateProcessing()
&& (!info.isTemplatesStoredInSession() || sessionParams == null ||
sessionParams.getSessionID() == null))
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/InvocationHandler.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/InvocationHandler.java 2011-01-06
11:56:39 UTC (rev 5681)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/handlers/InvocationHandler.java 2011-01-06
12:11:44 UTC (rev 5682)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, Red Hat Middleware, LLC, and individual
* contributors as indicated by the @authors tag. See the
* copyright.txt in the distribution for a full listing of
* individual contributors.
@@ -39,6 +39,7 @@
import org.gatein.wsrp.WSRPUtils;
import org.gatein.wsrp.consumer.ProducerInfo;
import org.gatein.wsrp.consumer.WSRPConsumerImpl;
+import org.gatein.wsrp.consumer.portlet.info.WSRPPortletInfo;
import org.gatein.wsrp.consumer.spi.WSRPConsumerSPI;
import org.gatein.wsrp.spec.v2.WSRP2RewritingConstants;
import org.oasis.wsrp.v2.InvalidCookie;
@@ -140,7 +141,6 @@
SessionHandler sessionHandler = consumer.getSessionHandler();
// prepare everything for the request
-// updateRegistrationContext(request);
RuntimeContext runtimeContext = getRuntimeContextFrom(request);
if (runtimeContext != null)
@@ -150,9 +150,6 @@
InstanceContext instanceContext = invocation.getInstanceContext();
runtimeContext.setPortletInstanceKey(instanceContext == null ? null :
instanceContext.getId());
-
-// updateUserContext(request, consumer.getUserContextFrom(invocation,
runtimeContext));
- consumer.setTemplatesIfNeeded(invocation, runtimeContext);
}
try
@@ -307,11 +304,11 @@
{
private final static Logger log = LoggerFactory.getLogger(RequestPrecursor.class);
- private PortletContext portletContext;
- private RuntimeContext runtimeContext;
- private MarkupParams markupParams;
- private RegistrationContext registrationContext;
- private UserContext userContext;
+ private final PortletContext portletContext;
+ private final RuntimeContext runtimeContext;
+ private final MarkupParams markupParams;
+ private final RegistrationContext registrationContext;
+ private final UserContext userContext;
private static final String PORTLET_HANDLE = "portlet handle";
private static final String SECURITY_CONTEXT = "security context";
private static final String USER_CONTEXT = "user context";
@@ -344,14 +341,17 @@
runtimeContext = WSRPTypeFactory.createRuntimeContext(authType,
portletInstanceKey, namespacePrefix);
+ WSRPPortletInfo info = wsrpConsumer.getPortletInfo(invocation);
+
// user context
- userContext = wsrpConsumer.getUserContextFrom(invocation, runtimeContext);
+ userContext = wsrpConsumer.getUserContextFrom(info, invocation,
runtimeContext);
+ // templates
+ wsrpConsumer.setTemplatesIfNeeded(info, invocation, getRuntimeContext());
+
// set the session id if needed
wsrpConsumer.getSessionHandler().setSessionIdIfNeeded(invocation,
getRuntimeContext(), getPortletHandle());
- wsrpConsumer.setTemplatesIfNeeded(invocation, getRuntimeContext());
-
// create markup params
org.gatein.pc.api.spi.UserContext userContext = invocation.getUserContext();
ParameterValidation.throwIllegalArgExceptionIfNull(userContext, USER_CONTEXT);
Modified:
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/spi/WSRPConsumerSPI.java
===================================================================
---
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/spi/WSRPConsumerSPI.java 2011-01-06
11:56:39 UTC (rev 5681)
+++
components/wsrp/trunk/consumer/src/main/java/org/gatein/wsrp/consumer/spi/WSRPConsumerSPI.java 2011-01-06
12:11:44 UTC (rev 5682)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, Red Hat Middleware, LLC, and individual
* contributors as indicated by the @authors tag. See the
* copyright.txt in the distribution for a full listing of
* individual contributors.
@@ -28,6 +28,7 @@
import org.gatein.wsrp.WSRPConsumer;
import org.gatein.wsrp.consumer.ProducerInfo;
import org.gatein.wsrp.consumer.handlers.SessionHandler;
+import org.gatein.wsrp.consumer.portlet.info.WSRPPortletInfo;
import org.gatein.wsrp.services.MarkupService;
import org.oasis.wsrp.v2.RegistrationContext;
import org.oasis.wsrp.v2.RuntimeContext;
@@ -41,11 +42,11 @@
{
RegistrationContext getRegistrationContext() throws PortletInvokerException;
- UserContext getUserContextFrom(PortletInvocation invocation, RuntimeContext
runtimeContext) throws PortletInvokerException;
+ UserContext getUserContextFrom(WSRPPortletInfo info, PortletInvocation invocation,
RuntimeContext runtimeContext) throws PortletInvokerException;
SessionHandler getSessionHandler();
- void setTemplatesIfNeeded(PortletInvocation invocation, RuntimeContext runtimeContext)
throws PortletInvokerException;
+ void setTemplatesIfNeeded(WSRPPortletInfo info, PortletInvocation invocation,
RuntimeContext runtimeContext) throws PortletInvokerException;
void refreshProducerInfo() throws PortletInvokerException;
@@ -62,4 +63,6 @@
* @return <code>true</code> if the given user scope is supported,
<code>false</code> otherwise
*/
boolean supportsUserScope(String userScope);
+
+ WSRPPortletInfo getPortletInfo(PortletInvocation invocation) throws
PortletInvokerException;
}
Modified:
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockWSRPConsumer.java
===================================================================
---
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockWSRPConsumer.java 2011-01-06
11:56:39 UTC (rev 5681)
+++
components/wsrp/trunk/consumer/src/test/java/org/gatein/wsrp/test/support/MockWSRPConsumer.java 2011-01-06
12:11:44 UTC (rev 5682)
@@ -1,6 +1,6 @@
/*
* JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * Copyright 2011, Red Hat Middleware, LLC, and individual
* contributors as indicated by the @authors tag. See the
* copyright.txt in the distribution for a full listing of
* individual contributors.
@@ -41,6 +41,7 @@
import org.gatein.wsrp.consumer.migration.ExportInfo;
import org.gatein.wsrp.consumer.migration.ImportInfo;
import org.gatein.wsrp.consumer.migration.MigrationService;
+import org.gatein.wsrp.consumer.portlet.info.WSRPPortletInfo;
import org.gatein.wsrp.consumer.spi.WSRPConsumerSPI;
import org.gatein.wsrp.services.MarkupService;
import org.oasis.wsrp.v2.RegistrationContext;
@@ -98,12 +99,17 @@
throw new NotYetImplemented();
}
+ public WSRPPortletInfo getPortletInfo(PortletInvocation invocation) throws
PortletInvokerException
+ {
+ throw new NotYetImplemented();
+ }
+
public RegistrationContext getRegistrationContext() throws PortletInvokerException
{
throw new NotYetImplemented();
}
- public UserContext getUserContextFrom(PortletInvocation invocation, RuntimeContext
runtimeContext) throws PortletInvokerException
+ public UserContext getUserContextFrom(WSRPPortletInfo info, PortletInvocation
invocation, RuntimeContext runtimeContext) throws PortletInvokerException
{
throw new NotYetImplemented();
}
@@ -113,7 +119,7 @@
throw new NotYetImplemented();
}
- public void setTemplatesIfNeeded(PortletInvocation invocation, RuntimeContext
runtimeContext) throws PortletInvokerException
+ public void setTemplatesIfNeeded(WSRPPortletInfo info, PortletInvocation invocation,
RuntimeContext runtimeContext) throws PortletInvokerException
{
throw new NotYetImplemented();
}