├── README.md
└── dts-parent
├── dts-server-web
└── src
│ └── main
│ ├── webapp
│ ├── ok.htm
│ └── WEB-INF
│ │ ├── servlet-context.xml
│ │ └── web.xml
│ ├── resources
│ ├── config.properties
│ ├── beanRefContext.xml
│ └── spring
│ │ └── spring-view.xml
│ └── java
│ └── org
│ └── github
│ └── dtsopensource
│ └── server
│ └── web
│ └── handler
│ ├── HttpAdapterManager.java
│ ├── HttpRuleAdapter.java
│ └── HttpScheduleAdapter.java
├── dts-local-example
├── src
│ └── main
│ │ ├── webapp
│ │ ├── ok.htm
│ │ └── WEB-INF
│ │ │ ├── servlet-context.xml
│ │ │ └── web.xml
│ │ ├── java
│ │ └── org
│ │ │ └── github
│ │ │ └── dtsopensource
│ │ │ └── local
│ │ │ └── test
│ │ │ ├── bizService
│ │ │ ├── ITradeFlowService.java
│ │ │ ├── AbstractPaymentTrade.java
│ │ │ ├── AbstraceOrderTrade.java
│ │ │ ├── IPaymentTrade.java
│ │ │ ├── IOrderTrade.java
│ │ │ ├── impl
│ │ │ │ ├── TradeFlowService.java
│ │ │ │ ├── TradeLog.java
│ │ │ │ └── OrderTrade.java
│ │ │ └── ITradeLog.java
│ │ │ ├── application
│ │ │ └── IPurchaseService.java
│ │ │ ├── dao
│ │ │ ├── dataobject
│ │ │ │ └── DtsTestDO.java
│ │ │ └── mapper
│ │ │ │ └── DtsTestDOMapper.java
│ │ │ ├── PurchaseContext.java
│ │ │ ├── GenerateId.java
│ │ │ └── controller
│ │ │ └── DTSController.java
│ │ └── resources
│ │ ├── config.properties
│ │ ├── spring
│ │ ├── spring-biz-persistence.xml
│ │ ├── spring-biz-transaction.xml
│ │ ├── spring-dts-local-example.xml
│ │ ├── spring-biz-dao.xml
│ │ ├── spring-view.xml
│ │ └── spring-dts-local-config.xml
│ │ └── beanRefContext.xml
└── pom.xml
├── dts-remote-example
├── src
│ └── main
│ │ ├── webapp
│ │ ├── ok.htm
│ │ └── WEB-INF
│ │ │ ├── servlet-context.xml
│ │ │ └── web.xml
│ │ ├── java
│ │ └── org
│ │ │ └── github
│ │ │ └── dtsopensource
│ │ │ └── remote
│ │ │ └── test
│ │ │ ├── bizService
│ │ │ ├── ITradeFlowService.java
│ │ │ ├── AbstractPaymentTrade.java
│ │ │ ├── AbstraceOrderTrade.java
│ │ │ ├── IPaymentTrade.java
│ │ │ ├── IOrderTrade.java
│ │ │ ├── impl
│ │ │ │ ├── TradeFlowService.java
│ │ │ │ ├── TradeLog.java
│ │ │ │ └── OrderTrade.java
│ │ │ └── ITradeLog.java
│ │ │ ├── application
│ │ │ └── IPurchaseService.java
│ │ │ ├── dao
│ │ │ ├── dataobject
│ │ │ │ └── DtsTestDO.java
│ │ │ └── mapper
│ │ │ │ └── DtsTestDOMapper.java
│ │ │ ├── PurchaseContext.java
│ │ │ └── GenerateId.java
│ │ └── resources
│ │ ├── config.properties
│ │ ├── spring
│ │ ├── spring-biz-persistence.xml
│ │ ├── spring-biz-transaction.xml
│ │ ├── spring-biz-dao.xml
│ │ ├── spring-dts-remote-example.xml
│ │ └── spring-view.xml
│ │ └── beanRefContext.xml
└── pom.xml
├── doc
├── dts.eap
├── 分布式事务系统DTS原理及使用.pptx
└── init
│ ├── init.data
│ └── init.sql
├── dts-admin
└── src
│ └── main
│ ├── resources
│ ├── static
│ │ ├── favicon.png
│ │ ├── fonts
│ │ │ ├── glyphicons-halflings-regular.eot
│ │ │ ├── glyphicons-halflings-regular.ttf
│ │ │ └── glyphicons-halflings-regular.woff
│ │ ├── js
│ │ │ ├── npm.js
│ │ │ └── plugin
│ │ │ │ └── bootstraptable
│ │ │ │ └── bootstrap-table-zh-CN.min.js
│ │ └── css
│ │ │ └── dashboard.css
│ ├── spring
│ │ ├── dts-admin-application.xml
│ │ └── spring-dts-admin-persistence.xml
│ ├── application.properties
│ └── generatorConfig.xml
│ ├── webapp
│ └── WEB-INF
│ │ └── web.xml
│ └── java
│ └── org
│ └── github
│ └── dtsopensource
│ └── admin
│ ├── vo
│ └── ActivityRuleVO.java
│ ├── service
│ ├── IActivityRuleService.java
│ └── helper
│ │ ├── ActivityActionRuleHelper.java
│ │ └── ActivityRuleHelper.java
│ ├── application
│ ├── IActicityRuleApplication.java
│ └── impl
│ │ └── ActicityRuleApplication.java
│ ├── DTSAdminApplication.java
│ ├── util
│ └── DTSCoreSpringHolder.java
│ ├── exception
│ └── DTSAdminException.java
│ └── dao
│ ├── mapper
│ ├── ActivityRuleDOMapper.java
│ └── ActivityActionRuleDOMapper.java
│ └── dataobject
│ └── ActivityRuleDO.java
├── dts-server-share
├── src
│ └── main
│ │ └── java
│ │ └── org
│ │ └── github
│ │ └── dtsopensource
│ │ └── server
│ │ └── share
│ │ ├── DTSResultCode.java
│ │ ├── DTSManageType.java
│ │ ├── util
│ │ └── DTSCoreSystem.java
│ │ ├── protocol
│ │ ├── IDTSProtocol.java
│ │ ├── ProtocolMethod.java
│ │ ├── ProtocolConstance.java
│ │ └── Protocol.java
│ │ ├── schedule
│ │ ├── IDTSTaskTracker.java
│ │ ├── TaskTrackerContext.java
│ │ └── IDTSSchedule.java
│ │ ├── IDTS.java
│ │ ├── rule
│ │ └── IDTSRule.java
│ │ ├── ResultBase.java
│ │ ├── store
│ │ ├── Status.java
│ │ └── IDTSStore.java
│ │ ├── DTSConfig.java
│ │ └── exception
│ │ ├── DTSBizException.java
│ │ ├── DTSStoreException.java
│ │ └── DTSRuntimeException.java
└── pom.xml
├── dts-schedule
├── src
│ └── main
│ │ └── java
│ │ └── org
│ │ └── github
│ │ └── dtsopensource
│ │ └── schedule
│ │ ├── IDTSJobTracker.java
│ │ ├── IJobTimerParse.java
│ │ ├── IJobRegister.java
│ │ ├── IJobNode.java
│ │ ├── taskTracker
│ │ ├── LocalTaskTrackerDelegate.java
│ │ ├── RemoteTaskTrackerDelegate.java
│ │ └── task
│ │ │ └── HangTransactionMonitorTask.java
│ │ ├── protocol
│ │ ├── HttpRemoteScheduleProtocol.java
│ │ └── http
│ │ │ └── HttpScheduleProtocol.java
│ │ ├── timerParse
│ │ └── springcron
│ │ │ └── SpringCronParse.java
│ │ ├── register
│ │ └── zookeeper
│ │ │ └── ZookeeperJobRegister.java
│ │ └── jobTracker
│ │ └── RemoteJobTrackerDelegate.java
└── pom.xml
├── dts-server
├── src
│ └── main
│ │ ├── java
│ │ └── org
│ │ │ └── github
│ │ │ └── dtsopensource
│ │ │ └── server
│ │ │ ├── store
│ │ │ ├── hsf
│ │ │ │ └── IHSFServerStore.java
│ │ │ └── http
│ │ │ │ └── IHttpServerStore.java
│ │ │ ├── schedule
│ │ │ └── http
│ │ │ │ ├── IHttpServerSchedule.java
│ │ │ │ └── impl
│ │ │ │ └── HttpServerScheduleProtocol.java
│ │ │ └── rule
│ │ │ └── HttpServerRuleProtocol.java
│ │ └── resources
│ │ └── dtsserver
│ │ ├── spring-dts-activity_rule.xml
│ │ ├── spring-dts-hsf-provider.xml
│ │ ├── spring-dts-schedule.xml
│ │ ├── spring-dts-server.xml
│ │ └── spring-dts-persistence.xml
└── pom.xml
├── dts-core
└── src
│ └── main
│ ├── java
│ └── org
│ │ └── github
│ │ └── dtsopensource
│ │ └── core
│ │ ├── protocol
│ │ ├── hsf
│ │ │ └── protocol
│ │ │ │ └── IHSFProtocol.java
│ │ ├── http
│ │ │ └── protocol
│ │ │ │ ├── IHttpProtocol.java
│ │ │ │ └── impl
│ │ │ │ └── HttpProtoclCallback.java
│ │ └── StoreProtocolManager.java
│ │ ├── annotation
│ │ ├── AopHandler.java
│ │ └── ITwoPhaseCommitAspect.java
│ │ ├── dao
│ │ ├── ActivityRuleSqlConstance.java
│ │ ├── ActivityActionRuleSqlConstance.java
│ │ ├── dataobject
│ │ │ ├── DtsActivityRuleDO.java
│ │ │ └── DtsActivityActionRuleDO.java
│ │ ├── ActionSqlConstance.java
│ │ ├── ActivitySqlConstance.java
│ │ └── rowMapper
│ │ │ ├── DtsActivityRuleRowMapper.java
│ │ │ ├── DtsActivityRowMapper.java
│ │ │ ├── DtsActivityActionRuleRowMapper.java
│ │ │ └── DtsActionRowMapper.java
│ │ ├── rule
│ │ ├── help
│ │ │ ├── ActivityRuleHelper.java
│ │ │ └── ActivityActionRuleHelper.java
│ │ └── ActivityRuleMananger.java
│ │ ├── ITwoPhaseCommit.java
│ │ ├── manager
│ │ ├── RemoteDTSManager.java
│ │ ├── LocalDTSManager.java
│ │ └── DTSManager.java
│ │ ├── util
│ │ └── ActivityIdGenerator.java
│ │ ├── DTSCoreSpringHolder.java
│ │ ├── store
│ │ ├── help
│ │ │ ├── ActivityHelper.java
│ │ │ └── ActionHelper.java
│ │ └── impl
│ │ │ └── RemoteDTSStore.java
│ │ └── DTS.java
│ └── resources
│ └── dtscore
│ └── spring-dts-core.xml
├── README.md
└── dts-test
└── pom.xml
/README.md:
--------------------------------------------------------------------------------
1 | # dtsopensource
--------------------------------------------------------------------------------
/dts-parent/dts-server-web/src/main/webapp/ok.htm:
--------------------------------------------------------------------------------
1 | OK
2 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/webapp/ok.htm:
--------------------------------------------------------------------------------
1 | OK
2 |
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/src/main/webapp/ok.htm:
--------------------------------------------------------------------------------
1 | OK
2 |
--------------------------------------------------------------------------------
/dts-parent/doc/dts.eap:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adealjason/dtsopensource/HEAD/dts-parent/doc/dts.eap
--------------------------------------------------------------------------------
/dts-parent/doc/分布式事务系统DTS原理及使用.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adealjason/dtsopensource/HEAD/dts-parent/doc/分布式事务系统DTS原理及使用.pptx
--------------------------------------------------------------------------------
/dts-parent/dts-admin/src/main/resources/static/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adealjason/dtsopensource/HEAD/dts-parent/dts-admin/src/main/resources/static/favicon.png
--------------------------------------------------------------------------------
/dts-parent/dts-admin/src/main/resources/static/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adealjason/dtsopensource/HEAD/dts-parent/dts-admin/src/main/resources/static/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/dts-parent/dts-admin/src/main/resources/static/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adealjason/dtsopensource/HEAD/dts-parent/dts-admin/src/main/resources/static/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/dts-parent/dts-admin/src/main/resources/static/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/adealjason/dtsopensource/HEAD/dts-parent/dts-admin/src/main/resources/static/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/dts-parent/dts-admin/src/main/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 | Archetype Created Web Application
7 |
8 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-share/src/main/java/org/github/dtsopensource/server/share/DTSResultCode.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.share;
2 |
3 | /**
4 | * @author ligaofeng 2016年12月2日 下午1:35:45
5 | */
6 | public enum DTSResultCode {
7 |
8 | SUCCESS,
9 |
10 | FAIL;
11 | }
12 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-share/src/main/java/org/github/dtsopensource/server/share/DTSManageType.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.share;
2 |
3 | /**
4 | * dts连接方式
5 | *
6 | * @author ligaofeng 2016年12月1日 上午11:48:54
7 | */
8 | public enum DTSManageType {
9 |
10 | LOCAL,
11 |
12 | REMOTE;
13 | }
14 |
--------------------------------------------------------------------------------
/dts-parent/dts-schedule/src/main/java/org/github/dtsopensource/schedule/IDTSJobTracker.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.schedule;
2 |
3 | /**
4 | * @author ligaofeng 2016年12月14日 上午11:16:05
5 | */
6 | public interface IDTSJobTracker {
7 |
8 | /**
9 | * 提交任务
10 | */
11 | public void submitTask();
12 | }
13 |
--------------------------------------------------------------------------------
/dts-parent/dts-server/src/main/java/org/github/dtsopensource/server/store/hsf/IHSFServerStore.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.store.hsf;
2 |
3 | import org.github.dtsopensource.server.share.store.IDTSStore;
4 |
5 | /**
6 | * @author ligaofeng 2016年12月11日 下午1:02:54
7 | */
8 | public interface IHSFServerStore extends IDTSStore {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/dts-parent/dts-server/src/main/java/org/github/dtsopensource/server/store/http/IHttpServerStore.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.store.http;
2 |
3 | import org.github.dtsopensource.server.share.store.IDTSStore;
4 |
5 | /**
6 | * @author ligaofeng 2016年12月11日 下午1:04:02
7 | */
8 | public interface IHttpServerStore extends IDTSStore {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/protocol/hsf/protocol/IHSFProtocol.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.protocol.hsf.protocol;
2 |
3 | import org.github.dtsopensource.server.share.protocol.IDTSProtocol;
4 |
5 | /**
6 | * @author ligaofeng 2016年12月11日 下午3:18:27
7 | */
8 | public interface IHSFProtocol extends IDTSProtocol {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/dts-parent/dts-schedule/src/main/java/org/github/dtsopensource/schedule/IJobTimerParse.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.schedule;
2 |
3 | /**
4 | * @author ligaofeng 2016年12月14日 上午11:19:05
5 | */
6 | public interface IJobTimerParse {
7 |
8 | /**
9 | * 解析任务是否可以跑
10 | *
11 | * @return
12 | */
13 | public boolean canRun();
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/protocol/http/protocol/IHttpProtocol.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.protocol.http.protocol;
2 |
3 | import org.github.dtsopensource.server.share.protocol.IDTSProtocol;
4 |
5 | /**
6 | * @author ligaofeng 2016年12月11日 下午3:15:15
7 | */
8 | public interface IHttpProtocol extends IDTSProtocol {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/dts-parent/dts-server/src/main/java/org/github/dtsopensource/server/schedule/http/IHttpServerSchedule.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.schedule.http;
2 |
3 | import org.github.dtsopensource.server.share.schedule.IDTSTaskTracker;
4 |
5 | /**
6 | * @author ligaofeng 2016年12月14日 下午2:41:27
7 | */
8 | public interface IHttpServerSchedule extends IDTSTaskTracker {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/dts-parent/dts-admin/src/main/java/org/github/dtsopensource/admin/vo/ActivityRuleVO.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.admin.vo;
2 |
3 | import lombok.Data;
4 |
5 | /**
6 | * @author ligaofeng 2016年12月23日 上午11:56:12
7 | */
8 | @Data
9 | public class ActivityRuleVO {
10 |
11 | private String bizType;
12 |
13 | private String bizTypeName;
14 |
15 | private String app;
16 |
17 | private String appCname;
18 | }
19 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/java/org/github/dtsopensource/local/test/bizService/ITradeFlowService.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.local.test.bizService;
2 |
3 | /**
4 | * 交易流水记录
5 | *
6 | * @author ligaofeng 2016年12月8日 下午9:48:54
7 | */
8 | public interface ITradeFlowService {
9 |
10 | /**
11 | * 登记交易流水
12 | *
13 | * @param flow
14 | */
15 | public void saveTradeFlow(String flow);
16 | }
17 |
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/src/main/java/org/github/dtsopensource/remote/test/bizService/ITradeFlowService.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.remote.test.bizService;
2 |
3 | /**
4 | * 交易流水记录
5 | *
6 | * @author ligaofeng 2016年12月8日 下午9:48:54
7 | */
8 | public interface ITradeFlowService {
9 |
10 | /**
11 | * 登记交易流水
12 | *
13 | * @param flow
14 | */
15 | public void saveTradeFlow(String flow);
16 | }
17 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/annotation/AopHandler.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.annotation;
2 |
3 | import org.aspectj.lang.JoinPoint;
4 |
5 | /**
6 | * @author ligaofeng 2016年12月2日 下午2:53:24
7 | */
8 | public interface AopHandler {
9 |
10 | /**
11 | * @param joinPoint
12 | * @throws Throwable
13 | */
14 | public void handleAop(JoinPoint joinPoint) throws Throwable;
15 | }
16 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-web/src/main/resources/config.properties:
--------------------------------------------------------------------------------
1 | ##druid datasource
2 | druid.jdbc.url = jdbc:mysql://ip:port/dbName
3 | druid.mysql.driver = com.mysql.jdbc.Driver
4 | druid.username = username
5 | druid.password = password
6 | #\u521D\u59CB\u5316\u7EBF\u7A0B\u6C60\u5927\u5C0F
7 | druid.initialSize = 5
8 | #\u7EBF\u7A0B\u6C60\u6700\u5C0F\u7A7A\u95F2
9 | druid.minIdle = 5
10 | #\u8FDE\u63A5\u6C60\u6700\u5927\u53EF\u7528\u8FDE\u63A5\u6570
11 | druid.maxActive = 25
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/dao/ActivityRuleSqlConstance.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.dao;
2 |
3 | /**
4 | * @author ligaofeng 2016年12月17日 下午12:00:42
5 | */
6 | public class ActivityRuleSqlConstance {
7 |
8 | private ActivityRuleSqlConstance() {
9 | }
10 |
11 | public static final String select_dts_activity_by_biztype = "select * from dts_activity_rule where biz_type=? and is_deleted='N'";
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/resources/config.properties:
--------------------------------------------------------------------------------
1 | ##druid datasource
2 | druid.jdbc.url = jdbc:mysql://ip:port/dbName
3 | druid.mysql.driver = com.mysql.jdbc.Driver
4 | druid.username = username
5 | druid.password = password
6 | #\u521D\u59CB\u5316\u7EBF\u7A0B\u6C60\u5927\u5C0F
7 | druid.initialSize = 5
8 | #\u7EBF\u7A0B\u6C60\u6700\u5C0F\u7A7A\u95F2
9 | druid.minIdle = 5
10 | #\u8FDE\u63A5\u6C60\u6700\u5927\u53EF\u7528\u8FDE\u63A5\u6570
11 | druid.maxActive = 25
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/src/main/resources/config.properties:
--------------------------------------------------------------------------------
1 | ##druid datasource
2 | druid.jdbc.url = jdbc:mysql://ip:port/dbName
3 | druid.mysql.driver = com.mysql.jdbc.Driver
4 | druid.username = username
5 | druid.password = password
6 | #\u521D\u59CB\u5316\u7EBF\u7A0B\u6C60\u5927\u5C0F
7 | druid.initialSize = 5
8 | #\u7EBF\u7A0B\u6C60\u6700\u5C0F\u7A7A\u95F2
9 | druid.minIdle = 5
10 | #\u8FDE\u63A5\u6C60\u6700\u5927\u53EF\u7528\u8FDE\u63A5\u6570
11 | druid.maxActive = 25
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/dao/ActivityActionRuleSqlConstance.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.dao;
2 |
3 | /**
4 | * @author ligaofeng 2016年12月17日 下午2:53:47
5 | */
6 | public class ActivityActionRuleSqlConstance {
7 |
8 | private ActivityActionRuleSqlConstance() {
9 | }
10 |
11 | public static final String select_biz_action_by_biz_type = "SELECT * FROM dts_activity_action_rule WHERE biz_type=? AND is_deleted='N'";
12 | }
13 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/protocol/http/protocol/impl/HttpProtoclCallback.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.protocol.http.protocol.impl;
2 |
3 | import java.util.Map;
4 |
5 | /**
6 | * @author ligaofeng 2016年12月12日 下午7:07:00
7 | */
8 | public abstract class HttpProtoclCallback {
9 |
10 | /**
11 | * 设置请求参数
12 | *
13 | * @return
14 | */
15 | public abstract Map buildParams();
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/dts-parent/dts-schedule/src/main/java/org/github/dtsopensource/schedule/IJobRegister.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.schedule;
2 |
3 | /**
4 | * @author ligaofeng 2016年12月14日 上午11:18:13
5 | */
6 | public interface IJobRegister {
7 |
8 | /**
9 | * @return
10 | */
11 | public boolean register();
12 |
13 | /**
14 | *
15 | */
16 | public void stop();
17 |
18 | /**
19 | *
20 | */
21 | public void destroy();
22 | }
23 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-share/src/main/java/org/github/dtsopensource/server/share/util/DTSCoreSystem.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.share.util;
2 |
3 | /**
4 | * @author ligaofeng 2016年11月30日 下午4:57:09
5 | */
6 | public class DTSCoreSystem {
7 |
8 | private DTSCoreSystem() {
9 | }
10 |
11 | public static final String UNDER_WRITE = "_";
12 |
13 | public static final String DOT = ".";
14 |
15 | public static final String COLON = ":";
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/java/org/github/dtsopensource/local/test/application/IPurchaseService.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.local.test.application;
2 |
3 | import org.github.dtsopensource.local.test.PurchaseContext;
4 |
5 | /**
6 | * @author ligaofeng 2016年12月8日 下午8:30:32
7 | */
8 | public interface IPurchaseService {
9 |
10 | /**
11 | * 购买服务
12 | *
13 | * @param context
14 | * @param response
15 | */
16 | public String puchase(PurchaseContext context);
17 | }
18 |
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/src/main/java/org/github/dtsopensource/remote/test/application/IPurchaseService.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.remote.test.application;
2 |
3 | import org.github.dtsopensource.remote.test.PurchaseContext;
4 |
5 | /**
6 | * @author ligaofeng 2016年12月8日 下午8:30:32
7 | */
8 | public interface IPurchaseService {
9 |
10 | /**
11 | * 购买服务
12 | *
13 | * @param context
14 | * @param response
15 | */
16 | public String puchase(PurchaseContext context);
17 | }
18 |
--------------------------------------------------------------------------------
/dts-parent/dts-schedule/src/main/java/org/github/dtsopensource/schedule/IJobNode.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.schedule;
2 |
3 | /**
4 | * @author ligaofeng 2016年12月14日 上午11:16:52
5 | */
6 | public interface IJobNode {
7 |
8 | /**
9 | * 开启节点
10 | *
11 | * @return
12 | */
13 | public boolean startNode();
14 |
15 | /**
16 | * 停止节点
17 | */
18 | public void stopNode();
19 |
20 | /**
21 | * 销毁节点
22 | */
23 | public void destroyNode();
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-share/src/main/java/org/github/dtsopensource/server/share/protocol/IDTSProtocol.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.share.protocol;
2 |
3 | import org.github.dtsopensource.server.share.exception.DTSBizException;
4 |
5 | /**
6 | * DTS 连接协议
7 | *
8 | * @author ligaofeng 2016年12月11日 下午12:50:26
9 | */
10 | public interface IDTSProtocol {
11 |
12 | /**
13 | * 获取连接
14 | *
15 | * @throws DTSBizException
16 | */
17 | public void getConnection() throws DTSBizException;
18 | }
19 |
--------------------------------------------------------------------------------
/dts-parent/dts-admin/src/main/resources/static/js/npm.js:
--------------------------------------------------------------------------------
1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
2 | require('../../js/transition.js')
3 | require('../../js/alert.js')
4 | require('../../js/button.js')
5 | require('../../js/carousel.js')
6 | require('../../js/collapse.js')
7 | require('../../js/dropdown.js')
8 | require('../../js/modal.js')
9 | require('../../js/tooltip.js')
10 | require('../../js/popover.js')
11 | require('../../js/scrollspy.js')
12 | require('../../js/tab.js')
13 | require('../../js/affix.js')
--------------------------------------------------------------------------------
/dts-parent/dts-server-share/src/main/java/org/github/dtsopensource/server/share/schedule/IDTSTaskTracker.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.share.schedule;
2 |
3 | import org.github.dtsopensource.server.share.exception.DTSBizException;
4 |
5 | /**
6 | * @author ligaofeng 2016年12月14日 上午11:14:33
7 | */
8 | public interface IDTSTaskTracker {
9 |
10 | /**
11 | * 执行任务
12 | *
13 | * @param taskTrackerContext
14 | * @throws DTSBizException
15 | */
16 | public void executeTask(TaskTrackerContext taskTrackerContext) throws DTSBizException;
17 | }
18 |
--------------------------------------------------------------------------------
/dts-parent/README.md:
--------------------------------------------------------------------------------
1 | ##1.工程说明
2 | 本工程提供三个war包如下:
3 | dts-server-web.war:dts-server端部署war
4 | dts-local-example.war:local模式测试war
5 | dts-remote-example.war:remote模式测试war
6 | 本工程提供三个jar包如下:
7 | dts-core.jar:提供核心的dts功能,嵌入业务系统使用
8 | dts-schedule.jar:提供核心的事务恢复功能,嵌入业务系统使用
9 | dts-server-share.jar:内部使用jar,业务系统可以不关注
10 | ##2.系统搭建
11 | 1)数据库初始化,执行init.sql文件创建相应的数据库
12 | 2)数据初始化,执行init.data文件初始化相应表数据
13 | ##3.创建测试日志目录
14 | mkdir /alidata1/admin/dtslog
15 | ##4.测试连接:
16 | http://ip:port/product/purchase?productName=爆炒牛肚&orderAmount=23¤tAmount=50
17 |
18 | ###5.开发计划
19 | 1.新增dts-admin目录,采用spring-boot完成
--------------------------------------------------------------------------------
/dts-parent/dts-server-share/src/main/java/org/github/dtsopensource/server/share/protocol/ProtocolMethod.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.share.protocol;
2 |
3 | /**
4 | * @author ligaofeng 2016年12月12日 下午1:06:24
5 | */
6 | public enum ProtocolMethod {
7 | //store
8 | openTransaction,
9 |
10 | getAndCreateAction,
11 |
12 | commitActivity,
13 |
14 | rollbackActivity,
15 |
16 | updateAction,
17 |
18 | getActionEntities,
19 |
20 | //rule
21 | getBizTypeRule,
22 |
23 | checkBizType,
24 |
25 | //schedule
26 | requestSchedule,
27 |
28 | unkonwn;
29 | }
30 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-share/src/main/java/org/github/dtsopensource/server/share/IDTS.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.share;
2 |
3 | import java.util.List;
4 |
5 | import org.github.dtsopensource.server.share.store.entity.ActionEntity;
6 |
7 | /**
8 | * 所有DTS抽象的公共父接口
9 | * 子接口有:IDTSStore(负责二阶交易)、IDTSSchedule(负责二阶事务回滚等任务)
10 | *
11 | * @author ligaofeng 2016年12月16日 上午11:03:08
12 | */
13 | public interface IDTS {
14 |
15 | /**
16 | * 获取指定业务活动的action
17 | *
18 | * @param activityId
19 | * @return
20 | */
21 | public ResultBase> getActionEntities(String activityId);
22 | }
23 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-share/src/main/java/org/github/dtsopensource/server/share/protocol/ProtocolConstance.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.share.protocol;
2 |
3 | /**
4 | * @author ligaofeng 2016年12月12日 下午11:57:59
5 | */
6 | public class ProtocolConstance {
7 |
8 | private ProtocolConstance() {
9 | }
10 |
11 | public static final String paramObject = "paramObject";
12 |
13 | public static final String requestStoreOperation = "requestStoreOperation";
14 |
15 | public static final String resultObject = "resultObject";
16 |
17 | public static final String jsonMap = "jsonMap";
18 | }
19 |
--------------------------------------------------------------------------------
/dts-parent/dts-test/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | org.github.dtsopensource
8 | dts-parent
9 | 1.0.0-SNAPSHOT
10 |
11 |
12 | dts-test
13 |
14 |
15 | com.alibaba
16 | druid
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/java/org/github/dtsopensource/local/test/dao/dataobject/DtsTestDO.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.local.test.dao.dataobject;
2 |
3 | public class DtsTestDO {
4 | private String name;
5 |
6 | private String value;
7 |
8 | public String getName() {
9 | return name;
10 | }
11 |
12 | public void setName(String name) {
13 | this.name = name == null ? null : name.trim();
14 | }
15 |
16 | public String getValue() {
17 | return value;
18 | }
19 |
20 | public void setValue(String value) {
21 | this.value = value == null ? null : value.trim();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/src/main/java/org/github/dtsopensource/remote/test/dao/dataobject/DtsTestDO.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.remote.test.dao.dataobject;
2 |
3 | public class DtsTestDO {
4 | private String name;
5 |
6 | private String value;
7 |
8 | public String getName() {
9 | return name;
10 | }
11 |
12 | public void setName(String name) {
13 | this.name = name == null ? null : name.trim();
14 | }
15 |
16 | public String getValue() {
17 | return value;
18 | }
19 |
20 | public void setValue(String value) {
21 | this.value = value == null ? null : value.trim();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/java/org/github/dtsopensource/local/test/PurchaseContext.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.local.test;
2 |
3 | import java.io.Serializable;
4 | import java.math.BigDecimal;
5 |
6 | import lombok.Data;
7 |
8 | /**
9 | * @author ligaofeng 2016年12月8日 下午8:32:05
10 | */
11 | @Data
12 | public class PurchaseContext implements Serializable {
13 |
14 | private static final long serialVersionUID = -5005501890585728538L;
15 |
16 | //商品名称
17 | private String productName;
18 |
19 | //商品价格
20 | private BigDecimal orderAmount;
21 |
22 | //账户余额
23 | private BigDecimal currentAmount;
24 | }
25 |
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/src/main/java/org/github/dtsopensource/remote/test/PurchaseContext.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.remote.test;
2 |
3 | import java.io.Serializable;
4 | import java.math.BigDecimal;
5 |
6 | import lombok.Data;
7 |
8 | /**
9 | * @author ligaofeng 2016年12月8日 下午8:32:05
10 | */
11 | @Data
12 | public class PurchaseContext implements Serializable {
13 |
14 | private static final long serialVersionUID = -5005501890585728538L;
15 |
16 | //商品名称
17 | private String productName;
18 |
19 | //商品价格
20 | private BigDecimal orderAmount;
21 |
22 | //账户余额
23 | private BigDecimal currentAmount;
24 | }
25 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/dao/dataobject/DtsActivityRuleDO.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.dao.dataobject;
2 |
3 | import java.util.Date;
4 |
5 | import lombok.Data;
6 |
7 | /**
8 | * @author ligaofeng 2016年12月16日 下午4:17:23
9 | */
10 | @Data
11 | public class DtsActivityRuleDO {
12 |
13 | private String bizType;
14 |
15 | private String bizTypeName;
16 |
17 | private String app;
18 |
19 | private String appCname;
20 |
21 | private String creator;
22 |
23 | private String modifier;
24 |
25 | private String isDeleted;
26 |
27 | private Date gmtCreated;
28 |
29 | private Date gmtModified;
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/dts-parent/dts-server/src/main/resources/dtsserver/spring-dts-activity_rule.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-web/src/main/webapp/WEB-INF/servlet-context.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/webapp/WEB-INF/servlet-context.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/src/main/webapp/WEB-INF/servlet-context.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/dao/dataobject/DtsActivityActionRuleDO.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.dao.dataobject;
2 |
3 | import java.util.Date;
4 |
5 | import lombok.Data;
6 |
7 | /**
8 | * @author ligaofeng 2016年12月17日 下午1:18:14
9 | */
10 | @Data
11 | public class DtsActivityActionRuleDO {
12 |
13 | private String bizAction;
14 |
15 | private String bizActionName;
16 |
17 | private String bizType;
18 |
19 | private String service;
20 |
21 | private String clazzName;
22 |
23 | private String transRecoveryId;
24 |
25 | private String isDeleted;
26 |
27 | private Date gmtCreated;
28 |
29 | private Date gmtModified;
30 |
31 | private String creator;
32 |
33 | private String modifier;
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/java/org/github/dtsopensource/local/test/dao/mapper/DtsTestDOMapper.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.local.test.dao.mapper;
2 |
3 | import java.util.List;
4 |
5 | import org.apache.ibatis.annotations.Param;
6 | import org.github.dtsopensource.local.test.dao.dataobject.DtsTestDO;
7 | import org.github.dtsopensource.local.test.dao.dataobject.DtsTestDOExample;
8 |
9 | public interface DtsTestDOMapper {
10 | int insert(DtsTestDO record);
11 |
12 | int insertSelective(DtsTestDO record);
13 |
14 | List selectByExample(DtsTestDOExample example);
15 |
16 | int updateByExampleSelective(@Param("record") DtsTestDO record, @Param("example") DtsTestDOExample example);
17 |
18 | int updateByExample(@Param("record") DtsTestDO record, @Param("example") DtsTestDOExample example);
19 | }
20 |
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/src/main/java/org/github/dtsopensource/remote/test/dao/mapper/DtsTestDOMapper.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.remote.test.dao.mapper;
2 |
3 | import java.util.List;
4 |
5 | import org.apache.ibatis.annotations.Param;
6 | import org.github.dtsopensource.remote.test.dao.dataobject.DtsTestDO;
7 | import org.github.dtsopensource.remote.test.dao.dataobject.DtsTestDOExample;
8 |
9 | public interface DtsTestDOMapper {
10 | int insert(DtsTestDO record);
11 |
12 | int insertSelective(DtsTestDO record);
13 |
14 | List selectByExample(DtsTestDOExample example);
15 |
16 | int updateByExampleSelective(@Param("record") DtsTestDO record, @Param("example") DtsTestDOExample example);
17 |
18 | int updateByExample(@Param("record") DtsTestDO record, @Param("example") DtsTestDOExample example);
19 | }
20 |
--------------------------------------------------------------------------------
/dts-parent/dts-admin/src/main/resources/spring/dts-admin-application.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/dts-parent/dts-admin/src/main/resources/static/js/plugin/bootstraptable/bootstrap-table-zh-CN.min.js:
--------------------------------------------------------------------------------
1 | /*
2 | * bootstrap-table - v1.11.0 - 2016-07-02
3 | * https://github.com/wenzhixin/bootstrap-table
4 | * Copyright (c) 2016 zhixin wen
5 | * Licensed MIT License
6 | */
7 | !function(a){"use strict";a.fn.bootstrapTable.locales["zh-CN"]={formatLoadingMessage:function(){return"正在努力地加载数据中,请稍候……"},formatRecordsPerPage:function(a){return"每页显示 "+a+" 条记录"},formatShowingRows:function(a,b,c){return"显示第 "+a+" 到第 "+b+" 条记录,总共 "+c+" 条记录"},formatSearch:function(){return"搜索"},formatNoMatches:function(){return"没有找到匹配的记录"},formatPaginationSwitch:function(){return"隐藏/显示分页"},formatRefresh:function(){return"刷新"},formatToggle:function(){return"切换"},formatColumns:function(){return"列"},formatExport:function(){return"导出数据"},formatClearFilters:function(){return"清空过滤"}},a.extend(a.fn.bootstrapTable.defaults,a.fn.bootstrapTable.locales["zh-CN"])}(jQuery);
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/rule/help/ActivityRuleHelper.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.rule.help;
2 |
3 | import org.github.dtsopensource.core.dao.dataobject.DtsActivityRuleDO;
4 | import org.github.dtsopensource.server.share.rule.entity.ActivityRuleEntity;
5 |
6 | /**
7 | * @author ligaofeng 2016年12月17日 下午2:20:36
8 | */
9 | public class ActivityRuleHelper {
10 |
11 | private ActivityRuleHelper() {
12 | }
13 |
14 | /**
15 | * @param activityRuleDO
16 | * @return
17 | */
18 | public static ActivityRuleEntity toActivityRuleEntity(DtsActivityRuleDO activityRuleDO) {
19 | return new ActivityRuleEntity.Builder(activityRuleDO.getBizType()).setApp(activityRuleDO.getApp())
20 | .setAppCname(activityRuleDO.getAppCname()).setBizTypeName(activityRuleDO.getBizTypeName()).build();
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-share/src/main/java/org/github/dtsopensource/server/share/rule/IDTSRule.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.share.rule;
2 |
3 | import org.github.dtsopensource.server.share.ResultBase;
4 | import org.github.dtsopensource.server.share.rule.entity.ActivityRuleEntity;
5 |
6 | /**
7 | * 业务规则类
8 | * 处理业务bizType的配置管理
9 | * 辅助IDTS完成交易及事务恢复的接口
10 | *
11 | * @author ligaofeng 2016年12月16日 下午2:55:44
12 | */
13 | public interface IDTSRule {
14 |
15 | /**
16 | * 校验业务规则
17 | *
18 | * @param bizType
19 | * @return
20 | */
21 | public ResultBase checkBizType(String bizType);
22 |
23 | /**
24 | * 获取该业务规则的配置信息
25 | * 返回业务action的配置
26 | *
27 | * @param bizType
28 | * @return
29 | */
30 | public ResultBase getBizTypeRule(String bizType);
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/java/org/github/dtsopensource/local/test/GenerateId.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.local.test;
2 |
3 | import java.util.UUID;
4 |
5 | /**
6 | * @author ligaofeng 2016年12月8日 下午9:02:58
7 | */
8 | public class GenerateId {
9 |
10 | private GenerateId() {
11 | }
12 |
13 | /**
14 | * @return
15 | */
16 | public static String generateOrderId() {
17 | return "order_" + UUID.randomUUID().toString().replaceAll("-", "");
18 | }
19 |
20 | /**
21 | * @return
22 | */
23 | public static String generatePaymentId() {
24 | return "payment_" + UUID.randomUUID().toString().replaceAll("-", "");
25 | }
26 |
27 | /**
28 | * @return
29 | */
30 | public static String generateFlowId() {
31 | return "flow_" + UUID.randomUUID().toString().replaceAll("-", "");
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/src/main/java/org/github/dtsopensource/remote/test/GenerateId.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.remote.test;
2 |
3 | import java.util.UUID;
4 |
5 | /**
6 | * @author ligaofeng 2016年12月8日 下午9:02:58
7 | */
8 | public class GenerateId {
9 |
10 | private GenerateId() {
11 | }
12 |
13 | /**
14 | * @return
15 | */
16 | public static String generateOrderId() {
17 | return "order_" + UUID.randomUUID().toString().replaceAll("-", "");
18 | }
19 |
20 | /**
21 | * @return
22 | */
23 | public static String generatePaymentId() {
24 | return "payment_" + UUID.randomUUID().toString().replaceAll("-", "");
25 | }
26 |
27 | /**
28 | * @return
29 | */
30 | public static String generateFlowId() {
31 | return "flow_" + UUID.randomUUID().toString().replaceAll("-", "");
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/dts-parent/dts-admin/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | ##druid datasource
2 | druid.jdbc.url = jdbc:mysql://ip:port/dts_server
3 | druid.mysql.driver = com.mysql.jdbc.Driver
4 | druid.username = username
5 | druid.password = password
6 | #初始化连接池
7 | druid.initialSize = 5
8 | #最小空闲
9 | druid.minIdle = 5
10 | #最大容量
11 | druid.maxActive = 25
12 |
13 | ##http encoding
14 | spring.http.encoding.charset = UTF-8
15 | spring.http.encoding.enabled = true
16 |
17 | ##velocity templates
18 | spring.velocity.enabled = true
19 | spring.velocity.cache = false
20 | spring.velocity.properties.input.encoding = UTF-8
21 | spring.velocity.properties.output.encoding = UTF-8
22 | spring.velocity.check-template-location = true
23 | spring.velocity.charset = UTF-8
24 | spring.velocity.content-type = text/html
25 | spring.velocity.prefix =
26 | spring.velocity.suffix = .vm
27 | spring.velocity.resource-loader-path = classpath:/templates/
28 |
--------------------------------------------------------------------------------
/dts-parent/dts-server/src/main/resources/dtsserver/spring-dts-hsf-provider.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/dts-parent/dts-admin/src/main/java/org/github/dtsopensource/admin/service/IActivityRuleService.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.admin.service;
2 |
3 | import java.util.List;
4 |
5 | import org.github.dtsopensource.admin.exception.DTSAdminException;
6 | import org.github.dtsopensource.server.share.rule.entity.ActivityRuleEntity;
7 |
8 | /**
9 | * @author ligaofeng 2016年12月23日 下午1:33:27
10 | */
11 | public interface IActivityRuleService {
12 |
13 | /**
14 | * 保存业务活动
15 | *
16 | * @param activityRuleEntity
17 | * @throws DTSAdminException
18 | */
19 | public void saveActivityRule(ActivityRuleEntity activityRuleEntity) throws DTSAdminException;
20 |
21 | /**
22 | * 查询业务活动
23 | *
24 | * @param activityRuleEntity
25 | * @return
26 | * @throws DTSAdminException
27 | */
28 | public List getActivityRule(ActivityRuleEntity activityRuleEntity) throws DTSAdminException;
29 | }
30 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/ITwoPhaseCommit.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core;
2 |
3 | import org.github.dtsopensource.server.share.DTSContext;
4 | import org.github.dtsopensource.server.share.exception.DTSBizException;
5 |
6 | /**
7 | * @author ligaofeng 2016年12月16日 下午3:47:39
8 | */
9 | public interface ITwoPhaseCommit {
10 |
11 | /**
12 | * 一阶准备
13 | *
14 | * @param dtsContext
15 | * @throws DTSBizException
16 | */
17 | public void pre(DTSContext dtsContext) throws DTSBizException;
18 |
19 | /**
20 | * 二阶提交
21 | *
22 | * @param dtsContext
23 | * @throws DTSBizException
24 | */
25 | public void commit(DTSContext dtsContext) throws DTSBizException;
26 |
27 | /**
28 | * 错误回滚
29 | *
30 | * @param dtsContext
31 | * @throws DTSBizException
32 | */
33 | public void rollback(DTSContext dtsContext) throws DTSBizException;
34 | }
35 |
--------------------------------------------------------------------------------
/dts-parent/dts-admin/src/main/java/org/github/dtsopensource/admin/application/IActicityRuleApplication.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.admin.application;
2 |
3 | import java.util.List;
4 |
5 | import org.github.dtsopensource.admin.exception.DTSAdminException;
6 | import org.github.dtsopensource.server.share.rule.entity.ActivityRuleEntity;
7 |
8 | /**
9 | * @author ligaofeng 2016年12月23日 下午2:01:22
10 | */
11 | public interface IActicityRuleApplication {
12 |
13 | /**
14 | * 创建业务活动
15 | *
16 | * @param activityRuleEntity
17 | * @throws DTSAdminException
18 | */
19 | public void addActivityRule(ActivityRuleEntity activityRuleEntity) throws DTSAdminException;
20 |
21 | /**
22 | * 查询业务活动
23 | *
24 | * @param activityRuleEntity
25 | * @return
26 | * @throws DTSAdminException
27 | */
28 | public List queryActivityRule(ActivityRuleEntity activityRuleEntity) throws DTSAdminException;
29 | }
30 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/java/org/github/dtsopensource/local/test/bizService/AbstractPaymentTrade.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.local.test.bizService;
2 |
3 | import org.github.dtsopensource.core.ITwoPhaseCommit;
4 | import org.github.dtsopensource.server.share.DTSContext;
5 | import org.github.dtsopensource.server.share.exception.DTSBizException;
6 |
7 | /**
8 | * 支付交易
9 | *
10 | * @author ligaofeng 2016年12月8日 下午8:37:35
11 | */
12 | public abstract class AbstractPaymentTrade implements ITwoPhaseCommit, IPaymentTrade {
13 |
14 | @Override
15 | public void pre(DTSContext dtsContext) throws DTSBizException {
16 | this.freeze(dtsContext);
17 | }
18 |
19 | @Override
20 | public void commit(DTSContext dtsContext) throws DTSBizException {
21 | this.deduct(dtsContext);
22 | }
23 |
24 | @Override
25 | public void rollback(DTSContext dtsContext) throws DTSBizException {
26 | this.unfreeze(dtsContext);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/src/main/java/org/github/dtsopensource/remote/test/bizService/AbstractPaymentTrade.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.remote.test.bizService;
2 |
3 | import org.github.dtsopensource.core.ITwoPhaseCommit;
4 | import org.github.dtsopensource.server.share.DTSContext;
5 | import org.github.dtsopensource.server.share.exception.DTSBizException;
6 |
7 | /**
8 | * 支付交易
9 | *
10 | * @author ligaofeng 2016年12月8日 下午8:37:35
11 | */
12 | public abstract class AbstractPaymentTrade implements ITwoPhaseCommit, IPaymentTrade {
13 |
14 | @Override
15 | public void pre(DTSContext dtsContext) throws DTSBizException {
16 | this.freeze(dtsContext);
17 | }
18 |
19 | @Override
20 | public void commit(DTSContext dtsContext) throws DTSBizException {
21 | this.deduct(dtsContext);
22 | }
23 |
24 | @Override
25 | public void rollback(DTSContext dtsContext) throws DTSBizException {
26 | this.unfreeze(dtsContext);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/java/org/github/dtsopensource/local/test/bizService/AbstraceOrderTrade.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.local.test.bizService;
2 |
3 | import org.github.dtsopensource.core.ITwoPhaseCommit;
4 | import org.github.dtsopensource.server.share.DTSContext;
5 | import org.github.dtsopensource.server.share.exception.DTSBizException;
6 |
7 | /**
8 | * 订单交易
9 | *
10 | * @author ligaofeng 2016年12月8日 下午8:35:55
11 | */
12 | public abstract class AbstraceOrderTrade implements ITwoPhaseCommit, IOrderTrade {
13 |
14 | @Override
15 | public void pre(DTSContext dtsContext) throws DTSBizException {
16 | this.createOrder(dtsContext);
17 | }
18 |
19 | @Override
20 | public void commit(DTSContext dtsContext) throws DTSBizException {
21 | this.submitOrder(dtsContext);
22 | }
23 |
24 | @Override
25 | public void rollback(DTSContext dtsContext) throws DTSBizException {
26 | this.cancleOrder(dtsContext);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/dts-parent/dts-server/src/main/java/org/github/dtsopensource/server/rule/HttpServerRuleProtocol.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.rule;
2 |
3 | import javax.annotation.Resource;
4 |
5 | import org.github.dtsopensource.server.share.ResultBase;
6 | import org.github.dtsopensource.server.share.rule.IDTSRule;
7 | import org.github.dtsopensource.server.share.rule.entity.ActivityRuleEntity;
8 | import org.springframework.stereotype.Service;
9 |
10 | /**
11 | * @author ligaofeng 2016年12月16日 下午3:49:47
12 | */
13 | @Service
14 | public class HttpServerRuleProtocol implements IDTSRule {
15 |
16 | @Resource
17 | private IDTSRule localDTSRule;
18 |
19 | @Override
20 | public ResultBase checkBizType(String bizType) {
21 | return localDTSRule.checkBizType(bizType);
22 | }
23 |
24 | @Override
25 | public ResultBase getBizTypeRule(String bizType) {
26 | return localDTSRule.getBizTypeRule(bizType);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/src/main/java/org/github/dtsopensource/remote/test/bizService/AbstraceOrderTrade.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.remote.test.bizService;
2 |
3 | import org.github.dtsopensource.core.ITwoPhaseCommit;
4 | import org.github.dtsopensource.server.share.DTSContext;
5 | import org.github.dtsopensource.server.share.exception.DTSBizException;
6 |
7 | /**
8 | * 订单交易
9 | *
10 | * @author ligaofeng 2016年12月8日 下午8:35:55
11 | */
12 | public abstract class AbstraceOrderTrade implements ITwoPhaseCommit, IOrderTrade {
13 |
14 | @Override
15 | public void pre(DTSContext dtsContext) throws DTSBizException {
16 | this.createOrder(dtsContext);
17 | }
18 |
19 | @Override
20 | public void commit(DTSContext dtsContext) throws DTSBizException {
21 | this.submitOrder(dtsContext);
22 | }
23 |
24 | @Override
25 | public void rollback(DTSContext dtsContext) throws DTSBizException {
26 | this.cancleOrder(dtsContext);
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/java/org/github/dtsopensource/local/test/bizService/IPaymentTrade.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.local.test.bizService;
2 |
3 | import org.github.dtsopensource.server.share.DTSContext;
4 | import org.github.dtsopensource.server.share.exception.DTSBizException;
5 |
6 | /**
7 | * @author ligaofeng 2016年12月8日 下午9:42:20
8 | */
9 | public interface IPaymentTrade {
10 |
11 | /**
12 | * 冻结
13 | *
14 | * @param dtsContext
15 | * @throws DTSBizException
16 | */
17 | public void freeze(DTSContext dtsContext) throws DTSBizException;
18 |
19 | /**
20 | * 解冻并减少扣除
21 | *
22 | * @param dtsContext
23 | * @throws DTSBizException
24 | */
25 | public void deduct(DTSContext dtsContext) throws DTSBizException;
26 |
27 | /**
28 | * 解冻
29 | *
30 | * @param dtsContext
31 | * @throws DTSBizException
32 | */
33 | public void unfreeze(DTSContext dtsContext) throws DTSBizException;
34 | }
35 |
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/src/main/java/org/github/dtsopensource/remote/test/bizService/IPaymentTrade.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.remote.test.bizService;
2 |
3 | import org.github.dtsopensource.server.share.DTSContext;
4 | import org.github.dtsopensource.server.share.exception.DTSBizException;
5 |
6 | /**
7 | * @author ligaofeng 2016年12月8日 下午9:42:20
8 | */
9 | public interface IPaymentTrade {
10 |
11 | /**
12 | * 冻结
13 | *
14 | * @param dtsContext
15 | * @throws DTSBizException
16 | */
17 | public void freeze(DTSContext dtsContext) throws DTSBizException;
18 |
19 | /**
20 | * 解冻并减少扣除
21 | *
22 | * @param dtsContext
23 | * @throws DTSBizException
24 | */
25 | public void deduct(DTSContext dtsContext) throws DTSBizException;
26 |
27 | /**
28 | * 解冻
29 | *
30 | * @param dtsContext
31 | * @throws DTSBizException
32 | */
33 | public void unfreeze(DTSContext dtsContext) throws DTSBizException;
34 | }
35 |
--------------------------------------------------------------------------------
/dts-parent/dts-schedule/src/main/java/org/github/dtsopensource/schedule/taskTracker/LocalTaskTrackerDelegate.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.schedule.taskTracker;
2 |
3 | import org.github.dtsopensource.server.share.exception.DTSBizException;
4 | import org.github.dtsopensource.server.share.schedule.IDTSTaskTracker;
5 | import org.github.dtsopensource.server.share.schedule.TaskTrackerContext;
6 |
7 | /**
8 | * @author ligaofeng 2016年12月14日 上午11:28:57
9 | */
10 | public class LocalTaskTrackerDelegate implements IDTSTaskTracker {
11 |
12 | private final IDTSTaskTracker taskTracker;
13 |
14 | /**
15 | * @param taskTracker
16 | * @param taskTrackerContext
17 | */
18 | public LocalTaskTrackerDelegate(IDTSTaskTracker taskTracker) {
19 | this.taskTracker = taskTracker;
20 | }
21 |
22 | @Override
23 | public void executeTask(TaskTrackerContext taskTrackerContext) throws DTSBizException {
24 | taskTracker.executeTask(taskTrackerContext);
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/resources/spring/spring-biz-persistence.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/java/org/github/dtsopensource/local/test/bizService/IOrderTrade.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.local.test.bizService;
2 |
3 | import org.github.dtsopensource.server.share.DTSContext;
4 | import org.github.dtsopensource.server.share.exception.DTSBizException;
5 |
6 | /**
7 | * @author ligaofeng 2016年12月8日 下午9:40:31
8 | */
9 | public interface IOrderTrade {
10 |
11 | /**
12 | * 创建一笔新订单
13 | *
14 | * @param dtsContext
15 | * @throws DTSBizException
16 | */
17 | public void createOrder(DTSContext dtsContext) throws DTSBizException;
18 |
19 | /**
20 | * 订单处理成功
21 | *
22 | * @param dtsContext
23 | * @throws DTSBizException
24 | */
25 | public void submitOrder(DTSContext dtsContext) throws DTSBizException;
26 |
27 | /**
28 | * 取消订单
29 | *
30 | * @param dtsContext
31 | * @throws DTSBizException
32 | */
33 | public void cancleOrder(DTSContext dtsContext) throws DTSBizException;
34 | }
35 |
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/src/main/java/org/github/dtsopensource/remote/test/bizService/IOrderTrade.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.remote.test.bizService;
2 |
3 | import org.github.dtsopensource.server.share.DTSContext;
4 | import org.github.dtsopensource.server.share.exception.DTSBizException;
5 |
6 | /**
7 | * @author ligaofeng 2016年12月8日 下午9:40:31
8 | */
9 | public interface IOrderTrade {
10 |
11 | /**
12 | * 创建一笔新订单
13 | *
14 | * @param dtsContext
15 | * @throws DTSBizException
16 | */
17 | public void createOrder(DTSContext dtsContext) throws DTSBizException;
18 |
19 | /**
20 | * 订单处理成功
21 | *
22 | * @param dtsContext
23 | * @throws DTSBizException
24 | */
25 | public void submitOrder(DTSContext dtsContext) throws DTSBizException;
26 |
27 | /**
28 | * 取消订单
29 | *
30 | * @param dtsContext
31 | * @throws DTSBizException
32 | */
33 | public void cancleOrder(DTSContext dtsContext) throws DTSBizException;
34 | }
35 |
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/src/main/resources/spring/spring-biz-persistence.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/dao/ActionSqlConstance.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.dao;
2 |
3 | /**
4 | * @author ligaofeng 2016年12月17日 上午11:21:08
5 | */
6 | public class ActionSqlConstance {
7 |
8 | private ActionSqlConstance() {
9 | }
10 |
11 | public static final String insert_dts_action = "INSERT INTO dts_action(activity_id, action_id, service,clazz_name, action, version, protocol, status, context,is_deleted,gmt_created,gmt_modified,creator,modifier)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
12 |
13 | public static final String select_dts_action_by_activity_id = "select * from dts_action where activity_id=? and is_deleted='N'";
14 |
15 | public static final String count_dts_action_by_actionid = "select count(*) from dts_action where action_id=? and is_deleted='N'";
16 |
17 | public static final String commit_rollback_action_by_activity_id = "update dts_action set status=?,context=?,gmt_modified=? where action_id=? and activity_id=?";
18 | }
19 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/dao/ActivitySqlConstance.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.dao;
2 |
3 | /**
4 | * @author ligaofeng 2016年12月16日 下午8:30:11
5 | */
6 | public class ActivitySqlConstance {
7 |
8 | private ActivitySqlConstance() {
9 | }
10 |
11 | public static final String insert_dts_activity = "INSERT INTO dts_activity(activity_id,app,biz_type,context,status,is_deleted,gmt_created,gmt_modified,creator,modifier) VALUES(?,?,?,?,?,?,?,?,?,?)";
12 |
13 | //查询二阶hang住的业务活动
14 | public static final String select_hang_avtivity = "select * from dts_activity where app=? and status=? and gmt_created<=? and is_deleted='N'";
15 |
16 | public static final String select_dts_activity_by_activity_id = "select * from dts_activity where activity_id=? and is_deleted='N'";
17 |
18 | public static final String commit_rollback_activity_by_activity_id = "update dts_activity set status=?,gmt_modified=? where activity_id=? and status=?";
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/java/org/github/dtsopensource/local/test/bizService/impl/TradeFlowService.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.local.test.bizService.impl;
2 |
3 | import javax.annotation.Resource;
4 |
5 | import org.github.dtsopensource.local.test.GenerateId;
6 | import org.github.dtsopensource.local.test.bizService.ITradeFlowService;
7 | import org.github.dtsopensource.local.test.dao.dataobject.DtsTestDO;
8 | import org.github.dtsopensource.local.test.dao.mapper.DtsTestDOMapper;
9 | import org.springframework.stereotype.Service;
10 |
11 | /**
12 | * @author ligaofeng 2016年12月8日 下午9:50:02
13 | */
14 | @Service
15 | public class TradeFlowService implements ITradeFlowService {
16 |
17 | @Resource
18 | private DtsTestDOMapper dtsTestDOMapper;
19 |
20 | @Override
21 | public void saveTradeFlow(String flow) {
22 | DtsTestDO dtsTestDO = new DtsTestDO();
23 | dtsTestDO.setName(GenerateId.generateFlowId());
24 | dtsTestDO.setValue(flow);
25 | dtsTestDOMapper.insert(dtsTestDO);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/src/main/java/org/github/dtsopensource/remote/test/bizService/impl/TradeFlowService.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.remote.test.bizService.impl;
2 |
3 | import javax.annotation.Resource;
4 |
5 | import org.github.dtsopensource.remote.test.GenerateId;
6 | import org.github.dtsopensource.remote.test.bizService.ITradeFlowService;
7 | import org.github.dtsopensource.remote.test.dao.dataobject.DtsTestDO;
8 | import org.github.dtsopensource.remote.test.dao.mapper.DtsTestDOMapper;
9 | import org.springframework.stereotype.Service;
10 |
11 | /**
12 | * @author ligaofeng 2016年12月8日 下午9:50:02
13 | */
14 | @Service
15 | public class TradeFlowService implements ITradeFlowService {
16 |
17 | @Resource
18 | private DtsTestDOMapper dtsTestDOMapper;
19 |
20 | @Override
21 | public void saveTradeFlow(String flow) {
22 | DtsTestDO dtsTestDO = new DtsTestDO();
23 | dtsTestDO.setName(GenerateId.generateFlowId());
24 | dtsTestDO.setValue(flow);
25 | dtsTestDOMapper.insert(dtsTestDO);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/java/org/github/dtsopensource/local/test/bizService/ITradeLog.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.local.test.bizService;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * @author ligaofeng 2016年12月9日 下午3:09:59
7 | */
8 | public interface ITradeLog {
9 |
10 | /**
11 | * @param operation
12 | * @param tradeLog
13 | */
14 | public void saveTradeLog(String operation, String tradeLog);
15 |
16 | /**
17 | * @param activityId
18 | * @param operation
19 | * @param tradeLog
20 | */
21 | public void saveTradeLog(String activityId, String operation, String tradeLog);
22 |
23 | /**
24 | * 不重复记录
25 | *
26 | * @param activityId
27 | * @param operation
28 | * @param tradeLog
29 | */
30 | public void saveTradeLogIfPossible(String activityId, String operation, String tradeLog);
31 |
32 | /**
33 | * 获取最新日志
34 | *
35 | * @param activityId
36 | * @return
37 | */
38 | public List getNewLog(String activityId);
39 | }
40 |
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/src/main/java/org/github/dtsopensource/remote/test/bizService/ITradeLog.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.remote.test.bizService;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * @author ligaofeng 2016年12月9日 下午3:09:59
7 | */
8 | public interface ITradeLog {
9 |
10 | /**
11 | * @param operation
12 | * @param tradeLog
13 | */
14 | public void saveTradeLog(String operation, String tradeLog);
15 |
16 | /**
17 | * @param acitvityId
18 | * @param operation
19 | * @param tradeLog
20 | */
21 | public void saveTradeLog(String acitvityId, String operation, String tradeLog);
22 |
23 | /**
24 | * 不重复记录
25 | *
26 | * @param activityId
27 | * @param operation
28 | * @param tradeLog
29 | */
30 | public void saveTradeLogIfPossible(String activityId, String operation, String tradeLog);
31 |
32 | /**
33 | * 获取最新日志
34 | *
35 | * @param activityId
36 | * @return
37 | */
38 | public List getNewLog(String activityId);
39 | }
40 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/rule/help/ActivityActionRuleHelper.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.rule.help;
2 |
3 | import org.github.dtsopensource.core.dao.dataobject.DtsActivityActionRuleDO;
4 | import org.github.dtsopensource.server.share.rule.entity.ActivityActionRuleEntity;
5 |
6 | /**
7 | * @author ligaofeng 2016年12月17日 下午2:59:23
8 | */
9 | public class ActivityActionRuleHelper {
10 |
11 | private ActivityActionRuleHelper() {
12 | }
13 |
14 | /**
15 | * @param actionRuleDO
16 | * @return
17 | */
18 | public static ActivityActionRuleEntity toActivityActionRuleEntity(DtsActivityActionRuleDO actionRuleDO) {
19 | return new ActivityActionRuleEntity.Builder(actionRuleDO.getBizAction())
20 | .setBizActionName(actionRuleDO.getBizActionName()).setBizType(actionRuleDO.getBizType())
21 | .setClazzName(actionRuleDO.getClazzName()).setService(actionRuleDO.getService())
22 | .setTransRecoveryId(actionRuleDO.getTransRecoveryId()).build();
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-share/src/main/java/org/github/dtsopensource/server/share/schedule/TaskTrackerContext.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.share.schedule;
2 |
3 | import java.io.Serializable;
4 |
5 | import org.github.dtsopensource.server.share.DTSConfig;
6 |
7 | import com.alibaba.fastjson.JSON;
8 | import com.alibaba.fastjson.annotation.JSONField;
9 |
10 | import lombok.Getter;
11 | import lombok.Setter;
12 |
13 | /**
14 | * @author ligaofeng 2016年12月14日 上午11:10:45
15 | */
16 | @Getter
17 | @Setter
18 | public class TaskTrackerContext implements Serializable {
19 |
20 | private static final long serialVersionUID = 1612166307850489500L;
21 |
22 | private DTSConfig dtsConfig;
23 |
24 | @JSONField(serialize = false)
25 | private IDTSTaskTracker taskTracker;
26 |
27 | @JSONField(serialize = false)
28 | private IDTSSchedule dtsSchedule;
29 |
30 | private String taskTrackerType;
31 |
32 | @Override
33 | public String toString() {
34 | return JSON.toJSONString(this);
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/dts-parent/dts-admin/src/main/java/org/github/dtsopensource/admin/DTSAdminApplication.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.admin;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
7 | import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
8 | import org.springframework.context.annotation.ImportResource;
9 |
10 | /**
11 | * Application
12 | *
13 | * @author ligaofeng 2016年12月21日 下午4:11:22
14 | */
15 | @EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class,
16 | DataSourceTransactionManagerAutoConfiguration.class })
17 | @SpringBootApplication
18 | @ImportResource("classpath:spring/dts-admin-application.xml")
19 | public class DTSAdminApplication {
20 |
21 | public static void main(String[] args) {
22 | SpringApplication.run(DTSAdminApplication.class, args);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/dts-parent/dts-admin/src/main/java/org/github/dtsopensource/admin/service/helper/ActivityActionRuleHelper.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.admin.service.helper;
2 |
3 | import org.github.dtsopensource.admin.dao.dataobject.ActivityActionRuleDO;
4 | import org.github.dtsopensource.server.share.rule.entity.ActivityActionRuleEntity;
5 |
6 | /**
7 | * @author ligaofeng 2016年12月17日 下午2:59:23
8 | */
9 | public class ActivityActionRuleHelper {
10 |
11 | private ActivityActionRuleHelper() {
12 | }
13 |
14 | /**
15 | * @param actionRuleDO
16 | * @return
17 | */
18 | public static ActivityActionRuleEntity toActivityActionRuleEntity(ActivityActionRuleDO actionRuleDO) {
19 | return new ActivityActionRuleEntity.Builder(actionRuleDO.getBizAction())
20 | .setBizActionName(actionRuleDO.getBizActionName()).setBizType(actionRuleDO.getBizType())
21 | .setClazzName(actionRuleDO.getClazzName()).setService(actionRuleDO.getService())
22 | .setTransRecoveryId(actionRuleDO.getTransRecoveryId()).build();
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-share/src/main/java/org/github/dtsopensource/server/share/ResultBase.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.share;
2 |
3 | import java.io.Serializable;
4 |
5 | import lombok.Data;
6 |
7 | /**
8 | * @author ligaofeng 2016年12月2日 下午1:37:08
9 | */
10 | @Data
11 | public class ResultBase implements Serializable {
12 |
13 | private static final long serialVersionUID = 2297155012372998859L;
14 |
15 | private DTSResultCode dtsResultCode;
16 |
17 | private String message;
18 |
19 | private T value;
20 |
21 | /**
22 | * @return
23 | */
24 | public boolean isSucess() {
25 | return DTSResultCode.SUCCESS == this.getDtsResultCode();
26 | }
27 |
28 | /**
29 | * @param errorMessage
30 | */
31 | public void addMessage(String errorMessage) {
32 | if (message != null && message.trim().length() > 0) {
33 | message = message.concat("|").concat(errorMessage);
34 | } else {
35 | message = errorMessage;
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/manager/RemoteDTSManager.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.manager;
2 |
3 | import org.github.dtsopensource.core.protocol.StoreProtocolManager;
4 | import org.github.dtsopensource.core.store.impl.RemoteDTSStore;
5 | import org.github.dtsopensource.server.share.exception.DTSRuntimeException;
6 | import org.github.dtsopensource.server.share.store.IDTSStore;
7 |
8 | import lombok.Setter;
9 | import lombok.extern.slf4j.Slf4j;
10 |
11 | /**
12 | * @author ligaofeng 2016年12月3日 下午4:28:49
13 | */
14 | @Slf4j
15 | @Setter
16 | public class RemoteDTSManager extends DTSManager {
17 |
18 | private StoreProtocolManager remoteProtocol;
19 |
20 | @Override
21 | protected void check() {
22 | if (remoteProtocol == null) {
23 | throw new DTSRuntimeException("remote模式下必须指定IStoreProtocol协议");
24 | }
25 | log.info("--->RemoteDTSManager check ok");
26 | }
27 |
28 | @Override
29 | protected IDTSStore initStore() {
30 | return new RemoteDTSStore(remoteProtocol);
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-share/src/main/java/org/github/dtsopensource/server/share/protocol/Protocol.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.share.protocol;
2 |
3 | import org.github.dtsopensource.server.share.exception.DTSRuntimeException;
4 |
5 | /**
6 | * @author ligaofeng 2016年12月4日 上午11:44:22
7 | */
8 | public enum Protocol {
9 |
10 | DUBBO("dubbo"),
11 | HSF("hsf"),
12 | HTTP("http");
13 |
14 | private String name;
15 |
16 | Protocol(String name) {
17 | this.name = name;
18 | }
19 |
20 | public String getName() {
21 | return name;
22 | }
23 |
24 | /**
25 | * get protocol
26 | *
27 | * @param name
28 | * @return
29 | */
30 | public static Protocol getProtocol(String name) {
31 | for (Protocol s : Protocol.values()) {
32 | if (s.getName().equals(name)) {
33 | return s;
34 | }
35 | }
36 | throw new DTSRuntimeException("No support protocol !" + " action=" + name);
37 | }
38 |
39 | @Override
40 | public String toString() {
41 | return this.name;
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-share/src/main/java/org/github/dtsopensource/server/share/store/Status.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.share.store;
2 |
3 | import org.github.dtsopensource.server.share.exception.DTSRuntimeException;
4 |
5 | /**
6 | * @author ligaofeng 2016年12月4日 上午11:43:05
7 | */
8 | public enum Status {
9 |
10 | S("start"),
11 | T("success"),
12 | F("fail"),
13 | R("rollback"),
14 | E("exception");
15 |
16 | private String name;
17 |
18 | Status(String name) {
19 | this.name = name;
20 | }
21 |
22 | public String getName() {
23 | return name;
24 | }
25 |
26 | /**
27 | * get status
28 | *
29 | * @param name
30 | * @return
31 | */
32 | public static Status getStatus(String name) {
33 | for (Status s : Status.values()) {
34 | if (s.getName().equals(name)) {
35 | return s;
36 | }
37 | }
38 |
39 | throw new DTSRuntimeException("Invalid status !" + " name=" + name);
40 | }
41 |
42 | @Override
43 | public String toString() {
44 | return this.name;
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/dts-parent/dts-schedule/src/main/java/org/github/dtsopensource/schedule/taskTracker/RemoteTaskTrackerDelegate.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.schedule.taskTracker;
2 |
3 | import org.github.dtsopensource.schedule.protocol.HttpRemoteScheduleProtocol;
4 | import org.github.dtsopensource.server.share.exception.DTSBizException;
5 | import org.github.dtsopensource.server.share.schedule.IDTSTaskTracker;
6 | import org.github.dtsopensource.server.share.schedule.TaskTrackerContext;
7 |
8 | /**
9 | * @author ligaofeng 2016年12月14日 下午1:27:52
10 | */
11 | public class RemoteTaskTrackerDelegate implements IDTSTaskTracker {
12 |
13 | private IDTSTaskTracker httpRemoteScheduleProtocol;
14 |
15 | /**
16 | * @param requestScheduleURL
17 | * @param timeOut
18 | */
19 | public RemoteTaskTrackerDelegate(String requestScheduleURL, int timeOut) {
20 | httpRemoteScheduleProtocol = new HttpRemoteScheduleProtocol(requestScheduleURL, timeOut);
21 | }
22 |
23 | @Override
24 | public void executeTask(TaskTrackerContext taskTrackerContext) throws DTSBizException {
25 | httpRemoteScheduleProtocol.executeTask(taskTrackerContext);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/resources/dtscore/spring-dts-core.xml:
--------------------------------------------------------------------------------
1 |
2 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/dao/rowMapper/DtsActivityRuleRowMapper.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.dao.rowMapper;
2 |
3 | import java.sql.ResultSet;
4 | import java.sql.SQLException;
5 |
6 | import org.github.dtsopensource.core.dao.dataobject.DtsActivityRuleDO;
7 | import org.springframework.jdbc.core.RowMapper;
8 |
9 | /**
10 | * @author ligaofeng 2016年12月16日 下午4:19:23
11 | */
12 | public class DtsActivityRuleRowMapper implements RowMapper {
13 |
14 | @Override
15 | public DtsActivityRuleDO mapRow(ResultSet rs, int rowNum) throws SQLException {
16 | DtsActivityRuleDO activityRuleDO = new DtsActivityRuleDO();
17 | activityRuleDO.setApp(rs.getString("app"));
18 | activityRuleDO.setBizType(rs.getString("biz_type"));
19 | activityRuleDO.setIsDeleted(rs.getString("is_deleted"));
20 | activityRuleDO.setGmtCreated(rs.getTimestamp("gmt_created"));
21 | activityRuleDO.setGmtModified(rs.getTimestamp("gmt_modified"));
22 | activityRuleDO.setCreator(rs.getString("creator"));
23 | activityRuleDO.setModifier(rs.getString("modifier"));
24 | return activityRuleDO;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/resources/spring/spring-biz-transaction.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/src/main/resources/spring/spring-biz-transaction.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/util/ActivityIdGenerator.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.util;
2 |
3 | import java.util.UUID;
4 |
5 | import org.github.dtsopensource.core.DTSCoreSpringHolder;
6 | import org.github.dtsopensource.server.share.DTSConfig;
7 | import org.github.dtsopensource.server.share.util.DTSCoreSystem;
8 |
9 | /**
10 | * @author ligaofeng 2016年11月30日 下午4:55:14
11 | */
12 | public class ActivityIdGenerator {
13 |
14 | private ActivityIdGenerator() {
15 | }
16 |
17 | /**
18 | * 生成活动id
19 | *
20 | * @param dtsConfig
21 | * @return
22 | */
23 | public static String generateActivityId() {
24 | return DTSCoreSpringHolder.getBean(DTSConfig.class).getApp().concat(DTSCoreSystem.UNDER_WRITE)
25 | .concat(getUUUId());
26 | }
27 |
28 | /**
29 | * @param action
30 | * @return
31 | */
32 | public static String generateActionId(String action) {
33 | return DTSCoreSpringHolder.getBean(DTSConfig.class).getApp().concat(DTSCoreSystem.UNDER_WRITE).concat(action)
34 | .concat(DTSCoreSystem.UNDER_WRITE).concat(getUUUId());
35 | }
36 |
37 | public static String getUUUId() {
38 | return UUID.randomUUID().toString().replaceAll("-", "");
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/dts-parent/dts-server/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | org.github.dtsopensource
8 | dts-parent
9 | 1.0.0-SNAPSHOT
10 |
11 |
12 | dts-server
13 | jar
14 |
15 |
16 |
17 | org.github.dtsopensource
18 | dts-server-share
19 | ${project.version}
20 |
21 |
22 | org.github.dtsopensource
23 | dts-core
24 | ${project.version}
25 |
26 |
27 | org.github.dtsopensource
28 | dts-schedule
29 | ${project.version}
30 |
31 |
32 | com.alibaba
33 | druid
34 |
35 |
36 | mysql
37 | mysql-connector-java
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/dts-parent/dts-server/src/main/resources/dtsserver/spring-dts-schedule.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/dts-parent/dts-server/src/main/resources/dtsserver/spring-dts-server.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/resources/beanRefContext.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 |
20 |
21 |
22 | classpath:config.properties
23 |
24 |
25 | UTF-8
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/dts-parent/dts-admin/src/main/java/org/github/dtsopensource/admin/application/impl/ActicityRuleApplication.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.admin.application.impl;
2 |
3 | import java.util.List;
4 |
5 | import javax.annotation.Resource;
6 |
7 | import org.github.dtsopensource.admin.application.IActicityRuleApplication;
8 | import org.github.dtsopensource.admin.exception.DTSAdminException;
9 | import org.github.dtsopensource.admin.service.IActivityRuleService;
10 | import org.github.dtsopensource.server.share.rule.entity.ActivityRuleEntity;
11 | import org.springframework.stereotype.Service;
12 | import org.springframework.transaction.annotation.Transactional;
13 |
14 | /**
15 | * @author ligaofeng 2016年12月23日 下午2:02:39
16 | */
17 | @Service
18 | public class ActicityRuleApplication implements IActicityRuleApplication {
19 |
20 | @Resource
21 | private IActivityRuleService activityRuleService;
22 |
23 | @Transactional(rollbackFor = Exception.class)
24 | @Override
25 | public void addActivityRule(ActivityRuleEntity activityRuleEntity) throws DTSAdminException {
26 | activityRuleService.saveActivityRule(activityRuleEntity);
27 | }
28 |
29 | @Override
30 | public List queryActivityRule(ActivityRuleEntity activityRuleEntity) throws DTSAdminException {
31 | return activityRuleService.getActivityRule(activityRuleEntity);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/src/main/resources/beanRefContext.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 |
20 |
21 |
22 |
23 | classpath:config.properties
24 |
25 |
26 | UTF-8
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/DTSCoreSpringHolder.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core;
2 |
3 | import org.springframework.beans.BeansException;
4 | import org.springframework.context.ApplicationContext;
5 | import org.springframework.context.ApplicationContextAware;
6 |
7 | /**
8 | * @author ligaofeng 2016年12月8日 上午11:30:57
9 | */
10 | public class DTSCoreSpringHolder implements ApplicationContextAware {
11 |
12 | private static ApplicationContext applicationContext;
13 |
14 | @Override
15 | public void setApplicationContext(ApplicationContext applicationContext) {
16 | DTSCoreSpringHolder.applicationContext = applicationContext;
17 | }
18 |
19 | /**
20 | * @param beanId
21 | * @return
22 | * @throws BeansException
23 | */
24 | public static Object getBean(String beanId) {
25 | return applicationContext.getBean(beanId);
26 | }
27 |
28 | /**
29 | * @param requiredType
30 | * @return
31 | */
32 | public static T getBean(Class requiredType) {
33 | return applicationContext.getBean(requiredType);
34 | }
35 |
36 | /**
37 | * @param beanId
38 | * @param requiredType
39 | * @return
40 | */
41 | public static T getBean(String beanId, Class requiredType) {
42 | return applicationContext.getBean(beanId, requiredType);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-web/src/main/resources/beanRefContext.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 |
20 |
21 |
22 | classpath:config.properties
23 |
24 |
25 | UTF-8
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/dts-parent/dts-schedule/src/main/java/org/github/dtsopensource/schedule/taskTracker/task/HangTransactionMonitorTask.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.schedule.taskTracker.task;
2 |
3 | import java.util.concurrent.ExecutorService;
4 | import java.util.concurrent.Executors;
5 |
6 | import org.github.dtsopensource.server.share.DTSConfig;
7 | import org.github.dtsopensource.server.share.exception.DTSBizException;
8 | import org.github.dtsopensource.server.share.schedule.IDTSSchedule;
9 | import org.github.dtsopensource.server.share.schedule.IDTSTaskTracker;
10 | import org.github.dtsopensource.server.share.schedule.TaskTrackerContext;
11 |
12 | import lombok.extern.slf4j.Slf4j;
13 |
14 | /**
15 | * dts二阶事务恢复监控
16 | * 执行超过一定次数自动将该业务活动置为异常(status:E)业务活动
17 | * taskTrackerType:hangTransactionMonitor
18 | *
19 | * @author ligaofeng 2016年12月18日 下午1:47:55
20 | */
21 | @Slf4j
22 | public class HangTransactionMonitorTask implements IDTSTaskTracker {
23 |
24 | private final ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
25 |
26 | @Override
27 | public void executeTask(TaskTrackerContext taskTrackerContext) throws DTSBizException {
28 | log.info("--->start to execute hang transaction monitor task:{}", taskTrackerContext);
29 | IDTSSchedule dtsSchedule = taskTrackerContext.getDtsSchedule();
30 | DTSConfig dtsConfig = taskTrackerContext.getDtsConfig();
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/dao/rowMapper/DtsActivityRowMapper.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.dao.rowMapper;
2 |
3 | import java.sql.ResultSet;
4 | import java.sql.SQLException;
5 |
6 | import org.apache.commons.lang.StringUtils;
7 | import org.github.dtsopensource.core.dao.dataobject.DtsActivityDO;
8 | import org.springframework.jdbc.core.RowMapper;
9 |
10 | /**
11 | * @author ligaofeng 2016年12月4日 上午11:11:47
12 | */
13 | public class DtsActivityRowMapper implements RowMapper {
14 |
15 | @Override
16 | public DtsActivityDO mapRow(ResultSet rs, int rowNum) throws SQLException {
17 | DtsActivityDO activityDO = new DtsActivityDO();
18 | activityDO.setActivityId(rs.getString("activity_id"));
19 | activityDO.setApp(rs.getString("app"));
20 | activityDO.setBizType(rs.getString("biz_type"));
21 | String context = rs.getString("context");
22 | activityDO.setContext(StringUtils.isEmpty(context) ? "" : context.replaceAll("\\\\", ""));
23 | activityDO.setStatus(rs.getString("status"));
24 | activityDO.setIsDeleted(rs.getString("is_deleted"));
25 | activityDO.setGmtCreated(rs.getTimestamp("gmt_created"));
26 | activityDO.setGmtModified(rs.getTimestamp("gmt_modified"));
27 | activityDO.setCreator(rs.getString("creator"));
28 | activityDO.setModifier(rs.getString("modifier"));
29 | return activityDO;
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/resources/spring/spring-dts-local-example.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-share/src/main/java/org/github/dtsopensource/server/share/DTSConfig.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.share;
2 |
3 | import java.io.Serializable;
4 |
5 | import javax.annotation.PostConstruct;
6 |
7 | import org.github.dtsopensource.server.share.exception.DTSRuntimeException;
8 |
9 | import com.alibaba.fastjson.JSON;
10 |
11 | import lombok.Getter;
12 | import lombok.Setter;
13 |
14 | /**
15 | * @author ligaofeng 2016年11月29日 上午11:30:46
16 | */
17 | @Getter
18 | @Setter
19 | public class DTSConfig implements Serializable {
20 |
21 | private static final long serialVersionUID = -2408123274907783162L;
22 |
23 | private DTSManageType dtsManageType;
24 |
25 | private String app;
26 |
27 | //dts业务规则请求地址
28 | private String requestActivityRuleURL;
29 |
30 | @PostConstruct
31 | public void checkConfig() {
32 | if (dtsManageType == null) {
33 | throw new DTSRuntimeException("dts连接方式dtsManageType未定义");
34 | }
35 | if (app == null || app.trim().length() == 0) {
36 | throw new DTSRuntimeException("业务系统名称app未定义");
37 | }
38 | if (requestActivityRuleURL == null || requestActivityRuleURL.trim().length() == 0) {
39 | throw new DTSRuntimeException("dts业务规则请求地址requestActivityRuleURL尚未配置");
40 | }
41 | }
42 |
43 | @Override
44 | public String toString() {
45 | return JSON.toJSONString(this);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/dts-parent/dts-admin/src/main/java/org/github/dtsopensource/admin/util/DTSCoreSpringHolder.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.admin.util;
2 |
3 | import org.springframework.beans.BeansException;
4 | import org.springframework.context.ApplicationContext;
5 | import org.springframework.context.ApplicationContextAware;
6 | import org.springframework.stereotype.Component;
7 |
8 | /**
9 | * @author ligaofeng 2016年12月8日 上午11:30:57
10 | */
11 | @Component
12 | public class DTSCoreSpringHolder implements ApplicationContextAware {
13 |
14 | private static ApplicationContext applicationContext;
15 |
16 | @Override
17 | public void setApplicationContext(ApplicationContext applicationContext) {
18 | DTSCoreSpringHolder.applicationContext = applicationContext;
19 | }
20 |
21 | /**
22 | * @param beanId
23 | * @return
24 | * @throws BeansException
25 | */
26 | public static Object getBean(String beanId) {
27 | return applicationContext.getBean(beanId);
28 | }
29 |
30 | /**
31 | * @param requiredType
32 | * @return
33 | */
34 | public static T getBean(Class requiredType) {
35 | return applicationContext.getBean(requiredType);
36 | }
37 |
38 | /**
39 | * @param beanId
40 | * @param requiredType
41 | * @return
42 | */
43 | public static T getBean(String beanId, Class requiredType) {
44 | return applicationContext.getBean(beanId, requiredType);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-share/src/main/java/org/github/dtsopensource/server/share/exception/DTSBizException.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.share.exception;
2 |
3 | /**
4 | * Created by Eason on 2016/10/20.
5 | */
6 | public class DTSBizException extends Exception {
7 |
8 | private static final long serialVersionUID = 3473398255173602638L;
9 |
10 | /**
11 | * init BizException
12 | */
13 | public DTSBizException() {
14 | super();
15 | }
16 |
17 | /**
18 | * init BizException
19 | *
20 | * @param message
21 | */
22 | public DTSBizException(String message) {
23 | super(message);
24 | }
25 |
26 | /**
27 | * init BizException
28 | *
29 | * @param message
30 | * @param cause
31 | */
32 | public DTSBizException(String message, Throwable cause) {
33 | super(message, cause);
34 | }
35 |
36 | /**
37 | * init BizException
38 | *
39 | * @param cause
40 | */
41 | public DTSBizException(Throwable cause) {
42 | super(cause);
43 | }
44 |
45 | /**
46 | * init BizException
47 | *
48 | * @param message
49 | * @param cause
50 | * @param enableSuppression
51 | * @param writableStackTrace
52 | */
53 | public DTSBizException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
54 | super(message, cause, enableSuppression, writableStackTrace);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/dts-parent/dts-admin/src/main/java/org/github/dtsopensource/admin/exception/DTSAdminException.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.admin.exception;
2 |
3 | /**
4 | * @author ligaofeng 2016年12月23日 下午1:34:26
5 | */
6 | public class DTSAdminException extends Exception {
7 |
8 | private static final long serialVersionUID = 674322939576507543L;
9 |
10 | /**
11 | * init BizException
12 | */
13 | public DTSAdminException() {
14 | super();
15 | }
16 |
17 | /**
18 | * init BizException
19 | *
20 | * @param message
21 | */
22 | public DTSAdminException(String message) {
23 | super(message);
24 | }
25 |
26 | /**
27 | * init BizException
28 | *
29 | * @param message
30 | * @param cause
31 | */
32 | public DTSAdminException(String message, Throwable cause) {
33 | super(message, cause);
34 | }
35 |
36 | /**
37 | * init BizException
38 | *
39 | * @param cause
40 | */
41 | public DTSAdminException(Throwable cause) {
42 | super(cause);
43 | }
44 |
45 | /**
46 | * init BizException
47 | *
48 | * @param message
49 | * @param cause
50 | * @param enableSuppression
51 | * @param writableStackTrace
52 | */
53 | public DTSAdminException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
54 | super(message, cause, enableSuppression, writableStackTrace);
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-share/src/main/java/org/github/dtsopensource/server/share/exception/DTSStoreException.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.share.exception;
2 |
3 | /**
4 | * Created by Eason on 2016/10/20.
5 | */
6 | public class DTSStoreException extends Exception {
7 |
8 | private static final long serialVersionUID = 3473398255173602638L;
9 |
10 | /**
11 | * init BizException
12 | */
13 | public DTSStoreException() {
14 | super();
15 | }
16 |
17 | /**
18 | * init BizException
19 | *
20 | * @param message
21 | */
22 | public DTSStoreException(String message) {
23 | super(message);
24 | }
25 |
26 | /**
27 | * init BizException
28 | *
29 | * @param message
30 | * @param cause
31 | */
32 | public DTSStoreException(String message, Throwable cause) {
33 | super(message, cause);
34 | }
35 |
36 | /**
37 | * init BizException
38 | *
39 | * @param cause
40 | */
41 | public DTSStoreException(Throwable cause) {
42 | super(cause);
43 | }
44 |
45 | /**
46 | * init BizException
47 | *
48 | * @param message
49 | * @param cause
50 | * @param enableSuppression
51 | * @param writableStackTrace
52 | */
53 | public DTSStoreException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
54 | super(message, cause, enableSuppression, writableStackTrace);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-share/src/main/java/org/github/dtsopensource/server/share/store/IDTSStore.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.share.store;
2 |
3 | import org.github.dtsopensource.server.share.DTSContext;
4 | import org.github.dtsopensource.server.share.IDTS;
5 | import org.github.dtsopensource.server.share.ResultBase;
6 | import org.github.dtsopensource.server.share.store.entity.ActionEntity;
7 | import org.github.dtsopensource.server.share.store.entity.ActivityEntity;
8 |
9 | /**
10 | * @author ligaofeng 2016年12月7日 下午9:39:51
11 | */
12 | public interface IDTSStore extends IDTS {
13 |
14 | /**
15 | * 开启事务
16 | *
17 | * @param activityEntity
18 | * @return
19 | */
20 | public ResultBase openTransaction(ActivityEntity activityEntity);
21 |
22 | /**
23 | * @param actionEntity
24 | * @return
25 | */
26 | public ResultBase getAndCreateAction(ActionEntity actionEntity);
27 |
28 | /**
29 | * 一阶commit时调用
30 | *
31 | * @param activityId
32 | * @return
33 | */
34 | public ResultBase commitActivity(String activityId);
35 |
36 | /**
37 | * 一阶rollback时调用
38 | *
39 | * @param activityId
40 | * @return
41 | */
42 | public ResultBase rollbackActivity(String activityId);
43 |
44 | /**
45 | * 更新action
46 | *
47 | * @param actionEntity
48 | * @return
49 | */
50 | public ResultBase updateAction(ActionEntity actionEntity);
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-share/src/main/java/org/github/dtsopensource/server/share/exception/DTSRuntimeException.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.share.exception;
2 |
3 | /**
4 | * @author ligaofeng 2016年11月3日 下午2:46:37
5 | */
6 | public class DTSRuntimeException extends RuntimeException {
7 |
8 | private static final long serialVersionUID = 4328158740883926572L;
9 |
10 | /**
11 | * init DTSRuntimeException
12 | */
13 | public DTSRuntimeException() {
14 | super();
15 | }
16 |
17 | /**
18 | * init DTSRuntimeException
19 | *
20 | * @param message
21 | */
22 | public DTSRuntimeException(String message) {
23 | super(message);
24 | }
25 |
26 | /**
27 | * init DTSRuntimeException
28 | *
29 | * @param message
30 | * @param cause
31 | */
32 | public DTSRuntimeException(String message, Throwable cause) {
33 | super(message, cause);
34 | }
35 |
36 | /**
37 | * init DTSRuntimeException
38 | *
39 | * @param cause
40 | */
41 | public DTSRuntimeException(Throwable cause) {
42 | super(cause);
43 | }
44 |
45 | /**
46 | * init DTSRuntimeException
47 | *
48 | * @param message
49 | * @param cause
50 | * @param enableSuppression
51 | * @param writableStackTrace
52 | */
53 | public DTSRuntimeException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
54 | super(message, cause, enableSuppression, writableStackTrace);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/dts-parent/dts-server/src/main/resources/dtsserver/spring-dts-persistence.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/protocol/StoreProtocolManager.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.protocol;
2 |
3 | import java.util.concurrent.atomic.AtomicBoolean;
4 |
5 | import org.github.dtsopensource.server.share.exception.DTSBizException;
6 | import org.github.dtsopensource.server.share.exception.DTSRuntimeException;
7 | import org.github.dtsopensource.server.share.protocol.IDTSProtocol;
8 | import org.github.dtsopensource.server.share.store.IDTSStore;
9 | import org.springframework.beans.factory.InitializingBean;
10 |
11 | import lombok.extern.slf4j.Slf4j;
12 |
13 | /**
14 | * @author ligaofeng 2016年12月11日 下午12:22:47
15 | */
16 | @Slf4j
17 | public abstract class StoreProtocolManager implements InitializingBean, IDTSProtocol, IDTSStore {
18 |
19 | private final AtomicBoolean isInit = new AtomicBoolean(false);
20 |
21 | @Override
22 | public void afterPropertiesSet() throws Exception {
23 | try {
24 | check();
25 | } catch (Exception e) {
26 | log.error("check error in dts's dataSource, make sure the ip of web server is in the white list");
27 | throw new DTSRuntimeException(e);
28 | }
29 | this.init();
30 | }
31 |
32 | private void init() throws DTSBizException {
33 | if (isInit.compareAndSet(false, true)) {
34 | this.initDTSProtocol();
35 | this.getConnection();
36 | }
37 | }
38 |
39 | protected abstract void check() throws DTSBizException;
40 |
41 | protected abstract void initDTSProtocol();
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/resources/spring/spring-biz-dao.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 | classpath*:sqlmap/DtsTestDOMapper.xml
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/src/main/resources/spring/spring-biz-dao.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 | classpath*:sqlmap/DtsTestDOMapper.xml
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/src/main/resources/spring/spring-dts-remote-example.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/dao/rowMapper/DtsActivityActionRuleRowMapper.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.dao.rowMapper;
2 |
3 | import java.sql.ResultSet;
4 | import java.sql.SQLException;
5 |
6 | import org.github.dtsopensource.core.dao.dataobject.DtsActivityActionRuleDO;
7 | import org.springframework.jdbc.core.RowMapper;
8 |
9 | /**
10 | * @author ligaofeng 2016年12月17日 下午1:28:28
11 | */
12 | public class DtsActivityActionRuleRowMapper implements RowMapper {
13 |
14 | @Override
15 | public DtsActivityActionRuleDO mapRow(ResultSet rs, int rowNum) throws SQLException {
16 | DtsActivityActionRuleDO activityActionRuleDO = new DtsActivityActionRuleDO();
17 | activityActionRuleDO.setBizAction(rs.getString("biz_action"));
18 | activityActionRuleDO.setBizActionName(rs.getString("biz_action_name"));
19 | activityActionRuleDO.setBizType(rs.getString("biz_type"));
20 | activityActionRuleDO.setService(rs.getString("service"));
21 | activityActionRuleDO.setClazzName(rs.getString("clazz_name"));
22 | activityActionRuleDO.setTransRecoveryId(rs.getString("trans_recovery_id"));
23 | activityActionRuleDO.setIsDeleted(rs.getString("is_deleted"));
24 | activityActionRuleDO.setGmtCreated(rs.getTimestamp("gmt_created"));
25 | activityActionRuleDO.setGmtModified(rs.getTimestamp("gmt_modified"));
26 | activityActionRuleDO.setCreator(rs.getString("creator"));
27 | activityActionRuleDO.setModifier(rs.getString("modifier"));
28 | return activityActionRuleDO;
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/dao/rowMapper/DtsActionRowMapper.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.dao.rowMapper;
2 |
3 | import java.sql.ResultSet;
4 | import java.sql.SQLException;
5 |
6 | import org.apache.commons.lang.StringUtils;
7 | import org.github.dtsopensource.core.dao.dataobject.DtsActionDO;
8 | import org.springframework.jdbc.core.RowMapper;
9 |
10 | /**
11 | * @author ligaofeng 2016年12月4日 上午11:16:41
12 | */
13 | public class DtsActionRowMapper implements RowMapper {
14 |
15 | @Override
16 | public DtsActionDO mapRow(ResultSet rs, int rowNum) throws SQLException {
17 | DtsActionDO actionDO = new DtsActionDO();
18 | actionDO.setAction(rs.getString("action"));
19 | actionDO.setActionId(rs.getString("action_id"));
20 | actionDO.setActivityId(rs.getString("activity_id"));
21 | String context = rs.getString("context");
22 | actionDO.setContext(StringUtils.isEmpty(context) ? "" : context.replaceAll("\\\\", ""));
23 | actionDO.setProtocol(rs.getString("protocol"));
24 | actionDO.setStatus(rs.getString("status"));
25 | actionDO.setService(rs.getString("service"));
26 | actionDO.setClazzName(rs.getString("clazz_name"));
27 | actionDO.setVersion(rs.getString("version"));
28 | actionDO.setIsDeleted(rs.getString("is_deleted"));
29 | actionDO.setGmtCreated(rs.getTimestamp("gmt_created"));
30 | actionDO.setGmtModified(rs.getTimestamp("gmt_modified"));
31 | actionDO.setCreator(rs.getString("creator"));
32 | actionDO.setModifier(rs.getString("modifier"));
33 | return actionDO;
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-share/src/main/java/org/github/dtsopensource/server/share/schedule/IDTSSchedule.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.share.schedule;
2 |
3 | import java.util.List;
4 |
5 | import org.github.dtsopensource.server.share.DTSContext;
6 | import org.github.dtsopensource.server.share.IDTS;
7 | import org.github.dtsopensource.server.share.ResultBase;
8 | import org.github.dtsopensource.server.share.exception.DTSBizException;
9 | import org.github.dtsopensource.server.share.rule.entity.ActivityActionRuleEntity;
10 | import org.github.dtsopensource.server.share.store.Status;
11 | import org.github.dtsopensource.server.share.store.entity.ActivityEntity;
12 |
13 | /**
14 | * @author ligaofeng 2016年12月16日 上午11:04:53
15 | */
16 | public interface IDTSSchedule extends IDTS {
17 |
18 | /**
19 | * 获取hang住的二阶事务
20 | * 默认返回5分钟之前的数据
21 | *
22 | * @param app 系统名称
23 | * @return
24 | */
25 | public ResultBase> getHangTransaction(String app);
26 |
27 | /**
28 | * 关闭业务活动,并改变状态
29 | *
30 | * @param activityId
31 | * @param orignStatus
32 | * @param targetStatus
33 | */
34 | public void closeActivity(String activityId, Status orignStatus, Status targetStatus);
35 |
36 | /**
37 | * commit
38 | *
39 | * @param context
40 | * @param bizActionRule
41 | */
42 | public void commit(DTSContext context, ActivityActionRuleEntity bizActionRule) throws DTSBizException;
43 |
44 | /**
45 | * rollback
46 | *
47 | * @param context
48 | * @param bizActionRule
49 | */
50 | public void rollback(DTSContext context, ActivityActionRuleEntity bizActionRule) throws DTSBizException;
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/manager/LocalDTSManager.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.manager;
2 |
3 | import javax.sql.DataSource;
4 |
5 | import org.github.dtsopensource.core.store.impl.LocalDTSStore;
6 | import org.github.dtsopensource.server.share.exception.DTSRuntimeException;
7 | import org.github.dtsopensource.server.share.store.IDTSStore;
8 | import org.springframework.jdbc.core.JdbcTemplate;
9 | import org.springframework.jdbc.datasource.DataSourceTransactionManager;
10 | import org.springframework.transaction.TransactionDefinition;
11 | import org.springframework.transaction.support.TransactionTemplate;
12 |
13 | import lombok.Setter;
14 | import lombok.ToString;
15 | import lombok.extern.slf4j.Slf4j;
16 |
17 | /**
18 | * Created by ligaofeng on 2016/10/31.
19 | */
20 | @Slf4j
21 | @ToString
22 | public class LocalDTSManager extends DTSManager {
23 |
24 | @Setter
25 | private DataSource dataSource;
26 |
27 | private JdbcTemplate jdbcTemplate;
28 |
29 | private TransactionTemplate transactionTemplate;
30 |
31 | @Override
32 | protected void check() {
33 | if (dataSource == null) {
34 | throw new DTSRuntimeException("local模式下必须指定DataSource数据源");
35 | }
36 | log.info("--->LocalDTSManager check ok...");
37 | }
38 |
39 | @Override
40 | public IDTSStore initStore() {
41 | jdbcTemplate = new JdbcTemplate(dataSource);
42 | transactionTemplate = new TransactionTemplate(new DataSourceTransactionManager(dataSource));
43 | transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
44 | return new LocalDTSStore(jdbcTemplate, transactionTemplate);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/dts-parent/dts-admin/src/main/java/org/github/dtsopensource/admin/service/helper/ActivityRuleHelper.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.admin.service.helper;
2 |
3 | import java.util.Date;
4 |
5 | import org.github.dtsopensource.admin.dao.dataobject.ActivityRuleDO;
6 | import org.github.dtsopensource.server.share.rule.entity.ActivityRuleEntity;
7 | import org.joda.time.DateTime;
8 |
9 | /**
10 | * @author ligaofeng 2016年12月17日 下午2:20:36
11 | */
12 | public class ActivityRuleHelper {
13 |
14 | private ActivityRuleHelper() {
15 | }
16 |
17 | /**
18 | * @param activityRuleDO
19 | * @return
20 | */
21 | public static ActivityRuleEntity toActivityRuleEntity(ActivityRuleDO activityRuleDO) {
22 | return new ActivityRuleEntity.Builder(activityRuleDO.getBizType()).setApp(activityRuleDO.getApp())
23 | .setAppCname(activityRuleDO.getAppCname()).setBizTypeName(activityRuleDO.getBizTypeName()).build();
24 | }
25 |
26 | /**
27 | * @param activityRuleEntity
28 | * @return
29 | */
30 | public static ActivityRuleDO toActivityRuleDO(ActivityRuleEntity activityRuleEntity) {
31 | ActivityRuleDO activityRuleDO = new ActivityRuleDO();
32 | activityRuleDO.setApp(activityRuleEntity.getApp());
33 | activityRuleDO.setAppCname(activityRuleEntity.getAppCname());
34 | activityRuleDO.setBizType(activityRuleEntity.getBizType());
35 | activityRuleDO.setBizTypeName(activityRuleEntity.getBizTypeName());
36 | activityRuleDO.setIsDeleted("N");
37 | Date now = DateTime.now().toDate();
38 | activityRuleDO.setGmtCreated(now);
39 | activityRuleDO.setGmtModified(now);
40 | activityRuleDO.setCreator("system");
41 | activityRuleDO.setModifier("system");
42 | return activityRuleDO;
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-web/src/main/java/org/github/dtsopensource/server/web/handler/HttpAdapterManager.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.web.handler;
2 |
3 | import java.util.Map;
4 |
5 | import org.github.dtsopensource.server.share.DTSResultCode;
6 | import org.github.dtsopensource.server.share.ResultBase;
7 | import org.github.dtsopensource.server.share.exception.DTSBizException;
8 | import org.github.dtsopensource.server.share.protocol.ProtocolConstance;
9 | import org.github.dtsopensource.server.share.protocol.ProtocolMethod;
10 |
11 | /**
12 | * @author ligaofeng 2016年12月18日 上午1:53:38
13 | */
14 | public abstract class HttpAdapterManager {
15 |
16 | /**
17 | * 路由处理
18 | *
19 | * @param params
20 | * @throws DTSBizException
21 | */
22 | public void adapter(Map params) throws DTSBizException {
23 | String operation = (String) params.get(ProtocolConstance.requestStoreOperation);
24 | ProtocolMethod protocolmethod = ProtocolMethod.valueOf(operation);
25 | this.handle(protocolmethod, params);
26 | }
27 |
28 | /**
29 | * @param protocolmethod
30 | * @param params
31 | */
32 | protected abstract void handle(ProtocolMethod protocolmethod, Map params);
33 |
34 | protected void unsupprotMethod(Map params) {
35 | ResultBase resultBase = new ResultBase();
36 | resultBase.setDtsResultCode(DTSResultCode.FAIL);
37 | resultBase.setMessage("dts-server尚不支持该方法:method:"
38 | + ((ProtocolMethod) params.get(ProtocolConstance.requestStoreOperation)).name());
39 | this.buildSuccessResponse(params, resultBase);
40 | }
41 |
42 | protected void buildSuccessResponse(Map params, Object resultBase) {
43 | params.put(ProtocolConstance.resultObject, resultBase);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/annotation/ITwoPhaseCommitAspect.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.annotation;
2 |
3 | import javax.annotation.Resource;
4 |
5 | import org.aspectj.lang.JoinPoint;
6 | import org.aspectj.lang.annotation.Around;
7 | import org.aspectj.lang.annotation.Aspect;
8 | import org.aspectj.lang.annotation.Pointcut;
9 | import org.springframework.stereotype.Component;
10 |
11 | /**
12 | * @author ligaofeng 2016年11月4日 下午2:26:56
13 | */
14 | @Component
15 | @Aspect
16 | public class ITwoPhaseCommitAspect {
17 |
18 | @Resource
19 | private AopHandler actionAroundAophandler;
20 |
21 | @Pointcut(value = "execution(* org.github.dtsopensource.core.ITwoPhaseCommit.pre(..))")
22 | public void prePointcut() {
23 | }
24 |
25 | @Pointcut(value = "execution(* org.github.dtsopensource.core.ITwoPhaseCommit.commit(..))")
26 | public void commitPointcut() {
27 | }
28 |
29 | @Pointcut(value = "execution(* org.github.dtsopensource.core.ITwoPhaseCommit.rollback(..))")
30 | public void rollbackPointcut() {
31 | }
32 |
33 | /**
34 | * @param joinPoint
35 | * @throws Throwable
36 | */
37 | @Around("prePointcut()")
38 | public void aroundPre(JoinPoint joinPoint) throws Throwable {
39 | actionAroundAophandler.handleAop(joinPoint);
40 | }
41 |
42 | /**
43 | * @param joinPoint
44 | * @throws Throwable
45 | */
46 | @Around("commitPointcut()")
47 | public void aroundCommit(JoinPoint joinPoint) throws Throwable {
48 | actionAroundAophandler.handleAop(joinPoint);
49 | }
50 |
51 | /**
52 | * @param joinPoint
53 | * @throws Throwable
54 | */
55 | @Around("rollbackPointcut()")
56 | public void aroundRollBack(JoinPoint joinPoint) throws Throwable {
57 | actionAroundAophandler.handleAop(joinPoint);
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/dts-parent/dts-admin/src/main/java/org/github/dtsopensource/admin/dao/mapper/ActivityRuleDOMapper.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.admin.dao.mapper;
2 |
3 | import java.util.List;
4 |
5 | import org.apache.ibatis.annotations.Param;
6 | import org.github.dtsopensource.admin.dao.dataobject.ActivityRuleDO;
7 | import org.github.dtsopensource.admin.dao.dataobject.ActivityRuleDOExample;
8 |
9 | /**
10 | * @author ligaofeng 2016年12月23日 下午1:37:08
11 | */
12 | public interface ActivityRuleDOMapper {
13 | /**
14 | * @param bizType
15 | * @return
16 | */
17 | int deleteByPrimaryKey(String bizType);
18 |
19 | /**
20 | * @param record
21 | * @return
22 | */
23 | int insert(ActivityRuleDO record);
24 |
25 | /**
26 | * @param record
27 | * @return
28 | */
29 | int insertSelective(ActivityRuleDO record);
30 |
31 | /**
32 | * @param example
33 | * @return
34 | */
35 | List selectByExample(ActivityRuleDOExample example);
36 |
37 | /**
38 | * @param bizType
39 | * @return
40 | */
41 | ActivityRuleDO selectByPrimaryKey(String bizType);
42 |
43 | /**
44 | * @param record
45 | * @param example
46 | * @return
47 | */
48 | int updateByExampleSelective(@Param("record") ActivityRuleDO record,
49 | @Param("example") ActivityRuleDOExample example);
50 |
51 | /**
52 | * @param record
53 | * @param example
54 | * @return
55 | */
56 | int updateByExample(@Param("record") ActivityRuleDO record, @Param("example") ActivityRuleDOExample example);
57 |
58 | /**
59 | * @param record
60 | * @return
61 | */
62 | int updateByPrimaryKeySelective(ActivityRuleDO record);
63 |
64 | /**
65 | * @param record
66 | * @return
67 | */
68 | int updateByPrimaryKey(ActivityRuleDO record);
69 | }
70 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/rule/ActivityRuleMananger.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.rule;
2 |
3 | import org.apache.commons.lang.StringUtils;
4 | import org.github.dtsopensource.core.protocol.http.HttpRemoteRuleProtocol;
5 | import org.github.dtsopensource.server.share.DTSResultCode;
6 | import org.github.dtsopensource.server.share.ResultBase;
7 | import org.github.dtsopensource.server.share.rule.IDTSRule;
8 | import org.github.dtsopensource.server.share.rule.entity.ActivityRuleEntity;
9 |
10 | /**
11 | * @author ligaofeng 2016年12月17日 下午1:47:11
12 | */
13 | public class ActivityRuleMananger implements IDTSRule {
14 |
15 | private IDTSRule httpRemoteRuleProtocol;
16 |
17 | /**
18 | * @param requestActivityRuleURL
19 | */
20 | public ActivityRuleMananger(String requestActivityRuleURL) {
21 | httpRemoteRuleProtocol = new HttpRemoteRuleProtocol(requestActivityRuleURL);
22 | }
23 |
24 | @Override
25 | public ResultBase checkBizType(String bizType) {
26 | ResultBase checkResult = new ResultBase();
27 | if (StringUtils.isEmpty(bizType)) {
28 | checkResult.setDtsResultCode(DTSResultCode.FAIL);
29 | checkResult.setMessage("业务活动不能为空");
30 | return checkResult;
31 | }
32 | return httpRemoteRuleProtocol.checkBizType(bizType);
33 | }
34 |
35 | @Override
36 | public ResultBase getBizTypeRule(String bizType) {
37 | ResultBase checkResult = new ResultBase();
38 | if (StringUtils.isEmpty(bizType)) {
39 | checkResult.setDtsResultCode(DTSResultCode.FAIL);
40 | checkResult.setMessage("业务活动不能为空");
41 | return checkResult;
42 | }
43 | return httpRemoteRuleProtocol.getBizTypeRule(bizType);
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/store/help/ActivityHelper.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.store.help;
2 |
3 | import java.util.Date;
4 |
5 | import org.github.dtsopensource.core.dao.dataobject.DtsActivityDO;
6 | import org.github.dtsopensource.server.share.store.entity.ActivityEntity;
7 |
8 | import com.alibaba.fastjson.JSON;
9 |
10 | /**
11 | * @author ligaofeng 2016年12月1日 下午9:09:08
12 | */
13 | public class ActivityHelper {
14 |
15 | private ActivityHelper() {
16 | }
17 |
18 | /**
19 | * @param activityDO
20 | * @return
21 | */
22 | public static ActivityEntity toActivityEntity(DtsActivityDO activityDO) {
23 | if (activityDO == null) {
24 | return null;
25 | }
26 | return new ActivityEntity.Builder(activityDO.getActivityId()).setBizType(activityDO.getBizType())
27 | .setContext(activityDO.getContext()).setStatus(activityDO.getStatus()).build();
28 | }
29 |
30 | /**
31 | * @param activityEntity
32 | * @return
33 | * @throws SequenceException
34 | */
35 | public static DtsActivityDO toDtsActivityDO(ActivityEntity activityEntity) {
36 | if (activityEntity == null) {
37 | return new DtsActivityDO();
38 | }
39 | Date now = new Date();
40 | DtsActivityDO activityDO = new DtsActivityDO();
41 | activityDO.setActivityId(activityEntity.getActivityId());
42 | activityDO.setApp(activityEntity.getDtsConfig().getApp());
43 | activityDO.setBizType(activityEntity.getBizType());
44 | activityDO.setContext(JSON.toJSONString(activityEntity.getContext()));
45 | activityDO.setStatus(activityEntity.status());
46 | activityDO.setIsDeleted("N");
47 | activityDO.setGmtCreated(now);
48 | activityDO.setGmtModified(now);
49 | activityDO.setCreator("system");
50 | activityDO.setModifier("system");
51 | return activityDO;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/dts-parent/dts-schedule/src/main/java/org/github/dtsopensource/schedule/protocol/HttpRemoteScheduleProtocol.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.schedule.protocol;
2 |
3 | import org.github.dtsopensource.schedule.protocol.http.HttpScheduleProtocol;
4 | import org.github.dtsopensource.server.share.exception.DTSBizException;
5 | import org.github.dtsopensource.server.share.protocol.IDTSProtocol;
6 | import org.github.dtsopensource.server.share.schedule.IDTSTaskTracker;
7 | import org.github.dtsopensource.server.share.schedule.TaskTrackerContext;
8 |
9 | import lombok.Getter;
10 | import lombok.Setter;
11 |
12 | /**
13 | * http 协议下的任务交互
14 | *
15 | * @author ligaofeng 2016年12月14日 下午1:21:50
16 | */
17 | @Getter
18 | @Setter
19 | public class HttpRemoteScheduleProtocol implements IDTSProtocol, IDTSTaskTracker {
20 |
21 | //dts-server服务端url
22 | private String serverURL;
23 | //超时时间 default 10s
24 | private int timeOut = 10 * 1000;
25 | //整个池子的大小 default 80
26 | private int maxTotal = 80;
27 | //连接到每个地址上的大小 default 20
28 | private int maxPerRoute = 20;
29 | //对指定端口的socket连接上限 default 20
30 | private int maxRoute = 20;
31 |
32 | private HttpScheduleProtocol storeProtocol;
33 |
34 | /**
35 | * @param serverURL
36 | * @param timeOut
37 | */
38 | public HttpRemoteScheduleProtocol(String serverURL, int timeOut) {
39 | this.serverURL = serverURL;
40 | this.timeOut = timeOut;
41 | storeProtocol = new HttpScheduleProtocol(serverURL, timeOut, maxTotal, maxPerRoute, maxRoute);
42 | }
43 |
44 | @Override
45 | public void getConnection() throws DTSBizException {
46 | storeProtocol.getConnection();
47 | }
48 |
49 | @Override
50 | public void executeTask(TaskTrackerContext taskTrackerContext) throws DTSBizException {
51 | this.getConnection();
52 | storeProtocol.executeTask(taskTrackerContext);
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-share/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | org.github.dtsopensource
8 | dts-parent
9 | 1.0.0-SNAPSHOT
10 |
11 |
12 | dts-server-share
13 | jar
14 |
15 |
16 |
17 | org.projectlombok
18 | lombok
19 |
20 |
21 | com.alibaba
22 | fastjson
23 |
24 |
25 |
26 |
27 | dts-server-share
28 |
29 |
30 | org.apache.maven.plugins
31 | maven-jar-plugin
32 |
33 | ../target
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | sonatype-nexus-snapshots
42 | Sonatype Nexus Snapshots
43 | http://192.168.197.129:8081/nexus/content/repositories/snapshots/
44 |
45 | false
46 |
47 |
48 | true
49 |
50 |
51 |
52 |
53 |
54 |
55 | nexus-snapshots
56 | nexus-snapshots
57 | http://192.168.197.129:8081/nexus/content/repositories/snapshots/
58 |
59 |
60 | nexus-releases
61 | nexus-releases
62 | http://192.168.197.129:8081/nexus/content/repositories/releases/
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-web/src/main/java/org/github/dtsopensource/server/web/handler/HttpRuleAdapter.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.web.handler;
2 |
3 | import java.util.Map;
4 |
5 | import javax.annotation.Resource;
6 |
7 | import org.github.dtsopensource.server.rule.HttpServerRuleProtocol;
8 | import org.github.dtsopensource.server.share.ResultBase;
9 | import org.github.dtsopensource.server.share.protocol.ProtocolConstance;
10 | import org.github.dtsopensource.server.share.protocol.ProtocolMethod;
11 | import org.github.dtsopensource.server.share.rule.entity.ActivityRuleEntity;
12 | import org.springframework.stereotype.Component;
13 |
14 | /**
15 | * @author ligaofeng 2016年12月16日 下午4:27:58
16 | */
17 | @Component
18 | public class HttpRuleAdapter extends HttpAdapterManager {
19 |
20 | @Resource
21 | private HttpServerRuleProtocol httpServerRuleProtocol;
22 |
23 | @Override
24 | protected void handle(ProtocolMethod protocolmethod, Map params) {
25 | switch (protocolmethod) {
26 | case getBizTypeRule:
27 | this.getBizTypeRule(params);
28 | break;
29 | case checkBizType:
30 | this.checkBizType(params);
31 | break;
32 | default:
33 | this.unsupprotMethod(params);
34 | break;
35 | }
36 | }
37 |
38 | private void getBizTypeRule(Map params) {
39 | String bizType = String.valueOf(params.get(ProtocolConstance.paramObject));
40 | ResultBase resultBase = httpServerRuleProtocol.getBizTypeRule(bizType);
41 | this.buildSuccessResponse(params, resultBase);
42 | }
43 |
44 | private void checkBizType(Map params) {
45 | String bizType = String.valueOf(params.get(ProtocolConstance.paramObject));
46 | ResultBase resultBase = httpServerRuleProtocol.checkBizType(bizType);
47 | this.buildSuccessResponse(params, resultBase);
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/dts-parent/dts-admin/src/main/java/org/github/dtsopensource/admin/dao/mapper/ActivityActionRuleDOMapper.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.admin.dao.mapper;
2 |
3 | import java.util.List;
4 |
5 | import org.apache.ibatis.annotations.Param;
6 | import org.github.dtsopensource.admin.dao.dataobject.ActivityActionRuleDO;
7 | import org.github.dtsopensource.admin.dao.dataobject.ActivityActionRuleDOExample;
8 |
9 | /**
10 | * @author ligaofeng 2016年12月23日 下午1:36:15
11 | */
12 | public interface ActivityActionRuleDOMapper {
13 | /**
14 | * @param bizAction
15 | * @return
16 | */
17 | int deleteByPrimaryKey(String bizAction);
18 |
19 | /**
20 | * @param record
21 | * @return
22 | */
23 | int insert(ActivityActionRuleDO record);
24 |
25 | /**
26 | * @param record
27 | * @return
28 | */
29 | int insertSelective(ActivityActionRuleDO record);
30 |
31 | /**
32 | * @param example
33 | * @return
34 | */
35 | List selectByExample(ActivityActionRuleDOExample example);
36 |
37 | /**
38 | * @param bizAction
39 | * @return
40 | */
41 | ActivityActionRuleDO selectByPrimaryKey(String bizAction);
42 |
43 | /**
44 | * @param record
45 | * @param example
46 | * @return
47 | */
48 | int updateByExampleSelective(@Param("record") ActivityActionRuleDO record,
49 | @Param("example") ActivityActionRuleDOExample example);
50 |
51 | /**
52 | * @param record
53 | * @param example
54 | * @return
55 | */
56 | int updateByExample(@Param("record") ActivityActionRuleDO record,
57 | @Param("example") ActivityActionRuleDOExample example);
58 |
59 | /**
60 | * @param record
61 | * @return
62 | */
63 | int updateByPrimaryKeySelective(ActivityActionRuleDO record);
64 |
65 | /**
66 | * @param record
67 | * @return
68 | */
69 | int updateByPrimaryKey(ActivityActionRuleDO record);
70 | }
71 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-web/src/main/java/org/github/dtsopensource/server/web/handler/HttpScheduleAdapter.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.web.handler;
2 |
3 | import java.util.Map;
4 |
5 | import javax.annotation.Resource;
6 |
7 | import org.github.dtsopensource.server.schedule.http.IHttpServerSchedule;
8 | import org.github.dtsopensource.server.share.exception.DTSBizException;
9 | import org.github.dtsopensource.server.share.protocol.ProtocolConstance;
10 | import org.github.dtsopensource.server.share.protocol.ProtocolMethod;
11 | import org.github.dtsopensource.server.share.schedule.TaskTrackerContext;
12 | import org.springframework.stereotype.Component;
13 |
14 | import com.alibaba.fastjson.JSON;
15 |
16 | import lombok.extern.slf4j.Slf4j;
17 |
18 | /**
19 | * @author ligaofeng 2016年12月18日 上午1:52:14
20 | */
21 | @Slf4j
22 | @Component
23 | public class HttpScheduleAdapter extends HttpAdapterManager {
24 |
25 | @Resource
26 | private IHttpServerSchedule httpServerScheduleProtocol;
27 |
28 | @Override
29 | protected void handle(ProtocolMethod protocolmethod, Map params) {
30 | switch (protocolmethod) {
31 | case requestSchedule:
32 | this.requestSchedule(params);
33 | break;
34 | default:
35 | this.unsupprotMethod(params);
36 | break;
37 | }
38 | }
39 |
40 | private void requestSchedule(Map params) {
41 | String paramObjectJson = String.valueOf(params.get(ProtocolConstance.paramObject));
42 | TaskTrackerContext taskTrackerContext = JSON.parseObject(paramObjectJson, TaskTrackerContext.class);
43 | try {
44 | httpServerScheduleProtocol.executeTask(taskTrackerContext);
45 | this.buildSuccessResponse(params, "dts-server处理成功");
46 | } catch (DTSBizException e) {
47 | log.error(e.getMessage(), e);
48 | this.buildSuccessResponse(params, "dts-server处理出现异常:" + e.getMessage());
49 | }
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/java/org/github/dtsopensource/local/test/bizService/impl/TradeLog.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.local.test.bizService.impl;
2 |
3 | import java.io.File;
4 | import java.util.List;
5 |
6 | import org.apache.commons.collections.CollectionUtils;
7 | import org.github.dtsopensource.local.test.FileCreator;
8 | import org.github.dtsopensource.local.test.bizService.ITradeLog;
9 | import org.github.dtsopensource.server.share.DTSContext;
10 | import org.springframework.stereotype.Service;
11 |
12 | import lombok.extern.slf4j.Slf4j;
13 |
14 | /**
15 | * @author ligaofeng 2016年12月9日 下午3:12:00
16 | */
17 | @Slf4j
18 | @Service("tradeLog")
19 | public class TradeLog implements ITradeLog {
20 |
21 | private static final String dtslogRootPath = "/alidata1/admin/dtslog";
22 |
23 | @Override
24 | public void saveTradeLog(String operation, String tradeLog) {
25 | DTSContext dtsContext = DTSContext.getInstance();
26 | String activityId = dtsContext.getActivityId();
27 | this.saveTradeLog(activityId, operation, tradeLog);
28 | }
29 |
30 | @Override
31 | public void saveTradeLog(String activityId, String operation, String tradeLog) {
32 | String acitivitylogPath = dtslogRootPath + File.separator + activityId;
33 | log.info("--->新增一笔:{} 日志:{}", operation, tradeLog);
34 | FileCreator.createFile(tradeLog, acitivitylogPath);
35 | }
36 |
37 | @Override
38 | public List getNewLog(String activityId) {
39 | String acitivitylogPath = dtslogRootPath + File.separator + activityId;
40 | return FileCreator.parseTxtFile(acitivitylogPath);
41 | }
42 |
43 | @Override
44 | public void saveTradeLogIfPossible(String activityId, String operation, String tradeLog) {
45 | List logs = this.getNewLog(activityId);
46 | if (CollectionUtils.isNotEmpty(logs) && logs.contains(tradeLog)) {
47 | return;
48 | }
49 | this.saveTradeLog(activityId, operation, tradeLog);
50 |
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/src/main/java/org/github/dtsopensource/remote/test/bizService/impl/TradeLog.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.remote.test.bizService.impl;
2 |
3 | import java.io.File;
4 | import java.util.List;
5 |
6 | import org.apache.commons.collections.CollectionUtils;
7 | import org.github.dtsopensource.remote.test.FileCreator;
8 | import org.github.dtsopensource.remote.test.bizService.ITradeLog;
9 | import org.github.dtsopensource.server.share.DTSContext;
10 | import org.springframework.stereotype.Service;
11 |
12 | import lombok.extern.slf4j.Slf4j;
13 |
14 | /**
15 | * @author ligaofeng 2016年12月9日 下午3:12:00
16 | */
17 | @Slf4j
18 | @Service("tradeLog")
19 | public class TradeLog implements ITradeLog {
20 |
21 | private static final String dtslogRootPath = "/alidata1/admin/dtslog";
22 |
23 | @Override
24 | public void saveTradeLog(String operation, String tradeLog) {
25 | DTSContext dtsContext = DTSContext.getInstance();
26 | String activityId = dtsContext.getActivityId();
27 | this.saveTradeLog(activityId, operation, tradeLog);
28 | }
29 |
30 | @Override
31 | public void saveTradeLog(String activityId, String operation, String tradeLog) {
32 | String acitivitylogPath = dtslogRootPath + File.separator + activityId;
33 | log.info("--->新增一笔:{} 日志:{}", operation, tradeLog);
34 | FileCreator.createFile(tradeLog, acitivitylogPath);
35 | }
36 |
37 | @Override
38 | public List getNewLog(String activityId) {
39 | String acitivitylogPath = dtslogRootPath + File.separator + activityId;
40 | return FileCreator.parseTxtFile(acitivitylogPath);
41 | }
42 |
43 | @Override
44 | public void saveTradeLogIfPossible(String activityId, String operation, String tradeLog) {
45 | List logs = this.getNewLog(activityId);
46 | if (CollectionUtils.isNotEmpty(logs) && logs.contains(tradeLog)) {
47 | return;
48 | }
49 | this.saveTradeLog(activityId, operation, tradeLog);
50 |
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/src/main/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 | contextConfigLocation
10 |
11 | classpath*:/beanRefContext.xml
12 |
13 |
14 |
15 |
16 |
17 | logbackConfigLocation
18 | /WEB-INF/logback.xml
19 |
20 |
21 |
22 | ch.qos.logback.ext.spring.web.LogbackConfigListener
23 |
24 |
25 |
26 | org.springframework.web.context.ContextLoaderListener
27 |
28 |
29 |
30 |
31 | Dispatcher
32 | org.springframework.web.servlet.DispatcherServlet
33 |
34 | contextConfigLocation
35 |
36 |
37 |
38 | 1
39 |
40 |
41 |
42 | Dispatcher
43 | /*
44 |
45 |
46 |
47 |
48 | encodingFilter
49 | org.springframework.web.filter.CharacterEncodingFilter
50 |
51 | encoding
52 | UTF-8
53 |
54 |
55 | forceEncoding
56 | true
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/src/main/resources/spring/spring-view.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
13 |
14 |
15 | text/plain;charset=UTF-8
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
32 |
33 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/store/impl/RemoteDTSStore.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.store.impl;
2 |
3 | import java.util.List;
4 |
5 | import org.github.dtsopensource.core.protocol.StoreProtocolManager;
6 | import org.github.dtsopensource.server.share.DTSContext;
7 | import org.github.dtsopensource.server.share.ResultBase;
8 | import org.github.dtsopensource.server.share.store.IDTSStore;
9 | import org.github.dtsopensource.server.share.store.entity.ActionEntity;
10 | import org.github.dtsopensource.server.share.store.entity.ActivityEntity;
11 |
12 | import lombok.Getter;
13 |
14 | /**
15 | * @author ligaofeng 2016年12月3日 下午4:33:16
16 | */
17 | public class RemoteDTSStore implements IDTSStore {
18 |
19 | @Getter
20 | private final StoreProtocolManager remoteProtocol;
21 |
22 | /**
23 | * @param remoteProtocol
24 | */
25 | public RemoteDTSStore(StoreProtocolManager remoteProtocol) {
26 | this.remoteProtocol = remoteProtocol;
27 | }
28 |
29 | @Override
30 | public ResultBase openTransaction(ActivityEntity activityEntity) {
31 | return remoteProtocol.openTransaction(activityEntity);
32 | }
33 |
34 | @Override
35 | public ResultBase getAndCreateAction(ActionEntity actionEntity) {
36 | return remoteProtocol.getAndCreateAction(actionEntity);
37 | }
38 |
39 | @Override
40 | public ResultBase updateAction(ActionEntity actionEntity) {
41 | return remoteProtocol.updateAction(actionEntity);
42 | }
43 |
44 | @Override
45 | public ResultBase commitActivity(String activityId) {
46 | return remoteProtocol.commitActivity(activityId);
47 | }
48 |
49 | @Override
50 | public ResultBase rollbackActivity(String activityId) {
51 | return remoteProtocol.rollbackActivity(activityId);
52 | }
53 |
54 | @Override
55 | public ResultBase> getActionEntities(String activityId) {
56 | return remoteProtocol.getActionEntities(activityId);
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/dts-parent/doc/init/init.data:
--------------------------------------------------------------------------------
1 | -------init.dts_activity_rule-------
2 | insert into `dts_activity_rule` (`biz_type`, `app`, `app_cname`, `biz_type_name`, `is_deleted`, `gmt_created`, `gmt_modified`, `creator`, `modifier`) values('dts-local-example','JRTZ','local模式测试','申购','N',now(),now(),'system','system');
3 | insert into `dts_activity_rule` (`biz_type`, `app`, `app_cname`, `biz_type_name`, `is_deleted`, `gmt_created`, `gmt_modified`, `creator`, `modifier`) values('dts-remote-example','JRTZ','remote模式测试','申购','N',now(),now(),'system','system');
4 |
5 | -------init.dts_activity_action_rule-------
6 | insert into `dts_activity_action_rule` (`biz_action`, `biz_action_name`, `biz_type`, `service`, `clazz_name`, `trans_recovery_id`, `is_deleted`, `gmt_created`, `gmt_modified`, `creator`, `modifier`) values('dts-local-example-order','申购下单','dts-local-example','orderTrade','org.github.dtsopensource.local.test.bizService.impl.OrderTrade','orderTrade','N',now(),now(),'system','system');
7 | insert into `dts_activity_action_rule` (`biz_action`, `biz_action_name`, `biz_type`, `service`, `clazz_name`, `trans_recovery_id`, `is_deleted`, `gmt_created`, `gmt_modified`, `creator`, `modifier`) values('dts-local-example-yuePaymentTrade','申购余额支付','dts-local-example','yuePaymentTrade','org.github.dtsopensource.local.test.bizService.impl.YuePaymentTrade','yuePaymentTrade','N',now(),now(),'system','system');
8 | insert into `dts_activity_action_rule` (`biz_action`, `biz_action_name`, `biz_type`, `service`, `clazz_name`, `trans_recovery_id`, `is_deleted`, `gmt_created`, `gmt_modified`, `creator`, `modifier`) values('dts-remote-example-order','申购下单','dts-remote-example','remoteOrderTrade','org.github.dtsopensource.local.test.bizService.impl.OrderTrade','orderTrade','N',now(),now(),'system','system');
9 | insert into `dts_activity_action_rule` (`biz_action`, `biz_action_name`, `biz_type`, `service`, `clazz_name`, `trans_recovery_id`, `is_deleted`, `gmt_created`, `gmt_modified`, `creator`, `modifier`) values('dts-remote-example-yuePaymentTrade','申购余额支付','dts-remote-example','remoteYuePaymentTrade','org.github.dtsopensource.local.test.bizService.impl.YuePaymentTrade','yuePaymentTrade','N',now(),now(),'system','system');
--------------------------------------------------------------------------------
/dts-parent/dts-admin/src/main/resources/static/css/dashboard.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Base structure
3 | */
4 |
5 | /* Move down content because we have a fixed navbar that is 50px tall */
6 | body {
7 | padding-top: 50px;
8 | }
9 |
10 |
11 | /*
12 | * Global add-ons
13 | */
14 |
15 | .sub-header {
16 | padding-bottom: 10px;
17 | border-bottom: 1px solid #eee;
18 | }
19 |
20 | /*
21 | * Top navigation
22 | * Hide default border to remove 1px line.
23 | */
24 | .navbar-fixed-top {
25 | border: 0;
26 | }
27 |
28 | /*
29 | * Sidebar
30 | */
31 |
32 | /* Hide for mobile, show later */
33 | .sidebar {
34 | display: none;
35 | }
36 | @media (min-width: 768px) {
37 | .sidebar {
38 | position: fixed;
39 | top: 51px;
40 | bottom: 0;
41 | left: 0;
42 | z-index: 1000;
43 | display: block;
44 | padding: 20px;
45 | overflow-x: hidden;
46 | overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */
47 | background-color: #f5f5f5;
48 | border-right: 1px solid #eee;
49 | }
50 | }
51 |
52 | /* Sidebar navigation */
53 | .nav-sidebar {
54 | margin-right: -21px; /* 20px padding + 1px border */
55 | margin-bottom: 20px;
56 | margin-left: -20px;
57 | }
58 | .nav-sidebar > li > a {
59 | padding-right: 20px;
60 | padding-left: 20px;
61 | }
62 | .nav-sidebar > .active > a,
63 | .nav-sidebar > .active > a:hover,
64 | .nav-sidebar > .active > a:focus {
65 | color: #fff;
66 | background-color: #428bca;
67 | }
68 |
69 |
70 | /*
71 | * Main content
72 | */
73 |
74 | .main {
75 | padding: 20px;
76 | }
77 | @media (min-width: 768px) {
78 | .main {
79 | padding-right: 40px;
80 | padding-left: 40px;
81 | }
82 | }
83 | .main .page-header {
84 | margin-top: 0;
85 | }
86 |
87 |
88 | /*
89 | * Placeholder dashboard ideas
90 | */
91 |
92 | .placeholders {
93 | margin-bottom: 30px;
94 | text-align: center;
95 | }
96 | .placeholders h4 {
97 | margin-bottom: 0;
98 | }
99 | .placeholder {
100 | margin-bottom: 20px;
101 | }
102 | .placeholder img {
103 | display: inline-block;
104 | border-radius: 50%;
105 | }
106 |
--------------------------------------------------------------------------------
/dts-parent/dts-schedule/src/main/java/org/github/dtsopensource/schedule/timerParse/springcron/SpringCronParse.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.schedule.timerParse.springcron;
2 |
3 | import java.util.Date;
4 |
5 | import javax.annotation.PostConstruct;
6 |
7 | import org.apache.commons.lang.StringUtils;
8 | import org.github.dtsopensource.schedule.IJobTimerParse;
9 | import org.github.dtsopensource.server.share.exception.DTSRuntimeException;
10 |
11 | import com.alibaba.fastjson.JSON;
12 |
13 | import lombok.Getter;
14 | import lombok.Setter;
15 | import lombok.extern.slf4j.Slf4j;
16 |
17 | /**
18 | * @author ligaofeng 2016年12月14日 下午2:59:12
19 | */
20 | @Slf4j
21 | public class SpringCronParse implements IJobTimerParse {
22 |
23 | private Object lock = new Object();
24 |
25 | private Date lastExecuteDate = null;
26 |
27 | private CronExpressionEx exp;
28 |
29 | @Getter
30 | @Setter
31 | private String cron;
32 |
33 | @PostConstruct
34 | public void initCronExpression() {
35 | if (StringUtils.isEmpty(cron)) {
36 | throw new DTSRuntimeException("spring cron表达式尚未配置");
37 | }
38 | if (exp == null) {
39 | try {
40 | exp = new CronExpressionEx(cron);
41 | } catch (Exception e) {
42 | throw new DTSRuntimeException("spring cron表达式格式不正确cron:" + cron);
43 | }
44 | }
45 | }
46 |
47 | @Override
48 | public boolean canRun() {
49 |
50 | synchronized (lock) {
51 | if (lastExecuteDate == null) {
52 | lastExecuteDate = new Date();
53 | }
54 | Date nextDate = exp.getNextValidTimeAfter(lastExecuteDate);
55 | boolean canRun = !nextDate.after(new Date());
56 | if (canRun) {
57 | lastExecuteDate = nextDate;
58 | return true;
59 | }
60 | return false;
61 | }
62 | }
63 |
64 | @Override
65 | public String toString() {
66 | return JSON.toJSONString(this);
67 | }
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-web/src/main/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 | contextConfigLocation
10 |
11 | classpath*:/beanRefContext.xml
12 |
13 |
14 |
15 |
16 |
17 | logbackConfigLocation
18 | /WEB-INF/logback.xml
19 |
20 |
21 |
22 | ch.qos.logback.ext.spring.web.LogbackConfigListener
23 |
24 |
25 |
26 | org.springframework.web.context.ContextLoaderListener
27 |
28 |
29 |
30 |
31 | Dispatcher
32 | org.springframework.web.servlet.DispatcherServlet
33 |
34 | contextConfigLocation
35 |
36 |
37 |
38 | 1
39 |
40 |
41 |
42 | Dispatcher
43 | /*
44 |
45 |
46 |
47 |
48 | encodingFilter
49 | org.springframework.web.filter.CharacterEncodingFilter
50 |
51 | encoding
52 | UTF-8
53 |
54 |
55 | forceEncoding
56 | true
57 |
58 |
59 |
60 |
61 | encodingFilter
62 | /*
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 | contextConfigLocation
9 |
10 | classpath*:/beanRefContext.xml
11 |
12 |
13 |
14 |
15 |
16 | logbackConfigLocation
17 | /WEB-INF/logback.xml
18 |
19 |
20 |
21 | ch.qos.logback.ext.spring.web.LogbackConfigListener
22 |
23 |
24 |
25 | org.springframework.web.context.ContextLoaderListener
26 |
27 |
28 |
29 |
30 | Dispatcher
31 | org.springframework.web.servlet.DispatcherServlet
32 |
33 | contextConfigLocation
34 |
35 |
36 |
37 | 1
38 |
39 |
40 |
41 | Dispatcher
42 | /*
43 |
44 |
45 |
46 |
47 | encodingFilter
48 | org.springframework.web.filter.CharacterEncodingFilter
49 |
50 | encoding
51 | UTF-8
52 |
53 |
54 | forceEncoding
55 | true
56 |
57 |
58 |
59 |
60 | encodingFilter
61 | /*
62 |
63 |
64 |
--------------------------------------------------------------------------------
/dts-parent/dts-server-web/src/main/resources/spring/spring-view.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
13 |
15 |
16 |
17 | text/plain;charset=UTF-8
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
36 |
37 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/resources/spring/spring-view.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
13 |
15 |
16 |
17 | text/plain;charset=UTF-8
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
36 |
37 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/dts-parent/dts-schedule/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | org.github.dtsopensource
7 | dts-parent
8 | 1.0.0-SNAPSHOT
9 |
10 |
11 | dts-schedule
12 | jar
13 |
14 |
15 |
16 | org.github.dtsopensource
17 | dts-core
18 | ${project.version}
19 |
20 |
21 | quartz
22 | quartz
23 |
24 |
25 | org.apache.zookeeper
26 | zookeeper
27 |
28 |
29 |
30 |
31 | dts-schedule
32 |
33 |
34 | org.apache.maven.plugins
35 | maven-jar-plugin
36 |
37 | ../target
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | sonatype-nexus-snapshots
46 | Sonatype Nexus Snapshots
47 | http://192.168.197.129:8081/nexus/content/repositories/snapshots/
48 |
49 | false
50 |
51 |
52 | true
53 |
54 |
55 |
56 |
57 |
58 |
59 | nexus-snapshots
60 | nexus-snapshots
61 | http://192.168.197.129:8081/nexus/content/repositories/snapshots/
62 |
63 |
64 | nexus-releases
65 | nexus-releases
66 | http://192.168.197.129:8081/nexus/content/repositories/releases/
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/dts-parent/dts-schedule/src/main/java/org/github/dtsopensource/schedule/register/zookeeper/ZookeeperJobRegister.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.schedule.register.zookeeper;
2 |
3 | import javax.annotation.PostConstruct;
4 |
5 | import org.apache.commons.lang.StringUtils;
6 | import org.github.dtsopensource.schedule.IJobRegister;
7 | import org.github.dtsopensource.server.share.exception.DTSRuntimeException;
8 |
9 | import com.alibaba.fastjson.JSON;
10 |
11 | import lombok.Getter;
12 | import lombok.Setter;
13 |
14 | /**
15 | * @author ligaofeng 2016年12月14日 下午3:51:14
16 | */
17 | public class ZookeeperJobRegister implements IJobRegister {
18 |
19 | @Getter
20 | @Setter
21 | private String zkConnectionString;
22 | @Getter
23 | @Setter
24 | private int zkSessionTimeout = 60000;
25 | @Getter
26 | @Setter
27 | private String ephemeralZnodeParent;
28 | @Getter
29 | @Setter
30 | private String ephemeralZnodeNamePrefix;
31 |
32 | private LeaderElector leaderElector;
33 |
34 | /**
35 | * 初始化
36 | */
37 | @PostConstruct
38 | public void initLeaderElector() {
39 | if (StringUtils.isEmpty(zkConnectionString)) {
40 | throw new DTSRuntimeException("zkConnectionString尚未配置");
41 | }
42 | if (StringUtils.isEmpty(ephemeralZnodeParent)) {
43 | throw new DTSRuntimeException("ephemeralZnodeParent尚未配置");
44 | }
45 | if (StringUtils.isEmpty(ephemeralZnodeNamePrefix)) {
46 | throw new DTSRuntimeException("ephemeralZnodeNamePrefix尚未配置");
47 | }
48 | leaderElector = new LeaderElector(zkConnectionString, zkSessionTimeout, ephemeralZnodeParent,
49 | ephemeralZnodeNamePrefix);
50 | }
51 |
52 | @Override
53 | public boolean register() {
54 | return leaderElector.isLeader();
55 | }
56 |
57 | @Override
58 | public void stop() {
59 | //do nothing
60 | }
61 |
62 | @Override
63 | public void destroy() {
64 | leaderElector.destroy();
65 | }
66 |
67 | @Override
68 | public String toString() {
69 | return JSON.toJSONString(this);
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/dts-parent/dts-schedule/src/main/java/org/github/dtsopensource/schedule/jobTracker/RemoteJobTrackerDelegate.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.schedule.jobTracker;
2 |
3 | import org.apache.commons.lang.StringUtils;
4 | import org.github.dtsopensource.schedule.taskTracker.RemoteTaskTrackerDelegate;
5 | import org.github.dtsopensource.server.share.exception.DTSRuntimeException;
6 | import org.github.dtsopensource.server.share.schedule.IDTSTaskTracker;
7 | import org.github.dtsopensource.server.share.schedule.TaskTrackerContext;
8 |
9 | import com.alibaba.fastjson.JSON;
10 |
11 | import lombok.Getter;
12 | import lombok.Setter;
13 |
14 | /**
15 | * @author ligaofeng 2016年12月14日 下午1:05:34
16 | */
17 | public class RemoteJobTrackerDelegate extends DTSJobTrackerDelegate {
18 |
19 | @Getter
20 | @Setter
21 | private String taskTrackerType;
22 | @Getter
23 | @Setter
24 | private String requestScheduleURL;
25 | @Getter
26 | @Setter
27 | private int timeOut = 10 * 1000;
28 |
29 | @Override
30 | protected void check() {
31 | if (jobRegister == null) {
32 | throw new DTSRuntimeException("尚未设置任务注册器jobRegister");
33 | }
34 | if (timerParse == null) {
35 | throw new DTSRuntimeException("尚未设置计时器timerParse");
36 | }
37 | if (dtsConfig == null) {
38 | throw new DTSRuntimeException("尚未设置系统配置dtsConfig");
39 | }
40 | if (taskTrackerType == null) {
41 | throw new DTSRuntimeException("尚未设置要执行的任务类型taskTrackerType");
42 | }
43 | if (StringUtils.isEmpty(requestScheduleURL)) {
44 | throw new DTSRuntimeException("REMOTE模式下请设置要请求的dts-server地址requestScheduleURL");
45 | }
46 | }
47 |
48 | @Override
49 | protected IDTSTaskTracker initTaskTrackerDelegate() {
50 | return new RemoteTaskTrackerDelegate(requestScheduleURL, timeOut);
51 | }
52 |
53 | @Override
54 | protected TaskTrackerContext initTaskTrackerContext() {
55 | TaskTrackerContext taskTrackerContext = new TaskTrackerContext();
56 | taskTrackerContext.setDtsConfig(dtsConfig);
57 | taskTrackerContext.setTaskTrackerType(taskTrackerType);
58 | return taskTrackerContext;
59 | }
60 |
61 | @Override
62 | public String toString() {
63 | return JSON.toJSONString(this);
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/dts-parent/dts-schedule/src/main/java/org/github/dtsopensource/schedule/protocol/http/HttpScheduleProtocol.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.schedule.protocol.http;
2 |
3 | import java.util.Map;
4 |
5 | import org.github.dtsopensource.core.protocol.http.protocol.impl.HttpProtoclCallback;
6 | import org.github.dtsopensource.core.protocol.http.protocol.impl.HttpProtocolParent;
7 | import org.github.dtsopensource.server.share.exception.DTSBizException;
8 | import org.github.dtsopensource.server.share.protocol.ProtocolConstance;
9 | import org.github.dtsopensource.server.share.protocol.ProtocolMethod;
10 | import org.github.dtsopensource.server.share.schedule.IDTSTaskTracker;
11 | import org.github.dtsopensource.server.share.schedule.TaskTrackerContext;
12 |
13 | import com.alibaba.fastjson.JSON;
14 | import com.google.common.collect.Maps;
15 |
16 | import lombok.extern.slf4j.Slf4j;
17 |
18 | /**
19 | * @author ligaofeng 2016年12月14日 下午1:46:27
20 | */
21 | @Slf4j
22 | public class HttpScheduleProtocol extends HttpProtocolParent implements IDTSTaskTracker {
23 |
24 | /**
25 | * @param serverURL
26 | * @param timeOut
27 | * @param maxTotal
28 | * @param maxPerRoute
29 | * @param maxRoute
30 | */
31 | public HttpScheduleProtocol(String serverURL, int timeOut, int maxTotal, int maxPerRoute, int maxRoute) {
32 | super(serverURL, timeOut, maxTotal, maxPerRoute, maxRoute);
33 | }
34 |
35 | @Override
36 | public void executeTask(final TaskTrackerContext taskTrackerContext) throws DTSBizException {
37 | try {
38 | String response = httpProtocolTemplate.execute(new HttpProtoclCallback() {
39 |
40 | @Override
41 | public Map buildParams() {
42 | Map params = Maps.newHashMap();
43 | params.put(ProtocolConstance.paramObject, taskTrackerContext);
44 | params.put(ProtocolConstance.requestStoreOperation, ProtocolMethod.requestSchedule);
45 | return params;
46 | }
47 | });
48 | log.info("--->response:{}", response);
49 | } catch (Exception e) {
50 | throw new DTSBizException(e);
51 | }
52 | }
53 |
54 | @Override
55 | public String toString() {
56 | return JSON.toJSONString(this);
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/store/help/ActionHelper.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.store.help;
2 |
3 | import java.util.Date;
4 |
5 | import org.github.dtsopensource.core.dao.dataobject.DtsActionDO;
6 | import org.github.dtsopensource.server.share.store.entity.ActionEntity;
7 |
8 | import com.alibaba.fastjson.JSON;
9 |
10 | /**
11 | * @author ligaofeng 2016年12月2日 下午5:21:22
12 | */
13 | public class ActionHelper {
14 |
15 | private ActionHelper() {
16 | }
17 |
18 | /**
19 | * @param actionDO
20 | * @return
21 | */
22 | public static ActionEntity toActionEntity(DtsActionDO actionDO) {
23 | if (actionDO == null) {
24 | return null;
25 | }
26 | return new ActionEntity.Builder(actionDO.getActionId()).setAction(actionDO.getAction())
27 | .setActivityId(actionDO.getActivityId()).setContext(actionDO.getContext())
28 | .setProtocol(actionDO.getProtocol()).setService(actionDO.getService())
29 | .setClazzName(actionDO.getClazzName()).setStatus(actionDO.getStatus()).setVersion(actionDO.getVersion())
30 | .build();
31 | }
32 |
33 | /**
34 | * @param actionEntity
35 | * @return
36 | * @throws SequenceException
37 | */
38 | public static DtsActionDO toDtsActionDO(ActionEntity actionEntity) {
39 | if (actionEntity == null) {
40 | return new DtsActionDO();
41 | }
42 | Date now = new Date();
43 | DtsActionDO actionDO = new DtsActionDO();
44 | actionDO.setAction(actionEntity.getAction());
45 | actionDO.setActivityId(actionEntity.getActivityId());
46 | actionDO.setActionId(actionEntity.getActionId());
47 | actionDO.setContext(JSON.toJSONString(actionEntity.getContext()));
48 | actionDO.setProtocol(actionEntity.protocol());
49 | actionDO.setService(actionEntity.getService());
50 | actionDO.setClazzName(actionEntity.getClazzName());
51 | actionDO.setStatus(actionEntity.status());
52 | actionDO.setVersion(actionEntity.getVersion());
53 | actionDO.setIsDeleted("N");
54 | actionDO.setGmtCreated(now);
55 | actionDO.setGmtModified(now);
56 | actionDO.setCreator("system");
57 | actionDO.setModifier("system");
58 | return actionDO;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/DTS.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core;
2 |
3 | import java.util.List;
4 |
5 | import org.github.dtsopensource.core.dao.ActionSqlConstance;
6 | import org.github.dtsopensource.core.dao.dataobject.DtsActionDO;
7 | import org.github.dtsopensource.core.dao.rowMapper.DtsActionRowMapper;
8 | import org.github.dtsopensource.core.store.help.ActionHelper;
9 | import org.github.dtsopensource.server.share.DTSResultCode;
10 | import org.github.dtsopensource.server.share.IDTS;
11 | import org.github.dtsopensource.server.share.ResultBase;
12 | import org.github.dtsopensource.server.share.store.entity.ActionEntity;
13 | import org.springframework.jdbc.core.JdbcTemplate;
14 | import org.springframework.transaction.support.TransactionTemplate;
15 |
16 | import com.google.common.collect.Lists;
17 |
18 | import lombok.extern.slf4j.Slf4j;
19 |
20 | /**
21 | * @author ligaofeng 2016年12月16日 上午11:07:30
22 | */
23 | @Slf4j
24 | public class DTS implements IDTS {
25 |
26 | protected final JdbcTemplate jdbcTemplate;
27 |
28 | protected final TransactionTemplate transactionTemplate;
29 |
30 | public DTS(JdbcTemplate jdbcTemplate, TransactionTemplate transactionTemplate) {
31 | this.jdbcTemplate = jdbcTemplate;
32 | this.transactionTemplate = transactionTemplate;
33 | }
34 |
35 | @Override
36 | public ResultBase> getActionEntities(String activityId) {
37 | ResultBase> actionListBase = new ResultBase>();
38 | List actionEntityList = Lists.newArrayList();
39 | actionListBase.setValue(actionEntityList);
40 | try {
41 | Object[] params = new Object[] { activityId };
42 | List actionList = jdbcTemplate.query(ActionSqlConstance.select_dts_action_by_activity_id,
43 | params, new DtsActionRowMapper());
44 | actionListBase.setDtsResultCode(DTSResultCode.SUCCESS);
45 | for (DtsActionDO actionDO : actionList) {
46 | actionEntityList.add(ActionHelper.toActionEntity(actionDO));
47 | }
48 | } catch (Exception e) {
49 | log.error(e.getMessage(), e);
50 | actionListBase.setDtsResultCode(DTSResultCode.FAIL);
51 | actionListBase.setMessage("数据库查询出错");
52 | }
53 | return actionListBase;
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/java/org/github/dtsopensource/local/test/bizService/impl/OrderTrade.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.local.test.bizService.impl;
2 |
3 | import java.math.BigDecimal;
4 |
5 | import javax.annotation.Resource;
6 |
7 | import org.github.dtsopensource.local.test.GenerateId;
8 | import org.github.dtsopensource.local.test.PurchaseContext;
9 | import org.github.dtsopensource.local.test.bizService.AbstraceOrderTrade;
10 | import org.github.dtsopensource.local.test.bizService.ITradeLog;
11 | import org.github.dtsopensource.server.share.DTSContext;
12 | import org.github.dtsopensource.server.share.exception.DTSBizException;
13 | import org.springframework.stereotype.Service;
14 |
15 | /**
16 | * 订单交易
17 | *
18 | * @author ligaofeng 2016年12月8日 下午8:46:32
19 | */
20 | @Service
21 | public class OrderTrade extends AbstraceOrderTrade {
22 |
23 | @Resource
24 | private ITradeLog tradeLog;
25 |
26 | @Override
27 | public void createOrder(DTSContext dtsContext) throws DTSBizException {
28 |
29 | PurchaseContext purchaseContext = dtsContext.getArgs(PurchaseContext.class.getName(), PurchaseContext.class);
30 | String orderId = GenerateId.generateOrderId();
31 | String productName = purchaseContext.getProductName();
32 | dtsContext.addArgs("orderId", orderId);
33 | String createOrder = "马云购买了一个 " + productName + ",订单号:" + orderId + "金额:¥" + purchaseContext.getOrderAmount()
34 | + ",当前状态:处理中";
35 | tradeLog.saveTradeLog("createOrder_" + orderId, createOrder);
36 | }
37 |
38 | @Override
39 | public void submitOrder(DTSContext dtsContext) throws DTSBizException {
40 |
41 | PurchaseContext purchaseContext = dtsContext.getArgs(PurchaseContext.class.getName(), PurchaseContext.class);
42 | String orderId = dtsContext.getArgs("orderId", String.class);
43 |
44 | String productName = purchaseContext.getProductName();
45 | BigDecimal orderAmount = purchaseContext.getOrderAmount();
46 | String submitOrder = "马云的订单:" + orderId + "已处理成功,马云花了 ¥" + orderAmount + " 购买了一个 " + productName;
47 | tradeLog.saveTradeLog("submitOrder_" + orderId, submitOrder);
48 |
49 | }
50 |
51 | @Override
52 | public void cancleOrder(DTSContext dtsContext) throws DTSBizException {
53 | String orderId = dtsContext.getArgs("orderId", String.class);
54 | String cancleOrder = "马云的订单:" + orderId + "已取消成功";
55 | tradeLog.saveTradeLog("cancleOrder_" + orderId, cancleOrder);
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/dts-parent/dts-admin/src/main/resources/generatorConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
29 |
30 |
31 |
32 |
33 |
34 |
36 |
37 |
38 |
39 |
40 |
42 |
43 |
44 |
45 |
47 |
48 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/src/main/java/org/github/dtsopensource/remote/test/bizService/impl/OrderTrade.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.remote.test.bizService.impl;
2 |
3 | import java.math.BigDecimal;
4 |
5 | import javax.annotation.Resource;
6 |
7 | import org.github.dtsopensource.remote.test.GenerateId;
8 | import org.github.dtsopensource.remote.test.PurchaseContext;
9 | import org.github.dtsopensource.remote.test.bizService.AbstraceOrderTrade;
10 | import org.github.dtsopensource.remote.test.bizService.ITradeLog;
11 | import org.github.dtsopensource.server.share.DTSContext;
12 | import org.github.dtsopensource.server.share.exception.DTSBizException;
13 | import org.springframework.stereotype.Service;
14 |
15 | import lombok.extern.slf4j.Slf4j;
16 |
17 | /**
18 | * 订单交易
19 | *
20 | * @author ligaofeng 2016年12月8日 下午8:46:32
21 | */
22 | @Slf4j
23 | @Service("remoteOrderTrade")
24 | public class OrderTrade extends AbstraceOrderTrade {
25 |
26 | @Resource
27 | private ITradeLog tradeLog;
28 |
29 | @Override
30 | public void createOrder(DTSContext dtsContext) throws DTSBizException {
31 | PurchaseContext purchaseContext = dtsContext.getArgs(PurchaseContext.class.getName(), PurchaseContext.class);
32 | String orderId = GenerateId.generateOrderId();
33 | String productName = purchaseContext.getProductName();
34 | dtsContext.addArgs("orderId", orderId);
35 | String createOrder = "马云购买了一个 " + productName + ",订单号:" + orderId + "金额:¥" + purchaseContext.getOrderAmount()
36 | + ",当前状态:处理中";
37 | tradeLog.saveTradeLog("createOrder_" + orderId, createOrder);
38 | }
39 |
40 | @Override
41 | public void submitOrder(DTSContext dtsContext) throws DTSBizException {
42 | PurchaseContext purchaseContext = dtsContext.getArgs(PurchaseContext.class.getName(), PurchaseContext.class);
43 | String orderId = dtsContext.getArgs("orderId", String.class);
44 | String productName = purchaseContext.getProductName();
45 | BigDecimal orderAmount = purchaseContext.getOrderAmount();
46 | String submitOrder = "马云的订单:" + orderId + "已处理成功,马云花了 ¥" + orderAmount + " 购买了一个 " + productName;
47 | tradeLog.saveTradeLog("submitOrder_" + orderId, submitOrder);
48 |
49 | }
50 |
51 | @Override
52 | public void cancleOrder(DTSContext dtsContext) throws DTSBizException {
53 | String orderId = dtsContext.getArgs("orderId", String.class);
54 | String cancleOrder = "马云的订单:" + orderId + "已取消成功";
55 | tradeLog.saveTradeLog("cancleOrder_" + orderId, cancleOrder);
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/dts-parent/dts-core/src/main/java/org/github/dtsopensource/core/manager/DTSManager.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.core.manager;
2 |
3 | import java.util.List;
4 | import java.util.concurrent.atomic.AtomicBoolean;
5 |
6 | import org.github.dtsopensource.server.share.DTSContext;
7 | import org.github.dtsopensource.server.share.ResultBase;
8 | import org.github.dtsopensource.server.share.exception.DTSRuntimeException;
9 | import org.github.dtsopensource.server.share.store.IDTSStore;
10 | import org.github.dtsopensource.server.share.store.entity.ActionEntity;
11 | import org.github.dtsopensource.server.share.store.entity.ActivityEntity;
12 | import org.springframework.beans.factory.InitializingBean;
13 |
14 | import lombok.extern.slf4j.Slf4j;
15 |
16 | /**
17 | * @author ligaofeng 2016年12月10日 下午2:17:55
18 | */
19 | @Slf4j
20 | public abstract class DTSManager implements InitializingBean, IDTSStore {
21 |
22 | protected IDTSStore store;
23 |
24 | private final AtomicBoolean isInit = new AtomicBoolean(false);
25 |
26 | @Override
27 | public void afterPropertiesSet() throws Exception {
28 | try {
29 | check();
30 | } catch (Exception e) {
31 | log.error(e.getMessage());
32 | throw new DTSRuntimeException(e);
33 | }
34 | init();
35 | }
36 |
37 | @Override
38 | public ResultBase openTransaction(ActivityEntity activityEntity) {
39 | return store.openTransaction(activityEntity);
40 | }
41 |
42 | @Override
43 | public ResultBase commitActivity(String activityId) {
44 | return store.commitActivity(activityId);
45 | }
46 |
47 | @Override
48 | public ResultBase> getActionEntities(String activityId) {
49 | return store.getActionEntities(activityId);
50 | }
51 |
52 | @Override
53 | public ResultBase rollbackActivity(String activityId) {
54 | return store.rollbackActivity(activityId);
55 | }
56 |
57 | @Override
58 | public ResultBase getAndCreateAction(ActionEntity actionEntity) {
59 | return store.getAndCreateAction(actionEntity);
60 | }
61 |
62 | @Override
63 | public ResultBase updateAction(ActionEntity actionEntity) {
64 | return store.updateAction(actionEntity);
65 | }
66 |
67 | private void init() {
68 | if (isInit.compareAndSet(false, true)) {
69 | store = initStore();
70 | }
71 | }
72 |
73 | protected abstract void check();
74 |
75 | protected abstract IDTSStore initStore();
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/dts-parent/dts-server/src/main/java/org/github/dtsopensource/server/schedule/http/impl/HttpServerScheduleProtocol.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.server.schedule.http.impl;
2 |
3 | import java.util.Map;
4 |
5 | import javax.annotation.PostConstruct;
6 | import javax.sql.DataSource;
7 |
8 | import org.github.dtsopensource.schedule.LocalDTSSchedule;
9 | import org.github.dtsopensource.server.schedule.http.IHttpServerSchedule;
10 | import org.github.dtsopensource.server.share.exception.DTSBizException;
11 | import org.github.dtsopensource.server.share.schedule.IDTSSchedule;
12 | import org.github.dtsopensource.server.share.schedule.IDTSTaskTracker;
13 | import org.github.dtsopensource.server.share.schedule.TaskTrackerContext;
14 | import org.springframework.jdbc.core.JdbcTemplate;
15 | import org.springframework.jdbc.datasource.DataSourceTransactionManager;
16 | import org.springframework.transaction.TransactionDefinition;
17 | import org.springframework.transaction.support.TransactionTemplate;
18 |
19 | import lombok.Getter;
20 | import lombok.Setter;
21 | import lombok.extern.slf4j.Slf4j;
22 |
23 | /**
24 | * @author ligaofeng 2016年12月14日 下午2:44:58
25 | */
26 | @Slf4j
27 | public class HttpServerScheduleProtocol implements IHttpServerSchedule {
28 |
29 | @Getter
30 | @Setter
31 | private DataSource dataSource;
32 | @Getter
33 | @Setter
34 | private Map taskTrackerMap;
35 |
36 | private IDTSSchedule localDTSSchedule;
37 |
38 | /**
39 | * initDTSSchedule
40 | */
41 | @PostConstruct
42 | public void initDTSSchedule() {
43 | JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
44 | TransactionTemplate transactionTemplate = new TransactionTemplate(new DataSourceTransactionManager(dataSource));
45 | transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
46 | localDTSSchedule = new LocalDTSSchedule(jdbcTemplate, transactionTemplate);
47 | }
48 |
49 | @Override
50 | public void executeTask(TaskTrackerContext taskTrackerContext) throws DTSBizException {
51 | log.info("--->dts-server success recevie:{}", taskTrackerContext);
52 | String taskTrackerType = taskTrackerContext.getTaskTrackerType();
53 | IDTSTaskTracker taskTracker = taskTrackerMap.get(taskTrackerType);
54 | if (taskTracker == null) {
55 | throw new DTSBizException("尚不支持该任务:" + taskTrackerType);
56 | }
57 | taskTrackerContext.setDtsSchedule(localDTSSchedule);
58 | taskTracker.executeTask(taskTrackerContext);
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/dts-parent/dts-admin/src/main/resources/spring/spring-dts-admin-persistence.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 |
23 |
24 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | classpath*:sqlmap/ActivityActionRuleDOMapper.xml
40 | classpath*:sqlmap/ActivityRuleDOMapper.xml
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/dts-parent/dts-admin/src/main/java/org/github/dtsopensource/admin/dao/dataobject/ActivityRuleDO.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.admin.dao.dataobject;
2 |
3 | import java.util.Date;
4 |
5 | /**
6 | * @author ligaofeng 2016年12月23日 下午1:32:52
7 | */
8 | public class ActivityRuleDO {
9 |
10 | private String bizType;
11 |
12 | private String app;
13 |
14 | private String appCname;
15 |
16 | private String bizTypeName;
17 |
18 | private String isDeleted;
19 |
20 | private Date gmtCreated;
21 |
22 | private Date gmtModified;
23 |
24 | private String creator;
25 |
26 | private String modifier;
27 |
28 | public String getBizType() {
29 | return bizType;
30 | }
31 |
32 | public void setBizType(String bizType) {
33 | this.bizType = bizType == null ? null : bizType.trim();
34 | }
35 |
36 | public String getApp() {
37 | return app;
38 | }
39 |
40 | public void setApp(String app) {
41 | this.app = app == null ? null : app.trim();
42 | }
43 |
44 | public String getAppCname() {
45 | return appCname;
46 | }
47 |
48 | public void setAppCname(String appCname) {
49 | this.appCname = appCname == null ? null : appCname.trim();
50 | }
51 |
52 | public String getBizTypeName() {
53 | return bizTypeName;
54 | }
55 |
56 | public void setBizTypeName(String bizTypeName) {
57 | this.bizTypeName = bizTypeName == null ? null : bizTypeName.trim();
58 | }
59 |
60 | public String getIsDeleted() {
61 | return isDeleted;
62 | }
63 |
64 | public void setIsDeleted(String isDeleted) {
65 | this.isDeleted = isDeleted == null ? null : isDeleted.trim();
66 | }
67 |
68 | public Date getGmtCreated() {
69 | return gmtCreated;
70 | }
71 |
72 | public void setGmtCreated(Date gmtCreated) {
73 | this.gmtCreated = gmtCreated;
74 | }
75 |
76 | public Date getGmtModified() {
77 | return gmtModified;
78 | }
79 |
80 | public void setGmtModified(Date gmtModified) {
81 | this.gmtModified = gmtModified;
82 | }
83 |
84 | public String getCreator() {
85 | return creator;
86 | }
87 |
88 | public void setCreator(String creator) {
89 | this.creator = creator == null ? null : creator.trim();
90 | }
91 |
92 | public String getModifier() {
93 | return modifier;
94 | }
95 |
96 | public void setModifier(String modifier) {
97 | this.modifier = modifier == null ? null : modifier.trim();
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/java/org/github/dtsopensource/local/test/controller/DTSController.java:
--------------------------------------------------------------------------------
1 | package org.github.dtsopensource.local.test.controller;
2 |
3 | import java.math.BigDecimal;
4 | import java.util.List;
5 |
6 | import javax.annotation.Resource;
7 | import javax.servlet.http.HttpServletResponse;
8 |
9 | import org.github.dtsopensource.local.test.PurchaseContext;
10 | import org.github.dtsopensource.local.test.application.IPurchaseService;
11 | import org.github.dtsopensource.local.test.bizService.ITradeLog;
12 | import org.springframework.stereotype.Controller;
13 | import org.springframework.web.bind.annotation.RequestMapping;
14 | import org.springframework.web.bind.annotation.RequestMethod;
15 | import org.springframework.web.bind.annotation.RequestParam;
16 |
17 | import lombok.extern.slf4j.Slf4j;
18 |
19 | /**
20 | * @author ligaofeng 2016年12月7日 上午12:01:29
21 | */
22 | @Slf4j
23 | @Controller
24 | @RequestMapping("/product")
25 | public class DTSController {
26 |
27 | @Resource
28 | private IPurchaseService purchaseService;
29 | @Resource
30 | private ITradeLog tradeLog;
31 |
32 | /**
33 | * 申购
34 | *
35 | * @param productName
36 | * @param orderAmount
37 | * @param currentAmount
38 | * @param response
39 | */
40 | @RequestMapping(value = "/purchase", method = RequestMethod.GET)
41 | public void puchase(@RequestParam String productName, @RequestParam BigDecimal orderAmount,
42 | @RequestParam BigDecimal currentAmount, HttpServletResponse response) {
43 | response.setHeader("Content-type", "text/html;charset=UTF-8");
44 | try {
45 | this.sysout(response, "购买商品:[" + productName + "],订单金额:[" + orderAmount + "],账户余额:[" + currentAmount + "]");
46 | PurchaseContext context = new PurchaseContext();
47 | context.setCurrentAmount(currentAmount);
48 | context.setOrderAmount(orderAmount);
49 | context.setProductName(productName);
50 | log.info(context.toString());
51 | String activityId = purchaseService.puchase(context);
52 | this.sysout(response, "业务活动ID:" + activityId);
53 | List list = tradeLog.getNewLog(activityId);
54 | for (String an : list) {
55 | this.sysout(response, an);
56 | }
57 | } catch (Exception e) {
58 | log.error(e.getMessage(), e);
59 | }
60 | }
61 |
62 | private void sysout(HttpServletResponse response, String dtsLog) {
63 | try {
64 | response.getOutputStream().write(dtsLog.getBytes("utf-8"));
65 | response.getOutputStream().write("
".getBytes("utf-8"));
66 | response.getOutputStream().flush();
67 | } catch (Exception e) {
68 | log.error(e.getMessage(), e);
69 | }
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | org.github.dtsopensource
8 | dts-parent
9 | 1.0.0-SNAPSHOT
10 |
11 |
12 | dts-local-example
13 | war
14 |
15 |
16 |
17 | org.github.dtsopensource
18 | dts-core
19 | ${project.version}
20 |
21 |
22 | org.github.dtsopensource
23 | dts-schedule
24 | ${project.version}
25 |
26 |
27 | com.alibaba
28 | druid
29 |
30 |
31 | mysql
32 | mysql-connector-java
33 |
34 |
35 | org.mybatis
36 | mybatis
37 |
38 |
39 | org.mybatis
40 | mybatis-spring
41 |
42 |
43 | ch.qos.logback
44 | logback-classic
45 |
46 |
47 | org.slf4j
48 | slf4j-api
49 |
50 |
51 | org.logback-extensions
52 | logback-ext-spring
53 |
54 |
55 | joda-time
56 | joda-time
57 |
58 |
59 |
60 | org.springframework
61 | spring-webmvc
62 |
63 |
64 | javax.servlet
65 | javax.servlet-api
66 | provided
67 |
68 |
69 |
70 | org.codehaus.jackson
71 | jackson-core-lgpl
72 |
73 |
74 | org.codehaus.jackson
75 | jackson-mapper-lgpl
76 |
77 |
78 |
79 | dts-local-example
80 |
81 |
82 | org.apache.maven.plugins
83 | maven-war-plugin
84 | 2.1.1
85 |
86 | ../target
87 |
88 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/dts-parent/dts-remote-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | org.github.dtsopensource
8 | dts-parent
9 | 1.0.0-SNAPSHOT
10 |
11 |
12 | dts-remote-example
13 | war
14 |
15 |
16 |
17 | org.github.dtsopensource
18 | dts-core
19 | ${project.version}
20 |
21 |
22 | org.github.dtsopensource
23 | dts-schedule
24 | ${project.version}
25 |
26 |
27 | com.alibaba
28 | druid
29 |
30 |
31 | mysql
32 | mysql-connector-java
33 |
34 |
35 | org.mybatis
36 | mybatis
37 |
38 |
39 | org.mybatis
40 | mybatis-spring
41 |
42 |
43 | ch.qos.logback
44 | logback-classic
45 |
46 |
47 | org.slf4j
48 | slf4j-api
49 |
50 |
51 | org.logback-extensions
52 | logback-ext-spring
53 |
54 |
55 | joda-time
56 | joda-time
57 |
58 |
59 |
60 | org.springframework
61 | spring-webmvc
62 |
63 |
64 | javax.servlet
65 | javax.servlet-api
66 | provided
67 |
68 |
69 |
70 | org.codehaus.jackson
71 | jackson-core-lgpl
72 |
73 |
74 | org.codehaus.jackson
75 | jackson-mapper-lgpl
76 |
77 |
78 |
79 | dts-remote-example
80 |
81 |
82 | org.apache.maven.plugins
83 | maven-war-plugin
84 | 2.1.1
85 |
86 | ../target
87 |
88 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/dts-parent/doc/init/init.sql:
--------------------------------------------------------------------------------
1 | -------------------dts.init start--------------------------
2 | --dts_action
3 | CREATE TABLE `dts_action` (
4 | `action_id` varchar(128) NOT NULL,
5 | `activity_id` varchar(128) NOT NULL,
6 | `service` varchar(32) NOT NULL COMMENT '业务系统beanId',
7 | `clazz_name` varchar(256) NOT NULL COMMENT '类名称',
8 | `action` varchar(32) NOT NULL COMMENT '二阶操作',
9 | `version` varchar(8) NOT NULL,
10 | `protocol` varchar(8) NOT NULL,
11 | `status` varchar(2) NOT NULL,
12 | `context` varchar(1024) NOT NULL,
13 | `is_deleted` char(1) NOT NULL,
14 | `gmt_created` datetime NOT NULL,
15 | `gmt_modified` datetime NOT NULL,
16 | `creator` varchar(32) NOT NULL,
17 | `modifier` varchar(32) NOT NULL,
18 | PRIMARY KEY (`action_id`)
19 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8
20 |
21 | --dts_activity
22 | CREATE TABLE `dts_activity` (
23 | `activity_id` varchar(128) NOT NULL,
24 | `app` varchar(32) NOT NULL,
25 | `biz_type` varchar(32) DEFAULT NULL,
26 | `context` varchar(1024) NOT NULL,
27 | `status` varchar(2) NOT NULL,
28 | `is_deleted` char(1) NOT NULL,
29 | `gmt_created` datetime NOT NULL,
30 | `gmt_modified` datetime NOT NULL,
31 | `creator` varchar(32) NOT NULL,
32 | `modifier` varchar(32) NOT NULL,
33 | PRIMARY KEY (`activity_id`)
34 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8
35 |
36 | --dts_activity_action_rule
37 | CREATE TABLE `dts_activity_action_rule` (
38 | `biz_action` varchar(128) NOT NULL,
39 | `biz_action_name` varchar(32) NOT NULL,
40 | `biz_type` varchar(128) NOT NULL,
41 | `service` varchar(32) NOT NULL COMMENT '业务系统beanId',
42 | `clazz_name` varchar(256) NOT NULL COMMENT '类名称',
43 | `trans_recovery_id` varchar(32) NOT NULL COMMENT 'dts二阶恢复beanId',
44 | `is_deleted` char(1) NOT NULL DEFAULT 'N',
45 | `gmt_created` datetime NOT NULL,
46 | `gmt_modified` datetime NOT NULL,
47 | `creator` varchar(32) NOT NULL DEFAULT 'system',
48 | `modifier` varchar(32) DEFAULT 'system',
49 | PRIMARY KEY (`biz_action`)
50 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8
51 |
52 | --dts_activity_rule
53 | CREATE TABLE `dts_activity_rule` (
54 | `biz_type` varchar(128) NOT NULL,
55 | `app` varchar(32) NOT NULL,
56 | `app_cname` varchar(128) NOT NULL,
57 | `biz_type_name` varchar(128) NOT NULL,
58 | `is_deleted` char(1) NOT NULL DEFAULT 'N',
59 | `gmt_created` datetime NOT NULL,
60 | `gmt_modified` datetime NOT NULL,
61 | `creator` varchar(32) NOT NULL,
62 | `modifier` varchar(32) NOT NULL,
63 | PRIMARY KEY (`biz_type`)
64 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8
65 |
66 | -----------------dts.init end---------------------------
67 |
68 | -----------------dts.test.init start--------------------
69 | --dts_test
70 | CREATE TABLE `dts_test` (
71 | `name` varchar(128) DEFAULT NULL,
72 | `value` varchar(1024) DEFAULT NULL
73 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8
74 | -----------------dts.test.init end--------------------
--------------------------------------------------------------------------------
/dts-parent/dts-local-example/src/main/resources/spring/spring-dts-local-config.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------