[jboss-dev-forums] [Design of JBoss Portal] - PortletContext and StateEvent design
chris.laprun@jboss.com
do-not-reply at jboss.com
Thu Dec 7 17:33:40 EST 2006
I think that we could simplify the current StateEvent/PortletContext handling in the context of state management of portlets. The current design, while based on subclasses, does not lend itself to polymorphism.
For example, in FederatedInstanceContext:
if (event instanceof PortletClonedEvent)
| {
| PortletClonedEvent pce = (PortletClonedEvent)event;
| PortletContext clonedContext = pce.getClonedContext();
| ctx.onStateEvent(new PortletClonedEvent(reference(clonedContext)));
| }
| else if (event instanceof PortletModifiedEvent)
| {
| PortletModifiedEvent pce = (PortletModifiedEvent)event;
| PortletContext modifiedContext = pce.getModifiedContext();
| ctx.onStateEvent(new PortletModifiedEvent(reference(modifiedContext)));
| }
I don't see the benefit of having such a split between different kinds of events. The above code could be simplified if StateEvent was taking on more responsibilities:
PortletContext portletContext = event.getPortletContext();
| ctx.onStateEvent(new StateEvent(reference(portletContext)), event.getType());
In this new design, StateEvent would not be subclassed but contain a type field for these cases where the exact nature of the event needs to be known.
This would only work with a rework of PortletContext. I think that PortletContext should add a getState method. It's perfectly fine for a PortletContext to have an optional state (this is how WSRP works after all). We could keep the subclass to optimize memory usage and avoid to carry a byte[] on all PortletContexts even these which don't have a state. getState would return null if there is no state, StatefulPortletContext would override getState to return the state.
I think that these modifications would make dealing with state events easier and simplify our code.
What do people think?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3992106#3992106
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3992106
More information about the jboss-dev-forums
mailing list