Upgrade to Spring Boot 3
This commit is contained in:
4
.github/workflows/ci-boot.yml
vendored
4
.github/workflows/ci-boot.yml
vendored
@@ -11,8 +11,8 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
java: [1.8]
|
||||
boot: [2.7.0, 2.7.12]
|
||||
java: [ 17 ]
|
||||
boot: [ 3.1.0, 3.1.3 ]
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
|
||||
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@@ -16,7 +16,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
java: [1.8, 11]
|
||||
java: [ 17 ]
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
@@ -52,7 +52,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.8
|
||||
java-version: 17
|
||||
- uses: jfrog/setup-jfrog-cli@v3
|
||||
with:
|
||||
version: 2.39.1
|
||||
|
||||
2
.github/workflows/mongodb.yml
vendored
2
.github/workflows/mongodb.yml
vendored
@@ -24,7 +24,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
java: [1.8, 11]
|
||||
java: [ 17 ]
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
|
||||
2
.github/workflows/pr.yml
vendored
2
.github/workflows/pr.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
java: [1.8, 11]
|
||||
java: [ 17 ]
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
|
||||
2
.github/workflows/redis.yml
vendored
2
.github/workflows/redis.yml
vendored
@@ -24,7 +24,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
java: [1.8, 11]
|
||||
java: [ 17 ]
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
|
||||
2
.github/workflows/release-ga.yml
vendored
2
.github/workflows/release-ga.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.8
|
||||
java-version: 17
|
||||
- uses: jfrog/setup-jfrog-cli@v3
|
||||
with:
|
||||
version: 2.39.1
|
||||
|
||||
2
.github/workflows/release-milestone.yml
vendored
2
.github/workflows/release-milestone.yml
vendored
@@ -25,7 +25,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.8
|
||||
java-version: 17
|
||||
- uses: jfrog/setup-jfrog-cli@v3
|
||||
with:
|
||||
version: 2.39.1
|
||||
|
||||
2
.github/workflows/smoke.yml
vendored
2
.github/workflows/smoke.yml
vendored
@@ -18,7 +18,7 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
java: [1.8, 11]
|
||||
java: [ 17 ]
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
|
||||
20
build.gradle
20
build.gradle
@@ -1,8 +1,8 @@
|
||||
buildscript {
|
||||
ext {
|
||||
log4jVersion = '1.2.17'
|
||||
springBootVersion = '2.7.0'
|
||||
eclipsePersistenceVersion = '2.1.1'
|
||||
springBootVersion = '3.1.3'
|
||||
jakartaPersistenceVersion = '3.1.0'
|
||||
kryoVersion = '4.0.2'
|
||||
springCloudClusterVersion = '1.0.2.RELEASE'
|
||||
springShellVersion = '1.1.0.RELEASE'
|
||||
@@ -67,13 +67,13 @@ configure(javaProjectsAndRoot) {
|
||||
}
|
||||
|
||||
compileJava {
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
sourceCompatibility = 17
|
||||
targetCompatibility = 17
|
||||
}
|
||||
|
||||
compileTestJava {
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
sourceCompatibility = 17
|
||||
targetCompatibility = 17
|
||||
}
|
||||
|
||||
group = 'org.springframework.statemachine'
|
||||
@@ -218,7 +218,7 @@ project('spring-statemachine-core') {
|
||||
testFixturesImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.springframework.security:spring-security-config'
|
||||
testImplementation 'org.springframework.security:spring-security-test'
|
||||
testImplementation 'javax.servlet:javax.servlet-api'
|
||||
testImplementation 'jakarta.servlet:jakarta.servlet-api'
|
||||
testImplementation 'org.awaitility:awaitility'
|
||||
testRuntimeOnly 'org.apache.logging.log4j:log4j-core'
|
||||
}
|
||||
@@ -237,7 +237,7 @@ project('spring-statemachine-autoconfigure') {
|
||||
optional project(':spring-statemachine-data-common:spring-statemachine-data-mongodb')
|
||||
optional 'org.springframework.boot:spring-boot-autoconfigure-processor'
|
||||
optional 'io.micrometer:micrometer-core'
|
||||
optional 'org.eclipse.persistence:javax.persistence'
|
||||
optional 'jakarta.persistence:jakarta.persistence-api'
|
||||
optional 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||
optional 'org.springframework.boot:spring-boot-starter-data-redis'
|
||||
optional 'org.springframework.boot:spring-boot-starter-data-mongodb'
|
||||
@@ -486,8 +486,8 @@ project('spring-statemachine-starter') {
|
||||
configure(sampleProjects()) {
|
||||
apply plugin: 'org.springframework.boot'
|
||||
compileJava {
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
sourceCompatibility = 17
|
||||
targetCompatibility = 17
|
||||
}
|
||||
dependencies {
|
||||
api project(':spring-statemachine-core')
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#Thu May 05 13:05:04 UTC 2022
|
||||
version=3.3.0-SNAPSHOT
|
||||
version=4.0.0-SNAPSHOT
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
apply plugin: 'java-test-fixtures'
|
||||
|
||||
compileTestFixturesJava {
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
sourceCompatibility = 17
|
||||
targetCompatibility = 17
|
||||
}
|
||||
|
||||
eclipse.classpath {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2018 the original author or authors.
|
||||
* Copyright 2016-2023 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,10 @@
|
||||
*/
|
||||
package org.springframework.statemachine.boot.autoconfigure;
|
||||
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
@@ -30,54 +32,52 @@ import org.springframework.statemachine.boot.actuate.StateMachineTraceEndpoint;
|
||||
import org.springframework.statemachine.boot.actuate.StateMachineTraceRepository;
|
||||
import org.springframework.statemachine.boot.support.BootStateMachineMonitor;
|
||||
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for Spring Statemachine.
|
||||
*
|
||||
* @author Janne Valkealahti
|
||||
*
|
||||
*/
|
||||
@Configuration
|
||||
@EnableConfigurationProperties({ StateMachineProperties.class })
|
||||
@AutoConfiguration
|
||||
@EnableConfigurationProperties({StateMachineProperties.class})
|
||||
@ConditionalOnClass(MeterRegistry.class)
|
||||
@ConditionalOnProperty(prefix = "spring.statemachine.monitor", name = "enabled", havingValue = "true", matchIfMissing = true)
|
||||
public class StateMachineAutoConfiguration {
|
||||
|
||||
@ManagementContextConfiguration
|
||||
public static class StateMachineTraceEndpointConfiguration {
|
||||
@ManagementContextConfiguration
|
||||
public static class StateMachineTraceEndpointConfiguration {
|
||||
|
||||
@Bean
|
||||
public StateMachineTraceEndpoint stateMachineTraceEndpoint(StateMachineTraceRepository stateMachineTraceRepository) {
|
||||
return new StateMachineTraceEndpoint(stateMachineTraceRepository);
|
||||
}
|
||||
}
|
||||
@Bean
|
||||
public StateMachineTraceEndpoint stateMachineTraceEndpoint(StateMachineTraceRepository stateMachineTraceRepository) {
|
||||
return new StateMachineTraceEndpoint(stateMachineTraceRepository);
|
||||
}
|
||||
}
|
||||
|
||||
@Configuration
|
||||
public static class StateMachineTraceRepositoryConfiguration {
|
||||
@Configuration
|
||||
public static class StateMachineTraceRepositoryConfiguration {
|
||||
|
||||
@ConditionalOnMissingBean(StateMachineTraceRepository.class)
|
||||
@Bean
|
||||
public InMemoryStateMachineTraceRepository stateMachineTraceRepository() {
|
||||
return new InMemoryStateMachineTraceRepository();
|
||||
}
|
||||
}
|
||||
@ConditionalOnMissingBean(StateMachineTraceRepository.class)
|
||||
@Bean
|
||||
public InMemoryStateMachineTraceRepository stateMachineTraceRepository() {
|
||||
return new InMemoryStateMachineTraceRepository();
|
||||
}
|
||||
}
|
||||
|
||||
@Configuration
|
||||
public static class StateMachineMonitoringConfiguration {
|
||||
@Configuration
|
||||
public static class StateMachineMonitoringConfiguration {
|
||||
|
||||
private final MeterRegistry meterRegistry;
|
||||
private final StateMachineTraceRepository stateMachineTraceRepository;
|
||||
private final MeterRegistry meterRegistry;
|
||||
private final StateMachineTraceRepository stateMachineTraceRepository;
|
||||
|
||||
public StateMachineMonitoringConfiguration(ObjectProvider<MeterRegistry> meterRegistryProvider,
|
||||
ObjectProvider<StateMachineTraceRepository> traceRepositoryProvider) {
|
||||
this.meterRegistry = meterRegistryProvider.getIfAvailable();
|
||||
this.stateMachineTraceRepository = traceRepositoryProvider.getIfAvailable();
|
||||
}
|
||||
public StateMachineMonitoringConfiguration(
|
||||
ObjectProvider<MeterRegistry> meterRegistryProvider,
|
||||
ObjectProvider<StateMachineTraceRepository> traceRepositoryProvider) {
|
||||
this.meterRegistry = meterRegistryProvider.getIfAvailable();
|
||||
this.stateMachineTraceRepository = traceRepositoryProvider.getIfAvailable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BootStateMachineMonitor<?, ?> bootStateMachineMonitor() {
|
||||
return new BootStateMachineMonitor<>(meterRegistry, stateMachineTraceRepository);
|
||||
}
|
||||
}
|
||||
@Bean
|
||||
public BootStateMachineMonitor<?, ?> bootStateMachineMonitor() {
|
||||
return new BootStateMachineMonitor<>(meterRegistry, stateMachineTraceRepository);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2023 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,27 +15,24 @@
|
||||
*/
|
||||
package org.springframework.statemachine.boot.autoconfigure;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.statemachine.data.jpa.JpaRepositoryState;
|
||||
import org.springframework.statemachine.data.jpa.JpaStateRepository;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for JPA repositories
|
||||
* and Entity classes.
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for JPA repositories and Entity classes.
|
||||
*/
|
||||
@Configuration
|
||||
@AutoConfiguration(after = JpaRepositoriesAutoConfiguration.class)
|
||||
@ConditionalOnClass(JpaStateRepository.class)
|
||||
@ConditionalOnProperty(prefix = "spring.statemachine.data.jpa.repositories", name = "enabled", havingValue = "true", matchIfMissing = true)
|
||||
@AutoConfigureAfter(JpaRepositoriesAutoConfiguration.class)
|
||||
@EntityScan(basePackageClasses = { JpaRepositoryState.class })
|
||||
@EnableJpaRepositories(basePackageClasses = { JpaStateRepository.class })
|
||||
@EntityScan(basePackageClasses = {JpaRepositoryState.class})
|
||||
@EnableJpaRepositories(basePackageClasses = {JpaStateRepository.class})
|
||||
public class StateMachineJpaRepositoriesAutoConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2023 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,27 +15,24 @@
|
||||
*/
|
||||
package org.springframework.statemachine.boot.autoconfigure;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
||||
import org.springframework.statemachine.data.mongodb.MongoDbRepositoryState;
|
||||
import org.springframework.statemachine.data.mongodb.MongoDbStateRepository;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for MongoDb repositories
|
||||
* and Entity classes.
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for MongoDb repositories and Entity classes.
|
||||
*/
|
||||
@Configuration
|
||||
@AutoConfiguration(after = MongoRepositoriesAutoConfiguration.class)
|
||||
@ConditionalOnClass(MongoDbStateRepository.class)
|
||||
@ConditionalOnProperty(prefix = "spring.statemachine.data.mongo.repositories", name = "enabled", havingValue = "true", matchIfMissing = true)
|
||||
@AutoConfigureAfter(MongoRepositoriesAutoConfiguration.class)
|
||||
@EntityScan(basePackageClasses = { MongoDbRepositoryState.class })
|
||||
@EnableMongoRepositories(basePackageClasses = { MongoDbStateRepository.class })
|
||||
@EntityScan(basePackageClasses = {MongoDbRepositoryState.class})
|
||||
@EnableMongoRepositories(basePackageClasses = {MongoDbStateRepository.class})
|
||||
public class StateMachineMongoDbRepositoriesAutoConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2023 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,27 +15,24 @@
|
||||
*/
|
||||
package org.springframework.statemachine.boot.autoconfigure;
|
||||
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
|
||||
import org.springframework.statemachine.data.redis.RedisRepositoryState;
|
||||
import org.springframework.statemachine.data.redis.RedisStateRepository;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for Redis repositories
|
||||
* and Entity classes.
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for Redis repositories and Entity classes.
|
||||
*/
|
||||
@Configuration
|
||||
@AutoConfiguration(after = RedisRepositoriesAutoConfiguration.class)
|
||||
@ConditionalOnClass(RedisStateRepository.class)
|
||||
@ConditionalOnProperty(prefix = "spring.statemachine.data.redis.repositories", name = "enabled", havingValue = "true", matchIfMissing = true)
|
||||
@AutoConfigureAfter(RedisRepositoriesAutoConfiguration.class)
|
||||
@EntityScan(basePackageClasses = { RedisRepositoryState.class })
|
||||
@EnableRedisRepositories(basePackageClasses = { RedisStateRepository.class })
|
||||
@EntityScan(basePackageClasses = {RedisRepositoryState.class})
|
||||
@EnableRedisRepositories(basePackageClasses = {RedisStateRepository.class})
|
||||
public class StateMachineRedisRepositoriesAutoConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
# Auto Configure
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
org.springframework.statemachine.boot.autoconfigure.StateMachineAutoConfiguration,\
|
||||
org.springframework.statemachine.boot.autoconfigure.StateMachineJpaRepositoriesAutoConfiguration,\
|
||||
org.springframework.statemachine.boot.autoconfigure.StateMachineRedisRepositoriesAutoConfiguration,\
|
||||
org.springframework.statemachine.boot.autoconfigure.StateMachineMongoDbRepositoriesAutoConfiguration
|
||||
|
||||
org.springframework.statemachine.boot.autoconfigure.StateMachineAutoConfiguration
|
||||
org.springframework.statemachine.boot.autoconfigure.StateMachineJpaRepositoriesAutoConfiguration
|
||||
org.springframework.statemachine.boot.autoconfigure.StateMachineRedisRepositoriesAutoConfiguration
|
||||
org.springframework.statemachine.boot.autoconfigure.StateMachineMongoDbRepositoriesAutoConfiguration
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 the original author or authors.
|
||||
* Copyright 2019-2023 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,24 +18,24 @@ package org.springframework.statemachine.buildtests.tck.mongodb;
|
||||
import static org.junit.jupiter.api.extension.ConditionEvaluationResult.disabled;
|
||||
import static org.junit.jupiter.api.extension.ConditionEvaluationResult.enabled;
|
||||
|
||||
import java.net.Socket;
|
||||
import org.junit.jupiter.api.extension.ConditionEvaluationResult;
|
||||
import org.junit.jupiter.api.extension.ExecutionCondition;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.springframework.util.SocketUtils;
|
||||
|
||||
public class EnabledOnMongoDbCondition implements ExecutionCondition {
|
||||
|
||||
static final ConditionEvaluationResult ENABLED_ON_MONGO = enabled("Mongo DB found");
|
||||
static final ConditionEvaluationResult ENABLED_ON_MONGO = enabled("Mongo DB found");
|
||||
|
||||
static final ConditionEvaluationResult DISABLED_ON_MONGO = disabled("Mongo DB not found");
|
||||
static final ConditionEvaluationResult DISABLED_ON_MONGO = disabled("Mongo DB not found");
|
||||
|
||||
@Override
|
||||
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
|
||||
try {
|
||||
SocketUtils.findAvailableTcpPort(27017, 27017);
|
||||
return DISABLED_ON_MONGO;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return ENABLED_ON_MONGO;
|
||||
}
|
||||
@Override
|
||||
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
|
||||
try {
|
||||
new Socket("localhost", 27017);
|
||||
return ENABLED_ON_MONGO;
|
||||
} catch (Exception e) {
|
||||
return DISABLED_ON_MONGO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import static org.springframework.statemachine.TestUtils.doStartAndAssert;
|
||||
import static org.springframework.statemachine.TestUtils.resolveMachine;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -253,10 +252,10 @@ public class StateDoActivityActionTests extends AbstractStateMachineTests {
|
||||
Message<TestEvents> event = MessageBuilder.withPayload(TestEvents.E1)
|
||||
.setHeader(StateMachineMessageHeaders.HEADER_DO_ACTION_TIMEOUT, 4000).build();
|
||||
doSendEventAndConsumeAll(machine, event);
|
||||
assertThat(testActionS2.onExecuteStartLatch.await(2, TimeUnit.SECONDS)).isTrue();
|
||||
assertThat(testActionS2.onExecuteStartLatch.await(6, TimeUnit.SECONDS)).isTrue();
|
||||
doSendEventAndConsumeAll(machine, TestEvents.E2);
|
||||
assertThat(testActionS2.onExecuteLatch.await(2, TimeUnit.SECONDS)).isTrue();
|
||||
assertThat(testActionS2.interruptedLatch.await(2, TimeUnit.SECONDS)).isFalse();
|
||||
assertThat(testActionS2.onExecuteLatch.await(6, TimeUnit.SECONDS)).isTrue();
|
||||
assertThat(testActionS2.interruptedLatch.await(6, TimeUnit.SECONDS)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2020 the original author or authors.
|
||||
* Copyright 2016-2023 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.
|
||||
@@ -20,7 +20,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -138,7 +137,7 @@ public class ConfigurationErrorTests extends AbstractStateMachineTests {
|
||||
builder.build();
|
||||
}).satisfies(e -> {
|
||||
assertThat(e.getCause()).isInstanceOf(MalformedConfigurationException.class);
|
||||
assertThat(e.getLocalizedMessage()).contains("No transitions for state S2");
|
||||
assertThat(e.getCause().getLocalizedMessage()).contains("No transitions for state S2");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2020 the original author or authors.
|
||||
* Copyright 2020-2023 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.
|
||||
@@ -28,7 +28,6 @@ import org.springframework.statemachine.config.EnableStateMachine;
|
||||
import org.springframework.statemachine.config.StateMachineConfigurerAdapter;
|
||||
import org.springframework.statemachine.config.builders.StateMachineStateConfigurer;
|
||||
import org.springframework.statemachine.config.builders.StateMachineTransitionConfigurer;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -74,7 +73,7 @@ public class DocsConfigurationSampleTests12 {
|
||||
StepVerifier.create(machine.sendEvent(Mono.just(MessageBuilder.withPayload("E1").build())))
|
||||
.consumeNextWith(result -> {
|
||||
StepVerifier.create(result.complete()).consumeErrorWith(e -> {
|
||||
assertThat(e).isInstanceOf(StateMachineException.class).hasMessageContaining("example error");
|
||||
assertThat(e).isInstanceOf(StateMachineException.class).cause().hasMessageContaining("example error");
|
||||
}).verify();
|
||||
})
|
||||
.verifyComplete();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
* Copyright 2015-2023 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,15 +15,14 @@
|
||||
*/
|
||||
package org.springframework.statemachine.docs;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.context.annotation.ScopedProxyMode;
|
||||
import org.springframework.security.access.annotation.Secured;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.statemachine.action.Action;
|
||||
import org.springframework.statemachine.config.EnableStateMachine;
|
||||
@@ -139,14 +138,16 @@ public class DocsConfigurationSampleTests3 {
|
||||
|
||||
// tag::snippetE[]
|
||||
@Configuration
|
||||
@EnableGlobalMethodSecurity(securedEnabled = true)
|
||||
public static class Config5 extends WebSecurityConfigurerAdapter {
|
||||
public static class Config5 {
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth
|
||||
.inMemoryAuthentication()
|
||||
.withUser("user").password("password").roles("USER");
|
||||
@Bean
|
||||
public InMemoryUserDetailsManager userDetailsService() {
|
||||
UserDetails user = User.withDefaultPasswordEncoder()
|
||||
.username("user")
|
||||
.password("password")
|
||||
.roles("USER")
|
||||
.build();
|
||||
return new InMemoryUserDetailsManager(user);
|
||||
}
|
||||
}
|
||||
// end::snippetE[]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2020 the original author or authors.
|
||||
* Copyright 2015-2023 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.
|
||||
@@ -20,7 +20,6 @@ import static org.springframework.statemachine.TestUtils.doSendEventAndConsumeAl
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
@@ -30,9 +29,9 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.context.annotation.ScopedProxyMode;
|
||||
import org.springframework.security.access.annotation.Secured;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
|
||||
import org.springframework.security.test.context.support.WithMockUser;
|
||||
import org.springframework.statemachine.AbstractStateMachineTests;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
@@ -103,16 +102,17 @@ public class ActionSecurityTests extends AbstractStateMachineTests {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableGlobalMethodSecurity(securedEnabled = true)
|
||||
public static class Config1 extends WebSecurityConfigurerAdapter {
|
||||
public static class Config1 {
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth
|
||||
.inMemoryAuthentication()
|
||||
.withUser("user").password("password").roles("USER");
|
||||
@Bean
|
||||
public InMemoryUserDetailsManager userDetailsService() {
|
||||
UserDetails user = User.withDefaultPasswordEncoder()
|
||||
.username("user")
|
||||
.password("password")
|
||||
.roles("USER")
|
||||
.build();
|
||||
return new InMemoryUserDetailsManager(user);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
|
||||
@@ -11,7 +11,7 @@ project('spring-statemachine-data-jpa') {
|
||||
testImplementation(testFixtures(project(":spring-statemachine-data-common")))
|
||||
testImplementation(testFixtures(project(":spring-statemachine-core")))
|
||||
testImplementation 'io.projectreactor:reactor-test'
|
||||
optional 'org.eclipse.persistence:javax.persistence'
|
||||
optional 'jakarta.persistence:jakarta.persistence-api'
|
||||
testImplementation 'org.hsqldb:hsqldb'
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
testRuntimeOnly 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||
@@ -27,7 +27,7 @@ project('spring-statemachine-data-redis') {
|
||||
api project(':spring-statemachine-data-common')
|
||||
api 'org.springframework.data:spring-data-redis'
|
||||
testImplementation project(':spring-statemachine-test')
|
||||
optional 'org.eclipse.persistence:javax.persistence'
|
||||
optional 'jakarta.persistence:jakarta.persistence-api'
|
||||
testImplementation(testFixtures(project(":spring-statemachine-data-common")))
|
||||
testImplementation(testFixtures(project(":spring-statemachine-core")))
|
||||
testImplementation 'io.projectreactor:reactor-test'
|
||||
@@ -47,7 +47,7 @@ project('spring-statemachine-data-mongodb') {
|
||||
api project(':spring-statemachine-data-common')
|
||||
api 'org.springframework.data:spring-data-mongodb'
|
||||
testImplementation project(':spring-statemachine-test')
|
||||
optional 'org.eclipse.persistence:javax.persistence'
|
||||
optional 'jakarta.persistence:jakarta.persistence-api'
|
||||
testImplementation(testFixtures(project(":spring-statemachine-data-common")))
|
||||
testImplementation(testFixtures(project(":spring-statemachine-core")))
|
||||
testImplementation 'io.projectreactor:reactor-test'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2018 the original author or authors.
|
||||
* Copyright 2016-2023 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,17 +15,15 @@
|
||||
*/
|
||||
package org.springframework.statemachine.data.jpa;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Column;
|
||||
|
||||
import org.springframework.statemachine.data.RepositoryAction;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import org.springframework.statemachine.data.RepositoryAction;
|
||||
|
||||
/**
|
||||
* JPA entity for actions.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2018 the original author or authors.
|
||||
* Copyright 2016-2023 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,17 +15,15 @@
|
||||
*/
|
||||
package org.springframework.statemachine.data.jpa;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Column;
|
||||
|
||||
import org.springframework.statemachine.data.RepositoryGuard;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import org.springframework.statemachine.data.RepositoryGuard;
|
||||
|
||||
/**
|
||||
* JPA entity for actions.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2018 the original author or authors.
|
||||
* Copyright 2016-2023 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,30 +15,28 @@
|
||||
*/
|
||||
package org.springframework.statemachine.data.jpa;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import jakarta.persistence.CollectionTable;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.ElementCollection;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.ForeignKey;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.JoinTable;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.CollectionTable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.ElementCollection;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.ForeignKey;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.springframework.statemachine.data.RepositoryAction;
|
||||
import org.springframework.statemachine.data.RepositoryState;
|
||||
import org.springframework.statemachine.state.PseudoStateKind;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
|
||||
/**
|
||||
* JPA entity for states.
|
||||
*
|
||||
@@ -76,7 +74,7 @@ public class JpaRepositoryState extends RepositoryState {
|
||||
@JoinColumn(foreignKey = @ForeignKey(name = "fk_state_initial_action"))
|
||||
private JpaRepositoryAction initialAction;
|
||||
|
||||
@OneToOne(fetch = FetchType.EAGER)
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(foreignKey = @ForeignKey(name = "fk_state_parent_state"))
|
||||
private JpaRepositoryState parentState;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2020 the original author or authors.
|
||||
* Copyright 2017-2023 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,16 +15,14 @@
|
||||
*/
|
||||
package org.springframework.statemachine.data.jpa;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Column;
|
||||
|
||||
import org.springframework.statemachine.data.RepositoryStateMachine;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Lob;
|
||||
import jakarta.persistence.Table;
|
||||
import org.springframework.statemachine.data.RepositoryStateMachine;
|
||||
|
||||
/**
|
||||
* A {@link RepositoryStateMachine} interface for JPA used for states machines.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2018 the original author or authors.
|
||||
* Copyright 2016-2023 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,26 +15,23 @@
|
||||
*/
|
||||
package org.springframework.statemachine.data.jpa;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ForeignKey;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.JoinTable;
|
||||
|
||||
import org.springframework.statemachine.data.RepositoryTransition;
|
||||
import org.springframework.statemachine.transition.TransitionKind;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.ForeignKey;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.JoinTable;
|
||||
import jakarta.persistence.ManyToMany;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import java.util.Set;
|
||||
import org.springframework.statemachine.data.RepositoryTransition;
|
||||
import org.springframework.statemachine.transition.TransitionKind;
|
||||
|
||||
/**
|
||||
* JPA entity for transitions.
|
||||
@@ -55,11 +52,11 @@ public class JpaRepositoryTransition extends RepositoryTransition {
|
||||
@Column(name = "machine_id")
|
||||
private String machineId;
|
||||
|
||||
@OneToOne(fetch = FetchType.EAGER)
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(foreignKey = @ForeignKey(name = "fk_transition_source"))
|
||||
private JpaRepositoryState source;
|
||||
|
||||
@OneToOne(fetch = FetchType.EAGER)
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(foreignKey = @ForeignKey(name = "fk_transition_target"))
|
||||
private JpaRepositoryState target;
|
||||
|
||||
@@ -73,7 +70,7 @@ public class JpaRepositoryTransition extends RepositoryTransition {
|
||||
@JoinTable(foreignKey = @ForeignKey(name = "fk_transition_actions_t"), inverseForeignKey = @ForeignKey(name = "fk_transition_actions_a"))
|
||||
private Set<JpaRepositoryAction> actions;
|
||||
|
||||
@OneToOne(fetch = FetchType.EAGER)
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(foreignKey = @ForeignKey(name = "fk_transition_guard"))
|
||||
private JpaRepositoryGuard guard;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 the original author or authors.
|
||||
* Copyright 2019-2023 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,24 +18,24 @@ package org.springframework.statemachine.data.mongodb;
|
||||
import static org.junit.jupiter.api.extension.ConditionEvaluationResult.disabled;
|
||||
import static org.junit.jupiter.api.extension.ConditionEvaluationResult.enabled;
|
||||
|
||||
import java.net.Socket;
|
||||
import org.junit.jupiter.api.extension.ConditionEvaluationResult;
|
||||
import org.junit.jupiter.api.extension.ExecutionCondition;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.springframework.util.SocketUtils;
|
||||
|
||||
public class EnabledOnMongoDbCondition implements ExecutionCondition {
|
||||
|
||||
static final ConditionEvaluationResult ENABLED_ON_MONGO = enabled("Mongo DB found");
|
||||
static final ConditionEvaluationResult ENABLED_ON_MONGO = enabled("Mongo DB found");
|
||||
|
||||
static final ConditionEvaluationResult DISABLED_ON_MONGO = disabled("Mongo DB not found");
|
||||
static final ConditionEvaluationResult DISABLED_ON_MONGO = disabled("Mongo DB not found");
|
||||
|
||||
@Override
|
||||
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
|
||||
try {
|
||||
SocketUtils.findAvailableTcpPort(27017, 27017);
|
||||
return DISABLED_ON_MONGO;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return ENABLED_ON_MONGO;
|
||||
}
|
||||
@Override
|
||||
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
|
||||
try {
|
||||
new Socket("localhost", 27017);
|
||||
return ENABLED_ON_MONGO;
|
||||
} catch (Exception e) {
|
||||
return DISABLED_ON_MONGO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2023 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,17 +15,11 @@
|
||||
*/
|
||||
package org.springframework.statemachine.data.redis;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
//import javax.persistence.GeneratedValue;
|
||||
//import javax.persistence.GenerationType;
|
||||
//import javax.persistence.Id;
|
||||
|
||||
import org.springframework.data.redis.core.RedisHash;
|
||||
import org.springframework.statemachine.data.RepositoryAction;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.redis.core.RedisHash;
|
||||
import org.springframework.statemachine.data.RepositoryAction;
|
||||
|
||||
/**
|
||||
* Redis entity for actions.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2023 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,17 +15,11 @@
|
||||
*/
|
||||
package org.springframework.statemachine.data.redis;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
//import javax.persistence.GeneratedValue;
|
||||
//import javax.persistence.GenerationType;
|
||||
//import javax.persistence.Id;
|
||||
|
||||
import org.springframework.data.redis.core.RedisHash;
|
||||
import org.springframework.statemachine.data.RepositoryGuard;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.redis.core.RedisHash;
|
||||
import org.springframework.statemachine.data.RepositoryGuard;
|
||||
|
||||
/**
|
||||
* Redis entity for actions.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2023 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,16 +15,9 @@
|
||||
*/
|
||||
package org.springframework.statemachine.data.redis;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import java.util.Set;
|
||||
|
||||
//import javax.persistence.ElementCollection;
|
||||
//import javax.persistence.FetchType;
|
||||
//import javax.persistence.GeneratedValue;
|
||||
//import javax.persistence.GenerationType;
|
||||
//import javax.persistence.Id;
|
||||
//import javax.persistence.OneToMany;
|
||||
//import javax.persistence.OneToOne;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.Reference;
|
||||
import org.springframework.data.redis.core.RedisHash;
|
||||
@@ -33,9 +26,6 @@ import org.springframework.statemachine.data.RepositoryAction;
|
||||
import org.springframework.statemachine.data.RepositoryState;
|
||||
import org.springframework.statemachine.state.PseudoStateKind;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
|
||||
/**
|
||||
* Redis entity for states.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 the original author or authors.
|
||||
* Copyright 2016-2023 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,26 +15,16 @@
|
||||
*/
|
||||
package org.springframework.statemachine.data.redis;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.Reference;
|
||||
|
||||
//import javax.persistence.FetchType;
|
||||
//import javax.persistence.GeneratedValue;
|
||||
//import javax.persistence.GenerationType;
|
||||
//import javax.persistence.Id;
|
||||
//import javax.persistence.OneToMany;
|
||||
//import javax.persistence.OneToOne;
|
||||
|
||||
import org.springframework.data.redis.core.RedisHash;
|
||||
import org.springframework.data.redis.core.index.Indexed;
|
||||
import org.springframework.statemachine.data.RepositoryTransition;
|
||||
import org.springframework.statemachine.transition.TransitionKind;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
|
||||
/**
|
||||
* Redis entity for transitions.
|
||||
*
|
||||
|
||||
@@ -10,7 +10,7 @@ dependencies {
|
||||
api platform("org.springframework.boot:spring-boot-dependencies:$springBootVersion")
|
||||
constraints {
|
||||
api "log4j:log4j:$log4jVersion"
|
||||
api "org.eclipse.persistence:javax.persistence:$eclipsePersistenceVersion"
|
||||
api "jakarta.persistence:jakarta.persistence-api:$jakartaPersistenceVersion"
|
||||
api "com.esotericsoftware:kryo-shaded:$kryoVersion"
|
||||
api "org.springframework.shell:spring-shell:$springShellVersion"
|
||||
api "org.eclipse.uml2:uml:$eclipseUml2UmlVersion"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2018 the original author or authors.
|
||||
* Copyright 2017-2023 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,7 +16,6 @@
|
||||
package demo.datapersist;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@@ -13,7 +13,9 @@ security:
|
||||
|
||||
---
|
||||
spring:
|
||||
profiles: jpa
|
||||
config:
|
||||
activate:
|
||||
on-profile: jpa
|
||||
statemachine:
|
||||
data:
|
||||
mongo:
|
||||
@@ -24,7 +26,9 @@ spring:
|
||||
enabled: false
|
||||
---
|
||||
spring:
|
||||
profiles: mongo
|
||||
config:
|
||||
activate:
|
||||
on-profile: mongo
|
||||
statemachine:
|
||||
data:
|
||||
jpa:
|
||||
@@ -35,7 +39,9 @@ spring:
|
||||
enabled: false
|
||||
---
|
||||
spring:
|
||||
profiles: redis
|
||||
config:
|
||||
activate:
|
||||
on-profile: redis
|
||||
statemachine:
|
||||
data:
|
||||
jpa:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
* Copyright 2015-2023 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,20 +19,17 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Scanner;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.context.annotation.ScopedProxyMode;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.security.access.annotation.Secured;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
|
||||
import org.springframework.statemachine.StateContext;
|
||||
import org.springframework.statemachine.action.Action;
|
||||
import org.springframework.statemachine.config.EnableStateMachine;
|
||||
@@ -45,133 +42,133 @@ import org.springframework.statemachine.security.SecurityRule.ComparisonType;
|
||||
@Configuration
|
||||
public class StateMachineConfig {
|
||||
|
||||
private static final Log log = LogFactory.getLog(StateMachineConfig.class);
|
||||
private static final Log log = LogFactory.getLog(StateMachineConfig.class);
|
||||
|
||||
//tag::snippetE[]
|
||||
@EnableWebSecurity
|
||||
@EnableGlobalMethodSecurity(securedEnabled = true)
|
||||
static class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
//tag::snippetE[]
|
||||
static class SecurityConfig {
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth
|
||||
.inMemoryAuthentication()
|
||||
.withUser("user")
|
||||
.password("password")
|
||||
.roles("USER")
|
||||
.and()
|
||||
.withUser("admin")
|
||||
.password("password")
|
||||
.roles("USER", "ADMIN");
|
||||
}
|
||||
}
|
||||
@Bean
|
||||
public InMemoryUserDetailsManager userDetailsService() {
|
||||
UserDetails user = User.withDefaultPasswordEncoder()
|
||||
.username("user")
|
||||
.password("password")
|
||||
.roles("USER")
|
||||
.build();
|
||||
UserDetails admin = User.withDefaultPasswordEncoder()
|
||||
.username("admin")
|
||||
.password("password")
|
||||
.roles("USER", "ADMIN")
|
||||
.build();
|
||||
return new InMemoryUserDetailsManager(user, admin);
|
||||
}
|
||||
}
|
||||
//end::snippetE[]
|
||||
|
||||
@Configuration
|
||||
@EnableStateMachine
|
||||
static class Config
|
||||
extends EnumStateMachineConfigurerAdapter<States, Events> {
|
||||
@Configuration
|
||||
@EnableStateMachine
|
||||
static class Config
|
||||
extends EnumStateMachineConfigurerAdapter<States, Events> {
|
||||
|
||||
//tag::snippetA[]
|
||||
@Override
|
||||
public void configure(StateMachineConfigurationConfigurer<States, Events> config)
|
||||
throws Exception {
|
||||
config
|
||||
.withConfiguration()
|
||||
.autoStartup(true)
|
||||
.and()
|
||||
.withSecurity()
|
||||
.enabled(true)
|
||||
.event("hasRole('USER')");
|
||||
}
|
||||
//tag::snippetA[]
|
||||
@Override
|
||||
public void configure(StateMachineConfigurationConfigurer<States, Events> config)
|
||||
throws Exception {
|
||||
config
|
||||
.withConfiguration()
|
||||
.autoStartup(true)
|
||||
.and()
|
||||
.withSecurity()
|
||||
.enabled(true)
|
||||
.event("hasRole('USER')");
|
||||
}
|
||||
//end::snippetA[]
|
||||
|
||||
@Override
|
||||
public void configure(StateMachineStateConfigurer<States, Events> states)
|
||||
throws Exception {
|
||||
states
|
||||
.withStates()
|
||||
.initial(States.S0)
|
||||
.states(EnumSet.allOf(States.class));
|
||||
}
|
||||
@Override
|
||||
public void configure(StateMachineStateConfigurer<States, Events> states)
|
||||
throws Exception {
|
||||
states
|
||||
.withStates()
|
||||
.initial(States.S0)
|
||||
.states(EnumSet.allOf(States.class));
|
||||
}
|
||||
|
||||
//tag::snippetB[]
|
||||
@Override
|
||||
public void configure(StateMachineTransitionConfigurer<States, Events> transitions)
|
||||
throws Exception {
|
||||
transitions
|
||||
.withExternal()
|
||||
.source(States.S0).target(States.S1).event(Events.A)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(States.S1).target(States.S2).event(Events.B)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(States.S2).target(States.S0).event(Events.C)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(States.S2).target(States.S3).event(Events.E)
|
||||
.secured("ROLE_ADMIN", ComparisonType.ANY)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(States.S3).target(States.S0).event(Events.C)
|
||||
.and()
|
||||
.withInternal()
|
||||
.source(States.S0).event(Events.D)
|
||||
.action(adminAction())
|
||||
.and()
|
||||
.withInternal()
|
||||
.source(States.S1).event(Events.F)
|
||||
.action(transitionAction())
|
||||
.secured("ROLE_ADMIN", ComparisonType.ANY);
|
||||
}
|
||||
//tag::snippetB[]
|
||||
@Override
|
||||
public void configure(StateMachineTransitionConfigurer<States, Events> transitions)
|
||||
throws Exception {
|
||||
transitions
|
||||
.withExternal()
|
||||
.source(States.S0).target(States.S1).event(Events.A)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(States.S1).target(States.S2).event(Events.B)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(States.S2).target(States.S0).event(Events.C)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(States.S2).target(States.S3).event(Events.E)
|
||||
.secured("ROLE_ADMIN", ComparisonType.ANY)
|
||||
.and()
|
||||
.withExternal()
|
||||
.source(States.S3).target(States.S0).event(Events.C)
|
||||
.and()
|
||||
.withInternal()
|
||||
.source(States.S0).event(Events.D)
|
||||
.action(adminAction())
|
||||
.and()
|
||||
.withInternal()
|
||||
.source(States.S1).event(Events.F)
|
||||
.action(transitionAction())
|
||||
.secured("ROLE_ADMIN", ComparisonType.ANY);
|
||||
}
|
||||
//end::snippetB[]
|
||||
|
||||
//tag::snippetC[]
|
||||
@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS)
|
||||
@Bean
|
||||
public Action<States, Events> adminAction() {
|
||||
return new Action<States, Events>() {
|
||||
//tag::snippetC[]
|
||||
@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS)
|
||||
@Bean
|
||||
public Action<States, Events> adminAction() {
|
||||
return new Action<States, Events>() {
|
||||
|
||||
@Secured("ROLE_ADMIN")
|
||||
@Override
|
||||
public void execute(StateContext<States, Events> context) {
|
||||
log.info("Executed only for admin role");
|
||||
}
|
||||
};
|
||||
}
|
||||
@Secured("ROLE_ADMIN")
|
||||
@Override
|
||||
public void execute(StateContext<States, Events> context) {
|
||||
log.info("Executed only for admin role");
|
||||
}
|
||||
};
|
||||
}
|
||||
//end::snippetC[]
|
||||
|
||||
//tag::snippetD[]
|
||||
@Bean
|
||||
public Action<States, Events> transitionAction() {
|
||||
return new Action<States, Events>() {
|
||||
//tag::snippetD[]
|
||||
@Bean
|
||||
public Action<States, Events> transitionAction() {
|
||||
return new Action<States, Events>() {
|
||||
|
||||
@Override
|
||||
public void execute(StateContext<States, Events> context) {
|
||||
log.info("Executed only for admin role");
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public void execute(StateContext<States, Events> context) {
|
||||
log.info("Executed only for admin role");
|
||||
}
|
||||
};
|
||||
}
|
||||
//end::snippetD[]
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
public String stateChartModel() throws IOException {
|
||||
ClassPathResource model = new ClassPathResource("statechartmodel.txt");
|
||||
InputStream inputStream = model.getInputStream();
|
||||
Scanner scanner = new Scanner(inputStream);
|
||||
String content = scanner.useDelimiter("\\Z").next();
|
||||
scanner.close();
|
||||
return content;
|
||||
}
|
||||
@Bean
|
||||
public String stateChartModel() throws IOException {
|
||||
ClassPathResource model = new ClassPathResource("statechartmodel.txt");
|
||||
InputStream inputStream = model.getInputStream();
|
||||
Scanner scanner = new Scanner(inputStream);
|
||||
String content = scanner.useDelimiter("\\Z").next();
|
||||
scanner.close();
|
||||
return content;
|
||||
}
|
||||
|
||||
public enum States {
|
||||
S0, S1, S2, S3;
|
||||
}
|
||||
public enum States {
|
||||
S0, S1, S2, S3;
|
||||
}
|
||||
|
||||
public enum Events {
|
||||
A, B, C, D, E, F;
|
||||
}
|
||||
public enum Events {
|
||||
A, B, C, D, E, F;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
* Copyright 2015-2023 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,13 +15,13 @@
|
||||
*/
|
||||
package demo.web;
|
||||
|
||||
import demo.web.StateMachineConfig.Events;
|
||||
import demo.web.StateMachineConfig.States;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -46,9 +46,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
import demo.web.StateMachineConfig.Events;
|
||||
import demo.web.StateMachineConfig.States;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@Controller
|
||||
|
||||
Reference in New Issue
Block a user