Merge pull request #1104 from egreijus
* pr/1104: Polish "Upgrade to Spring Boot 3" 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,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.
|
||||
@@ -17,6 +17,7 @@ package org.springframework.statemachine.boot.autoconfigure;
|
||||
|
||||
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;
|
||||
@@ -36,10 +37,9 @@ 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 {
|
||||
@@ -47,20 +47,20 @@ public class StateMachineAutoConfiguration {
|
||||
@ManagementContextConfiguration
|
||||
public static class StateMachineTraceEndpointConfiguration {
|
||||
|
||||
@Bean
|
||||
public StateMachineTraceEndpoint stateMachineTraceEndpoint(StateMachineTraceRepository stateMachineTraceRepository) {
|
||||
@Bean
|
||||
public StateMachineTraceEndpoint stateMachineTraceEndpoint(StateMachineTraceRepository stateMachineTraceRepository) {
|
||||
return new StateMachineTraceEndpoint(stateMachineTraceRepository);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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
|
||||
@@ -69,7 +69,8 @@ public class StateMachineAutoConfiguration {
|
||||
private final MeterRegistry meterRegistry;
|
||||
private final StateMachineTraceRepository stateMachineTraceRepository;
|
||||
|
||||
public StateMachineMonitoringConfiguration(ObjectProvider<MeterRegistry> meterRegistryProvider,
|
||||
public StateMachineMonitoringConfiguration(
|
||||
ObjectProvider<MeterRegistry> meterRegistryProvider,
|
||||
ObjectProvider<StateMachineTraceRepository> traceRepositoryProvider) {
|
||||
this.meterRegistry = meterRegistryProvider.getIfAvailable();
|
||||
this.stateMachineTraceRepository = traceRepositoryProvider.getIfAvailable();
|
||||
|
||||
@@ -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,36 @@ 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.InetAddress;
|
||||
import java.net.ServerSocket;
|
||||
|
||||
import javax.net.ServerSocketFactory;
|
||||
|
||||
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) {
|
||||
@Override
|
||||
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
|
||||
return isPortAvailable(27017) ? DISABLED_ON_MONGO : ENABLED_ON_MONGO;
|
||||
}
|
||||
|
||||
private static boolean isPortAvailable(int port) {
|
||||
try {
|
||||
SocketUtils.findAvailableTcpPort(27017, 27017);
|
||||
return DISABLED_ON_MONGO;
|
||||
} catch (Exception e) {
|
||||
ServerSocket serverSocket = ServerSocketFactory.getDefault()
|
||||
.createServerSocket(port, 1, InetAddress.getByName("localhost"));
|
||||
serverSocket.close();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return false;
|
||||
}
|
||||
return ENABLED_ON_MONGO;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -253,10 +253,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.
|
||||
@@ -138,7 +138,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.
|
||||
@@ -74,7 +74,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.
|
||||
@@ -30,9 +30,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 +103,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,18 +15,18 @@
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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,18 +15,18 @@
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@@ -17,21 +17,6 @@ package org.springframework.statemachine.data.jpa;
|
||||
|
||||
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;
|
||||
@@ -39,6 +24,22 @@ import org.springframework.statemachine.state.PseudoStateKind;
|
||||
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;
|
||||
|
||||
/**
|
||||
* JPA entity for states.
|
||||
*
|
||||
@@ -76,7 +77,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,17 +15,17 @@
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@@ -17,25 +17,25 @@ 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;
|
||||
|
||||
/**
|
||||
* JPA entity for transitions.
|
||||
*
|
||||
@@ -55,11 +55,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 +73,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,36 @@ 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.InetAddress;
|
||||
import java.net.ServerSocket;
|
||||
|
||||
import javax.net.ServerSocketFactory;
|
||||
|
||||
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 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;
|
||||
return isPortAvailable(27017) ? DISABLED_ON_MONGO : ENABLED_ON_MONGO;
|
||||
}
|
||||
|
||||
private static boolean isPortAvailable(int port) {
|
||||
try {
|
||||
ServerSocket serverSocket = ServerSocketFactory.getDefault()
|
||||
.createServerSocket(port, 1, InetAddress.getByName("localhost"));
|
||||
serverSocket.close();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -16,11 +16,6 @@
|
||||
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;
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -16,11 +16,6 @@
|
||||
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;
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -17,14 +17,6 @@ package org.springframework.statemachine.data.redis;
|
||||
|
||||
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;
|
||||
|
||||
@@ -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.
|
||||
@@ -19,14 +19,6 @@ 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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
@@ -22,17 +22,15 @@ 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;
|
||||
@@ -47,22 +45,22 @@ public class StateMachineConfig {
|
||||
|
||||
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[]
|
||||
@@ -72,7 +70,7 @@ public class StateMachineConfig {
|
||||
static class Config
|
||||
extends EnumStateMachineConfigurerAdapter<States, Events> {
|
||||
|
||||
//tag::snippetA[]
|
||||
//tag::snippetA[]
|
||||
@Override
|
||||
public void configure(StateMachineConfigurationConfigurer<States, Events> config)
|
||||
throws Exception {
|
||||
@@ -90,12 +88,12 @@ public class StateMachineConfig {
|
||||
public void configure(StateMachineStateConfigurer<States, Events> states)
|
||||
throws Exception {
|
||||
states
|
||||
.withStates()
|
||||
.withStates()
|
||||
.initial(States.S0)
|
||||
.states(EnumSet.allOf(States.class));
|
||||
}
|
||||
|
||||
//tag::snippetB[]
|
||||
//tag::snippetB[]
|
||||
@Override
|
||||
public void configure(StateMachineTransitionConfigurer<States, Events> transitions)
|
||||
throws Exception {
|
||||
@@ -127,7 +125,7 @@ public class StateMachineConfig {
|
||||
}
|
||||
//end::snippetB[]
|
||||
|
||||
//tag::snippetC[]
|
||||
//tag::snippetC[]
|
||||
@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS)
|
||||
@Bean
|
||||
public Action<States, Events> adminAction() {
|
||||
@@ -142,7 +140,7 @@ public class StateMachineConfig {
|
||||
}
|
||||
//end::snippetC[]
|
||||
|
||||
//tag::snippetD[]
|
||||
//tag::snippetD[]
|
||||
@Bean
|
||||
public Action<States, Events> transitionAction() {
|
||||
return new Action<States, Events>() {
|
||||
|
||||
@@ -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.
|
||||
@@ -20,8 +20,6 @@ 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;
|
||||
@@ -49,6 +47,7 @@ import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
import demo.web.StateMachineConfig.Events;
|
||||
import demo.web.StateMachineConfig.States;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@Controller
|
||||
|
||||
Reference in New Issue
Block a user