我试图在Spring Boot中使用Akka构建一个简单的FSM。不幸的是,因为记录的FSM应该在范围块中初始化。
例如,在以下示例中,
public class Buncher extends AbstractFSM<State, Data> {
{
startWith(Idle, Uninitialized);
when(Idle,
matchEvent(SetTarget.class, Uninitialized.class,
(setTarget, uninitialized) ->
stay().using(new Todo(setTarget.getRef(), new LinkedList<>()))));
onTransition(
matchState(Active, Idle, () -> {
// reuse this matcher
final UnitMatch<Data> m = UnitMatch.create(
matchData(Todo.class,
todo -> todo.getTarget().tell(new Batch(todo.getQueue()), getSelf())));
m.match(stateData());
}).
state(Idle, Active, () -> {/* Do something here */}));
when(Active, Duration.ofSeconds(1L),
matchEvent(Arrays.asList(Flush.class, StateTimeout()), Todo.class,
(event, todo) -> goTo(Idle).using(todo.copy(new LinkedList<>()))));
whenUnhandled(
matchEvent(Queue.class, Todo.class,
(queue, todo) -> goTo(Active).using(todo.addElement(queue.getObj()))).
anyEvent((event, state) -> {
log().warning("received unhandled request {} in state {}/{}",
event, stateName(), state);
return stay();
}));
initialize();
}
}
我想在此块中使用带ConfigurationProperties
注释的应用程序属性。我可以在这个区块中自动装配属性吗?