Hi everybody,
Ever since I created the workflow APIs, I've regretted the lack of a
way to save workflows between WikiEngine restarts. Today, if you turn
on workflows for things like page saves or user profile creation, and
the WikiEngine stops, they vanish. So, workflow persistence is highly
desirable.
The most obvious and "simplest" way (in theory) to persist workflows
would be to serialize them to disk. However, this requires that we
change the public APIs in the workflow packages that pass or return
Objects to Serializable instead. This is probably not a big deal: few
3rd party developers use the workflow package today.
So, here are my questions:
1) What does this group think about workflow persistence as a JSPWiki
feature? Do we need it? (I think we do...)
2) If we need it, when should we implement it? 2.8 or 3.0? (2.8 might
be easier, considering everything that is slated for 3.0)
BTW, the API changes are pretty minor (everything that used to say
"Object" would be changed to "Serializable"):
public interface Step extends Serializable
+-- public Serializable[] getMessageArguments()
public class DecisionQueue implements Serializable
public class Fact implements Serializable
+--- public Fact(String messageKey, Serializable value)
public Serializable getValue()
public final class Outcome implements Serializable
public class Workflow implements Serializable
+--- public final void addMessageArgument( Serializable obj )
public final synchronized Serializable getAttribute( String attr )
+--- public final Serializable[] getMessageArguments()
+--- public final synchronized void setAttribute(String attr,
Serializable obj)
+--- public final synchronized Serializable getAttribute( String attr )
In short: any custom workflows (of which there are only two in JSPWiki
out of the box) would need to make sure that if they add message
arguments or Facts that these are serializable objects. Pretty easy.
There are some other things we'd need to tackle, not all of which I
have a complete grip on yet. The PreSave/SaveWikiPageTask that
PageManager uses to route wiki page saves through its workflow would
need to be slightly refactored.
We would also need to add some writeReplace/readResolve methods in
objects that should be replaced during the deserialization process. In
particular, any WorkFlowManager references would need to be
dynamically replaced during deserialization with the one used by the
current WikiEngine.
How would we do this, given that readResolve() et al doesn't accept
parameters? I think one way to do it might be to turn util.Serializer
into a singleton, and stash object instances there that
deserialization methods could use. For example, before deserializing a
Workflow object we could call
Serializer.getInstance().stash(WorkflowManager.class,
m_workflowManager), then inside WorkflowManager's readResolve call use
Serializer.getInstance.get(WorkflowManager.class) to retrieve it.
What do you think? Worth doing in the short term? Am I missing anything?
Andrew