Processes involving multiple steps that require decision points within and outside of each step can be inordinately complex to program. But this type of process modeling has long-established solutions in computing. This article by Justin McCarter and Jim Ladd, presents the Physhun project, a Spring-based framework for implementing complex processes through Finite State Machine models. Physhun provides finite State Model persistence and transaction management with synchronous or asynchronous behavior.
Read Article
-
Implementing Finite State Machines with Physhun and Spring (25 messages)
- Posted by: Nuno Teixeira
- Posted on: July 18 2008 10:24 EDT
Threaded Messages (25)
- Re: Implementing Finite State Machines with Physhun and Spring by James Watson on July 21 2008 14:54 EDT
- Re: Implementing Finite State Machines with Physhun and Spring by James Cook on July 21 2008 15:59 EDT
-
Re: Implementing Finite State Machines with Physhun and Spring by James Watson on July 21 2008 04:47 EDT
-
:) by Peter Szara??ski on July 21 2008 05:35 EDT
-
States hierarchical? by Olli Plough on July 22 2008 03:23 EDT
-
Hierarchical states by Justin McCarter on July 22 2008 11:04 EDT
-
hierarchical by Olli Plough on July 22 2008 12:26 EDT
-
re: hierarchical by Justin McCarter on July 22 2008 12:44 EDT
- simple machines forum smf.gen.tr ödüllü seo webmaster yarışması by sado san on July 22 2008 04:33 EDT
-
re: hierarchical by Justin McCarter on July 22 2008 12:44 EDT
-
hierarchical by Olli Plough on July 22 2008 12:26 EDT
-
Hierarchical states by Justin McCarter on July 22 2008 11:04 EDT
-
States hierarchical? by Olli Plough on July 22 2008 03:23 EDT
-
:) by Peter Szara??ski on July 21 2008 05:35 EDT
-
Re: Implementing Finite State Machines with Physhun and Spring by James Watson on July 21 2008 04:47 EDT
- Re: Implementing Finite State Machines with Physhun and Spring by David McCoy on July 22 2008 10:23 EDT
-
Re: Implementing Finite State Machines with Physhun and Spring by James Watson on July 22 2008 12:20 EDT
-
Re: Implementing Finite State Machines with Physhun and Spring by David McCoy on July 22 2008 05:04 EDT
- Re: Implementing Finite State Machines with Physhun and Spring by James Watson on July 22 2008 11:22 EDT
-
Re: Implementing Finite State Machines with Physhun and Spring by David McCoy on July 22 2008 05:04 EDT
-
Re: Implementing Finite State Machines with Physhun and Spring by James Watson on July 22 2008 12:20 EDT
- Re: Implementing Finite State Machines with Physhun and Spring by James Cook on July 21 2008 15:59 EDT
- Comments and Question by Steven Peh on July 22 2008 19:34 EDT
- re: questions by Justin McCarter on July 23 2008 01:40 EDT
- Re: Implementing Finite State Machines with Physhun and Spring by Richard Nduka on July 24 2008 04:57 EDT
- Re: Implementing Finite State Machines with Physhun and Spring by Richard Nduka on July 24 2008 06:00 EDT
- Re: Implementing Finite State Machines with Physhun and Spring by David Soroko on July 28 2008 04:15 EDT
- Tutorial Example by Justin McCarter on August 01 2008 06:15 EDT
- Re: Implementing Finite State Machines with Physhun and Spring by David Soroko on July 28 2008 04:15 EDT
- Similar Solution by Benjamin Possolo on July 30 2008 12:59 EDT
- Database dependency by Justin McCarter on August 01 2008 17:58 EDT
-
Oracle and mySQL reference implementations by oscar serna on August 19 2008 01:30 EDT
- Persistence examples by Justin McCarter on August 20 2008 10:15 EDT
-
Oracle and mySQL reference implementations by oscar serna on August 19 2008 01:30 EDT
- Database dependency by Justin McCarter on August 01 2008 17:58 EDT
- methinks is good but... by Lupu Slobodu on August 15 2008 13:10 EDT
- methinks is good but... by Justin McCarter on August 20 2008 10:38 EDT
-
Re: Implementing Finite State Machines with Physhun and Spring[ Go to top ]
- Posted by: James Watson
- Posted on: July 21 2008 14:54 EDT
- in response to Nuno Teixeira
I'm not interested if it's inherently coupled to Spring. -
Re: Implementing Finite State Machines with Physhun and Spring[ Go to top ]
- Posted by: James Cook
- Posted on: July 21 2008 15:59 EDT
- in response to James Watson
I am. -
Re: Implementing Finite State Machines with Physhun and Spring[ Go to top ]
- Posted by: James Watson
- Posted on: July 21 2008 16:47 EDT
- in response to James Cook
I am.
Would you still be interested in it if it weren't inherently coupled to Spring? -
:)[ Go to top ]
- Posted by: Peter Szara??ski
- Posted on: July 21 2008 17:35 EDT
- in response to James Watson
Hey, thats not so complicated... You just need to put spring-ioc on classpath, spring-aop, spring-jdbc, spring-mvc, spring-jcr, spring-extras, spring-extras-extras, at least one (but it would be much better if you had more, or even more) xml file and here you have it :)
I heard that with Spring you are able to implement even INfinite State Machine, just like wearing pants through your head :)
Ok, but to be honest, do we really have to use Spring wherever we implement our own interfaces ? :) -
States hierarchical?[ Go to top ]
- Posted by: Olli Plough
- Posted on: July 22 2008 03:23 EDT
- in response to Peter Szara??ski
I didn't see anything that says that states can be hierarchical. I only perused the article quickly and might have missed a sentence saying that states can be hierarchical. However, if they cannot I won't use this for anything heavy.
Regards, Oliver -
Hierarchical states[ Go to top ]
- Posted by: Justin McCarter
- Posted on: July 22 2008 11:04 EDT
- in response to Olli Plough
I didn't see anything that says that states can be hierarchical. I only perused the article quickly and might have missed a sentence saying that states can be hierarchical. However, if they cannot I won't use this for anything heavy.
Regards, Oliver
Oliver - what exactly do you mean by states being "hierarchical"? -
hierarchical[ Go to top ]
- Posted by: Olli Plough
- Posted on: July 22 2008 12:26 EDT
- in response to Justin McCarter
Oliver - what exactly do you mean by states being "hierarchical"?
Hi Justin,
I was a little blunt in my reply... Well, what I mean is whether a state may consist of other states that may consist of other states and so on as with Harel state machines (also adopted by UML).
Regards, Oliver -
re: hierarchical[ Go to top ]
- Posted by: Justin McCarter
- Posted on: July 22 2008 12:44 EDT
- in response to Olli Plough
Oliver - nested models are supported. -
simple machines forum smf.gen.tr ödüllü seo webmaster yarışması[ Go to top ]
- Posted by: sado san
- Posted on: July 22 2008 16:33 EDT
- in response to Justin McCarter
wery thanks good shared
simple machines forum smf.gen.tr ödüllü seo webmaster yarışmasısimple machines forum smf.gen.tr ödüllü seo webmaster yarışmasısimple machines forum smf.gen.tr ödüllü seo webmaster yarışması
Günlük Plan, Yıllık Plan, Öğretmen, Forum -
Re: Implementing Finite State Machines with Physhun and Spring[ Go to top ]
- Posted by: David McCoy
- Posted on: July 22 2008 10:23 EDT
- in response to James Watson
So why post? It never ceases to amaze me that people waste their time posting to topics that "don't interest" them. Why? Surely there must be more productive ways to spend one's time. -
Re: Implementing Finite State Machines with Physhun and Spring[ Go to top ]
- Posted by: James Watson
- Posted on: July 22 2008 12:20 EDT
- in response to David McCoy
So why post? It never ceases to amaze me that people waste their time posting to topics that "don't interest" them. Why? Surely there must be more productive ways to spend one's time.
If I have misunderstood and it does not depend on Spring, then I might look more closely. Or, if it does depend on Spring it serves message to the developers that they could expand their user base by eliminating the dependency.
It never ceases to amaze me that people waste their time criticizing people for posting to public forums. Surely there must be more productive ways to spend one's time. It's also annoying that these criticism often have more to do with the criticizers own preconceptions and prejudices than the posts they are actually criticizing. -
Re: Implementing Finite State Machines with Physhun and Spring[ Go to top ]
- Posted by: David McCoy
- Posted on: July 22 2008 17:04 EDT
- in response to James Watson
So why post? It never ceases to amaze me that people waste their time posting to topics that "don't interest" them. Why? Surely there must be more productive ways to spend one's time.
If I have misunderstood and it does not depend on Spring, then I might look more closely. Or, if it does depend on Spring it serves message to the developers that they could expand their user base by eliminating the dependency.
It never ceases to amaze me that people waste their time criticizing people for posting to public forums. Surely there must be more productive ways to spend one's time. It's also annoying that these criticism often have more to do with the criticizers own preconceptions and prejudices than the posts they are actually criticizing.
You don't like Spring. Fine. You've said it again and again. So why not look at the header and move on? What possible satisfaction do you get restating the same position again and again?
You are quick to point out bias, but like others of your bent, fail to point that eye inward.
Even the response consisting of copying me is poor retread. Such a response is typical when one has no real agenda beyond tearing down a item they don't like merely because it is popular and they derive validation by "going against the herd." -
Re: Implementing Finite State Machines with Physhun and Spring[ Go to top ]
- Posted by: James Watson
- Posted on: July 22 2008 23:22 EDT
- in response to David McCoy
You don't like Spring. Fine. You've said it again and again. So why not look at the header and move on? What possible satisfaction do you get restating the same position again and again?
I'm actually not aware that I've posted anything about disliking Spring so I call bullshit. I haven't formed much of an opinion on Spring. I have formed an opinion on what I see as Spring-mania. Maybe you have confused the two completely distinct and separate concepts.
The fact is that you don't know me but you feel free to make broad assessments of my motivations. You should notice that haven't returned this 'favor'. I think it's extremely rude and disrespectful aside from being silly and childish.
You are quick to point out bias, but like others of your bent, fail to point that eye inward.
You took the time out of you busy day to criticize me about how I was wasting my time. You are not being rational. I was happily uninvolved in any discussion with you.
Even the response consisting of copying me is poor retread.
It's called pointing out irony. Apparently it is lost on you. You see, there's this thing called 'sarcasm'. You should consider learning about it. Here's a crash course. Unlike your post, my response to it wasn't serious. I didn't actually mean what I wrote. I think it's just dandy for people to post any fool thing they want as long as they don't fill the forums with so much nonsense that the forums become unusable. -
Comments and Question[ Go to top ]
- Posted by: Steven Peh
- Posted on: July 22 2008 19:34 EDT
- in response to Nuno Teixeira
First off some comments. XML is a poor choice for configuring state graphs, it gets really difficult to visualize when the graphs starts to get big and complex. Let me rephrase, I suppose internally how the framework wants to store its config can be abstracted, so long as the visualization of it is not limited to editing XML. So if the framework do support other means of config visualization, it'll be good to include in the article as putting up XML configs really doesnt help in promoting the framework. Case in point, a simple 3 node state graph and you have almost a full page of XML. Just my 2 cents.
Question time:
1. Can conditions be expressed via el? I suppose if it doesnt we can always implement our own facade condition that loads and parses el. But it'll be nice to have the framework support it out of the box.
2. Coupling to Spring. Can it easily be decoupled? Personally I dont think frameworks should be tightly coupled to other frameworks, this makes adoption difficult as existing applications may use similar frameworks. For example some existing application may use Guice for IOC already, and adopting this framework would then make the application use 2 different IOC frameworks which makes maintanence non-standard and messy. -
re: questions[ Go to top ]
- Posted by: Justin McCarter
- Posted on: July 23 2008 01:40 EDT
- in response to Steven Peh
Regarding questions/comments that have come up in this thread:
1. decoupling from Spring. This can certainly be done. The main thing that Spring provides to Physhun is the bean factory -- this inflates the state model's classes at runtime from the XML defining the process model. It would be straightforward to write a non-Spring engine (implementation of com.wazeegroup.physhun.engine.StateEngine) and bootstrap the state engine from a non-spring bean factory. Physhun Modeler (the graphical editor) outputs Spring compliant XML, so if you were to do this you'd either have to develop a new modeling tool, or something to convert Modeler's output to a format that is compliant with the bean factory you choose.
2. Representation of the state model as XML. True, the XML representation of a state model can be extremely verbose. Frankly, any textual representation of a non-trivial state model is likely to be verbose and hard to visualize. This is why it is extremely useful to have a graphical editor. Physhun provides a graphical modeling tool which can be used to create, view and edit Physhun state models. In most scenarios you don't have to work with the raw XML.
-Justin -
Re: Implementing Finite State Machines with Physhun and Spring[ Go to top ]
- Posted by: Richard Nduka
- Posted on: July 24 2008 04:57 EDT
- in response to Nuno Teixeira
Hi I just want to know if this is similar to business process implementations like jBPM? If not how do they differ?
Thanks y'all. -
Re: Implementing Finite State Machines with Physhun and Spring[ Go to top ]
- Posted by: Richard Nduka
- Posted on: July 24 2008 06:00 EDT
- in response to Nuno Teixeira
Another question i have is that in your example for processobject persistence you used spring jdbc is it possible to use hibernate instead without any problems?
I really like the simplicity of this product but one thing that is restraining me from using this framework in a production application is the apparent lack of a community around the framework and i am not sure where to go to if i run into problems. And again there dosent seem to be frequent releases as i can see it takes a long while for new releases to be made. -
Re: Implementing Finite State Machines with Physhun and Spring[ Go to top ]
- Posted by: David Soroko
- Posted on: July 28 2008 04:15 EDT
- in response to Richard Nduka
There is something not right with tutorial example ( http://physhun.sourceforge.net/tutorial/tutorial.html ). You have:
container.startProcess(sodaTx, stateModel);
container.sendTriggerEventToProcess("mySodaTransaction", new soda.events.FundsAdded(0.1f)); // put in a dime
but sending FundsAdded does not do what it's name implies (it does not add funds) because at that point the FSM in in the "New Transaction" state which has no actions associated with with moving out of that state. I am curious to see how would you change things to make the example work. -
Tutorial Example[ Go to top ]
- Posted by: Justin McCarter
- Posted on: August 01 2008 18:15 EDT
- in response to David Soroko
David -
You are absolutely right -- since the condition for transition from NewTransaction to TransactionInProgress is defaultTriggeredCondition, after startProcess() returns the process state is indeed NewTransaction. The condition on transition from NewTransaction to TransactionInProgress should be DefaultCondition. If set as such, on return from startProcess() the process state would be TransactionInProgress.
I need to update the tutorial example accordingly, thanks for the heads up!
-Justin -
Similar Solution[ Go to top ]
- Posted by: Benjamin Possolo
- Posted on: July 30 2008 12:59 EDT
- in response to Nuno Teixeira
This is actually very very similar to something i've been working on and which i've described here (UML documents are located at the bottom of the page):
http://www.javenue.org/process_framework/index.html
There are quite a few differences between the two solutions though.
It seems Pyshun is almost entirely XML-based while mine is purely java based. Additionally, it seem's the Pyshun solution is more tightly tied to specific technologies like Spring and the two databases they mentioned.
They have also more distinctly defined conditions for executing transitions. -
Database dependency[ Go to top ]
- Posted by: Justin McCarter
- Posted on: August 01 2008 17:58 EDT
- in response to Benjamin Possolo
There is currently a dependency on Spring in that the default StateEngine (which can be overriden) uses the Spring BeanFactory to inflate the process model. However, there is absolutely not a dependency on the two mentioned databases. The persistence mechanism in Physhun is completely decoupled. You can implement and plug in whatever persistence mechanism you like. Although reference implementations for Oracle and mysql are provided, implementation of custom persistence mechanisms is extremely straightforward.
The main reason that we went with an XML representation for the state models was so that processes could be modified or added on the fly without recompilation. -
Oracle and mySQL reference implementations[ Go to top ]
- Posted by: oscar serna
- Posted on: August 19 2008 13:30 EDT
- in response to Justin McCarter
Hi Justin,
I downloaded the binary code and th sources, but I can not find where are the reference implementations for Oracle and mysql. ¿What do you mean with reference implementations? -
Persistence examples[ Go to top ]
- Posted by: Justin McCarter
- Posted on: August 20 2008 10:15 EDT
- in response to oscar serna
You can find samples of persistence support in the Examples package (separate download on sourceforge). -
methinks is good but...[ Go to top ]
- Posted by: Lupu Slobodu
- Posted on: August 15 2008 13:10 EDT
- in response to Nuno Teixeira
1)One should be able to create a new state machine model as a variation of an already existing model without duplicating the common definitions.
2)Conditions need to support an expression language -
methinks is good but...[ Go to top ]
- Posted by: Justin McCarter
- Posted on: August 20 2008 10:38 EDT
- in response to Lupu Slobodu
Using physhun, state models can be created as variations of others fairly easily by factoring common logic into reusable subprocesses, or simply by saving a model under a new name and modifying.
As far as Conditions supporting an expression language, out of the box Conditions can be defined inline (without creating custom Condition implementation classes) in Java or in Groovy Script. So, yes, Physhun conditions (and Actions for that matter) do support expression languages.
-Justin