Is there a standard pattern for implementing state machines using java?
One way i could think about is having a class which listens to events and has the开发者_如何学Python different states stored in variables.
Is there a standard pattern for implementing state machines using java?
The article I read before seems to be down right now, but if you Google enough you should be able to find other sources on how to implement finite state machines using Java enum
s.
Found it: http://www.javacodegeeks.com/2011/07/java-secret-using-enum-to-build-state.html
state pattern can be used. See an example implementation in C++ here.
I found this article very useful when I had to implement the state pattern: State Design Pattern using java .. A different approach!
There's jBPM, which can run standalone. It's essentially a persistent state machine with bells and whistles.
精彩评论