Change StateMachinePersist interface

- Remove away from plain serialize/deserialize to write/read
  concept which works better in a generic abstraction.
- Tweak related class in zookeeper package.
- Relates to #35
This commit is contained in:
Janne Valkealahti
2015-06-20 15:41:35 +01:00
parent e2fe4907d3
commit 44d09f257e
4 changed files with 88 additions and 28 deletions

View File

@@ -25,23 +25,28 @@ import org.springframework.statemachine.StateMachineContext;
*
* @param <S> the type of state
* @param <E> the type of event
* @param <T> the type of context object
*/
public interface StateMachinePersist<S, E> {
public interface StateMachinePersist<S, E, T> {
/**
* Serialize a {@link StateMachineContext}.
* Write a {@link StateMachineContext} into a persistent store
* with a context object {@code T}.
*
* @param context the state machine context
* @return the serialized data
* @param contect the contect
* @param contextOjb the context ojb
* @throws Exception the exception
*/
byte[] serialize(StateMachineContext<S, E> context);
void write(StateMachineContext<S, E> contect, T contextOjb) throws Exception;
/**
* Deserialize a data into a {@link StateMachineContext}.
* Read a {@link StateMachineContext} from a persistent store
* with a context object {@code T}.
*
* @param data the data
* @param contextOjb the context ojb
* @return the state machine context
* @throws Exception the exception
*/
StateMachineContext<S, E> deserialize(byte[] data);
StateMachineContext<S, E> read(T contextOjb) throws Exception;
}