Remove dependency to Spring Shell
This commit updates the samples to use Java's standard CLI utilities instead of Spring Shell. Resolves #1184
This commit is contained in:
@@ -23,7 +23,6 @@ import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.shell.command.annotation.CommandScan;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.statemachine.action.Action;
|
||||
import org.springframework.statemachine.config.EnableStateMachine;
|
||||
@@ -32,7 +31,6 @@ import org.springframework.statemachine.config.builders.StateMachineStateConfigu
|
||||
import org.springframework.statemachine.config.builders.StateMachineTransitionConfigurer;
|
||||
import org.springframework.statemachine.guard.Guard;
|
||||
|
||||
@CommandScan
|
||||
@SpringBootApplication(scanBasePackages = "demo")
|
||||
public class Application {
|
||||
|
||||
|
||||
@@ -15,24 +15,32 @@
|
||||
*/
|
||||
package demo.showcase;
|
||||
|
||||
import demo.BasicCommand;
|
||||
import demo.Command;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.messaging.support.MessageBuilder;
|
||||
import org.springframework.shell.command.annotation.Command;
|
||||
import org.springframework.shell.command.annotation.Option;
|
||||
|
||||
import demo.AbstractStateMachineCommands;
|
||||
import demo.showcase.Application.Events;
|
||||
import demo.showcase.Application.States;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@Command
|
||||
@Configuration
|
||||
public class StateMachineCommands extends AbstractStateMachineCommands<States, Events> {
|
||||
|
||||
@Command(command = "sm event", description = "Sends an event to a state machine")
|
||||
public String event(@Option(longNames = { "", "event" }, required = true, description = "The event") final Events event) {
|
||||
getStateMachine()
|
||||
.sendEvent(Mono.just(MessageBuilder
|
||||
.withPayload(event).build()))
|
||||
.subscribe();
|
||||
return "Event " + event + " send";
|
||||
@Bean
|
||||
public Command event() {
|
||||
return new BasicCommand("event", "Sends an event to a state machine") {
|
||||
@Override
|
||||
public String execute(String[] args) {
|
||||
Events event = Events.valueOf(args[0]);
|
||||
getStateMachine()
|
||||
.sendEvent(Mono.just(MessageBuilder
|
||||
.withPayload(event).build()))
|
||||
.subscribe();
|
||||
return "Event " + event + " sent";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
spring.shell.interactive.enabled=true
|
||||
spring.main.allow-bean-definition-overriding=true
|
||||
Reference in New Issue
Block a user