diff --git a/.idea/jpa.xml b/.idea/jpa.xml
new file mode 100644
index 0000000..898e07a
--- /dev/null
+++ b/.idea/jpa.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 6774fba..c8b4141 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -11,4 +11,7 @@
+
+
+
\ No newline at end of file
diff --git a/adapter/flowable-spring-boot-jpa-starter/pom.xml b/adapter/flowable-spring-boot-jpa-starter/pom.xml
index ed709de..f8184a6 100644
--- a/adapter/flowable-spring-boot-jpa-starter/pom.xml
+++ b/adapter/flowable-spring-boot-jpa-starter/pom.xml
@@ -23,6 +23,11 @@
org.springframework.boot
spring-boot-starter-logging
+
+ org.springframework.boot
+ spring-boot-configuration-processor
+ true
+
org.springframework.boot
spring-boot-starter-data-jpa
diff --git a/adapter/flowable-spring-boot-jpa-starter/src/main/java/com/lanyuanxiaoyao/flowable/jpa/SpringFlowableConfiguration.java b/adapter/flowable-spring-boot-jpa-starter/src/main/java/com/lanyuanxiaoyao/flowable/jpa/SpringFlowableConfiguration.java
new file mode 100644
index 0000000..6b80dfb
--- /dev/null
+++ b/adapter/flowable-spring-boot-jpa-starter/src/main/java/com/lanyuanxiaoyao/flowable/jpa/SpringFlowableConfiguration.java
@@ -0,0 +1,18 @@
+package com.lanyuanxiaoyao.flowable.jpa;
+
+import com.lanyuanxiaoyao.flowable.core.manager.FlowableConfiguration;
+import lombok.ToString;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * 配置类
+ *
+ * @author lanyuanxiaoyao
+ * @version 20250103
+ */
+@ToString(callSuper = true)
+@Configuration
+@ConfigurationProperties("flowable")
+public class SpringFlowableConfiguration extends FlowableConfiguration {
+}
diff --git a/adapter/flowable-spring-boot-jpa-starter/src/main/java/com/lanyuanxiaoyao/flowable/jpa/SpringFlowableManager.java b/adapter/flowable-spring-boot-jpa-starter/src/main/java/com/lanyuanxiaoyao/flowable/jpa/SpringFlowableManager.java
index d8411ce..008dc33 100644
--- a/adapter/flowable-spring-boot-jpa-starter/src/main/java/com/lanyuanxiaoyao/flowable/jpa/SpringFlowableManager.java
+++ b/adapter/flowable-spring-boot-jpa-starter/src/main/java/com/lanyuanxiaoyao/flowable/jpa/SpringFlowableManager.java
@@ -1,5 +1,6 @@
package com.lanyuanxiaoyao.flowable.jpa;
+import com.lanyuanxiaoyao.flowable.core.manager.FlowableConfiguration;
import com.lanyuanxiaoyao.flowable.core.manager.FlowableManager;
import com.lanyuanxiaoyao.flowable.core.repository.FlowableRepository;
import java.util.UUID;
@@ -17,8 +18,9 @@ import org.springframework.stereotype.Service;
public class SpringFlowableManager extends FlowableManager {
private final ApplicationContext applicationContext;
- public SpringFlowableManager(FlowableRepository flowableRepository, ApplicationContext applicationContext) {
- super(flowableRepository, () -> UUID.randomUUID().toString());
+ public SpringFlowableManager(FlowableConfiguration configuration, FlowableRepository repository, ApplicationContext applicationContext) {
+ super(configuration, repository);
+ log.info("Configuration: {}", configuration);
this.applicationContext = applicationContext;
}
@@ -38,4 +40,9 @@ public class SpringFlowableManager extends FlowableManager {
}
return targetObject;
}
+
+ @Override
+ protected String createId() {
+ return UUID.randomUUID().toString();
+ }
}
diff --git a/flowable-core/src/main/java/com/lanyuanxiaoyao/flowable/core/manager/FlowableConfiguration.java b/flowable-core/src/main/java/com/lanyuanxiaoyao/flowable/core/manager/FlowableConfiguration.java
new file mode 100644
index 0000000..aad77cb
--- /dev/null
+++ b/flowable-core/src/main/java/com/lanyuanxiaoyao/flowable/core/manager/FlowableConfiguration.java
@@ -0,0 +1,28 @@
+package com.lanyuanxiaoyao.flowable.core.manager;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 配置项
+ *
+ * @author lanyuanxiaoyao
+ * @version 20250103
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class FlowableConfiguration {
+ /**
+ * 在上下文中查询权限的key
+ */
+ @Builder.Default
+ private String accessorKey = Constants.DEFAULT_ACCESSOR_KEY;
+
+ public interface Constants {
+ String DEFAULT_ACCESSOR_KEY = "accessor";
+ }
+}
diff --git a/flowable-core/src/main/java/com/lanyuanxiaoyao/flowable/core/manager/FlowableManager.java b/flowable-core/src/main/java/com/lanyuanxiaoyao/flowable/core/manager/FlowableManager.java
index 29dab60..afe4b01 100644
--- a/flowable-core/src/main/java/com/lanyuanxiaoyao/flowable/core/manager/FlowableManager.java
+++ b/flowable-core/src/main/java/com/lanyuanxiaoyao/flowable/core/manager/FlowableManager.java
@@ -25,40 +25,40 @@ import lombok.extern.slf4j.Slf4j;
*/
@Slf4j
public abstract class FlowableManager {
- private final FlowableRepository flowableRepository;
- private final IdGenerator idGenerator;
+ private final FlowableConfiguration configuration;
+ private final FlowableRepository repository;
- public FlowableManager(FlowableRepository flowableRepository, IdGenerator idGenerator) {
- this.flowableRepository = flowableRepository;
- this.idGenerator = idGenerator;
+ public FlowableManager(FlowableConfiguration configuration, FlowableRepository repository) {
+ this.configuration = configuration;
+ this.repository = repository;
}
public List listNodes() {
- return flowableRepository.listNodes();
+ return repository.listNodes();
}
public FlowableNode getNode(String nodeId) {
- return flowableRepository.getNode(nodeId);
+ return repository.getNode(nodeId);
}
public List listInstances() {
- return flowableRepository.listInstances();
+ return repository.listInstances();
}
public FlowableInstance getInstance(String instantId) {
- return flowableRepository.getInstance(instantId);
+ return repository.getInstance(instantId);
}
public List listHistories(String instanceId) {
- return flowableRepository.listHistories(instanceId);
+ return repository.listHistories(instanceId);
}
public FlowableHistory getHistory(String historyId) {
- return flowableRepository.getHistory(historyId);
+ return repository.getHistory(historyId);
}
public void create(FlowableNode... node) {
- flowableRepository.saveNode(ListHelper.of(node));
+ repository.saveNode(ListHelper.of(node));
}
public String start(String nodeId) {
@@ -66,9 +66,9 @@ public abstract class FlowableManager {
}
public String start(String nodeId, Map metadata) {
- FlowableNode node = flowableRepository.getNode(nodeId);
- FlowableInstance instance = new FlowableInstance(idGenerator.createId(), node.getNodeId(), metadata);
- flowableRepository.saveInstance(instance);
+ FlowableNode node = repository.getNode(nodeId);
+ FlowableInstance instance = new FlowableInstance(createId(), node.getNodeId(), metadata);
+ repository.saveInstance(instance);
if (FlowableNode.Type.AUTOMATIC.equals(node.getType())) {
autoAction(instance, node, MapHelper.empty());
@@ -109,8 +109,8 @@ public abstract class FlowableManager {
}
private void action(String instanceId, FlowableAction action, String comment, Map metadata) {
- FlowableInstance instance = flowableRepository.getInstance(instanceId);
- FlowableNode node = flowableRepository.getNode(instance.getCurrentNodeId());
+ FlowableInstance instance = repository.getInstance(instanceId);
+ FlowableNode node = repository.getNode(instance.getCurrentNodeId());
action(instance, node, action, comment, metadata);
}
@@ -137,7 +137,7 @@ public abstract class FlowableManager {
return;
}
String nextNodeId = node.getTargets().get(action);
- FlowableNode nextNode = flowableRepository.getNode(nextNodeId);
+ FlowableNode nextNode = repository.getNode(nextNodeId);
instance.setCurrentNodeId(nextNode.getNodeId());
saveInstance(instance, FlowableInstance.Status.RUNNING, metadata, action, comment);
@@ -153,8 +153,8 @@ public abstract class FlowableManager {
}
instance.setUpdatedTime(LocalDateTime.now());
- FlowableHistory history = new FlowableHistory(idGenerator.createId(), instance.getInstanceId(), action, comment);
- flowableRepository.saveInstanceAndHistory(instance, history);
+ FlowableHistory history = new FlowableHistory(createId(), instance.getInstanceId(), action, comment);
+ repository.saveInstanceAndHistory(instance, history);
}
private void callListeners(List listeners, Consumer handler) {
@@ -165,7 +165,5 @@ public abstract class FlowableManager {
protected abstract T createBean(String classpath);
- public interface IdGenerator {
- String createId();
- }
+ protected abstract String createId();
}
diff --git a/flowable-core/src/main/java/com/lanyuanxiaoyao/flowable/core/model/FlowableAccessor.java b/flowable-core/src/main/java/com/lanyuanxiaoyao/flowable/core/model/FlowableAccessor.java
index ebb9304..4258d33 100644
--- a/flowable-core/src/main/java/com/lanyuanxiaoyao/flowable/core/model/FlowableAccessor.java
+++ b/flowable-core/src/main/java/com/lanyuanxiaoyao/flowable/core/model/FlowableAccessor.java
@@ -7,5 +7,5 @@ package com.lanyuanxiaoyao.flowable.core.model;
* @version 20241231
*/
public interface FlowableAccessor {
- void access(String accessor);
+ void access(Object accessor);
}
diff --git a/flowable-example/src/test/java/com/lanyuanxiaoyao/flowable/test/SimpleFlowableManager.java b/flowable-example/src/test/java/com/lanyuanxiaoyao/flowable/test/SimpleFlowableManager.java
index 05fb551..ceba052 100644
--- a/flowable-example/src/test/java/com/lanyuanxiaoyao/flowable/test/SimpleFlowableManager.java
+++ b/flowable-example/src/test/java/com/lanyuanxiaoyao/flowable/test/SimpleFlowableManager.java
@@ -1,5 +1,6 @@
package com.lanyuanxiaoyao.flowable.test;
+import com.lanyuanxiaoyao.flowable.core.manager.FlowableConfiguration;
import com.lanyuanxiaoyao.flowable.core.manager.FlowableManager;
import java.util.UUID;
import lombok.SneakyThrows;
@@ -10,7 +11,7 @@ import lombok.SneakyThrows;
*/
public class SimpleFlowableManager extends FlowableManager {
public SimpleFlowableManager() {
- super(new InMemoryFlowableRepository(), () -> UUID.randomUUID().toString());
+ super(FlowableConfiguration.builder().build(), new InMemoryFlowableRepository());
}
@SneakyThrows
@@ -18,4 +19,9 @@ public class SimpleFlowableManager extends FlowableManager {
protected T createBean(String classpath) {
return (T) Class.forName(classpath).newInstance();
}
+
+ @Override
+ protected String createId() {
+ return UUID.randomUUID().toString();
+ }
}