You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@seata.apache.org by xi...@apache.org on 2024/01/30 05:49:15 UTC
(incubator-seata) branch 2.x updated: optimize: add saga io.seata compatible api (#6312)
This is an automated email from the ASF dual-hosted git repository.
xingfudeshi pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/incubator-seata.git
The following commit(s) were added to refs/heads/2.x by this push:
new 74785d2214 optimize: add saga io.seata compatible api (#6312)
74785d2214 is described below
commit 74785d2214438b155d8a5dd69dd5c05d329ff232
Author: Xiangkun Yin <32...@users.noreply.github.com>
AuthorDate: Tue Jan 30 13:49:10 2024 +0800
optimize: add saga io.seata compatible api (#6312)
---
changes/en-us/2.x.md | 1 +
changes/zh-cn/2.x.md | 1 +
compatible/pom.xml | 21 +-
.../seata/{tmp => }/core/context/RootContext.java | 2 +-
.../java/io/seata/saga/engine/AsyncCallback.java | 44 +++
.../io/seata/saga/engine/StateMachineConfig.java | 170 ++++++++++
.../io/seata/saga/engine/StateMachineEngine.java | 163 +++++++++
.../saga/engine/config/DbStateMachineConfig.java | 21 ++
.../engine/impl/DefaultStateMachineConfig.java | 266 +++++++++++++++
.../engine/impl/ProcessCtrlStateMachineEngine.java | 139 ++++++++
.../saga/proctrl/HierarchicalProcessContext.java | 77 +++++
.../java/io/seata/saga/proctrl/ProcessContext.java | 99 ++++++
.../saga/proctrl/impl/ProcessContextImpl.java | 139 ++++++++
.../saga/statelang/domain/DomainConstants.java | 99 ++++++
.../saga/statelang/domain/ExecutionStatus.java | 93 +++++
.../seata/saga/statelang/domain/StateInstance.java | 376 +++++++++++++++++++++
.../statelang/domain/StateMachineInstance.java | 332 ++++++++++++++++++
.../statelang/domain/impl/StateInstanceImpl.java | 296 ++++++++++++++++
.../domain/impl/StateMachineInstanceImpl.java | 277 +++++++++++++++
pom.xml | 1 +
20 files changed, 2613 insertions(+), 4 deletions(-)
diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index a298298cfa..72abf73bd4 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -77,6 +77,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#6306](https://github.com/apache/incubator-seata/pull/6306)] replace some URL to org/apache/seata
- [[#6304](https://github.com/apache/incubator-seata/pull/6304)] disable Publish OSSRH workflow
- [[#6301](https://github.com/apache/incubator-seata/pull/6301)] upgrade console frontend dependencies and supported nodejs versions
+- [[#6301](https://github.com/apache/incubator-seata/pull/6312)] add saga related io.seata compatible api
- [[#6313](https://github.com/apache/incubator-seata/pull/6313)] console display the version number
### security:
diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md
index 1f37683a0d..6ec756c487 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -75,6 +75,7 @@
- [[#6306](https://github.com/apache/incubator-seata/pull/6306)] 替换一些URL 至 org/apache/seata
- [[#6304](https://github.com/apache/incubator-seata/pull/6304)] 禁用 OSSRH 发布工作流
- [[#6301](https://github.com/apache/incubator-seata/pull/6301)] 升级console前端依赖及支持的nodejs版本
+- [[#6301](https://github.com/apache/incubator-seata/pull/6312)] 添加saga相关的io.seata兼容性API
- [[#6313](https://github.com/apache/incubator-seata/pull/6313)] console展示版本号
### security:
diff --git a/compatible/pom.xml b/compatible/pom.xml
index 109e5114b7..8e2a25c09f 100644
--- a/compatible/pom.xml
+++ b/compatible/pom.xml
@@ -21,18 +21,33 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>io.seata</groupId>
- <version>${revision}</version>
+ <version>2.1.0-SNAPSHOT</version>
<modelVersion>4.0.0</modelVersion>
<artifactId>seata-all</artifactId>
<packaging>jar</packaging>
<name>seata-all ${project.version}</name>
<description>compatible with io.seata API</description>
-
+ <properties>
+ <maven.compiler.source>8</maven.compiler.source>
+ <maven.compiler.target>8</maven.compiler.target>
+ </properties>
<dependencies>
<dependency>
- <groupId>${project.groupId}</groupId>
+ <groupId>org.apache.seata</groupId>
<artifactId>seata-core</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.seata</groupId>
+ <artifactId>seata-saga-engine</artifactId>
+ <version>2.1.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.seata</groupId>
+ <artifactId>seata-saga-engine-store</artifactId>
+ <version>2.1.0-SNAPSHOT</version>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/compatible/src/main/java/io/seata/tmp/core/context/RootContext.java b/compatible/src/main/java/io/seata/core/context/RootContext.java
similarity index 99%
rename from compatible/src/main/java/io/seata/tmp/core/context/RootContext.java
rename to compatible/src/main/java/io/seata/core/context/RootContext.java
index 731bd896e1..c671e253c8 100644
--- a/compatible/src/main/java/io/seata/tmp/core/context/RootContext.java
+++ b/compatible/src/main/java/io/seata/core/context/RootContext.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.seata.tmp.core.context;
+package io.seata.core.context;
import java.util.Map;
diff --git a/compatible/src/main/java/io/seata/saga/engine/AsyncCallback.java b/compatible/src/main/java/io/seata/saga/engine/AsyncCallback.java
new file mode 100644
index 0000000000..1d1f13137b
--- /dev/null
+++ b/compatible/src/main/java/io/seata/saga/engine/AsyncCallback.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.seata.saga.engine;
+
+import io.seata.saga.proctrl.ProcessContext;
+import io.seata.saga.statelang.domain.StateMachineInstance;
+
+/**
+ * Async Callback
+ *
+ */
+public interface AsyncCallback {
+
+ /**
+ * on finished
+ *
+ * @param context
+ * @param stateMachineInstance
+ */
+ void onFinished(ProcessContext context, StateMachineInstance stateMachineInstance);
+
+ /**
+ * on error
+ *
+ * @param context
+ * @param stateMachineInstance
+ * @param exp
+ */
+ void onError(ProcessContext context, StateMachineInstance stateMachineInstance, Exception exp);
+}
diff --git a/compatible/src/main/java/io/seata/saga/engine/StateMachineConfig.java b/compatible/src/main/java/io/seata/saga/engine/StateMachineConfig.java
new file mode 100644
index 0000000000..bf078722ac
--- /dev/null
+++ b/compatible/src/main/java/io/seata/saga/engine/StateMachineConfig.java
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.seata.saga.engine;
+
+import org.apache.seata.saga.engine.expression.ExpressionFactoryManager;
+import org.apache.seata.saga.engine.expression.ExpressionResolver;
+import org.apache.seata.saga.engine.invoker.ServiceInvokerManager;
+import org.apache.seata.saga.engine.repo.StateLogRepository;
+import org.apache.seata.saga.engine.repo.StateMachineRepository;
+import org.apache.seata.saga.engine.sequence.SeqGenerator;
+import org.apache.seata.saga.engine.store.StateLangStore;
+import org.apache.seata.saga.engine.store.StateLogStore;
+import org.apache.seata.saga.engine.strategy.StatusDecisionStrategy;
+import org.apache.seata.saga.proctrl.eventing.impl.ProcessCtrlEventPublisher;
+import org.springframework.context.ApplicationContext;
+
+import javax.script.ScriptEngineManager;
+import java.util.concurrent.ThreadPoolExecutor;
+
+/**
+ * StateMachineConfig
+ *
+ */
+public interface StateMachineConfig {
+
+ /**
+ * Gets state log store.
+ *
+ * @return the StateLogRepository
+ */
+ StateLogRepository getStateLogRepository();
+
+ /**
+ * Gets get state log store.
+ *
+ * @return the get StateLogStore
+ */
+ StateLogStore getStateLogStore();
+
+ /**
+ * Gets get state language definition store.
+ *
+ * @return the get StateLangStore
+ */
+ StateLangStore getStateLangStore();
+
+ /**
+ * Gets get expression factory manager.
+ *
+ * @return the get expression factory manager
+ */
+ ExpressionFactoryManager getExpressionFactoryManager();
+
+ /**
+ * Gets get expression resolver
+ *
+ * @return the get expression resolver
+ */
+ ExpressionResolver getExpressionResolver();
+
+ /**
+ * Gets get charset.
+ *
+ * @return the get charset
+ */
+ String getCharset();
+
+ /**
+ * Gets get default tenant id.
+ *
+ * @return the default tenant id
+ */
+ String getDefaultTenantId();
+
+ /**
+ * Gets get state machine repository.
+ *
+ * @return the get state machine repository
+ */
+ StateMachineRepository getStateMachineRepository();
+
+ /**
+ * Gets get status decision strategy.
+ *
+ * @return the get status decision strategy
+ */
+ StatusDecisionStrategy getStatusDecisionStrategy();
+
+ /**
+ * Gets get seq generator.
+ *
+ * @return the get seq generator
+ */
+ SeqGenerator getSeqGenerator();
+
+ /**
+ * Gets get process ctrl event publisher.
+ *
+ * @return the get process ctrl event publisher
+ */
+ ProcessCtrlEventPublisher getProcessCtrlEventPublisher();
+
+ /**
+ * Gets get async process ctrl event publisher.
+ *
+ * @return the get async process ctrl event publisher
+ */
+ ProcessCtrlEventPublisher getAsyncProcessCtrlEventPublisher();
+
+ /**
+ * Gets get application context.
+ *
+ * @return the get application context
+ */
+ ApplicationContext getApplicationContext();
+
+ /**
+ * Gets get thread pool executor.
+ *
+ * @return the get thread pool executor
+ */
+ ThreadPoolExecutor getThreadPoolExecutor();
+
+ /**
+ * Is enable async boolean.
+ *
+ * @return the boolean
+ */
+ boolean isEnableAsync();
+
+ /**
+ * get ServiceInvokerManager
+ *
+ * @return the service invoker manager info
+ */
+ ServiceInvokerManager getServiceInvokerManager();
+
+ /**
+ * get trans operation timeout
+ * @return the transaction operate time out
+ */
+ int getTransOperationTimeout();
+
+ /**
+ * get service invoke timeout
+ * @return the service invoke time out
+ */
+ int getServiceInvokeTimeout();
+
+ /**
+ * get ScriptEngineManager
+ *
+ * @return the script engine manager info
+ */
+ ScriptEngineManager getScriptEngineManager();
+}
diff --git a/compatible/src/main/java/io/seata/saga/engine/StateMachineEngine.java b/compatible/src/main/java/io/seata/saga/engine/StateMachineEngine.java
new file mode 100644
index 0000000000..9b846d367d
--- /dev/null
+++ b/compatible/src/main/java/io/seata/saga/engine/StateMachineEngine.java
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.seata.saga.engine;
+
+import org.apache.seata.saga.engine.exception.EngineExecutionException;
+import org.apache.seata.saga.engine.exception.ForwardInvalidException;
+import io.seata.saga.statelang.domain.StateMachineInstance;
+
+import java.util.Map;
+
+/**
+ * State machine engine
+ *
+ */
+public interface StateMachineEngine {
+
+ /**
+ * start a state machine instance
+ *
+ * @param stateMachineName the state machine name
+ * @param tenantId the tenant id
+ * @param startParams the start params
+ * @return the state machine instance
+ * @throws EngineExecutionException the engine execution exception
+ */
+ StateMachineInstance start(String stateMachineName, String tenantId, Map<String, Object> startParams)
+ throws EngineExecutionException;
+
+ /**
+ * start a state machine instance with businessKey
+ *
+ * @param stateMachineName the state machine name
+ * @param tenantId the tenant id
+ * @param businessKey the businessKey
+ * @param startParams the start params
+ * @return the state machine instance
+ * @throws EngineExecutionException the engine execution exception
+ */
+ StateMachineInstance startWithBusinessKey(String stateMachineName, String tenantId, String businessKey,
+ Map<String, Object> startParams) throws EngineExecutionException;
+
+ /**
+ * start a state machine instance asynchronously
+ *
+ * @param stateMachineName the state machine name
+ * @param tenantId the tenant id
+ * @param startParams the start params
+ * @param callback callback after start machine
+ * @return the state machine instance
+ * @throws EngineExecutionException the engine execution exception
+ */
+ StateMachineInstance startAsync(String stateMachineName, String tenantId, Map<String, Object> startParams,
+ AsyncCallback callback) throws EngineExecutionException;
+
+ /**
+ * start a state machine instance asynchronously with businessKey
+ *
+ * @param stateMachineName the state machine name
+ * @param tenantId the tenant id
+ * @param businessKey the businessKey
+ * @param startParams the start params
+ * @param callback the callback after start a state machine
+ * @return the state machine instance
+ * @throws EngineExecutionException the engine execution exception
+ */
+ StateMachineInstance startWithBusinessKeyAsync(String stateMachineName, String tenantId, String businessKey,
+ Map<String, Object> startParams, AsyncCallback callback)
+ throws EngineExecutionException;
+
+ /**
+ * forward restart a failed state machine instance
+ *
+ * @param stateMachineInstId the state machine instance id
+ * @param replaceParams the replace params
+ * @return the state machine instance
+ * @throws ForwardInvalidException forward invalid exception
+ */
+ StateMachineInstance forward(String stateMachineInstId, Map<String, Object> replaceParams)
+ throws ForwardInvalidException;
+
+ /**
+ * forward restart a failed state machine instance asynchronously
+ *
+ * @param stateMachineInstId the state machine instance id
+ * @param replaceParams the replace params
+ * @param callback callback after forward restart a failed state machine
+ * @return the state machine instance
+ * @throws ForwardInvalidException the forward invalid exception
+ */
+ StateMachineInstance forwardAsync(String stateMachineInstId, Map<String, Object> replaceParams,
+ AsyncCallback callback) throws ForwardInvalidException;
+
+ /**
+ * compensate a state machine instance
+ *
+ * @param stateMachineInstId the state machine id
+ * @param replaceParams the replace params
+ * @return the state machine instance
+ * @throws EngineExecutionException the engin execution exception
+ */
+ StateMachineInstance compensate(String stateMachineInstId, Map<String, Object> replaceParams)
+ throws EngineExecutionException;
+
+ /**
+ * compensate a state machine instance asynchronously
+ *
+ * @param stateMachineInstId the state machine instance id
+ * @param replaceParams the replace params
+ * @param callback callback after compensate a failed state machine
+ * @return the state machine instance
+ * @throws EngineExecutionException the engine execution exception
+ */
+ StateMachineInstance compensateAsync(String stateMachineInstId, Map<String, Object> replaceParams,
+ AsyncCallback callback) throws EngineExecutionException;
+
+ /**
+ * skip current failed state instance and forward restart state machine instance
+ *
+ * @param stateMachineInstId the state machine instance id
+ * @return the state machine instance
+ * @throws EngineExecutionException the engine execution exception
+ */
+ StateMachineInstance skipAndForward(String stateMachineInstId, Map<String, Object> replaceParams) throws EngineExecutionException;
+
+ /**
+ * skip current failed state instance and forward restart state machine instance asynchronously
+ *
+ * @param stateMachineInstId the state machine instance id
+ * @param callback callback after skip and forward restart a failed state machine
+ * @return the state machine instance
+ * @throws EngineExecutionException the engine execution exception
+ */
+ StateMachineInstance skipAndForwardAsync(String stateMachineInstId, AsyncCallback callback)
+ throws EngineExecutionException;
+
+ /**
+ * get state machine configurations
+ *
+ * @return the state machine configurations
+ */
+ StateMachineConfig getStateMachineConfig();
+
+ /**
+ * Reload StateMachine Instance
+ * @param instId the state machine instance id
+ * @return the state machine instance
+ */
+ StateMachineInstance reloadStateMachineInstance(String instId);
+}
diff --git a/compatible/src/main/java/io/seata/saga/engine/config/DbStateMachineConfig.java b/compatible/src/main/java/io/seata/saga/engine/config/DbStateMachineConfig.java
new file mode 100644
index 0000000000..c08d5a5381
--- /dev/null
+++ b/compatible/src/main/java/io/seata/saga/engine/config/DbStateMachineConfig.java
@@ -0,0 +1,21 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.seata.saga.engine.config;
+
+public class DbStateMachineConfig extends org.apache.seata.saga.engine.config.DbStateMachineConfig {
+
+}
diff --git a/compatible/src/main/java/io/seata/saga/engine/impl/DefaultStateMachineConfig.java b/compatible/src/main/java/io/seata/saga/engine/impl/DefaultStateMachineConfig.java
new file mode 100644
index 0000000000..4f0866fdec
--- /dev/null
+++ b/compatible/src/main/java/io/seata/saga/engine/impl/DefaultStateMachineConfig.java
@@ -0,0 +1,266 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.seata.saga.engine.impl;
+
+import io.seata.saga.engine.StateMachineConfig;
+import org.apache.seata.saga.engine.expression.ExpressionFactoryManager;
+import org.apache.seata.saga.engine.expression.ExpressionResolver;
+import org.apache.seata.saga.engine.invoker.ServiceInvokerManager;
+import org.apache.seata.saga.engine.repo.StateLogRepository;
+import org.apache.seata.saga.engine.repo.StateMachineRepository;
+import org.apache.seata.saga.engine.sequence.SeqGenerator;
+import org.apache.seata.saga.engine.store.StateLangStore;
+import org.apache.seata.saga.engine.store.StateLogStore;
+import org.apache.seata.saga.engine.strategy.StatusDecisionStrategy;
+import org.apache.seata.saga.proctrl.eventing.impl.ProcessCtrlEventPublisher;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+import javax.script.ScriptEngineManager;
+import java.util.concurrent.ThreadPoolExecutor;
+
+/**
+ * Default state machine configuration
+ *
+ */
+public class DefaultStateMachineConfig implements StateMachineConfig, ApplicationContextAware, InitializingBean {
+
+ private final org.apache.seata.saga.engine.impl.DefaultStateMachineConfig actual;
+
+ public DefaultStateMachineConfig(org.apache.seata.saga.engine.impl.DefaultStateMachineConfig actual) {
+ this.actual = actual;
+ }
+
+ @Override
+ public void afterPropertiesSet() throws Exception {
+ actual.afterPropertiesSet();
+ }
+
+ @Override
+ public StateLogStore getStateLogStore() {
+ return actual.getStateLogStore();
+ }
+
+ public void setStateLogStore(StateLogStore stateLogStore) {
+ actual.setStateLogStore(stateLogStore);
+ }
+
+ @Override
+ public StateLangStore getStateLangStore() {
+ return actual.getStateLangStore();
+ }
+
+ public void setStateLangStore(StateLangStore stateLangStore) {
+ actual.setStateLangStore(stateLangStore);
+ }
+
+ @Override
+ public ExpressionFactoryManager getExpressionFactoryManager() {
+ return actual.getExpressionFactoryManager();
+ }
+
+ public void setExpressionFactoryManager(ExpressionFactoryManager expressionFactoryManager) {
+ actual.setExpressionFactoryManager(expressionFactoryManager);
+ }
+
+ @Override
+ public ExpressionResolver getExpressionResolver() {
+ return actual.getExpressionResolver();
+ }
+
+ public void setExpressionResolver(ExpressionResolver expressionResolver) {
+ actual.setExpressionResolver(expressionResolver);
+ }
+
+ @Override
+ public String getCharset() {
+ return actual.getCharset();
+ }
+
+ public void setCharset(String charset) {
+ actual.setCharset(charset);
+ }
+
+ @Override
+ public StateMachineRepository getStateMachineRepository() {
+ return actual.getStateMachineRepository();
+ }
+
+ public void setStateMachineRepository(StateMachineRepository stateMachineRepository) {
+ actual.setStateMachineRepository(stateMachineRepository);
+ }
+
+ @Override
+ public StatusDecisionStrategy getStatusDecisionStrategy() {
+ return actual.getStatusDecisionStrategy();
+ }
+
+ public void setStatusDecisionStrategy(StatusDecisionStrategy statusDecisionStrategy) {
+ actual.setStatusDecisionStrategy(statusDecisionStrategy);
+ }
+
+ @SuppressWarnings("lgtm[java/unsafe-double-checked-locking]")
+ @Override
+ public SeqGenerator getSeqGenerator() {
+ return actual.getSeqGenerator();
+ }
+
+ public void setSeqGenerator(SeqGenerator seqGenerator) {
+ actual.setSeqGenerator(seqGenerator);
+ }
+
+ @Override
+ public ProcessCtrlEventPublisher getProcessCtrlEventPublisher() {
+ return actual.getProcessCtrlEventPublisher();
+ }
+
+ @Override
+ public ProcessCtrlEventPublisher getAsyncProcessCtrlEventPublisher() {
+ return actual.getAsyncProcessCtrlEventPublisher();
+ }
+
+ public void setAsyncProcessCtrlEventPublisher(ProcessCtrlEventPublisher asyncProcessCtrlEventPublisher) {
+ actual.setAsyncProcessCtrlEventPublisher(asyncProcessCtrlEventPublisher);
+ }
+
+ @Override
+ public ApplicationContext getApplicationContext() {
+ return actual.getApplicationContext();
+ }
+
+ @Override
+ public void setApplicationContext(ApplicationContext applicationContext) {
+ actual.setApplicationContext(applicationContext);
+ }
+
+ @Override
+ public ThreadPoolExecutor getThreadPoolExecutor() {
+ return actual.getThreadPoolExecutor();
+ }
+
+ public void setThreadPoolExecutor(ThreadPoolExecutor threadPoolExecutor) {
+ actual.setThreadPoolExecutor(threadPoolExecutor);
+ }
+
+ @Override
+ public boolean isEnableAsync() {
+ return actual.isEnableAsync();
+ }
+
+ public void setEnableAsync(boolean enableAsync) {
+ actual.setEnableAsync(enableAsync);
+ }
+
+ @Override
+ public StateLogRepository getStateLogRepository() {
+ return actual.getStateLogRepository();
+ }
+
+ public void setStateLogRepository(StateLogRepository stateLogRepository) {
+ actual.setStateLogRepository(stateLogRepository);
+ }
+
+ public void setSyncProcessCtrlEventPublisher(ProcessCtrlEventPublisher syncProcessCtrlEventPublisher) {
+ actual.setSyncProcessCtrlEventPublisher(syncProcessCtrlEventPublisher);
+ }
+
+ public void setAutoRegisterResources(boolean autoRegisterResources) {
+ actual.setAutoRegisterResources(autoRegisterResources);
+ }
+
+ public void setResources(String[] resources) {
+ actual.setResources(resources);
+ }
+
+ @Override
+ public ServiceInvokerManager getServiceInvokerManager() {
+ return actual.getServiceInvokerManager();
+ }
+
+ public void setServiceInvokerManager(ServiceInvokerManager serviceInvokerManager) {
+ actual.setServiceInvokerManager(serviceInvokerManager);
+ }
+
+ @Override
+ public String getDefaultTenantId() {
+ return actual.getDefaultTenantId();
+ }
+
+ public void setDefaultTenantId(String defaultTenantId) {
+ actual.setDefaultTenantId(defaultTenantId);
+ }
+
+ @Override
+ public int getTransOperationTimeout() {
+ return actual.getTransOperationTimeout();
+ }
+
+ public void setTransOperationTimeout(int transOperationTimeout) {
+ actual.setTransOperationTimeout(transOperationTimeout);
+ }
+
+ @Override
+ public int getServiceInvokeTimeout() {
+ return actual.getServiceInvokeTimeout();
+ }
+
+ public void setServiceInvokeTimeout(int serviceInvokeTimeout) {
+ actual.setServiceInvokeTimeout(serviceInvokeTimeout);
+ }
+
+ @Override
+ public ScriptEngineManager getScriptEngineManager() {
+ return actual.getScriptEngineManager();
+ }
+
+ public void setScriptEngineManager(ScriptEngineManager scriptEngineManager) {
+ actual.setScriptEngineManager(scriptEngineManager);
+ }
+
+ public String getSagaJsonParser() {
+ return actual.getSagaJsonParser();
+ }
+
+ public void setSagaJsonParser(String sagaJsonParser) {
+ actual.setSagaJsonParser(sagaJsonParser);
+ }
+
+ public boolean isSagaRetryPersistModeUpdate() {
+ return actual.isSagaRetryPersistModeUpdate();
+ }
+
+ public void setSagaRetryPersistModeUpdate(boolean sagaRetryPersistModeUpdate) {
+ actual.setSagaRetryPersistModeUpdate(sagaRetryPersistModeUpdate);
+ }
+
+ public boolean isSagaCompensatePersistModeUpdate() {
+ return actual.isSagaCompensatePersistModeUpdate();
+ }
+
+ public void setSagaCompensatePersistModeUpdate(boolean sagaCompensatePersistModeUpdate) {
+ actual.setSagaCompensatePersistModeUpdate(sagaCompensatePersistModeUpdate);
+ }
+
+ public static DefaultStateMachineConfig wrap(org.apache.seata.saga.engine.impl.DefaultStateMachineConfig target) {
+ return new DefaultStateMachineConfig(target);
+ }
+
+ public org.apache.seata.saga.engine.impl.DefaultStateMachineConfig unwrap() {
+ return actual;
+ }
+}
diff --git a/compatible/src/main/java/io/seata/saga/engine/impl/ProcessCtrlStateMachineEngine.java b/compatible/src/main/java/io/seata/saga/engine/impl/ProcessCtrlStateMachineEngine.java
new file mode 100644
index 0000000000..9e169bef0f
--- /dev/null
+++ b/compatible/src/main/java/io/seata/saga/engine/impl/ProcessCtrlStateMachineEngine.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.seata.saga.engine.impl;
+
+import io.seata.saga.engine.AsyncCallback;
+import io.seata.saga.engine.StateMachineConfig;
+import io.seata.saga.engine.StateMachineEngine;
+import io.seata.saga.proctrl.impl.ProcessContextImpl;
+import io.seata.saga.statelang.domain.StateMachineInstance;
+import io.seata.saga.statelang.domain.impl.StateMachineInstanceImpl;
+import org.apache.seata.saga.engine.exception.EngineExecutionException;
+import org.apache.seata.saga.engine.exception.ForwardInvalidException;
+import io.seata.saga.proctrl.ProcessContext;
+
+import java.util.Map;
+
+/**
+ * ProcessCtrl-based state machine engine
+ */
+public class ProcessCtrlStateMachineEngine implements StateMachineEngine {
+
+ private final org.apache.seata.saga.engine.impl.ProcessCtrlStateMachineEngine actual =
+ new org.apache.seata.saga.engine.impl.ProcessCtrlStateMachineEngine();
+
+ @Override
+ public StateMachineInstance start(String stateMachineName, String tenantId, Map<String, Object> startParams) throws EngineExecutionException {
+ org.apache.seata.saga.statelang.domain.StateMachineInstance inst =
+ actual.start(stateMachineName, tenantId, startParams);
+ return StateMachineInstanceImpl.wrap(inst);
+ }
+
+ @Override
+ public StateMachineInstance startWithBusinessKey(String stateMachineName, String tenantId, String businessKey, Map<String, Object> startParams) throws EngineExecutionException {
+ org.apache.seata.saga.statelang.domain.StateMachineInstance inst =
+ actual.startWithBusinessKey(stateMachineName, tenantId, businessKey, startParams);
+ return StateMachineInstanceImpl.wrap(inst);
+ }
+
+ private org.apache.seata.saga.engine.AsyncCallback wrapCallback(AsyncCallback callback) {
+ return new org.apache.seata.saga.engine.AsyncCallback() {
+ @Override
+ public void onFinished(org.apache.seata.saga.proctrl.ProcessContext context,
+ org.apache.seata.saga.statelang.domain.StateMachineInstance stateMachineInstance) {
+ ProcessContext compatibleContext = ProcessContextImpl.wrap((org.apache.seata.saga.proctrl.impl.ProcessContextImpl) context);
+ callback.onFinished(compatibleContext, StateMachineInstanceImpl.wrap(stateMachineInstance));
+ }
+
+ @Override
+ public void onError(org.apache.seata.saga.proctrl.ProcessContext context,
+ org.apache.seata.saga.statelang.domain.StateMachineInstance stateMachineInstance,
+ Exception exp) {
+ ProcessContext compatibleContext = ProcessContextImpl.wrap((org.apache.seata.saga.proctrl.impl.ProcessContextImpl) context);
+ callback.onError(compatibleContext, StateMachineInstanceImpl.wrap(stateMachineInstance), exp);
+ }
+ };
+ }
+
+ @Override
+ public StateMachineInstance startAsync(String stateMachineName, String tenantId, Map<String, Object> startParams, AsyncCallback callback) throws EngineExecutionException {
+ org.apache.seata.saga.statelang.domain.StateMachineInstance inst =
+ actual.startAsync(stateMachineName, tenantId, startParams, wrapCallback(callback));
+ return StateMachineInstanceImpl.wrap(inst);
+ }
+
+ @Override
+ public StateMachineInstance startWithBusinessKeyAsync(String stateMachineName, String tenantId, String businessKey, Map<String, Object> startParams, AsyncCallback callback) throws EngineExecutionException {
+ org.apache.seata.saga.statelang.domain.StateMachineInstance inst =
+ actual.startWithBusinessKeyAsync(stateMachineName, tenantId, businessKey, startParams,
+ wrapCallback(callback));
+ return StateMachineInstanceImpl.wrap(inst);
+ }
+
+ @Override
+ public StateMachineInstance forward(String stateMachineInstId, Map<String, Object> replaceParams) throws ForwardInvalidException {
+ org.apache.seata.saga.statelang.domain.StateMachineInstance inst =
+ actual.forward(stateMachineInstId, replaceParams);
+ return StateMachineInstanceImpl.wrap(inst);
+ }
+
+ @Override
+ public StateMachineInstance forwardAsync(String stateMachineInstId, Map<String, Object> replaceParams, AsyncCallback callback) throws ForwardInvalidException {
+ org.apache.seata.saga.statelang.domain.StateMachineInstance inst =
+ actual.forwardAsync(stateMachineInstId, replaceParams, wrapCallback(callback));
+ return StateMachineInstanceImpl.wrap(inst);
+ }
+
+ @Override
+ public StateMachineInstance compensate(String stateMachineInstId, Map<String, Object> replaceParams) throws EngineExecutionException {
+ org.apache.seata.saga.statelang.domain.StateMachineInstance inst =
+ actual.compensate(stateMachineInstId, replaceParams);
+ return StateMachineInstanceImpl.wrap(inst);
+ }
+
+ @Override
+ public StateMachineInstance compensateAsync(String stateMachineInstId, Map<String, Object> replaceParams, AsyncCallback callback) throws EngineExecutionException {
+ org.apache.seata.saga.statelang.domain.StateMachineInstance inst =
+ actual.compensateAsync(stateMachineInstId, replaceParams, wrapCallback(callback));
+ return StateMachineInstanceImpl.wrap(inst);
+ }
+
+ @Override
+ public StateMachineInstance skipAndForward(String stateMachineInstId, Map<String, Object> replaceParams) throws EngineExecutionException {
+ org.apache.seata.saga.statelang.domain.StateMachineInstance inst =
+ actual.skipAndForward(stateMachineInstId, replaceParams);
+ return StateMachineInstanceImpl.wrap(inst);
+ }
+
+ @Override
+ public StateMachineInstance skipAndForwardAsync(String stateMachineInstId, AsyncCallback callback) throws EngineExecutionException {
+ org.apache.seata.saga.statelang.domain.StateMachineInstance inst =
+ actual.skipAndForwardAsync(stateMachineInstId, wrapCallback(callback));
+ return StateMachineInstanceImpl.wrap(inst);
+ }
+
+ @Override
+ public StateMachineConfig getStateMachineConfig() {
+ return DefaultStateMachineConfig.wrap((org.apache.seata.saga.engine.impl.DefaultStateMachineConfig)
+ actual.getStateMachineConfig());
+ }
+
+ @Override
+ public StateMachineInstance reloadStateMachineInstance(String instId) {
+ return StateMachineInstanceImpl.wrap(actual.reloadStateMachineInstance(instId));
+ }
+}
diff --git a/compatible/src/main/java/io/seata/saga/proctrl/HierarchicalProcessContext.java b/compatible/src/main/java/io/seata/saga/proctrl/HierarchicalProcessContext.java
new file mode 100644
index 0000000000..ab5f82990e
--- /dev/null
+++ b/compatible/src/main/java/io/seata/saga/proctrl/HierarchicalProcessContext.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.seata.saga.proctrl;
+
+import java.util.Map;
+
+/**
+ * Hierarchical process context
+ *
+ */
+public interface HierarchicalProcessContext extends ProcessContext {
+
+ /**
+ * Gets get variable locally.
+ *
+ * @param name the name
+ * @return the get variable locally
+ */
+ Object getVariableLocally(String name);
+
+ /**
+ * Sets set variable locally.
+ *
+ * @param name the name
+ * @param value the value
+ */
+ void setVariableLocally(String name, Object value);
+
+ /**
+ * Gets get variables locally.
+ *
+ * @return the get variables locally
+ */
+ Map<String, Object> getVariablesLocally();
+
+ /**
+ * Sets set variables locally.
+ *
+ * @param variables the variables
+ */
+ void setVariablesLocally(Map<String, Object> variables);
+
+ /**
+ * Has variable local boolean.
+ *
+ * @param name the name
+ * @return the boolean
+ */
+ boolean hasVariableLocal(String name);
+
+ /**
+ * Remove variable locally.
+ *
+ * @param name the name
+ * @return the removed variable or null
+ */
+ Object removeVariableLocally(String name);
+
+ /**
+ * Clear locally.
+ */
+ void clearLocally();
+}
diff --git a/compatible/src/main/java/io/seata/saga/proctrl/ProcessContext.java b/compatible/src/main/java/io/seata/saga/proctrl/ProcessContext.java
new file mode 100644
index 0000000000..d53f9d549d
--- /dev/null
+++ b/compatible/src/main/java/io/seata/saga/proctrl/ProcessContext.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.seata.saga.proctrl;
+
+import org.apache.seata.saga.proctrl.Instruction;
+
+import java.util.Map;
+
+/**
+ * Process Context
+ *
+ */
+public interface ProcessContext extends org.apache.seata.saga.proctrl.ProcessContext {
+
+ String VAR_NAME_PROCESS_TYPE = "_ProcessType_";
+
+ /**
+ * Gets get variable.
+ *
+ * @param name the name
+ * @return the get variable
+ */
+ Object getVariable(String name);
+
+ /**
+ * Sets set variable.
+ *
+ * @param name the name
+ * @param value the value
+ */
+ void setVariable(String name, Object value);
+
+ /**
+ * Gets get variables.
+ *
+ * @return the get variables
+ */
+ Map<String, Object> getVariables();
+
+ /**
+ * Sets set variables.
+ *
+ * @param variables the variables
+ */
+ void setVariables(Map<String, Object> variables);
+
+ /**
+ * Remove variable.
+ *
+ * @param name the name
+ * @return the removed variable or null
+ */
+ Object removeVariable(String name);
+
+ /**
+ * Has variable boolean.
+ *
+ * @param name the name
+ * @return the boolean
+ */
+ boolean hasVariable(String name);
+
+ /**
+ * Gets get instruction.
+ *
+ * @return the get instruction
+ */
+ Instruction getInstruction();
+
+ /**
+ * Sets set instruction.
+ *
+ * @param instruction the instruction
+ */
+ void setInstruction(Instruction instruction);
+
+ /**
+ * Gets get instruction.
+ *
+ * @param <T> the type parameter
+ * @param clazz the clazz
+ * @return the get instruction
+ */
+ <T extends Instruction> T getInstruction(Class<T> clazz);
+}
diff --git a/compatible/src/main/java/io/seata/saga/proctrl/impl/ProcessContextImpl.java b/compatible/src/main/java/io/seata/saga/proctrl/impl/ProcessContextImpl.java
new file mode 100644
index 0000000000..ce9cbc95a2
--- /dev/null
+++ b/compatible/src/main/java/io/seata/saga/proctrl/impl/ProcessContextImpl.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.seata.saga.proctrl.impl;
+
+import io.seata.saga.proctrl.HierarchicalProcessContext;
+import io.seata.saga.proctrl.ProcessContext;
+import org.apache.seata.saga.proctrl.Instruction;
+
+import java.util.Map;
+
+/**
+ * The default process context implementation
+ *
+ */
+public class ProcessContextImpl implements HierarchicalProcessContext, ProcessContext {
+
+ private final org.apache.seata.saga.proctrl.HierarchicalProcessContext actual;
+
+ private ProcessContextImpl(org.apache.seata.saga.proctrl.HierarchicalProcessContext target) {
+ this.actual = target;
+ }
+
+ @Override
+ public Object getVariable(String name) {
+ return actual.getVariable(name);
+ }
+
+ @Override
+ public void setVariable(String name, Object value) {
+ actual.setVariable(name, value);
+ }
+
+ @Override
+ public Map<String, Object> getVariables() {
+ return actual.getVariables();
+ }
+
+ @Override
+ public void setVariables(final Map<String, Object> variables) {
+ actual.setVariables(variables);
+ }
+
+ @Override
+ public Object getVariableLocally(String name) {
+ return actual.getVariableLocally(name);
+ }
+
+ @Override
+ public void setVariableLocally(String name, Object value) {
+ actual.setVariableLocally(name, value);
+ }
+
+ @Override
+ public Map<String, Object> getVariablesLocally() {
+ return actual.getVariablesLocally();
+ }
+
+ @Override
+ public void setVariablesLocally(Map<String, Object> variables) {
+ actual.setVariablesLocally(variables);
+ }
+
+ @Override
+ public boolean hasVariable(String name) {
+ return actual.hasVariable(name);
+ }
+
+ @Override
+ public Instruction getInstruction() {
+ return actual.getInstruction();
+ }
+
+ @Override
+ public void setInstruction(Instruction instruction) {
+ actual.setInstruction(instruction);
+ }
+
+ @Override
+ public <T extends Instruction> T getInstruction(Class<T> clazz) {
+ return actual.getInstruction(clazz);
+ }
+
+ @Override
+ public boolean hasVariableLocal(String name) {
+ return actual.hasVariableLocal(name);
+ }
+
+ @Override
+ public Object removeVariable(String name) {
+ return actual.removeVariable(name);
+ }
+
+ @Override
+ public Object removeVariableLocally(String name) {
+ return actual.removeVariableLocally(name);
+ }
+
+ @Override
+ public void clearLocally() {
+ actual.clearLocally();
+ }
+
+ public ProcessContext getParent() {
+ return wrap((org.apache.seata.saga.proctrl.HierarchicalProcessContext)
+ ((org.apache.seata.saga.proctrl.impl.ProcessContextImpl) actual).getParent());
+ }
+
+ public void setParent(ProcessContext parent) {
+ ((org.apache.seata.saga.proctrl.impl.ProcessContextImpl) actual)
+ .setParent(((ProcessContextImpl) parent).unwrap());
+ }
+
+ @Override
+ public String toString() {
+ return actual.toString();
+ }
+
+ public static ProcessContextImpl wrap(org.apache.seata.saga.proctrl.HierarchicalProcessContext target) {
+ return new ProcessContextImpl(target);
+ }
+
+ public org.apache.seata.saga.proctrl.ProcessContext unwrap() {
+ return actual;
+ }
+}
diff --git a/compatible/src/main/java/io/seata/saga/statelang/domain/DomainConstants.java b/compatible/src/main/java/io/seata/saga/statelang/domain/DomainConstants.java
new file mode 100644
index 0000000000..87bd9fe44a
--- /dev/null
+++ b/compatible/src/main/java/io/seata/saga/statelang/domain/DomainConstants.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.seata.saga.statelang.domain;
+
+/**
+ * State Language Domain Constants
+ *
+ */
+public interface DomainConstants {
+
+ //region State Types
+ String STATE_TYPE_SERVICE_TASK = "ServiceTask";
+ String STATE_TYPE_CHOICE = "Choice";
+ String STATE_TYPE_FAIL = "Fail";
+ String STATE_TYPE_SUCCEED = "Succeed";
+ String STATE_TYPE_COMPENSATION_TRIGGER = "CompensationTrigger";
+ String STATE_TYPE_SUB_STATE_MACHINE = "SubStateMachine";
+ String STATE_TYPE_SUB_MACHINE_COMPENSATION = "CompensateSubMachine";
+ String STATE_TYPE_SCRIPT_TASK = "ScriptTask";
+ String STATE_TYPE_LOOP_START = "LoopStart";
+ //endregion
+
+ String COMPENSATE_SUB_MACHINE_STATE_NAME_PREFIX = "_compensate_sub_machine_state_";
+
+ //region Service Types
+ String SERVICE_TYPE_SPRING_BEAN = "SpringBean";
+ //endregion
+
+ //region System Variables
+ String VAR_NAME_STATEMACHINE_CONTEXT = "context";
+ String VAR_NAME_INPUT_PARAMS = "inputParams";
+ String VAR_NAME_OUTPUT_PARAMS = "outputParams";
+ String VAR_NAME_CURRENT_EXCEPTION = "currentException";//exception of current state
+ String VAR_NAME_BUSINESSKEY = "_business_key_";
+ String VAR_NAME_SUB_MACHINE_PARENT_ID = "_sub_machine_parent_id_";
+ String VAR_NAME_CURRENT_CHOICE = "_current_choice_";
+ String VAR_NAME_STATEMACHINE_ERROR_CODE = "_statemachine_error_code_";
+ String VAR_NAME_STATEMACHINE_ERROR_MSG = "_statemachine_error_message_";
+ String VAR_NAME_CURRENT_EXCEPTION_ROUTE = "_current_exception_route_";
+ String VAR_NAME_STATEMACHINE = "_current_statemachine_";
+ String VAR_NAME_STATEMACHINE_INST = "_current_statemachine_instance_";
+ String VAR_NAME_STATEMACHINE_ENGINE = "_current_statemachine_engine_";
+ String VAR_NAME_STATE_INST = "_current_state_instance_";
+ String VAR_NAME_STATEMACHINE_CONFIG = "_statemachine_config_";
+ String VAR_NAME_FAIL_END_STATE_FLAG = "_fail_end_state_flag_";
+ String VAR_NAME_CURRENT_COMPENSATION_HOLDER = "_current_compensation_holder_";
+ String VAR_NAME_RETRIED_STATE_INST_ID = "_retried_state_instance_id";
+ String VAR_NAME_OPERATION_NAME = "_operation_name_";
+ String VAR_NAME_ASYNC_CALLBACK = "_async_callback_";
+ String VAR_NAME_CURRENT_COMPEN_TRIGGER_STATE = "_is_compensating_";
+ String VAR_NAME_IS_EXCEPTION_NOT_CATCH = "_is_exception_not_catch_";
+ String VAR_NAME_PARENT_ID = "_parent_id_";
+ String VAR_NAME_SUB_STATEMACHINE_EXEC_STATUE = "_sub_statemachine_execution_status_";
+ String VAR_NAME_IS_FOR_SUB_STATMACHINE_FORWARD = "_is_for_sub_statemachine_forward_";
+ String VAR_NAME_FIRST_COMPENSATION_STATE_STARTED = "_first_compensation_state_started";
+ String VAR_NAME_GLOBAL_TX = "_global_transaction_";
+ String VAR_NAME_IS_ASYNC_EXECUTION = "_is_async_execution_";
+ String VAR_NAME_IS_LOOP_STATE = "_is_loop_state_";
+ String VAR_NAME_CURRENT_LOOP_CONTEXT_HOLDER = "_current_loop_context_holder_";
+ //endregion
+
+ // region of loop
+ String LOOP_COUNTER = "loopCounter";
+ String LOOP_SEMAPHORE = "loopSemaphore";
+ String LOOP_RESULT = "loopResult";
+ String NUMBER_OF_INSTANCES = "nrOfInstances";
+ String NUMBER_OF_ACTIVE_INSTANCES = "nrOfActiveInstances";
+ String NUMBER_OF_COMPLETED_INSTANCES = "nrOfCompletedInstances";
+ // endregion
+
+ String OPERATION_NAME_START = "start";
+ String OPERATION_NAME_FORWARD = "forward";
+ String OPERATION_NAME_COMPENSATE = "compensate";
+
+ String SEQ_ENTITY_STATE_MACHINE = "STATE_MACHINE";
+ String SEQ_ENTITY_STATE_MACHINE_INST = "STATE_MACHINE_INST";
+ String SEQ_ENTITY_STATE_INST = "STATE_INST";
+
+ String EXPRESSION_TYPE_SEQUENCE = "Sequence";
+ String EXPRESSION_TYPE_EXCEPTION = "Exception";
+
+ String SEPERATOR_PARENT_ID = ":";
+
+ String DEFAULT_JSON_PARSER = "fastjson";
+}
diff --git a/compatible/src/main/java/io/seata/saga/statelang/domain/ExecutionStatus.java b/compatible/src/main/java/io/seata/saga/statelang/domain/ExecutionStatus.java
new file mode 100644
index 0000000000..388e6bcf93
--- /dev/null
+++ b/compatible/src/main/java/io/seata/saga/statelang/domain/ExecutionStatus.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.seata.saga.statelang.domain;
+
+/**
+ * Execution Status
+ *
+ */
+public enum ExecutionStatus {
+
+ /**
+ * Running
+ */
+ RU("Running"),
+
+ /**
+ * Succeed
+ */
+ SU("Succeed"),
+
+ /**
+ * Failed
+ */
+ FA("Failed"),
+
+ /**
+ * Unknown
+ */
+ UN("Unknown"),
+
+ /**
+ * Skipped
+ */
+ SK("Skipped");
+
+ private String statusString;
+
+ private ExecutionStatus(String statusString) {
+ this.statusString = statusString;
+ }
+
+ public String getStatusString() {
+ return statusString;
+ }
+
+ public static ExecutionStatus wrap(org.apache.seata.saga.statelang.domain.ExecutionStatus target) {
+ switch (target) {
+ case RU:
+ return RU;
+ case SU:
+ return SU;
+ case FA:
+ return FA;
+ case UN:
+ return UN;
+ case SK:
+ return SK;
+ default:
+ throw new IllegalArgumentException("Cannot convert " + target.name());
+ }
+ }
+
+ public org.apache.seata.saga.statelang.domain.ExecutionStatus unwrap() {
+ switch (this) {
+ case RU:
+ return org.apache.seata.saga.statelang.domain.ExecutionStatus.RU;
+ case SU:
+ return org.apache.seata.saga.statelang.domain.ExecutionStatus.SU;
+ case FA:
+ return org.apache.seata.saga.statelang.domain.ExecutionStatus.FA;
+ case UN:
+ return org.apache.seata.saga.statelang.domain.ExecutionStatus.UN;
+ case SK:
+ return org.apache.seata.saga.statelang.domain.ExecutionStatus.SK;
+ default:
+ throw new IllegalArgumentException("Cannot convert " + this.name());
+ }
+ }
+}
diff --git a/compatible/src/main/java/io/seata/saga/statelang/domain/StateInstance.java b/compatible/src/main/java/io/seata/saga/statelang/domain/StateInstance.java
new file mode 100644
index 0000000000..39109b3c0c
--- /dev/null
+++ b/compatible/src/main/java/io/seata/saga/statelang/domain/StateInstance.java
@@ -0,0 +1,376 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.seata.saga.statelang.domain;
+
+import java.util.Date;
+
+/**
+ * State execution instance
+ *
+ */
+public interface StateInstance {
+
+ /**
+ * id
+ *
+ * @return the state instance id
+ */
+ String getId();
+
+ /**
+ * set id
+ *
+ * @param id the id
+ */
+ void setId(String id);
+
+ /**
+ * get Machine InstanceId
+ *
+ * @return the Machine InstanceId
+ */
+ String getMachineInstanceId();
+
+ /**
+ * set Machine InstanceId
+ *
+ * @param machineInstanceId Machine InstanceId
+ */
+ void setMachineInstanceId(String machineInstanceId);
+
+ /**
+ * get name
+ *
+ * @return the name
+ */
+ String getName();
+
+ /**
+ * set name
+ *
+ * @param name state instance name
+ */
+ void setName(String name);
+
+ /**
+ * get type
+ *
+ * @return state instance type
+ */
+ String getType();
+
+ /**
+ * set type
+ *
+ * @param type state instance type
+ */
+ void setType(String type);
+
+ /**
+ * get service name
+ *
+ * @return the state instance service name
+ */
+ String getServiceName();
+
+ /**
+ * set service name
+ *
+ * @param serviceName the state instance service name
+ */
+ void setServiceName(String serviceName);
+
+ /**
+ * get service method
+ *
+ * @return the state instance service method
+ */
+ String getServiceMethod();
+
+ /**
+ * set service method
+ *
+ * @param serviceMethod the state instance service method
+ */
+ void setServiceMethod(String serviceMethod);
+
+ /**
+ * get service type
+ *
+ * @return the state instance service type
+ */
+ String getServiceType();
+
+ /**
+ * get service type
+ *
+ * @param serviceType the state instance service type
+ */
+ void setServiceType(String serviceType);
+
+ /**
+ * get businessKey
+ *
+ * @return the state instance businessKey
+ */
+ String getBusinessKey();
+
+ /**
+ * set business key
+ *
+ * @param businessKey the state instance businessKey
+ */
+ void setBusinessKey(String businessKey);
+
+ /**
+ * get start time
+ *
+ * @return the state instance start time
+ */
+ Date getGmtStarted();
+
+ /**
+ * set start time
+ *
+ * @param gmtStarted the state instance start time
+ */
+ void setGmtStarted(Date gmtStarted);
+
+ /**
+ * get update time
+ *
+ * @return the state instance update time
+ */
+ Date getGmtUpdated();
+
+ /**
+ * set update time
+ *
+ * @param gmtUpdated the state instance update time
+ */
+ void setGmtUpdated(Date gmtUpdated);
+
+ /**
+ * get end time
+ *
+ * @return the state instance end time
+ */
+ Date getGmtEnd();
+
+ /**
+ * set end time
+ *
+ * @param gmtEnd the state instance end time
+ */
+ void setGmtEnd(Date gmtEnd);
+
+ /**
+ * Is this state task will update data?
+ *
+ * @return the boolean
+ */
+ boolean isForUpdate();
+
+ /**
+ * setForUpdate
+ *
+ * @param forUpdate is for update
+ */
+ void setForUpdate(boolean forUpdate);
+
+ /**
+ * get exception
+ *
+ * @return exception
+ */
+ Exception getException();
+
+ /**
+ * set exception
+ *
+ * @param exception exception
+ */
+ void setException(Exception exception);
+
+ /**
+ * get input params
+ *
+ * @return input params
+ */
+ Object getInputParams();
+
+ /**
+ * set inout params
+ *
+ * @param inputParams inputParams
+ */
+ void setInputParams(Object inputParams);
+
+ /**
+ * get output params
+ *
+ * @return output params
+ */
+ Object getOutputParams();
+
+ /**
+ * Sets set output params.
+ *
+ * @param outputParams the output params
+ */
+ void setOutputParams(Object outputParams);
+
+ /**
+ * Gets get status.
+ *
+ * @return the get status
+ */
+ ExecutionStatus getStatus();
+
+ /**
+ * Sets set status.
+ *
+ * @param status the status
+ */
+ void setStatus(ExecutionStatus status);
+
+ /**
+ * Gets get state id compensated for.
+ *
+ * @return the get state id compensated for
+ */
+ String getStateIdCompensatedFor();
+
+ /**
+ * Sets set state id compensated for.
+ *
+ * @param stateIdCompensatedFor the state id compensated for
+ */
+ void setStateIdCompensatedFor(String stateIdCompensatedFor);
+
+ /**
+ * Gets get state id retried for.
+ *
+ * @return the get state id retried for
+ */
+ String getStateIdRetriedFor();
+
+ /**
+ * Sets set state id retried for.
+ *
+ * @param stateIdRetriedFor the state id retried for
+ */
+ void setStateIdRetriedFor(String stateIdRetriedFor);
+
+ /**
+ * Gets get compensation state.
+ *
+ * @return the get compensation state
+ */
+ StateInstance getCompensationState();
+
+ /**
+ * Sets set compensation state.
+ *
+ * @param compensationState the compensation state
+ */
+ void setCompensationState(StateInstance compensationState);
+
+ /**
+ * Gets get state machine instance.
+ *
+ * @return the get state machine instance
+ */
+ StateMachineInstance getStateMachineInstance();
+
+ /**
+ * Sets set state machine instance.
+ *
+ * @param stateMachineInstance the state machine instance
+ */
+ void setStateMachineInstance(StateMachineInstance stateMachineInstance);
+
+ /**
+ * Is ignore status boolean.
+ *
+ * @return the boolean
+ */
+ boolean isIgnoreStatus();
+
+ /**
+ * Sets set ignore status.
+ *
+ * @param ignoreStatus the ignore status
+ */
+ void setIgnoreStatus(boolean ignoreStatus);
+
+ /**
+ * Is for compensation boolean.
+ *
+ * @return the boolean
+ */
+ boolean isForCompensation();
+
+ /**
+ * Gets get serialized input params.
+ *
+ * @return the get serialized input params
+ */
+ Object getSerializedInputParams();
+
+ /**
+ * Sets set serialized input params.
+ *
+ * @param serializedInputParams the serialized input params
+ */
+ void setSerializedInputParams(Object serializedInputParams);
+
+ /**
+ * Gets get serialized output params.
+ *
+ * @return the get serialized output params
+ */
+ Object getSerializedOutputParams();
+
+ /**
+ * Sets set serialized output params.
+ *
+ * @param serializedOutputParams the serialized output params
+ */
+ void setSerializedOutputParams(Object serializedOutputParams);
+
+ /**
+ * Gets get serialized exception.
+ *
+ * @return the get serialized exception
+ */
+ Object getSerializedException();
+
+ /**
+ * Sets set serialized exception.
+ *
+ * @param serializedException the serialized exception
+ */
+ void setSerializedException(Object serializedException);
+
+ /**
+ * Gets get compensation status.
+ *
+ * @return the get compensation status
+ */
+ ExecutionStatus getCompensationStatus();
+}
diff --git a/compatible/src/main/java/io/seata/saga/statelang/domain/StateMachineInstance.java b/compatible/src/main/java/io/seata/saga/statelang/domain/StateMachineInstance.java
new file mode 100644
index 0000000000..0ce42b0a99
--- /dev/null
+++ b/compatible/src/main/java/io/seata/saga/statelang/domain/StateMachineInstance.java
@@ -0,0 +1,332 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.seata.saga.statelang.domain;
+
+import org.apache.seata.saga.statelang.domain.StateMachine;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * StateMachine execution instance
+ *
+ */
+public interface StateMachineInstance {
+
+ /**
+ * Gets get id.
+ *
+ * @return the get id
+ */
+ String getId();
+
+ /**
+ * Sets set id.
+ *
+ * @param id the id
+ */
+ void setId(String id);
+
+ /**
+ * Gets get machine id.
+ *
+ * @return the get machine id
+ */
+ String getMachineId();
+
+ /**
+ * Sets set machine id.
+ *
+ * @param machineId the machine id
+ */
+ void setMachineId(String machineId);
+
+ /**
+ * Gets get tenant id.
+ *
+ * @return the tenant id
+ */
+ String getTenantId();
+
+ /**
+ * Sets set tenant id.
+ *
+ * @param tenantId the tenant id
+ */
+ void setTenantId(String tenantId);
+
+ /**
+ * Gets get parent id.
+ *
+ * @return the get parent id
+ */
+ String getParentId();
+
+ /**
+ * Sets set parent id.
+ *
+ * @param parentId the parent id
+ */
+ void setParentId(String parentId);
+
+ /**
+ * Gets get gmt started.
+ *
+ * @return the get gmt started
+ */
+ Date getGmtStarted();
+
+ /**
+ * Sets set gmt started.
+ *
+ * @param gmtStarted the gmt started
+ */
+ void setGmtStarted(Date gmtStarted);
+
+ /**
+ * Gets get gmt end.
+ *
+ * @return the get gmt end
+ */
+ Date getGmtEnd();
+
+ /**
+ * Sets set gmt end.
+ *
+ * @param gmtEnd the gmt end
+ */
+ void setGmtEnd(Date gmtEnd);
+
+ /**
+ * Put state instance.
+ *
+ * @param stateId the state id
+ * @param stateInstance the state instance
+ */
+ void putStateInstance(String stateId, StateInstance stateInstance);
+
+ /**
+ * Gets get status.
+ *
+ * @return the get status
+ */
+ ExecutionStatus getStatus();
+
+ /**
+ * Sets set status.
+ *
+ * @param status the status
+ */
+ void setStatus(ExecutionStatus status);
+
+ /**
+ * Gets get compensation status.
+ *
+ * @return the get compensation status
+ */
+ ExecutionStatus getCompensationStatus();
+
+ /**
+ * Sets set compensation status.
+ *
+ * @param compensationStatus the compensation status
+ */
+ void setCompensationStatus(ExecutionStatus compensationStatus);
+
+ /**
+ * Is running boolean.
+ *
+ * @return the boolean
+ */
+ boolean isRunning();
+
+ /**
+ * Sets set running.
+ *
+ * @param running the running
+ */
+ void setRunning(boolean running);
+
+ /**
+ * Gets get gmt updated.
+ *
+ * @return the get gmt updated
+ */
+ Date getGmtUpdated();
+
+ /**
+ * Sets set gmt updated.
+ *
+ * @param gmtUpdated the gmt updated
+ */
+ void setGmtUpdated(Date gmtUpdated);
+
+ /**
+ * Gets get business key.
+ *
+ * @return the get business key
+ */
+ String getBusinessKey();
+
+ /**
+ * Sets set business key.
+ *
+ * @param businessKey the business key
+ */
+ void setBusinessKey(String businessKey);
+
+ /**
+ * Gets get exception.
+ *
+ * @return the get exception
+ */
+ Exception getException();
+
+ /**
+ * Sets set exception.
+ *
+ * @param exception the exception
+ */
+ void setException(Exception exception);
+
+ /**
+ * Gets get start params.
+ *
+ * @return the get start params
+ */
+ Map<String, Object> getStartParams();
+
+ /**
+ * Sets set start params.
+ *
+ * @param startParams the start params
+ */
+ void setStartParams(Map<String, Object> startParams);
+
+ /**
+ * Gets get end params.
+ *
+ * @return the get end params
+ */
+ Map<String, Object> getEndParams();
+
+ /**
+ * Sets set end params.
+ *
+ * @param endParams the end params
+ */
+ void setEndParams(Map<String, Object> endParams);
+
+ /**
+ * Gets get context.
+ *
+ * @return the state machine context
+ */
+ Map<String, Object> getContext();
+
+ /**
+ * Sets set context.
+ *
+ * @param context the key and value context
+ */
+ void setContext(Map<String, Object> context);
+
+ /**
+ * Gets get state machine.
+ *
+ * @return the get state machine
+ */
+ StateMachine getStateMachine();
+
+ /**
+ * Sets set state machine.
+ *
+ * @param stateMachine the state machine
+ */
+ void setStateMachine(StateMachine stateMachine);
+
+ /**
+ * Gets get state list.
+ *
+ * @return the get state list
+ */
+ List<StateInstance> getStateList();
+
+ /**
+ * Sets set state list.
+ *
+ * @param stateList the state list
+ */
+ void setStateList(List<StateInstance> stateList);
+
+ /**
+ * Gets get state map.
+ *
+ * @return the get state map
+ */
+ Map<String, StateInstance> getStateMap();
+
+ /**
+ * Sets set state map.
+ *
+ * @param stateMap the state map
+ */
+ void setStateMap(Map<String, StateInstance> stateMap);
+
+ /**
+ * Gets get serialized start params.
+ *
+ * @return the get serialized start params
+ */
+ Object getSerializedStartParams();
+
+ /**
+ * Sets set serialized start params.
+ *
+ * @param serializedStartParams the serialized start params
+ */
+ void setSerializedStartParams(Object serializedStartParams);
+
+ /**
+ * Gets get serialized end params.
+ *
+ * @return the get serialized end params
+ */
+ Object getSerializedEndParams();
+
+ /**
+ * Sets set serialized end params.
+ *
+ * @param serializedEndParams the serialized end params
+ */
+ void setSerializedEndParams(Object serializedEndParams);
+
+ /**
+ * Gets get serialized exception.
+ *
+ * @return the get serialized exception
+ */
+ Object getSerializedException();
+
+ /**
+ * Sets set serialized exception.
+ *
+ * @param serializedException the serialized exception
+ */
+ void setSerializedException(Object serializedException);
+}
diff --git a/compatible/src/main/java/io/seata/saga/statelang/domain/impl/StateInstanceImpl.java b/compatible/src/main/java/io/seata/saga/statelang/domain/impl/StateInstanceImpl.java
new file mode 100644
index 0000000000..be52a688a7
--- /dev/null
+++ b/compatible/src/main/java/io/seata/saga/statelang/domain/impl/StateInstanceImpl.java
@@ -0,0 +1,296 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.seata.saga.statelang.domain.impl;
+
+import io.seata.saga.statelang.domain.ExecutionStatus;
+import io.seata.saga.statelang.domain.StateInstance;
+import io.seata.saga.statelang.domain.StateMachineInstance;
+
+import java.util.Date;
+
+/**
+ * state execution instance
+ *
+ */
+public class StateInstanceImpl implements StateInstance {
+
+ private final org.apache.seata.saga.statelang.domain.StateInstance actual;
+
+ private StateMachineInstance stateMachineInstance;
+
+ private StateInstanceImpl(org.apache.seata.saga.statelang.domain.StateInstance actual) {
+ this.actual = actual;
+ }
+
+ @Override
+ public String getId() {
+ return actual.getId();
+ }
+
+ @Override
+ public void setId(String id) {
+ actual.setId(id);
+ }
+
+ @Override
+ public String getMachineInstanceId() {
+ return actual.getMachineInstanceId();
+ }
+
+ @Override
+ public void setMachineInstanceId(String machineInstanceId) {
+ actual.setMachineInstanceId(machineInstanceId);
+ }
+
+ @Override
+ public String getName() {
+ return actual.getName();
+ }
+
+ @Override
+ public void setName(String name) {
+ actual.setName(name);
+ }
+
+ @Override
+ public String getType() {
+ return actual.getType();
+ }
+
+ @Override
+ public void setType(String type) {
+ actual.setType(type);
+ }
+
+ @Override
+ public String getServiceName() {
+ return actual.getServiceName();
+ }
+
+ @Override
+ public void setServiceName(String serviceName) {
+ actual.setServiceName(serviceName);
+ }
+
+ @Override
+ public String getServiceMethod() {
+ return actual.getServiceMethod();
+ }
+
+ @Override
+ public void setServiceMethod(String serviceMethod) {
+ actual.setServiceMethod(serviceMethod);
+ }
+
+ @Override
+ public String getServiceType() {
+ return actual.getServiceType();
+ }
+
+ @Override
+ public void setServiceType(String serviceType) {
+ actual.setServiceType(serviceType);
+ }
+
+ @Override
+ public String getBusinessKey() {
+ return actual.getBusinessKey();
+ }
+
+ @Override
+ public void setBusinessKey(String businessKey) {
+ actual.setBusinessKey(businessKey);
+ }
+
+ @Override
+ public Date getGmtStarted() {
+ return actual.getGmtStarted();
+ }
+
+ @Override
+ public void setGmtStarted(Date gmtStarted) {
+ actual.setGmtStarted(gmtStarted);
+ }
+
+ @Override
+ public Date getGmtUpdated() {
+ return actual.getGmtUpdated();
+ }
+
+ @Override
+ public void setGmtUpdated(Date gmtUpdated) {
+ actual.setGmtUpdated(gmtUpdated);
+ }
+
+ @Override
+ public Date getGmtEnd() {
+ return actual.getGmtEnd();
+ }
+
+ @Override
+ public void setGmtEnd(Date gmtEnd) {
+ actual.setGmtEnd(gmtEnd);
+ }
+
+ @Override
+ public boolean isForUpdate() {
+ return actual.isForUpdate();
+ }
+
+ @Override
+ public void setForUpdate(boolean forUpdate) {
+ setForUpdate(forUpdate);
+ }
+
+ @Override
+ public String getStateIdCompensatedFor() {
+ return actual.getStateIdCompensatedFor();
+ }
+
+ @Override
+ public void setStateIdCompensatedFor(String stateIdCompensatedFor) {
+ actual.setStateIdCompensatedFor(stateIdCompensatedFor);
+ }
+
+ @Override
+ public String getStateIdRetriedFor() {
+ return actual.getStateIdRetriedFor();
+ }
+
+ @Override
+ public void setStateIdRetriedFor(String stateIdRetriedFor) {
+ actual.setStateIdRetriedFor(stateIdRetriedFor);
+ }
+
+ @Override
+ public Exception getException() {
+ return actual.getException();
+ }
+
+ @Override
+ public void setException(Exception exception) {
+ actual.setException(exception);
+ }
+
+ @Override
+ public Object getInputParams() {
+ return actual.getInputParams();
+ }
+
+ @Override
+ public void setInputParams(Object inputParams) {
+ actual.setInputParams(inputParams);
+ }
+
+ @Override
+ public Object getOutputParams() {
+ return actual.getOutputParams();
+ }
+
+ @Override
+ public void setOutputParams(Object outputParams) {
+ actual.setOutputParams(outputParams);
+ }
+
+ @Override
+ public ExecutionStatus getStatus() {
+ return ExecutionStatus.wrap(actual.getStatus());
+ }
+
+ @Override
+ public void setStatus(ExecutionStatus status) {
+ actual.setStatus(status.unwrap());
+ }
+
+ @Override
+ public StateInstance getCompensationState() {
+ return wrap(actual.getCompensationState());
+ }
+
+ @Override
+ public void setCompensationState(StateInstance compensationState) {
+ actual.setCompensationState(((StateInstanceImpl) compensationState).unwrap());
+ }
+
+ @Override
+ public StateMachineInstance getStateMachineInstance() {
+ return stateMachineInstance;
+ }
+
+ @Override
+ public void setStateMachineInstance(StateMachineInstance stateMachineInstance) {
+ this.stateMachineInstance = stateMachineInstance;
+ }
+
+ @Override
+ public boolean isIgnoreStatus() {
+ return actual.isIgnoreStatus();
+ }
+
+ @Override
+ public void setIgnoreStatus(boolean ignoreStatus) {
+ actual.setIgnoreStatus(ignoreStatus);
+ }
+
+ @Override
+ public boolean isForCompensation() {
+ return actual.isForCompensation();
+ }
+
+ @Override
+ public Object getSerializedInputParams() {
+ return actual.getSerializedInputParams();
+ }
+
+ @Override
+ public void setSerializedInputParams(Object serializedInputParams) {
+ actual.setSerializedInputParams(serializedInputParams);
+ }
+
+ @Override
+ public Object getSerializedOutputParams() {
+ return actual.getSerializedOutputParams();
+ }
+
+ @Override
+ public void setSerializedOutputParams(Object serializedOutputParams) {
+ actual.setSerializedOutputParams(serializedOutputParams);
+ }
+
+ @Override
+ public Object getSerializedException() {
+ return actual.getSerializedException();
+ }
+
+ @Override
+ public void setSerializedException(Object serializedException) {
+ actual.setSerializedException(serializedException);
+ }
+
+ @Override
+ public ExecutionStatus getCompensationStatus() {
+ return ExecutionStatus.wrap(actual.getCompensationStatus());
+ }
+
+ public static StateInstanceImpl wrap(org.apache.seata.saga.statelang.domain.StateInstance target) {
+ return new StateInstanceImpl(target);
+ }
+
+ public org.apache.seata.saga.statelang.domain.StateInstance unwrap() {
+ return actual;
+ }
+}
diff --git a/compatible/src/main/java/io/seata/saga/statelang/domain/impl/StateMachineInstanceImpl.java b/compatible/src/main/java/io/seata/saga/statelang/domain/impl/StateMachineInstanceImpl.java
new file mode 100644
index 0000000000..4d04d00296
--- /dev/null
+++ b/compatible/src/main/java/io/seata/saga/statelang/domain/impl/StateMachineInstanceImpl.java
@@ -0,0 +1,277 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.seata.saga.statelang.domain.impl;
+
+import io.seata.saga.statelang.domain.ExecutionStatus;
+import io.seata.saga.statelang.domain.StateInstance;
+import io.seata.saga.statelang.domain.StateMachineInstance;
+import org.apache.seata.saga.statelang.domain.StateMachine;
+
+import java.util.AbstractMap;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+/**
+ * state machine execution instance
+ */
+public class StateMachineInstanceImpl implements StateMachineInstance {
+
+ private final org.apache.seata.saga.statelang.domain.StateMachineInstance actual;
+
+ private StateMachineInstanceImpl(org.apache.seata.saga.statelang.domain.StateMachineInstance actual) {
+ this.actual = actual;
+ }
+
+ @Override
+ public String getId() {
+ return actual.getId();
+ }
+
+ @Override
+ public void setId(String id) {
+ actual.setId(id);
+ }
+
+ @Override
+ public String getMachineId() {
+ return actual.getMachineId();
+ }
+
+ @Override
+ public void setMachineId(String machineId) {
+ actual.setMachineId(machineId);
+ }
+
+ @Override
+ public String getTenantId() {
+ return actual.getTenantId();
+ }
+
+ @Override
+ public void setTenantId(String tenantId) {
+ actual.setTenantId(tenantId);
+ }
+
+ @Override
+ public String getParentId() {
+ return actual.getParentId();
+ }
+
+ @Override
+ public void setParentId(String parentId) {
+ actual.setParentId(parentId);
+ }
+
+ @Override
+ public Date getGmtStarted() {
+ return actual.getGmtStarted();
+ }
+
+ @Override
+ public void setGmtStarted(Date gmtStarted) {
+ actual.setGmtStarted(gmtStarted);
+ }
+
+ @Override
+ public Date getGmtEnd() {
+ return actual.getGmtEnd();
+ }
+
+ @Override
+ public void setGmtEnd(Date gmtEnd) {
+ actual.setGmtEnd(gmtEnd);
+ }
+
+ @Override
+ public void putStateInstance(String stateId, StateInstance stateInstance) {
+ actual.putStateInstance(stateId, ((StateInstanceImpl) stateInstance).unwrap());
+ }
+
+ @Override
+ public ExecutionStatus getStatus() {
+ return ExecutionStatus.wrap(actual.getStatus());
+ }
+
+ @Override
+ public void setStatus(ExecutionStatus status) {
+ actual.setStatus(status.unwrap());
+ }
+
+ @Override
+ public ExecutionStatus getCompensationStatus() {
+ return ExecutionStatus.wrap(actual.getCompensationStatus());
+ }
+
+ @Override
+ public void setCompensationStatus(ExecutionStatus compensationStatus) {
+ actual.setCompensationStatus(compensationStatus.unwrap());
+ }
+
+ @Override
+ public boolean isRunning() {
+ return actual.isRunning();
+ }
+
+ @Override
+ public void setRunning(boolean running) {
+ actual.setRunning(running);
+ }
+
+ @Override
+ public Date getGmtUpdated() {
+ return actual.getGmtUpdated();
+ }
+
+ @Override
+ public void setGmtUpdated(Date gmtUpdated) {
+ actual.setGmtUpdated(gmtUpdated);
+ }
+
+ @Override
+ public String getBusinessKey() {
+ return actual.getBusinessKey();
+ }
+
+ @Override
+ public void setBusinessKey(String businessKey) {
+ actual.setBusinessKey(businessKey);
+ }
+
+ @Override
+ public Exception getException() {
+ return actual.getException();
+ }
+
+ @Override
+ public void setException(Exception exception) {
+ actual.setException(exception);
+ }
+
+ @Override
+ public Map<String, Object> getStartParams() {
+ return actual.getStartParams();
+ }
+
+ @Override
+ public void setStartParams(Map<String, Object> startParams) {
+ actual.setStartParams(startParams);
+ }
+
+ @Override
+ public Map<String, Object> getEndParams() {
+ return actual.getEndParams();
+ }
+
+ @Override
+ public void setEndParams(Map<String, Object> endParams) {
+ actual.setEndParams(endParams);
+ }
+
+ @Override
+ public Map<String, Object> getContext() {
+ return actual.getContext();
+ }
+
+ @Override
+ public void setContext(Map<String, Object> context) {
+ actual.setContext(context);
+ }
+
+ @Override
+ public StateMachine getStateMachine() {
+ return actual.getStateMachine();
+ }
+
+ @Override
+ public void setStateMachine(StateMachine stateMachine) {
+ actual.setStateMachine(stateMachine);
+ }
+
+ @Override
+ public List<StateInstance> getStateList() {
+ List<StateInstance> stateList = actual.getStateList().stream()
+ .map(StateInstanceImpl::wrap).collect(Collectors.toList());
+ stateList.forEach(state -> state.setStateMachineInstance(this));
+ return stateList;
+ }
+
+ @Override
+ public void setStateList(List<StateInstance> stateList) {
+ List<org.apache.seata.saga.statelang.domain.StateInstance> actualStateList = stateList.stream()
+ .map(state -> ((StateInstanceImpl) state).unwrap()).collect(Collectors.toList());
+
+ actual.setStateList(actualStateList);
+ }
+
+ @Override
+ public Map<String, StateInstance> getStateMap() {
+ List<StateInstance> stateList = actual.getStateList().stream()
+ .map(StateInstanceImpl::wrap).collect(Collectors.toList());
+ stateList.forEach(state -> state.setStateMachineInstance(this));
+ return stateList.stream()
+ .collect(Collectors.toMap(StateInstance::getId, Function.identity()));
+ }
+
+ @Override
+ public void setStateMap(Map<String, StateInstance> stateMap) {
+ Map<String, org.apache.seata.saga.statelang.domain.StateInstance> actualStateMap = stateMap.entrySet().stream()
+ .map(e -> new AbstractMap.SimpleEntry<>(e.getKey(), ((StateInstanceImpl) e.getValue()).unwrap()))
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
+ actual.setStateMap(actualStateMap);
+ }
+
+ @Override
+ public Object getSerializedStartParams() {
+ return actual.getSerializedStartParams();
+ }
+
+ @Override
+ public void setSerializedStartParams(Object serializedStartParams) {
+ actual.setSerializedStartParams(serializedStartParams);
+ }
+
+ @Override
+ public Object getSerializedEndParams() {
+ return actual.getSerializedEndParams();
+ }
+
+ @Override
+ public void setSerializedEndParams(Object serializedEndParams) {
+ actual.setSerializedEndParams(serializedEndParams);
+ }
+
+ @Override
+ public Object getSerializedException() {
+ return actual.getSerializedException();
+ }
+
+ @Override
+ public void setSerializedException(Object serializedException) {
+ actual.setSerializedException(serializedException);
+ }
+
+ public static StateMachineInstanceImpl wrap(org.apache.seata.saga.statelang.domain.StateMachineInstance target) {
+ return new StateMachineInstanceImpl(target);
+ }
+
+ public org.apache.seata.saga.statelang.domain.StateMachineInstance unwrap() {
+ return actual;
+ }
+}
diff --git a/pom.xml b/pom.xml
index 560a7ab4d8..d403ecebc7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -41,6 +41,7 @@
<module>config</module>
<module>console</module>
<module>core</module>
+ <module>compatible</module>
<module>dependencies</module>
<module>discovery</module>
<module>distribution</module>
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org