public static byte[] getStateOrNullFor(PortletContext portletContext) { if (portletContext instanceof StatefulPortletContext) { StatefulPortletContext context = (StatefulPortletContext)portletContext; if (PortletStateType.OPAQUE.equals(context.getType())) { return ((StatefulPortletContext<byte[]>)context).getState(); } } return null; }
private <S extends Serializable> PortletContext marshall(PortletStateType<S> stateType, String portletId, PropertyMap props) throws PortletInvokerException { try { PortletState sstate = new PortletState(portletId, props); S marshalledState = stateConverter.marshall(stateType, sstate); return StatefulPortletContext.create(PortletContext.CONSUMER_CLONE_ID, stateType, marshalledState); } catch (StateConversionException e) { throw new PortletInvokerException(e); } }
Boolean persistLocally = stateManagementPolicy.persistLocally(); PortletState portletState = getStateConverter().unmarshall(stateType, statefulPortletContext.getState()); String originalPortletId = portletState.getPortletId();
public PortletContext createClone(PortletStateType stateType, PortletContext portletContext) throws IllegalArgumentException, PortletInvokerException, UnsupportedOperationException { ConsumerContext consumerContext = getConsumerContext(portletContext); // PortletContext clonedContext = super.createClone(stateType, consumerContext.producerPortletContext); if (clonedContext instanceof StatefulPortletContext) { StatefulPortletContext statefulClonedContext = (StatefulPortletContext)clonedContext; ConsumerState consumerState = new ConsumerState<Serializable>(clonedContext.getId(), statefulClonedContext.getType(), statefulClonedContext.getState()); String id = persistenceManager.createState(consumerState); return PortletContext.createPortletContext(PortletContext.CONSUMER_CLONE_ID_PREFIX + id); } else { return clonedContext; } }
StatefulPortletContext<Serializable> blah = StatefulPortletContext.create( stateCtx.getPortletId(), stateCtx.getStateType(),
public PortletContext importPortlet(PortletStateType stateType, PortletContext portletContext) throws PortletInvokerException, IllegalArgumentException { ConsumerContext consumerContext = getConsumerContext(portletContext); PortletContext importContext = super.importPortlet(stateType, consumerContext.producerPortletContext); if (importContext instanceof StatefulPortletContext) { StatefulPortletContext statefulimportContext = (StatefulPortletContext)importContext; ConsumerState consumerState = new ConsumerState<Serializable>(importContext.getId(), statefulimportContext.getType(), statefulimportContext.getState()); String id = persistenceManager.createState(consumerState); return PortletContext.createPortletContext(PortletContext.CONSUMER_CLONE_ID_PREFIX + id); } else { return importContext; } }
/** * @param registrationContext * @param portletContext * @return * @since 2.6 */ public static V1GetPortletDescription createGetPortletDescription(V1RegistrationContext registrationContext, org.gatein.pc.api.PortletContext portletContext) { ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "portlet context"); V1PortletContext wsrpPC = createPortletContext(portletContext.getId()); if (portletContext instanceof StatefulPortletContext) { StatefulPortletContext context = (StatefulPortletContext)portletContext; if (PortletStateType.OPAQUE.equals(context.getType())) { wsrpPC.setPortletState(((StatefulPortletContext<byte[]>)context).getState()); } } V1GetPortletDescription getPortletDescription = new V1GetPortletDescription(); getPortletDescription.setRegistrationContext(registrationContext); getPortletDescription.setPortletContext(wsrpPC); return getPortletDescription; }
/** * @param registrationContext * @param portletContext * @return * @since 2.6 */ public static GetPortletDescription createGetPortletDescription(RegistrationContext registrationContext, org.gatein.pc.api.PortletContext portletContext) { ParameterValidation.throwIllegalArgExceptionIfNull(portletContext, "portlet context"); PortletContext wsrpPC = createPortletContext(portletContext.getId()); if (portletContext instanceof StatefulPortletContext) { StatefulPortletContext context = (StatefulPortletContext)portletContext; if (PortletStateType.OPAQUE.equals(context.getType())) { wsrpPC.setPortletState(((StatefulPortletContext<byte[]>)context).getState()); } } GetPortletDescription getPortletDescription = new GetPortletDescription(); getPortletDescription.setRegistrationContext(registrationContext); getPortletDescription.setPortletContext(wsrpPC); return getPortletDescription; }
if (portletContext instanceof StatefulPortletContext) { StatefulPortletContext context = (StatefulPortletContext) portletContext; if (PortletStateType.OPAQUE.equals(context.getType())) { wsrp.setState((byte[]) context.getState()); } else { throw new IllegalArgumentException("Don't know how to deal with state: " + context.getState());