@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package demo.showcase;
|
||||
|
||||
import org.springframework.messaging.support.MessageBuilder;
|
||||
import org.springframework.shell.core.annotation.CliCommand;
|
||||
import org.springframework.shell.core.annotation.CliOption;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -22,14 +23,17 @@ import org.springframework.stereotype.Component;
|
||||
import demo.AbstractStateMachineCommands;
|
||||
import demo.showcase.Application.Events;
|
||||
import demo.showcase.Application.States;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@Component
|
||||
public class StateMachineCommands extends AbstractStateMachineCommands<States, Events> {
|
||||
|
||||
@CliCommand(value = "sm event", help = "Sends an event to a state machine")
|
||||
public String event(@CliOption(key = { "", "event" }, mandatory = true, help = "The event") final Events event) {
|
||||
getStateMachine().sendEvent(event);
|
||||
getStateMachine()
|
||||
.sendEvent(Mono.just(MessageBuilder
|
||||
.withPayload(event).build()))
|
||||
.subscribe();
|
||||
return "Event " + event + " send";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user