11

One way i could think about is having a class which listens to events and has the different states stored in variables.

Is there a standard pattern for implementing state machines using java?

4 Answers 4

6

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 enums.

Found it: http://www.javacodegeeks.com/2011/07/java-secret-using-enum-to-build-state.html

Sign up to request clarification or add additional context in comments.

Comments

1

state pattern can be used. See an example implementation in C++ here.

1 Comment

The 2nd link is dead
1

Use a state pattern, as described here: State Design Pattern using java .. A different approach!

Comments

0

There's jBPM, which can run standalone. It's essentially a persistent state machine with bells and whistles.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.