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:
Mahmoud Ben Hassine
2025-04-15 14:08:19 +02:00
parent 5170c0e2d2
commit 1a017dced2
71 changed files with 733 additions and 2024 deletions

View File

@@ -9,5 +9,5 @@ dependencies {
implementation project(':spring-statemachine-zookeeper')
implementation project(':spring-statemachine-samples-common')
implementation project(':spring-statemachine-core')
implementation 'org.springframework.shell:spring-shell-core'
implementation 'org.springframework.boot:spring-boot-starter'
}

View File

@@ -19,6 +19,7 @@ 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.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.statemachine.config.EnableStateMachine;
@@ -29,7 +30,7 @@ import org.springframework.statemachine.config.builders.StateMachineTransitionCo
import org.springframework.statemachine.ensemble.StateMachineEnsemble;
import org.springframework.statemachine.zookeeper.ZookeeperStateMachineEnsemble;
@Configuration
@SpringBootApplication(scanBasePackages = "demo")
public class Application {
@Configuration

View File

@@ -15,22 +15,30 @@
*/
package demo.zookeeper;
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 reactor.core.publisher.Mono;
@Command
@Configuration
public class StateMachineCommands extends AbstractStateMachineCommands<String, String> {
@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()))
.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) {
String event = args[0];
getStateMachine()
.sendEvent(Mono.just(MessageBuilder
.withPayload(event).build()))
.subscribe();
return "Event " + event + " sent";
}
};
}
}

View File

@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="demo" />
</beans>

View File

@@ -0,0 +1 @@
spring.main.allow-bean-definition-overriding=true