multi pom
This commit is contained in:
33
state_machines/maven_multi_module/core-module/.gitignore
vendored
Normal file
33
state_machines/maven_multi_module/core-module/.gitignore
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
38
state_machines/maven_multi_module/core-module/pom.xml
Normal file
38
state_machines/maven_multi_module/core-module/pom.xml
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>click.kamil.maven</groupId>
|
||||
<artifactId>maven-multi-module</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<artifactId>core-module</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>click.kamil.maven</groupId>
|
||||
<artifactId>base-module</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>click.kamil.maven</groupId>
|
||||
<artifactId>api-module</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.statemachine</groupId>
|
||||
<artifactId>spring-statemachine-core</artifactId>
|
||||
<version>3.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,55 @@
|
||||
package click.kamil.maven.core;
|
||||
|
||||
import click.kamil.maven.api.JmsOrderListener;
|
||||
import click.kamil.maven.api.MavenOrderApi;
|
||||
import click.kamil.maven.base.AbstractMavenStateMachine;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.statemachine.StateMachine;
|
||||
import org.springframework.statemachine.config.EnableStateMachineFactory;
|
||||
import org.springframework.statemachine.config.StateMachineFactory;
|
||||
import org.springframework.statemachine.config.builders.StateMachineTransitionConfigurer;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Configuration
|
||||
@EnableStateMachineFactory
|
||||
public class MavenOrderStateMachine extends AbstractMavenStateMachine {
|
||||
|
||||
@Override
|
||||
public void configure(StateMachineTransitionConfigurer<String, String> transitions) throws Exception {
|
||||
transitions
|
||||
.withExternal()
|
||||
.source("INIT").target("BUSY")
|
||||
.event("SUBMIT")
|
||||
.action(loggingAction())
|
||||
.and()
|
||||
.withExternal()
|
||||
.source("BUSY").target("DONE")
|
||||
.event("ORDER_EVENT");
|
||||
}
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
public static class OrderController implements MavenOrderApi {
|
||||
private final StateMachineFactory<String, String> factory;
|
||||
|
||||
@Override
|
||||
public void submitOrder(String orderId) {
|
||||
StateMachine<String, String> sm = factory.getStateMachine(orderId);
|
||||
sm.sendEvent("SUBMIT");
|
||||
}
|
||||
}
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public static class OrderService implements JmsOrderListener {
|
||||
private final StateMachineFactory<String, String> factory;
|
||||
|
||||
@Override
|
||||
public void onMessage(String message) {
|
||||
StateMachine<String, String> sm = factory.getStateMachine();
|
||||
sm.sendEvent("ORDER_EVENT");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user