Update samples to the latest Spring Shell and Boot versions

This commit is contained in:
Mahmoud Ben Hassine
2025-02-07 05:21:01 +01:00
parent 45350cbdfb
commit f3d582009e
20 changed files with 124 additions and 143 deletions

View File

@@ -1,9 +1,9 @@
#Mon Jun 19 10:33:34 UTC 2023
version=4.0.1-SNAPSHOT
springBootVersion=3.4.2
springBootVersion=3.5.0-SNAPSHOT
springShellVersion=3.4.1-SNAPSHOT
jakartaPersistenceVersion=3.1.0
kryoVersion=4.0.3
springShellVersion=3.4.0
eclipseEmfXmiVersion=2.11.1
eclipseUml2CommonVersion=2.0.0-v20140602-0749
eclipseEmfCommonVersion=2.11.0

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2019 the original author or authors.
* Copyright 2015-2025 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.
@@ -21,10 +21,10 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.Map;
import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.shell.Bootstrap;
import org.springframework.statemachine.ExtendedState;
import org.springframework.statemachine.StateContext;
import org.springframework.statemachine.action.Action;
@@ -308,8 +308,8 @@ public class Application {
}
//end::snippetL[]
public static void main(String[] args) throws Exception {
Bootstrap.main(args);
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2025 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.
@@ -19,13 +19,11 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.shell.core.CommandMarker;
import org.springframework.shell.core.annotation.CliCommand;
import org.springframework.shell.core.annotation.CliOption;
import org.springframework.stereotype.Component;
import org.springframework.shell.command.annotation.Command;
import org.springframework.shell.command.annotation.Option;
@Component
public class CdPlayerCommands implements CommandMarker {
@Command
public class CdPlayerCommands {
@Autowired
private CdPlayer cdPlayer;
@@ -33,12 +31,12 @@ public class CdPlayerCommands implements CommandMarker {
@Autowired
private Library library;
@CliCommand(value = "cd lcd", help = "Prints CD player lcd info")
@Command(command = "cd lcd", description = "Prints CD player lcd info")
public String lcd() {
return cdPlayer.getLdcStatus();
}
@CliCommand(value = "cd library", help = "List user CD library")
@Command(command = "cd library", description = "List user CD library")
public String library() {
SimpleDateFormat format = new SimpleDateFormat("mm:ss");
StringBuilder buf = new StringBuilder();
@@ -53,8 +51,8 @@ public class CdPlayerCommands implements CommandMarker {
return buf.toString();
}
@CliCommand(value = "cd load", help = "Load CD into player")
public String load(@CliOption(key = {"", "index"}) int index) {
@Command(command = "cd load", description = "Load CD into player")
public String load(@Option(longNames = {"", "index"}) int index) {
StringBuilder buf = new StringBuilder();
try {
Cd cd = library.getCollection().get(index);
@@ -66,32 +64,32 @@ public class CdPlayerCommands implements CommandMarker {
return buf.toString();
}
@CliCommand(value = "cd play", help = "Press player play button")
@Command(command = "cd play", description = "Press player play button")
public void play() {
cdPlayer.play();
}
@CliCommand(value = "cd stop", help = "Press player stop button")
@Command(command = "cd stop", description = "Press player stop button")
public void stop() {
cdPlayer.stop();
}
@CliCommand(value = "cd pause", help = "Press player pause button")
@Command(command = "cd pause", description = "Press player pause button")
public void pause() {
cdPlayer.pause();
}
@CliCommand(value = "cd eject", help = "Press player eject button")
@Command(command = "cd eject", description = "Press player eject button")
public void eject() {
cdPlayer.eject();
}
@CliCommand(value = "cd forward", help = "Press player forward button")
@Command(command = "cd forward", description = "Press player forward button")
public void forward() {
cdPlayer.forward();
}
@CliCommand(value = "cd back", help = "Press player back button")
@Command(command = "cd back", description = "Press player back button")
public void back() {
cdPlayer.back();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2019 the original author or authors.
* Copyright 2015-2025 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.
@@ -16,20 +16,19 @@
package demo.cdplayer;
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;
import org.springframework.shell.command.annotation.Command;
import org.springframework.shell.command.annotation.Option;
import demo.AbstractStateMachineCommands;
import demo.cdplayer.Application.Events;
import demo.cdplayer.Application.States;
import reactor.core.publisher.Mono;
@Component
@Command
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) {
@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()))

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2025 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.
@@ -16,10 +16,10 @@
package demo.persist;
import org.springframework.beans.factory.annotation.Autowired;
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.Bootstrap;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.StateMachineConfigurerAdapter;
@@ -105,8 +105,8 @@ public class Application {
}
//end::snippetC[]
public static void main(String[] args) throws Exception {
Bootstrap.main(args);
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2025 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.
@@ -16,34 +16,32 @@
package demo.persist;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.shell.core.CommandMarker;
import org.springframework.shell.core.annotation.CliCommand;
import org.springframework.shell.core.annotation.CliOption;
import org.springframework.stereotype.Component;
import org.springframework.shell.command.annotation.Command;
import org.springframework.shell.command.annotation.Option;
@Component
public class PersistCommands implements CommandMarker {
@Command
public class PersistCommands {
@Autowired
private Persist persist;
@CliCommand(value = "persist db", help = "List entries from db")
@Command(command = "persist db", description = "List entries from db")
public String listDbEntries() {
return persist.listDbEntries();
}
@CliCommand(value = "persist process", help = "Process order")
public void process(@CliOption(key = {"", "id"}, help = "Order id") int order) {
@Command(command = "persist process", description = "Process order")
public void process(@Option(longNames = {"", "id"}, description = "Order id") int order) {
persist.change(order, "PROCESS");
}
@CliCommand(value = "persist send", help = "Send order")
public void send(@CliOption(key = {"", "id"}, help = "Order id") int order) {
@Command(command = "persist send", description = "Send order")
public void send(@Option(longNames = {"", "id"}, description = "Order id") int order) {
persist.change(order, "SEND");
}
@CliCommand(value = "persist deliver", help = "Deliver order")
public void deliver(@CliOption(key = {"", "id"}, help = "Order id") int order) {
@Command(command = "persist deliver", description = "Deliver order")
public void deliver(@Option(longNames = {"", "id"}, description = "Order id") int order) {
persist.change(order, "DELIVER");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2019 the original author or authors.
* Copyright 2015-2025 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.
@@ -16,18 +16,17 @@
package demo.persist;
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;
import org.springframework.shell.command.annotation.Command;
import org.springframework.shell.command.annotation.Option;
import demo.AbstractStateMachineCommands;
import reactor.core.publisher.Mono;
@Component
@Command
public class StateMachineCommands extends AbstractStateMachineCommands<String, String> {
@CliCommand(value = "sm event", help = "Sends an event to a state machine")
public String event(@CliOption(key = { "", "event" }, mandatory = true, help = "The event") final String event) {
@Command(command = "sm event", description = "Sends an event to a state machine")
public String event(@Option(longNames = { "", "event" }, required = true, description = "The event") final String event) {
getStateMachine()
.sendEvent(Mono.just(MessageBuilder
.withPayload(event).build()))

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2025 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.
@@ -19,9 +19,9 @@ import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.shell.Bootstrap;
import org.springframework.statemachine.StateContext;
import org.springframework.statemachine.action.Action;
import org.springframework.statemachine.config.EnableStateMachine;
@@ -214,8 +214,8 @@ public class Application {
}
// end::snippetE[]
public static void main(String[] args) throws Exception {
Bootstrap.main(args);
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2019 the original author or authors.
* Copyright 2015-2025 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.
@@ -16,8 +16,8 @@
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.shell.command.annotation.Command;
import org.springframework.shell.command.annotation.Option;
import org.springframework.stereotype.Component;
import demo.AbstractStateMachineCommands;
@@ -28,8 +28,8 @@ 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) {
@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()))

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2019 the original author or authors.
* Copyright 2015-2025 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.
@@ -21,15 +21,13 @@ import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.shell.core.CommandMarker;
import org.springframework.shell.core.annotation.CliCommand;
import org.springframework.shell.command.annotation.Command;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.state.State;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@Component
public class AbstractStateMachineCommands<S, E> implements CommandMarker {
@Command
public class AbstractStateMachineCommands<S, E> {
@Autowired
private StateMachine<S, E> stateMachine;
@@ -42,7 +40,7 @@ public class AbstractStateMachineCommands<S, E> implements CommandMarker {
@Qualifier("stateChartModel")
private String stateChartModel;
@CliCommand(value = "sm state", help = "Prints current state")
@Command(command = "sm state", description = "Prints current state")
public String state() {
State<S, E> state = stateMachine.getState();
if (state != null) {
@@ -52,24 +50,24 @@ public class AbstractStateMachineCommands<S, E> implements CommandMarker {
}
}
@CliCommand(value = "sm start", help = "Start a state machine")
@Command(command = "sm start", description = "Start a state machine")
public String start() {
stateMachine.startReactively().subscribe();
return "State machine started";
}
@CliCommand(value = "sm stop", help = "Stop a state machine")
@Command(command = "sm stop", description = "Stop a state machine")
public String stop() {
stateMachine.stopReactively().subscribe();
return "State machine stopped";
}
@CliCommand(value = "sm print", help = "Print state machine")
@Command(command = "sm print", description = "Print state machine")
public String print() {
return stateChartModel;
}
@CliCommand(value = "sm variables", help = "Prints extended state variables")
@Command(command = "sm variables", description = "Prints extended state variables")
public String variables() {
StringBuilder buf = new StringBuilder();
Set<Entry<Object, Object>> entrySet = stateMachine.getExtendedState().getVariables().entrySet();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2025 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,24 +15,19 @@
*/
package demo;
import org.jline.utils.AttributedString;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.shell.plugin.support.DefaultPromptProvider;
import org.springframework.shell.jline.PromptProvider;
import org.springframework.stereotype.Component;
@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
public class StateMachinePromptProvider extends DefaultPromptProvider {
public class StateMachinePromptProvider implements PromptProvider {
@Override
public String getPrompt() {
return "sm>";
}
@Override
public String getProviderName() {
return "State machine prompt provider";
public AttributedString getPrompt() {
return AttributedString.fromAnsi("sm>");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2019 the original author or authors.
* Copyright 2015-2025 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.
@@ -21,10 +21,10 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.Map;
import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.shell.Bootstrap;
import org.springframework.statemachine.StateContext;
import org.springframework.statemachine.action.Action;
import org.springframework.statemachine.annotation.OnTransition;
@@ -232,8 +232,8 @@ public class Application {
}
public static void main(String[] args) throws Exception {
Bootstrap.main(args);
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2019 the original author or authors.
* Copyright 2015-2025 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.
@@ -16,20 +16,19 @@
package demo.tasks;
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;
import org.springframework.shell.command.annotation.Command;
import org.springframework.shell.command.annotation.Option;
import demo.AbstractStateMachineCommands;
import demo.tasks.Application.Events;
import demo.tasks.Application.States;
import reactor.core.publisher.Mono;
@Component
@Command
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) {
@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()))

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2025 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.
@@ -16,34 +16,32 @@
package demo.tasks;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.shell.core.CommandMarker;
import org.springframework.shell.core.annotation.CliCommand;
import org.springframework.shell.core.annotation.CliOption;
import org.springframework.stereotype.Component;
import org.springframework.shell.command.annotation.Command;
import org.springframework.shell.command.annotation.Option;
@Component
public class TasksCommands implements CommandMarker {
@Command
public class TasksCommands {
@Autowired
private Tasks tasks;
@CliCommand(value = "tasks run", help = "Run tasks")
@Command(command = "tasks run", description = "Run tasks")
public void run() {
tasks.run();
}
@CliCommand(value = "tasks list", help = "List tasks")
@Command(command = "tasks list", description = "List tasks")
public String list() {
return tasks.toString();
}
@CliCommand(value = "tasks fix", help = "Fix tasks")
@Command(command = "tasks fix", description = "Fix tasks")
public void fix() {
tasks.fix();
}
@CliCommand(value = "tasks fail", help = "Fail task")
public void fail(@CliOption(key = {"", "task"}, help = "Task id") String task) {
@Command(command = "tasks fail", description = "Fail task")
public void fail(@Option(longNames = {"", "task"}, description = "Task id") String task) {
tasks.fail(task);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2025 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.
@@ -17,8 +17,8 @@ package demo.turnstile;
import java.util.EnumSet;
import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.Configuration;
import org.springframework.shell.Bootstrap;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.EnumStateMachineConfigurerAdapter;
import org.springframework.statemachine.config.builders.StateMachineStateConfigurer;
@@ -72,8 +72,8 @@ public class Application {
}
//end::snippetC[]
public static void main(String[] args) throws Exception {
Bootstrap.main(args);
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2019 the original author or authors.
* Copyright 2015-2025 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.
@@ -16,20 +16,19 @@
package demo.turnstile;
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;
import org.springframework.shell.command.annotation.Command;
import org.springframework.shell.command.annotation.Option;
import demo.AbstractStateMachineCommands;
import demo.turnstile.Application.Events;
import demo.turnstile.Application.States;
import reactor.core.publisher.Mono;
@Component
@Command
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) {
@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()))

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2025 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,8 +15,8 @@
*/
package demo.washer;
import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.Configuration;
import org.springframework.shell.Bootstrap;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.EnumStateMachineConfigurerAdapter;
import org.springframework.statemachine.config.builders.StateMachineStateConfigurer;
@@ -94,8 +94,8 @@ public class Application {
}
//end::snippetC[]
public static void main(String[] args) throws Exception {
Bootstrap.main(args);
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2019 the original author or authors.
* Copyright 2015-2025 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.
@@ -16,20 +16,19 @@
package demo.washer;
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;
import org.springframework.shell.command.annotation.Command;
import org.springframework.shell.command.annotation.Option;
import demo.AbstractStateMachineCommands;
import demo.washer.Application.Events;
import demo.washer.Application.States;
import reactor.core.publisher.Mono;
@Component
@Command
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) {
@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()))

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015 the original author or authors.
* Copyright 2015-2025 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.
@@ -18,9 +18,9 @@ package demo.zookeeper;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;
import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.shell.Bootstrap;
import org.springframework.statemachine.config.EnableStateMachine;
import org.springframework.statemachine.config.StateMachineConfigurerAdapter;
import org.springframework.statemachine.config.builders.StateMachineConfigurationConfigurer;
@@ -96,8 +96,8 @@ public class Application {
COIN, PUSH
}
public static void main(String[] args) throws Exception {
Bootstrap.main(args);
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2019 the original author or authors.
* Copyright 2015-2025 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.
@@ -16,18 +16,17 @@
package demo.zookeeper;
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;
import org.springframework.shell.command.annotation.Command;
import org.springframework.shell.command.annotation.Option;
import demo.AbstractStateMachineCommands;
import reactor.core.publisher.Mono;
@Component
@Command
public class StateMachineCommands extends AbstractStateMachineCommands<String, String> {
@CliCommand(value = "sm event", help = "Sends an event to a state machine")
public String event(@CliOption(key = { "", "event" }, mandatory = true, help = "The event") final String event) {
@Command(command = "sm event", description = "Sends an event to a state machine")
public String event(@Option(longNames = { "", "event" }, required = true, description = "The event") final String event) {
getStateMachine()
.sendEvent(Mono.just(MessageBuilder
.withPayload(event).build()))