Author: julien_viet
Date: 2009-08-25 16:21:36 -0400 (Tue, 25 Aug 2009)
New Revision: 60
Modified:
components/pc/trunk/api/src/main/java/org/gatein/pc/api/PortletInvoker.java
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatedPortletInvokerService.java
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java
components/pc/trunk/pc/src/main/java/org/gatein/pc/PortletInvokerInterceptor.java
components/pc/trunk/pc/src/main/java/org/gatein/pc/container/ContainerPortletInvoker.java
components/pc/trunk/pc/src/main/java/org/gatein/pc/state/consumer/ConsumerPortletInvoker.java
components/pc/trunk/pc/src/main/java/org/gatein/pc/state/producer/ProducerPortletInvoker.java
components/pc/trunk/pc/src/test/java/org/gatein/pc/state/ConsumerStatefulPortletInvokerTestCase.java
components/pc/trunk/pc/src/test/java/org/gatein/pc/state/ProducerStatefulPortletInvokerTestCase.java
components/pc/trunk/pc/src/test/java/org/gatein/pc/support/PortletInvokerSupport.java
Log:
fix bugs in portlet state type
Modified: components/pc/trunk/api/src/main/java/org/gatein/pc/api/PortletInvoker.java
===================================================================
--- components/pc/trunk/api/src/main/java/org/gatein/pc/api/PortletInvoker.java 2009-08-25
20:17:52 UTC (rev 59)
+++ components/pc/trunk/api/src/main/java/org/gatein/pc/api/PortletInvoker.java 2009-08-25
20:21:36 UTC (rev 60)
@@ -69,13 +69,14 @@
/**
* Clone a portlet.
*
- * @param portletContext the portlet context to clone
- * @return the clone id
+ * @param stateType the portle state type desired
+ * @param portletContext the portlet context to clone @return the clone id
+ * @return the cloned portlet context
* @throws IllegalArgumentException if the portletId is null
* @throws UnsupportedOperationException if the invoker does not support this
operation
* @throws PortletInvokerException a portlet invoker exception
*/
- PortletContext createClone(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException;
+ PortletContext createClone(PortletStateType stateType, PortletContext portletContext)
throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException;
/**
* Destroy a cloned portlet.
Modified:
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatedPortletInvokerService.java
===================================================================
---
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatedPortletInvokerService.java 2009-08-25
20:17:52 UTC (rev 59)
+++
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatedPortletInvokerService.java 2009-08-25
20:21:36 UTC (rev 60)
@@ -157,10 +157,10 @@
}
}
- public PortletContext createClone(PortletContext compoundPortletContext) throws
PortletInvokerException
+ public PortletContext createClone(PortletStateType stateType, PortletContext
compoundPortletContext) throws PortletInvokerException
{
PortletContext portletContext = dereference(compoundPortletContext);
- PortletContext cloneContext = portletInvoker.createClone(portletContext);
+ PortletContext cloneContext = portletInvoker.createClone(stateType,
portletContext);
return reference(cloneContext);
}
Modified:
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java
===================================================================
---
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java 2009-08-25
20:17:52 UTC (rev 59)
+++
components/pc/trunk/federation/src/main/java/org/gatein/pc/federation/impl/FederatingPortletInvokerService.java 2009-08-25
20:21:36 UTC (rev 60)
@@ -30,6 +30,7 @@
import org.gatein.pc.api.PortletContext;
import org.gatein.pc.api.PortletInvoker;
import org.gatein.pc.api.PortletInvokerException;
+import org.gatein.pc.api.PortletStateType;
import org.gatein.pc.api.invocation.PortletInvocation;
import org.gatein.pc.api.invocation.response.PortletInvocationResponse;
import org.gatein.pc.api.state.DestroyCloneFailure;
@@ -154,10 +155,10 @@
return federated.invoke(invocation);
}
- public PortletContext createClone(PortletContext compoundPortletContext) throws
PortletInvokerException
+ public PortletContext createClone(PortletStateType stateType, PortletContext
compoundPortletContext) throws PortletInvokerException
{
FederatedPortletInvoker federated =
getFederatedPortletInvokerFor(compoundPortletContext);
- return federated.createClone(compoundPortletContext);
+ return federated.createClone(stateType, compoundPortletContext);
}
public List<DestroyCloneFailure> destroyClones(List<PortletContext>
portletContexts) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
@@ -278,9 +279,9 @@
return invoker.invoke(invocation);
}
- public PortletContext createClone(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PortletContext createClone(PortletStateType stateType, PortletContext
portletContext) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
{
- return invoker.createClone(portletContext);
+ return invoker.createClone(stateType, portletContext);
}
public List<DestroyCloneFailure> destroyClones(List<PortletContext>
portletContexts) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
Modified:
components/pc/trunk/pc/src/main/java/org/gatein/pc/PortletInvokerInterceptor.java
===================================================================
---
components/pc/trunk/pc/src/main/java/org/gatein/pc/PortletInvokerInterceptor.java 2009-08-25
20:17:52 UTC (rev 59)
+++
components/pc/trunk/pc/src/main/java/org/gatein/pc/PortletInvokerInterceptor.java 2009-08-25
20:21:36 UTC (rev 60)
@@ -31,6 +31,7 @@
import org.gatein.pc.api.PortletContext;
import org.gatein.pc.api.PortletInvokerException;
import org.gatein.pc.api.PortletInvoker;
+import org.gatein.pc.api.PortletStateType;
import java.util.Set;
import java.util.List;
@@ -86,9 +87,9 @@
return safeGetNext().invoke(invocation);
}
- public PortletContext createClone(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PortletContext createClone(PortletStateType stateType, PortletContext
portletContext) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
{
- return safeGetNext().createClone(portletContext);
+ return safeGetNext().createClone(stateType, portletContext);
}
public List<DestroyCloneFailure> destroyClones(List<PortletContext>
portletContexts) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
Modified:
components/pc/trunk/pc/src/main/java/org/gatein/pc/container/ContainerPortletInvoker.java
===================================================================
---
components/pc/trunk/pc/src/main/java/org/gatein/pc/container/ContainerPortletInvoker.java 2009-08-25
20:17:52 UTC (rev 59)
+++
components/pc/trunk/pc/src/main/java/org/gatein/pc/container/ContainerPortletInvoker.java 2009-08-25
20:21:36 UTC (rev 60)
@@ -27,6 +27,7 @@
import org.gatein.pc.api.Portlet;
import org.gatein.pc.api.PortletContext;
import org.gatein.pc.api.PortletInvokerException;
+import org.gatein.pc.api.PortletStateType;
import org.gatein.pc.api.state.PropertyMap;
import org.gatein.pc.impl.info.ContainerPreferencesInfo;
import org.gatein.pc.impl.info.ContainerPortletInfo;
@@ -178,7 +179,7 @@
return result;
}
- public PortletContext createClone(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PortletContext createClone(PortletStateType stateType, PortletContext
portletContext) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
{
throw new UnsupportedOperationException();
}
Modified:
components/pc/trunk/pc/src/main/java/org/gatein/pc/state/consumer/ConsumerPortletInvoker.java
===================================================================
---
components/pc/trunk/pc/src/main/java/org/gatein/pc/state/consumer/ConsumerPortletInvoker.java 2009-08-25
20:17:52 UTC (rev 59)
+++
components/pc/trunk/pc/src/main/java/org/gatein/pc/state/consumer/ConsumerPortletInvoker.java 2009-08-25
20:21:36 UTC (rev 60)
@@ -174,9 +174,9 @@
if (modifiedContext != null)
{
// update state if needed
- if (clonedContext instanceof StatefulPortletContext)
+ if (modifiedContext instanceof StatefulPortletContext)
{
- StatefulPortletContext statefulClonedContext =
(StatefulPortletContext)clonedContext;
+ StatefulPortletContext statefulClonedContext =
(StatefulPortletContext)modifiedContext;
Serializable state = statefulClonedContext.getState();
PortletStateType stateType = statefulClonedContext.getType();
try
@@ -206,12 +206,12 @@
}
}
- public PortletContext createClone(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PortletContext createClone(PortletStateType stateType, PortletContext
portletContext) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
{
ConsumerContext consumerContext = getConsumerContext(portletContext);
//
- PortletContext clonedContext =
super.createClone(consumerContext.producerPortletContext);
+ PortletContext clonedContext = super.createClone(stateType,
consumerContext.producerPortletContext);
if (clonedContext instanceof StatefulPortletContext)
{
Modified:
components/pc/trunk/pc/src/main/java/org/gatein/pc/state/producer/ProducerPortletInvoker.java
===================================================================
---
components/pc/trunk/pc/src/main/java/org/gatein/pc/state/producer/ProducerPortletInvoker.java 2009-08-25
20:17:52 UTC (rev 59)
+++
components/pc/trunk/pc/src/main/java/org/gatein/pc/state/producer/ProducerPortletInvoker.java 2009-08-25
20:21:36 UTC (rev 60)
@@ -121,6 +121,11 @@
public Portlet getPortlet(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException
{
+ return _getPortlet(portletContext);
+ }
+
+ private <S extends Serializable> Portlet _getPortlet(PortletContext
portletContext) throws IllegalArgumentException, PortletInvokerException
+ {
if (portletContext == null)
{
throw new IllegalArgumentException("No null portlet id accepted");
@@ -134,9 +139,10 @@
{
if (portletContext instanceof StatefulPortletContext)
{
- StatefulPortletContext<PortletState> statefulPortletContext =
(StatefulPortletContext)portletContext;
- PortletState state = statefulPortletContext.getState();
+ StatefulPortletContext<S> statefulPortletContext =
(StatefulPortletContext)portletContext;
+ S state = statefulPortletContext.getState();
+ //
try
{
PortletState portletState =
stateConverter.unmarshall(statefulPortletContext.getType(), state);
@@ -240,7 +246,15 @@
//
PortletStateType<?> stateType = instanceCtx.getStateType();
- boolean persistLocally = stateType == null ||
stateManagementPolicy.persistLocally();
+ boolean persistLocally;
+ if (stateType == null)
+ {
+ persistLocally = true;
+ }
+ else
+ {
+ persistLocally = stateManagementPolicy.persistLocally();
+ }
//
switch(access)
@@ -349,7 +363,7 @@
return response;
}
- public PortletContext createClone(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PortletContext createClone(PortletStateType stateType, PortletContext
portletContext) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
{
if (portletContext == null)
{
@@ -361,7 +375,15 @@
InternalContext context = getStateContext(portletContext);
//
- boolean persistLocally = !(portletContext instanceof StatefulPortletContext) ||
stateManagementPolicy.persistLocally();
+ boolean persistLocally;
+ if (stateType == null)
+ {
+ persistLocally = true;
+ }
+ else
+ {
+ persistLocally = stateManagementPolicy.persistLocally();
+ }
//
if (context.isStateful())
@@ -386,7 +408,6 @@
}
else
{
- PortletStateType<PortletContext> stateType =
((StatefulPortletContext)portletContext).getType();
return marshall(stateType, statefulContext.getPortletId(),
statefulContext.getProperties());
}
}
@@ -401,7 +422,6 @@
}
else
{
- PortletStateType<PortletContext> stateType =
((StatefulPortletContext)portletContext).getType();
return marshall(stateType, portletId, newState);
}
}
Modified:
components/pc/trunk/pc/src/test/java/org/gatein/pc/state/ConsumerStatefulPortletInvokerTestCase.java
===================================================================
---
components/pc/trunk/pc/src/test/java/org/gatein/pc/state/ConsumerStatefulPortletInvokerTestCase.java 2009-08-25
20:17:52 UTC (rev 59)
+++
components/pc/trunk/pc/src/test/java/org/gatein/pc/state/ConsumerStatefulPortletInvokerTestCase.java 2009-08-25
20:21:36 UTC (rev 60)
@@ -25,6 +25,7 @@
import org.gatein.pc.api.Portlet;
import org.gatein.pc.api.PortletContext;
import org.gatein.pc.api.PortletInvokerException;
+import org.gatein.pc.api.PortletStateType;
import org.gatein.pc.api.state.PropertyMap;
import org.gatein.pc.support.info.PortletInfoSupport;
import org.gatein.pc.support.PortletInvokerSupport;
@@ -161,7 +162,7 @@
protected PortletContext createLocalClone(PortletContext portletRef) throws Exception
{
stateManagementPolicy.setPersistLocally(true);
- PortletContext cloneRef = consumer.createClone(portletRef);
+ PortletContext cloneRef = consumer.createClone(null, portletRef);
stateManagementPolicy.setPersistLocally(persistLocally);
return cloneRef;
}
@@ -188,7 +189,7 @@
protected PortletContext createClone(PortletContext portletRef) throws
PortletInvokerException
{
- return consumer.createClone(portletRef);
+ return consumer.createClone(persistLocally ? null : PortletStateType.OPAQUE,
portletRef);
}
protected PortletContext setProperties(PortletContext portletRef, PropertyChange[]
changes) throws PortletInvokerException
Modified:
components/pc/trunk/pc/src/test/java/org/gatein/pc/state/ProducerStatefulPortletInvokerTestCase.java
===================================================================
---
components/pc/trunk/pc/src/test/java/org/gatein/pc/state/ProducerStatefulPortletInvokerTestCase.java 2009-08-25
20:17:52 UTC (rev 59)
+++
components/pc/trunk/pc/src/test/java/org/gatein/pc/state/ProducerStatefulPortletInvokerTestCase.java 2009-08-25
20:21:36 UTC (rev 60)
@@ -25,6 +25,7 @@
import org.gatein.pc.api.Portlet;
import org.gatein.pc.api.PortletContext;
import org.gatein.pc.api.PortletInvokerException;
+import org.gatein.pc.api.PortletStateType;
import org.gatein.pc.api.state.PropertyMap;
import org.gatein.pc.impl.state.StateManagementPolicyService;
import org.gatein.pc.impl.state.StateConverterV0;
@@ -126,7 +127,7 @@
protected PortletContext createLocalClone(PortletContext portletRef) throws Exception
{
stateManagementPolicy.setPersistLocally(true);
- PortletContext cloneContext = producer.createClone(portletRef);
+ PortletContext cloneContext = producer.createClone(null, portletRef);
stateManagementPolicy.setPersistLocally(persistLocally);
return cloneContext;
}
@@ -148,7 +149,7 @@
protected PortletContext createClone(PortletContext portletRef) throws
PortletInvokerException
{
- return producer.createClone(portletRef);
+ return producer.createClone(persistLocally ? null : PortletStateType.OPAQUE,
portletRef);
}
protected PortletContext setProperties(PortletContext portletRef, PropertyChange[]
changes) throws PortletInvokerException
@@ -210,7 +211,12 @@
protected ActionInvocation createAction(PortletContext portletRef, AccessMode
accessMode)
{
ActionContextImpl actionCtx = new ActionContextImpl();
- AbstractInstanceContext instanceCtx = new AbstractInstanceContext("blah",
accessMode);
+ AbstractInstanceContext instanceCtx = new AbstractInstanceContext("blah",
accessMode) {
+ @Override
+ public PortletStateType<?> getStateType() {
+ return persistLocally ? null : PortletStateType.OPAQUE;
+ }
+ };
//
ActionInvocation action = new ActionInvocation(actionCtx);
Modified:
components/pc/trunk/pc/src/test/java/org/gatein/pc/support/PortletInvokerSupport.java
===================================================================
---
components/pc/trunk/pc/src/test/java/org/gatein/pc/support/PortletInvokerSupport.java 2009-08-25
20:17:52 UTC (rev 59)
+++
components/pc/trunk/pc/src/test/java/org/gatein/pc/support/PortletInvokerSupport.java 2009-08-25
20:21:36 UTC (rev 60)
@@ -28,6 +28,7 @@
import org.gatein.pc.api.PortletContext;
import org.gatein.pc.api.PortletInvokerException;
import org.gatein.pc.api.PortletInvoker;
+import org.gatein.pc.api.PortletStateType;
import org.gatein.pc.api.state.PropertyMap;
import org.gatein.pc.support.info.PortletInfoSupport;
import org.gatein.pc.api.invocation.PortletInvocation;
@@ -197,7 +198,7 @@
return props;
}
- public PortletContext createClone(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ public PortletContext createClone(PortletStateType stateType, PortletContext
portletContext) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
{
throw new UnsupportedOperationException();
}