Hi, I have some questions regarding the Mina state machine project.
First question: When I look at the current implementation of the StateMachine class it uses ThreadLocal to store the event queue and some processing state. So I figure that the SM won't work well if state changes are performed from different threads which is a use-case that I have right now? My question is why threadlocal is used at all? The only place where it's used seems to be in the StateMachine class and the StateMachineFactory creates a new instance of the StateMachine on each call to create. Why can't the use of threadlocal be replaced with pure instance variables not based on ThreadLocal? If this is not possible for some reason I'd like to be able to replace the Thread to EventQueue mapping and be able to pass in my own mapper based on some other key so that the SM state changes can be performed from different threads if it's not possible today. I'd be happy to help out with this if needed. Second question: It doesn't seem to be possible to define the state definitions (i.e. the final static fields annotated with @State) outside of a handler? I think this is quite bad since let's say you have two handlers A & B and some of the state definitions are shared between the two then you need to duplicate the state definition to both A & B instead of just importing it from a common state definition class/context. I.e. I'd like to see something like: "StateMachine sm = StateMachineFactory.getInstance(Transition.class).create(MyStateDef.MY_START_STATE, MyStateDef.class, instanceOfHandlerA, instanceOfHandlerB)" because then you don't have to duplicate the state definitions if they are shared by multiple handlers. Or is this a bad thing? I've implemented this (and written tests for it) and I can send you a patch if you're interested. Third question: Why can you only annotate Strings with @State? It would be nice to be able to annotate an Enum for example (you use @State at the class-level of the enum ad then Mina SM can know that each Enum (or it's string representation) should be used as the state). /Johan
