├── .github
└── FUNDING.yml
├── .gitignore
├── LICENSE
├── README-zh.md
├── README.md
├── bytejta-core
├── pom.xml
└── src
│ └── main
│ └── java
│ └── org
│ └── bytesoft
│ ├── bytejta
│ ├── TransactionBeanFactoryImpl.java
│ ├── TransactionCoordinator.java
│ ├── TransactionImpl.java
│ ├── TransactionManagerImpl.java
│ ├── TransactionRecoveryImpl.java
│ ├── TransactionRepositoryImpl.java
│ ├── TransactionStrategy.java
│ ├── UserTransactionImpl.java
│ ├── VacantTransactionLock.java
│ ├── logging
│ │ ├── ArchiveDeserializerImpl.java
│ │ ├── SampleTransactionLogger.java
│ │ ├── deserializer
│ │ │ ├── TransactionArchiveDeserializer.java
│ │ │ └── XAResourceArchiveDeserializer.java
│ │ └── store
│ │ │ ├── VirtualLoggingFile.java
│ │ │ └── VirtualLoggingSystemImpl.java
│ ├── resource
│ │ ├── XATerminatorImpl.java
│ │ └── XATerminatorOptd.java
│ ├── strategy
│ │ ├── CommonTransactionStrategy.java
│ │ ├── LastResourceOptimizeStrategy.java
│ │ ├── SimpleTransactionStrategy.java
│ │ └── VacantTransactionStrategy.java
│ ├── supports
│ │ ├── jdbc
│ │ │ ├── DataSourceHolder.java
│ │ │ ├── LocalXACompatible.java
│ │ │ ├── LocalXAConnection.java
│ │ │ ├── LocalXAResource.java
│ │ │ ├── LogicalConnection.java
│ │ │ └── RecoveredResource.java
│ │ └── resource
│ │ │ ├── CommonResourceDescriptor.java
│ │ │ ├── LocalXAResourceDescriptor.java
│ │ │ ├── RemoteResourceDescriptor.java
│ │ │ └── UnidentifiedResourceDescriptor.java
│ ├── work
│ │ └── TransactionWork.java
│ └── xa
│ │ └── XidFactoryImpl.java
│ ├── common
│ └── utils
│ │ ├── ByteUtils.java
│ │ ├── CommonUtils.java
│ │ └── SerializeUtils.java
│ └── transaction
│ ├── CommitRequiredException.java
│ ├── RemoteSystemException.java
│ ├── RollbackRequiredException.java
│ ├── Transaction.java
│ ├── TransactionBeanFactory.java
│ ├── TransactionContext.java
│ ├── TransactionException.java
│ ├── TransactionLock.java
│ ├── TransactionManager.java
│ ├── TransactionParticipant.java
│ ├── TransactionRecovery.java
│ ├── TransactionRepository.java
│ ├── adapter
│ └── ResourceAdapterImpl.java
│ ├── archive
│ ├── TransactionArchive.java
│ └── XAResourceArchive.java
│ ├── aware
│ ├── TransactionBeanFactoryAware.java
│ ├── TransactionDebuggable.java
│ └── TransactionEndpointAware.java
│ ├── cmd
│ └── CommandDispatcher.java
│ ├── internal
│ ├── SynchronizationImpl.java
│ ├── SynchronizationList.java
│ ├── TransactionListenerList.java
│ └── TransactionResourceListenerList.java
│ ├── logging
│ ├── ArchiveDeserializer.java
│ ├── LoggingFlushable.java
│ ├── TransactionLogger.java
│ └── store
│ │ ├── VirtualLoggingKey.java
│ │ ├── VirtualLoggingListener.java
│ │ ├── VirtualLoggingRecord.java
│ │ ├── VirtualLoggingSystem.java
│ │ └── VirtualLoggingTrigger.java
│ ├── recovery
│ ├── TransactionRecoveryCallback.java
│ └── TransactionRecoveryListener.java
│ ├── remote
│ ├── RemoteAddr.java
│ ├── RemoteCoordinator.java
│ ├── RemoteNode.java
│ └── RemoteSvc.java
│ ├── resource
│ └── XATerminator.java
│ ├── supports
│ ├── TransactionExtra.java
│ ├── TransactionListener.java
│ ├── TransactionListenerAdapter.java
│ ├── TransactionResourceListener.java
│ ├── TransactionResourceListenerAdapter.java
│ ├── TransactionStatistic.java
│ ├── TransactionTimer.java
│ ├── resource
│ │ └── XAResourceDescriptor.java
│ ├── rpc
│ │ ├── TransactionInterceptor.java
│ │ ├── TransactionRequest.java
│ │ └── TransactionResponse.java
│ └── serialize
│ │ └── XAResourceDeserializer.java
│ ├── work
│ ├── SimpleWork.java
│ ├── SimpleWorkListener.java
│ └── SimpleWorkManager.java
│ └── xa
│ ├── TransactionXid.java
│ └── XidFactory.java
├── bytejta-supports-dubbo
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── org
│ │ └── bytesoft
│ │ └── bytejta
│ │ └── supports
│ │ └── dubbo
│ │ ├── DubboRemoteCoordinator.java
│ │ ├── InvocationContextRegistry.java
│ │ ├── TransactionBeanRegistry.java
│ │ ├── config
│ │ └── DubboSupportConfiguration.java
│ │ ├── ext
│ │ └── ILoadBalancer.java
│ │ ├── internal
│ │ ├── TransactionBeanConfigValidator.java
│ │ ├── TransactionEndpointAutoInjector.java
│ │ └── TransactionParticipantRegistrant.java
│ │ ├── serialize
│ │ └── XAResourceDeserializerImpl.java
│ │ └── spi
│ │ ├── TransactionLoadBalance.java
│ │ ├── TransactionLoadBalancer.java
│ │ └── TransactionServiceFilter.java
│ └── resources
│ ├── META-INF
│ └── dubbo
│ │ ├── com.alibaba.dubbo.rpc.Filter
│ │ ├── com.alibaba.dubbo.rpc.cluster.LoadBalance
│ │ └── org.bytesoft.bytejta.supports.dubbo.ext.ILoadBalancer
│ └── bytejta-supports-dubbo.xml
├── bytejta-supports-springcloud
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── org
│ │ └── bytesoft
│ │ └── bytejta
│ │ └── supports
│ │ └── springcloud
│ │ ├── SpringCloudBeanRegistry.java
│ │ ├── SpringCloudCoordinator.java
│ │ ├── SpringCloudEndpointPostProcessor.java
│ │ ├── config
│ │ └── SpringCloudConfiguration.java
│ │ ├── controller
│ │ └── TransactionCoordinatorController.java
│ │ ├── dbcp
│ │ └── CommonDBCPXADataSourceWrapper.java
│ │ ├── feign
│ │ ├── TransactionClientRegistry.java
│ │ ├── TransactionFeignBeanPostProcessor.java
│ │ ├── TransactionFeignContract.java
│ │ ├── TransactionFeignDecoder.java
│ │ ├── TransactionFeignErrorDecoder.java
│ │ ├── TransactionFeignHandler.java
│ │ └── TransactionFeignInterceptor.java
│ │ ├── hystrix
│ │ ├── TransactionHystrixBeanPostProcessor.java
│ │ ├── TransactionHystrixFallbackFactoryHandler.java
│ │ ├── TransactionHystrixFallbackHandler.java
│ │ ├── TransactionHystrixFeignHandler.java
│ │ ├── TransactionHystrixInvocation.java
│ │ ├── TransactionHystrixInvocationHandler.java
│ │ └── TransactionHystrixMethodHandler.java
│ │ ├── loadbalancer
│ │ ├── TransactionLoadBalancerInterceptor.java
│ │ └── TransactionLoadBalancerRuleImpl.java
│ │ ├── property
│ │ ├── TransactionPropertySource.java
│ │ └── TransactionPropertySourceFactory.java
│ │ ├── rule
│ │ ├── TransactionRule.java
│ │ └── TransactionRuleImpl.java
│ │ ├── serialize
│ │ └── XAResourceDeserializerImpl.java
│ │ └── web
│ │ ├── TransactionHandlerInterceptor.java
│ │ └── TransactionRequestInterceptor.java
│ └── resources
│ └── bytejta-supports-springcloud.xml
├── bytejta-supports
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── org
│ │ └── bytesoft
│ │ └── bytejta
│ │ └── supports
│ │ ├── boot
│ │ └── jdbc
│ │ │ ├── DataSourceCciBuilder.java
│ │ │ └── DataSourceSpiBuilder.java
│ │ ├── internal
│ │ ├── RemoteCoordinatorRegistry.java
│ │ └── TransactionCommandDispatcher.java
│ │ ├── jdbc
│ │ └── LocalXADataSource.java
│ │ ├── jpa
│ │ └── hibernate
│ │ │ └── HibernateJtaPlatform.java
│ │ ├── resource
│ │ ├── ManagedConnectionFactoryHandler.java
│ │ ├── ManagedConnectionHandler.java
│ │ ├── ManagedXASessionHandler.java
│ │ ├── jdbc
│ │ │ ├── CallableStatementImpl.java
│ │ │ ├── ConnectionImpl.java
│ │ │ ├── DatabaseMetaDataImpl.java
│ │ │ ├── PreparedStatementImpl.java
│ │ │ ├── StatementImpl.java
│ │ │ ├── XAConnectionImpl.java
│ │ │ └── XADataSourceImpl.java
│ │ └── properties
│ │ │ ├── ConnectorResourcePropertySource.java
│ │ │ └── ConnectorResourcePropertySourceFactory.java
│ │ ├── rpc
│ │ ├── TransactionInterceptorImpl.java
│ │ ├── TransactionRequestImpl.java
│ │ └── TransactionResponseImpl.java
│ │ ├── serialize
│ │ └── XAResourceDeserializerImpl.java
│ │ └── spring
│ │ ├── ManagedConnectionFactoryPostProcessor.java
│ │ ├── TransactionBeanFactoryAutoInjector.java
│ │ └── TransactionDebuggablePostProcessor.java
│ └── resources
│ ├── bytejta-supports-core.xml
│ ├── bytejta-supports-standalone.xml
│ └── bytejta-supports-task.xml
└── pom.xml
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | custom: ['https://raw.githubusercontent.com/wiki/liuyangming/ByteTCC/resources/donation/liuyangming%40alipay.png', 'https://raw.githubusercontent.com/wiki/liuyangming/ByteTCC/resources/donation/liuyangming%40weixin.png'] # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
13 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.class
2 |
3 | # Mobile Tools for Java (J2ME)
4 | .mtj.tmp/
5 |
6 | # Package Files #
7 | *.jar
8 | *.war
9 | *.ear
10 |
11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
12 | hs_err_pid*
13 | .settings
14 | /bytejta-core/.classpath
15 | /bytejta-core/.project
16 | /bytejta-core/.gitignore
17 | /bytejta-supports/.classpath
18 | /bytejta-supports/.gitignore
19 | /bytejta-supports/.project
20 | target
21 | /bytejta-supports-dubbo/.classpath
22 | /bytejta-supports-dubbo/.project
23 | /bytejta-supports-springcloud/.classpath
24 | /bytejta-supports-springcloud/.project
25 | /bytejta-logger/.classpath
26 | /bytejta-logger/.project
27 | /bytejta-transaction-logger/.classpath
28 | /bytejta-transaction-logger/.project
29 |
--------------------------------------------------------------------------------
/README-zh.md:
--------------------------------------------------------------------------------
1 | ByteJTA是一个基于XA/2PC机制的分布式事务管理器。实现了JTA接口,可以很好的与EJB、Spring等容器(本文档下文说明中将以Spring容器为例)进行集成。
2 |
3 | ## 一、文档 & 样例
4 | * 使用文档: https://github.com/liuyangming/ByteJTA/wiki
5 | * 使用样例: https://github.com/liuyangming/ByteJTA-sample
6 |
7 | ## 二、ByteJTA特性
8 | * 1、支持Spring容器的声明式事务管理;
9 | * 2、支持多数据源、跨应用、跨服务器等分布式事务场景;
10 | * 3、支持spring cloud;
11 | * 4、支持dubbo服务框架;
12 |
13 | ## 三、建议及改进
14 | 若您有任何建议,可以通过1)加入qq群537445956/606453172向群主提出,或2)发送邮件至bytefox#126.com向我反馈。本人承诺,任何建议都将会被认真考虑,优秀的建议将会被采用,但不保证一定会在当前版本中实现。
15 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | **ByteJTA** is an implementation of Distributed Transaction Manager, based on the XA/2PC mechanism.
3 |
4 | **ByteJTA** is comptible with JTA and could be seamlessly integrated with Spring and other Java containers.
5 |
6 |
7 | ## 1. Quick Start
8 |
9 | #### 1.1 Add maven depenency
10 | ###### 1.1.1. Spring Cloud
11 | ```xml
12 |
13 | org.bytesoft
14 | bytejta-supports-springcloud
15 | 0.5.0-BETA9
16 |
17 | ```
18 | ###### 1.1.2. dubbo
19 | ```xml
20 |
21 | org.bytesoft
22 | bytejta-supports-dubbo
23 | 0.5.0-BETA9
24 |
25 | ```
26 |
27 |
28 |
29 | ## 2. Documentation & Samples
30 | * [Document](https://github.com/liuyangming/ByteJTA/wiki)
31 | * [Sample](https://github.com/liuyangming/ByteJTA-sample)
32 |
33 |
34 |
35 | ## 3. Features
36 | * support declarative transaction management
37 | * support distributed transaction scenarios. e.g. multi-datasource, cross-applications and cross-servers transaction
38 | * support Dubbo framework
39 | * support Spring Cloud
40 |
41 |
42 |
43 | ## 4. Contact Me
44 | If you have any questions or comments regarding this project, please feel free to contact me at:
45 |
46 | 1. send mail to _[bytefox#126.com](bytefox@126.com)_
47 | ~OR~
48 | 2. add Tecent QQ group 537445956/606453172
49 |
50 | We will review all the suggestions and implement good ones in future release.
51 |
--------------------------------------------------------------------------------
/bytejta-core/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 |
6 | org.bytesoft
7 | bytejta-parent
8 | 0.5.0-BETA9
9 |
10 | bytejta-core
11 |
12 | jar
13 |
14 | bytejta-core
15 | The bytejta-core project is the core module of ByteJTA.
16 | http://www.bytesoft.org
17 |
18 |
19 | UTF-8
20 |
21 |
22 |
23 |
24 | javax.transaction
25 | javax.transaction-api
26 |
27 |
28 | javax.jms
29 | javax.jms-api
30 |
31 |
32 | javax.resource
33 | javax.resource-api
34 |
35 |
36 | org.slf4j
37 | slf4j-api
38 |
39 |
40 |
41 | org.apache.commons
42 | commons-lang3
43 |
44 |
45 | commons-io
46 | commons-io
47 |
48 |
49 |
50 | com.caucho
51 | hessian
52 |
53 |
54 | com.esotericsoftware
55 | kryo
56 |
57 |
58 |
59 | javax.annotation
60 | javax.annotation-api
61 |
62 |
63 | javax.inject
64 | javax.inject
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/bytejta/TransactionRepositoryImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2016 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.bytejta;
17 |
18 | import java.util.ArrayList;
19 | import java.util.List;
20 | import java.util.Map;
21 | import java.util.concurrent.ConcurrentHashMap;
22 |
23 | import org.bytesoft.transaction.Transaction;
24 | import org.bytesoft.transaction.TransactionRepository;
25 | import org.bytesoft.transaction.xa.TransactionXid;
26 |
27 | public class TransactionRepositoryImpl implements TransactionRepository {
28 | private final Map xidToTxMap = new ConcurrentHashMap();
29 | private final Map xidToErrTxMap = new ConcurrentHashMap();
30 |
31 | public void putTransaction(TransactionXid globalXid, Transaction transaction) {
32 | this.xidToTxMap.put(globalXid, transaction);
33 | }
34 |
35 | public Transaction getTransaction(TransactionXid globalXid) {
36 | return this.xidToTxMap.get(globalXid);
37 | }
38 |
39 | public Transaction removeTransaction(TransactionXid globalXid) {
40 | return this.xidToTxMap.remove(globalXid);
41 | }
42 |
43 | public void putErrorTransaction(TransactionXid globalXid, Transaction transaction) {
44 | this.xidToErrTxMap.put(globalXid, transaction);
45 | }
46 |
47 | public Transaction getErrorTransaction(TransactionXid globalXid) {
48 | return this.xidToErrTxMap.get(globalXid);
49 | }
50 |
51 | public Transaction removeErrorTransaction(TransactionXid globalXid) {
52 | return this.xidToErrTxMap.remove(globalXid);
53 | }
54 |
55 | public List getErrorTransactionList() {
56 | return new ArrayList(this.xidToErrTxMap.values());
57 | }
58 |
59 | public List getActiveTransactionList() {
60 | return new ArrayList(this.xidToTxMap.values());
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/bytejta/TransactionStrategy.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2017 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.bytejta;
17 |
18 | import javax.transaction.HeuristicCommitException;
19 | import javax.transaction.HeuristicMixedException;
20 | import javax.transaction.HeuristicRollbackException;
21 | import javax.transaction.SystemException;
22 | import javax.transaction.xa.Xid;
23 |
24 | import org.bytesoft.transaction.CommitRequiredException;
25 | import org.bytesoft.transaction.RollbackRequiredException;
26 |
27 | public interface TransactionStrategy /* extends TransactionBeanFactoryAware */ {
28 |
29 | public int TRANSACTION_STRATEGY_VACANT = 0;
30 | public int TRANSACTION_STRATEGY_SIMPLE = 1;
31 | public int TRANSACTION_STRATEGY_COMMON = 2;
32 | public int TRANSACTION_STRATEGY_LRO = 3;
33 |
34 | public int prepare(Xid xid) throws RollbackRequiredException, CommitRequiredException;
35 |
36 | public void commit(Xid xid, boolean onePhaseCommit)
37 | throws HeuristicMixedException, HeuristicRollbackException, IllegalStateException, SystemException;
38 |
39 | public void rollback(Xid xid)
40 | throws HeuristicMixedException, HeuristicCommitException, IllegalStateException, SystemException;
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/bytejta/UserTransactionImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2016 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.bytejta;
17 |
18 | import java.io.Serializable;
19 |
20 | import javax.naming.NamingException;
21 | import javax.naming.Reference;
22 | import javax.naming.Referenceable;
23 | import javax.transaction.HeuristicMixedException;
24 | import javax.transaction.HeuristicRollbackException;
25 | import javax.transaction.NotSupportedException;
26 | import javax.transaction.RollbackException;
27 | import javax.transaction.SystemException;
28 | import javax.transaction.TransactionManager;
29 | import javax.transaction.UserTransaction;
30 |
31 | public class UserTransactionImpl implements UserTransaction, Referenceable, Serializable {
32 | private static final long serialVersionUID = 1L;
33 |
34 | @javax.inject.Inject
35 | private transient TransactionManager transactionManager;
36 |
37 | public void begin() throws NotSupportedException, SystemException {
38 | this.transactionManager.begin();
39 | }
40 |
41 | public void commit() throws HeuristicMixedException, HeuristicRollbackException, IllegalStateException,
42 | RollbackException, SecurityException, SystemException {
43 | this.transactionManager.commit();
44 | }
45 |
46 | public int getStatus() throws SystemException {
47 | return this.transactionManager.getStatus();
48 | }
49 |
50 | public void rollback() throws IllegalStateException, SecurityException, SystemException {
51 | this.transactionManager.rollback();
52 | }
53 |
54 | public void setRollbackOnly() throws IllegalStateException, SystemException {
55 | this.transactionManager.setRollbackOnly();
56 | }
57 |
58 | public void setTransactionTimeout(int timeout) throws SystemException {
59 | this.transactionManager.setTransactionTimeout(timeout);
60 | }
61 |
62 | public Reference getReference() throws NamingException {
63 | throw new NamingException("Not supported yet!");
64 | }
65 |
66 | public TransactionManager getTransactionManager() {
67 | return transactionManager;
68 | }
69 |
70 | public void setTransactionManager(TransactionManager transactionManager) {
71 | this.transactionManager = transactionManager;
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/bytejta/VacantTransactionLock.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2017 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.bytejta;
17 |
18 | import org.bytesoft.transaction.TransactionLock;
19 | import org.bytesoft.transaction.xa.TransactionXid;
20 |
21 | public class VacantTransactionLock implements TransactionLock {
22 |
23 | public boolean lockTransaction(TransactionXid transactionXid, String identifier) {
24 | return true;
25 | }
26 |
27 | public void unlockTransaction(TransactionXid transactionXid, String identifier) {
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/bytejta/logging/ArchiveDeserializerImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2016 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.bytejta.logging;
17 |
18 | import org.bytesoft.transaction.archive.TransactionArchive;
19 | import org.bytesoft.transaction.archive.XAResourceArchive;
20 | import org.bytesoft.transaction.logging.ArchiveDeserializer;
21 | import org.bytesoft.transaction.xa.TransactionXid;
22 |
23 | public class ArchiveDeserializerImpl implements ArchiveDeserializer {
24 | static final byte TYPE_TRANSACTION = 0x0;
25 | static final byte TYPE_XA_RESOURCE = 0x1;
26 |
27 | private ArchiveDeserializer xaResourceArchiveDeserializer;
28 | private ArchiveDeserializer transactionArchiveDeserializer;
29 |
30 | public byte[] serialize(TransactionXid xid, Object archive) {
31 |
32 | if (TransactionArchive.class.isInstance(archive)) {
33 | byte[] array = this.transactionArchiveDeserializer.serialize(xid, archive);
34 | byte[] byteArray = new byte[array.length + 1];
35 | byteArray[0] = TYPE_TRANSACTION;
36 | System.arraycopy(array, 0, byteArray, 1, array.length);
37 | return byteArray;
38 | } else if (XAResourceArchive.class.isInstance(archive)) {
39 | byte[] array = this.xaResourceArchiveDeserializer.serialize(xid, archive);
40 | byte[] byteArray = new byte[array.length + 1];
41 | byteArray[0] = TYPE_XA_RESOURCE;
42 | System.arraycopy(array, 0, byteArray, 1, array.length);
43 | return byteArray;
44 | } else {
45 | throw new IllegalArgumentException();
46 | }
47 |
48 | }
49 |
50 | public Object deserialize(TransactionXid xid, byte[] array) {
51 | if (array == null || array.length <= 1) {
52 | throw new IllegalArgumentException();
53 | }
54 |
55 | byte type = array[0];
56 | if (type == TYPE_TRANSACTION) {
57 | byte[] byteArray = new byte[array.length - 1];
58 | System.arraycopy(array, 1, byteArray, 0, byteArray.length);
59 | return this.transactionArchiveDeserializer.deserialize(xid, byteArray);
60 | } else if (type == TYPE_XA_RESOURCE) {
61 | byte[] byteArray = new byte[array.length - 1];
62 | System.arraycopy(array, 1, byteArray, 0, byteArray.length);
63 | return this.xaResourceArchiveDeserializer.deserialize(xid, byteArray);
64 | } else {
65 | throw new IllegalArgumentException();
66 | }
67 |
68 | }
69 |
70 | public ArchiveDeserializer getXaResourceArchiveDeserializer() {
71 | return xaResourceArchiveDeserializer;
72 | }
73 |
74 | public void setXaResourceArchiveDeserializer(ArchiveDeserializer xaResourceArchiveDeserializer) {
75 | this.xaResourceArchiveDeserializer = xaResourceArchiveDeserializer;
76 | }
77 |
78 | public ArchiveDeserializer getTransactionArchiveDeserializer() {
79 | return transactionArchiveDeserializer;
80 | }
81 |
82 | public void setTransactionArchiveDeserializer(ArchiveDeserializer transactionArchiveDeserializer) {
83 | this.transactionArchiveDeserializer = transactionArchiveDeserializer;
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/bytejta/strategy/SimpleTransactionStrategy.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2017 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.bytejta.strategy;
17 |
18 | import javax.transaction.HeuristicCommitException;
19 | import javax.transaction.HeuristicMixedException;
20 | import javax.transaction.HeuristicRollbackException;
21 | import javax.transaction.SystemException;
22 | import javax.transaction.xa.XAException;
23 | import javax.transaction.xa.Xid;
24 |
25 | import org.bytesoft.bytejta.TransactionStrategy;
26 | import org.bytesoft.transaction.CommitRequiredException;
27 | import org.bytesoft.transaction.RollbackRequiredException;
28 | import org.bytesoft.transaction.resource.XATerminator;
29 | import org.slf4j.Logger;
30 | import org.slf4j.LoggerFactory;
31 |
32 | public class SimpleTransactionStrategy implements TransactionStrategy {
33 | static final Logger logger = LoggerFactory.getLogger(SimpleTransactionStrategy.class);
34 |
35 | private final XATerminator terminator;
36 |
37 | public SimpleTransactionStrategy(XATerminator terminator) {
38 | if (terminator == null || terminator.getResourceArchives().isEmpty()) {
39 | throw new IllegalStateException();
40 | }
41 |
42 | this.terminator = terminator;
43 | }
44 |
45 | public int prepare(Xid xid) throws RollbackRequiredException, CommitRequiredException {
46 |
47 | try {
48 | return this.terminator.prepare(xid);
49 | } catch (XAException xaex) {
50 | throw new RollbackRequiredException();
51 | } catch (RuntimeException xaex) {
52 | throw new RollbackRequiredException();
53 | }
54 |
55 | }
56 |
57 | public void commit(Xid xid, boolean onePhaseCommit)
58 | throws HeuristicMixedException, HeuristicRollbackException, IllegalStateException, SystemException {
59 | try {
60 | this.terminator.commit(xid, onePhaseCommit);
61 | } catch (XAException xaex) {
62 | switch (xaex.errorCode) {
63 | case XAException.XA_HEURCOM:
64 | break;
65 | case XAException.XA_HEURMIX:
66 | throw new HeuristicMixedException();
67 | case XAException.XA_HEURRB:
68 | throw new HeuristicRollbackException();
69 | default:
70 | logger.error("Unknown state in committing transaction phase.", xaex);
71 | throw new SystemException();
72 | }
73 | } catch (RuntimeException rex) {
74 | logger.error("Unknown state in committing transaction phase.", rex);
75 | throw new SystemException();
76 | }
77 | }
78 |
79 | public void rollback(Xid xid)
80 | throws HeuristicMixedException, HeuristicCommitException, IllegalStateException, SystemException {
81 | try {
82 | this.terminator.rollback(xid);
83 | } catch (XAException xaex) {
84 | switch (xaex.errorCode) {
85 | case XAException.XA_HEURRB:
86 | break;
87 | case XAException.XA_HEURMIX:
88 | throw new HeuristicMixedException();
89 | case XAException.XA_HEURCOM:
90 | throw new HeuristicCommitException();
91 | default:
92 | logger.error("Unknown state in rollingback transaction phase.", xaex);
93 | throw new SystemException();
94 | }
95 | } catch (RuntimeException rex) {
96 | logger.error("Unknown state in rollingback transaction phase.", rex);
97 | throw new SystemException();
98 | }
99 | }
100 |
101 | }
102 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/bytejta/strategy/VacantTransactionStrategy.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2017 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.bytejta.strategy;
17 |
18 | import javax.transaction.HeuristicCommitException;
19 | import javax.transaction.HeuristicMixedException;
20 | import javax.transaction.HeuristicRollbackException;
21 | import javax.transaction.SystemException;
22 | import javax.transaction.xa.XAResource;
23 | import javax.transaction.xa.Xid;
24 |
25 | import org.bytesoft.bytejta.TransactionStrategy;
26 | import org.bytesoft.transaction.CommitRequiredException;
27 | import org.bytesoft.transaction.RollbackRequiredException;
28 |
29 | public class VacantTransactionStrategy implements TransactionStrategy {
30 |
31 | public int prepare(Xid xid) throws RollbackRequiredException, CommitRequiredException {
32 | return XAResource.XA_RDONLY;
33 | }
34 |
35 | public void commit(Xid xid, boolean onePhaseCommit)
36 | throws HeuristicMixedException, HeuristicRollbackException, IllegalStateException, SystemException {
37 | }
38 |
39 | public void rollback(Xid xid)
40 | throws HeuristicMixedException, HeuristicCommitException, IllegalStateException, SystemException {
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/bytejta/supports/jdbc/DataSourceHolder.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2016 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.bytejta.supports.jdbc;
17 |
18 | import javax.sql.DataSource;
19 |
20 | public interface DataSourceHolder {
21 |
22 | public DataSource getDataSource();
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/bytejta/supports/jdbc/LocalXACompatible.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2017 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.bytejta.supports.jdbc;
17 |
18 | public interface LocalXACompatible {
19 |
20 | public boolean compatibleLoggingLRO();
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/bytejta/supports/resource/UnidentifiedResourceDescriptor.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2016 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.bytejta.supports.resource;
17 |
18 | import javax.transaction.xa.XAException;
19 | import javax.transaction.xa.XAResource;
20 | import javax.transaction.xa.Xid;
21 |
22 | import org.bytesoft.transaction.supports.resource.XAResourceDescriptor;
23 |
24 | public class UnidentifiedResourceDescriptor implements XAResourceDescriptor {
25 |
26 | private String identifier;
27 | private XAResource delegate;
28 |
29 | public boolean isTransactionCommitted(Xid xid) throws IllegalStateException {
30 | throw new IllegalStateException();
31 | }
32 |
33 | public String toString() {
34 | return String.format("unknown-resource[%s]", this.delegate);
35 | }
36 |
37 | public void setTransactionTimeoutQuietly(int timeout) {
38 | try {
39 | this.delegate.setTransactionTimeout(timeout);
40 | } catch (Exception ex) {
41 | return;
42 | }
43 | }
44 |
45 | public void commit(Xid arg0, boolean arg1) throws XAException {
46 | if (this.delegate == null) {
47 | return;
48 | }
49 | delegate.commit(arg0, arg1);
50 | }
51 |
52 | public void end(Xid arg0, int arg1) throws XAException {
53 | if (this.delegate == null) {
54 | return;
55 | }
56 | delegate.end(arg0, arg1);
57 | }
58 |
59 | public void forget(Xid arg0) throws XAException {
60 | if (this.delegate == null) {
61 | return;
62 | }
63 | delegate.forget(arg0);
64 | }
65 |
66 | public int getTransactionTimeout() throws XAException {
67 | if (this.delegate == null) {
68 | return 0;
69 | }
70 | return delegate.getTransactionTimeout();
71 | }
72 |
73 | public boolean isSameRM(XAResource arg0) throws XAException {
74 | if (this.delegate == null) {
75 | return false;
76 | }
77 | return delegate.isSameRM(arg0);
78 | }
79 |
80 | public int prepare(Xid arg0) throws XAException {
81 | if (this.delegate == null) {
82 | return XAResource.XA_RDONLY;
83 | }
84 | return delegate.prepare(arg0);
85 | }
86 |
87 | public Xid[] recover(int arg0) throws XAException {
88 | if (this.delegate == null) {
89 | return new Xid[0];
90 | }
91 | return delegate.recover(arg0);
92 | }
93 |
94 | public void rollback(Xid arg0) throws XAException {
95 | if (this.delegate == null) {
96 | return;
97 | }
98 | delegate.rollback(arg0);
99 | }
100 |
101 | public boolean setTransactionTimeout(int arg0) throws XAException {
102 | if (this.delegate == null) {
103 | return false;
104 | }
105 | return delegate.setTransactionTimeout(arg0);
106 | }
107 |
108 | public void start(Xid arg0, int arg1) throws XAException {
109 | if (this.delegate == null) {
110 | return;
111 | }
112 | delegate.start(arg0, arg1);
113 | }
114 |
115 | public String getIdentifier() {
116 | return identifier;
117 | }
118 |
119 | public void setIdentifier(String identifier) {
120 | this.identifier = identifier;
121 | }
122 |
123 | public XAResource getDelegate() {
124 | return delegate;
125 | }
126 |
127 | public void setDelegate(XAResource delegate) {
128 | this.delegate = delegate;
129 | }
130 |
131 | }
132 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/transaction/CommitRequiredException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2016 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.transaction;
17 |
18 | import javax.transaction.SystemException;
19 |
20 | public class CommitRequiredException extends SystemException {
21 | private static final long serialVersionUID = 1L;
22 |
23 | public CommitRequiredException() {
24 | super();
25 | }
26 |
27 | public CommitRequiredException(String s) {
28 | super(s);
29 | }
30 |
31 | public CommitRequiredException(int errcode) {
32 | super(errcode);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/transaction/RemoteSystemException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2016 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.transaction;
17 |
18 | import java.rmi.RemoteException;
19 |
20 | import javax.transaction.SystemException;
21 |
22 | public class RemoteSystemException extends SystemException {
23 | private static final long serialVersionUID = 1L;
24 |
25 | public RemoteSystemException() {
26 | super();
27 | }
28 |
29 | public RemoteSystemException(String s) {
30 | super(s);
31 | }
32 |
33 | public RemoteSystemException(int errcode) {
34 | super(errcode);
35 | }
36 |
37 | public Throwable initCause(Throwable cause) {
38 | if (RemoteException.class.isInstance(cause) == false) {
39 | throw new IllegalArgumentException();
40 | }
41 | return super.initCause(cause);
42 | }
43 |
44 | public RemoteException getRemoteException() {
45 | Throwable thrown = super.getCause();
46 | return RemoteException.class.cast(thrown);
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/transaction/RollbackRequiredException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2016 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.transaction;
17 |
18 | import javax.transaction.SystemException;
19 |
20 | public class RollbackRequiredException extends SystemException {
21 | private static final long serialVersionUID = 1L;
22 |
23 | public RollbackRequiredException() {
24 | super();
25 | }
26 |
27 | public RollbackRequiredException(String s) {
28 | super(s);
29 | }
30 |
31 | public RollbackRequiredException(int errcode) {
32 | super(errcode);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/transaction/Transaction.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2016 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.transaction;
17 |
18 | import javax.transaction.HeuristicMixedException;
19 | import javax.transaction.HeuristicRollbackException;
20 | import javax.transaction.RollbackException;
21 | import javax.transaction.SystemException;
22 |
23 | import org.bytesoft.transaction.archive.TransactionArchive;
24 | import org.bytesoft.transaction.remote.RemoteSvc;
25 | import org.bytesoft.transaction.supports.TransactionExtra;
26 | import org.bytesoft.transaction.supports.TransactionListener;
27 | import org.bytesoft.transaction.supports.TransactionResourceListener;
28 | import org.bytesoft.transaction.supports.resource.XAResourceDescriptor;
29 |
30 | public interface Transaction extends javax.transaction.Transaction, TransactionExtra {
31 |
32 | public void fireBeforeTransactionCompletion() throws RollbackRequiredException, SystemException;
33 |
34 | public void fireBeforeTransactionCompletionQuietly();
35 |
36 | public void fireAfterTransactionCompletion();
37 |
38 | public boolean isLocalTransaction();
39 |
40 | public boolean isMarkedRollbackOnly();
41 |
42 | public void setRollbackOnlyQuietly();
43 |
44 | public int getTransactionStatus();
45 |
46 | public void setTransactionStatus(int status);
47 |
48 | public void resume() throws SystemException;
49 |
50 | public void suspend() throws SystemException;
51 |
52 | public boolean isTiming();
53 |
54 | public void setTransactionTimeout(int seconds);
55 |
56 | public void registerTransactionListener(TransactionListener listener);
57 |
58 | public void registerTransactionResourceListener(TransactionResourceListener listener);
59 |
60 | public TransactionExtra getTransactionalExtra();
61 |
62 | public void setTransactionalExtra(TransactionExtra transactionalExtra);
63 |
64 | public XAResourceDescriptor getResourceDescriptor(String beanName);
65 |
66 | public XAResourceDescriptor getRemoteCoordinator(RemoteSvc remoteSvc);
67 |
68 | public XAResourceDescriptor getRemoteCoordinator(String application);
69 |
70 | public TransactionContext getTransactionContext();
71 |
72 | public TransactionArchive getTransactionArchive();
73 |
74 | public int participantPrepare() throws RollbackRequiredException, CommitRequiredException;
75 |
76 | public void participantCommit(boolean opc) throws RollbackException, HeuristicMixedException, HeuristicRollbackException,
77 | SecurityException, IllegalStateException, CommitRequiredException, SystemException;
78 |
79 | public void participantRollback() throws IllegalStateException, RollbackRequiredException, SystemException;
80 |
81 | public void forget() throws SystemException;
82 |
83 | public void forgetQuietly();
84 |
85 | public void recover() throws SystemException;
86 |
87 | public void recoveryCommit() throws CommitRequiredException, SystemException;
88 |
89 | public void recoveryRollback() throws RollbackRequiredException, SystemException;
90 |
91 | public Exception getCreatedAt();
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/transaction/TransactionBeanFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2016 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.transaction;
17 |
18 | import org.bytesoft.transaction.logging.ArchiveDeserializer;
19 | import org.bytesoft.transaction.logging.TransactionLogger;
20 | import org.bytesoft.transaction.supports.TransactionTimer;
21 | import org.bytesoft.transaction.supports.rpc.TransactionInterceptor;
22 | import org.bytesoft.transaction.supports.serialize.XAResourceDeserializer;
23 | import org.bytesoft.transaction.xa.XidFactory;
24 |
25 | public interface TransactionBeanFactory {
26 |
27 | public TransactionLock getTransactionLock();
28 |
29 | public TransactionManager getTransactionManager();
30 |
31 | public XidFactory getXidFactory();
32 |
33 | public TransactionTimer getTransactionTimer();
34 |
35 | public TransactionRepository getTransactionRepository();
36 |
37 | public TransactionInterceptor getTransactionInterceptor();
38 |
39 | public TransactionRecovery getTransactionRecovery();
40 |
41 | public TransactionParticipant getNativeParticipant();
42 |
43 | public TransactionLogger getTransactionLogger();
44 |
45 | public ArchiveDeserializer getArchiveDeserializer();
46 |
47 | public XAResourceDeserializer getResourceDeserializer();
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/transaction/TransactionContext.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2016 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.transaction;
17 |
18 | import java.io.Serializable;
19 |
20 | import org.bytesoft.transaction.xa.TransactionXid;
21 |
22 | public class TransactionContext implements Serializable, Cloneable {
23 | private static final long serialVersionUID = 1L;
24 |
25 | protected transient Object propagatedBy;
26 | protected transient boolean propagated;
27 | protected transient boolean coordinator;
28 | protected transient boolean recoveried;
29 | protected transient int recoveredTimes;
30 |
31 | protected TransactionXid xid;
32 | protected long createdTime;
33 | protected long expiredTime;
34 | protected boolean rollbackOnly;
35 | protected long configFlags;
36 |
37 | public TransactionContext clone() {
38 | TransactionContext that = new TransactionContext();
39 | that.xid = this.xid.clone();
40 | that.createdTime = System.currentTimeMillis();
41 | that.expiredTime = this.expiredTime;
42 | that.rollbackOnly = this.rollbackOnly;
43 | that.configFlags = this.configFlags;
44 | return that;
45 | }
46 |
47 | public int getRecoveredTimes() {
48 | return recoveredTimes;
49 | }
50 |
51 | public void setRecoveredTimes(int recoveredTimes) {
52 | this.recoveredTimes = recoveredTimes;
53 | }
54 |
55 | public boolean isCoordinator() {
56 | return coordinator;
57 | }
58 |
59 | public void setCoordinator(boolean coordinator) {
60 | this.coordinator = coordinator;
61 | }
62 |
63 | public boolean isRecoveried() {
64 | return recoveried;
65 | }
66 |
67 | public void setRecoveried(boolean recoveried) {
68 | this.recoveried = recoveried;
69 | }
70 |
71 | public TransactionXid getXid() {
72 | return xid;
73 | }
74 |
75 | public void setXid(TransactionXid xid) {
76 | this.xid = xid;
77 | }
78 |
79 | public long getCreatedTime() {
80 | return createdTime;
81 | }
82 |
83 | public void setCreatedTime(long createdTime) {
84 | this.createdTime = createdTime;
85 | }
86 |
87 | public long getExpiredTime() {
88 | return expiredTime;
89 | }
90 |
91 | public void setExpiredTime(long expiredTime) {
92 | this.expiredTime = expiredTime;
93 | }
94 |
95 | public long getConfigFlags() {
96 | return configFlags;
97 | }
98 |
99 | public void setConfigFlags(long configFlags) {
100 | this.configFlags = configFlags;
101 | }
102 |
103 | public boolean isPropagated() {
104 | return propagated;
105 | }
106 |
107 | public void setPropagated(boolean propagated) {
108 | this.propagated = propagated;
109 | }
110 |
111 | public Object getPropagatedBy() {
112 | return propagatedBy;
113 | }
114 |
115 | public void setPropagatedBy(Object propagatedBy) {
116 | this.propagatedBy = propagatedBy;
117 | }
118 |
119 | public boolean isRollbackOnly() {
120 | return rollbackOnly;
121 | }
122 |
123 | public void setRollbackOnly(boolean rollbackOnly) {
124 | this.rollbackOnly = rollbackOnly;
125 | }
126 |
127 | }
128 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/transaction/TransactionException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2018 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.transaction;
17 |
18 | public class TransactionException extends RuntimeException {
19 | private static final long serialVersionUID = 1L;
20 |
21 | /* XAException.errorCode */
22 | public int errorCode;
23 |
24 | public TransactionException(int errcode) {
25 | super();
26 | errorCode = errcode;
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/transaction/TransactionLock.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2017 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.transaction;
17 |
18 | import org.bytesoft.transaction.xa.TransactionXid;
19 |
20 | public interface TransactionLock {
21 |
22 | public boolean lockTransaction(TransactionXid transactionXid, String identifier);
23 |
24 | public void unlockTransaction(TransactionXid transactionXid, String identifier);
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/transaction/TransactionManager.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2016 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.transaction;
17 |
18 | import javax.transaction.SystemException;
19 |
20 | public interface TransactionManager extends javax.transaction.TransactionManager {
21 |
22 | public int getTimeoutSeconds();
23 |
24 | public void setTimeoutSeconds(int timeoutSeconds);
25 |
26 | public void associateThread(Transaction transaction);
27 |
28 | public Transaction desociateThread();
29 |
30 | public Transaction getTransaction(Thread thread);
31 |
32 | public Transaction getTransactionQuietly();
33 |
34 | public Transaction getTransaction() throws SystemException;
35 |
36 | public Transaction suspend() throws SystemException;
37 |
38 | public void setRollbackOnlyQuietly();
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/transaction/TransactionParticipant.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2018 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.transaction;
17 |
18 | import javax.transaction.xa.XAException;
19 | import javax.transaction.xa.XAResource;
20 | import javax.transaction.xa.Xid;
21 |
22 | public interface TransactionParticipant extends XAResource {
23 |
24 | public Transaction end(TransactionContext transactionContext, int flags) throws XAException;
25 |
26 | public void forgetQuietly(Xid xid);
27 |
28 | public Transaction start(TransactionContext transactionContext, int flags) throws XAException;
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/transaction/TransactionRecovery.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2016 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.transaction;
17 |
18 | import org.bytesoft.transaction.archive.TransactionArchive;
19 |
20 | public interface TransactionRecovery {
21 |
22 | public Transaction reconstruct(TransactionArchive archive);
23 |
24 | public void timingRecover();
25 |
26 | public void startRecovery();
27 |
28 | public void branchRecover();
29 |
30 | public boolean isInitialized();
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/transaction/TransactionRepository.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2016 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.transaction;
17 |
18 | import java.util.List;
19 |
20 | import org.bytesoft.transaction.xa.TransactionXid;
21 |
22 | public interface TransactionRepository {
23 |
24 | // active-transaction & error-transaction
25 | public void putTransaction(TransactionXid xid, Transaction transaction);
26 |
27 | public Transaction getTransaction(TransactionXid xid);
28 |
29 | public Transaction removeTransaction(TransactionXid xid);
30 |
31 | // error-transaction
32 | public void putErrorTransaction(TransactionXid xid, Transaction transaction);
33 |
34 | public Transaction getErrorTransaction(TransactionXid xid);
35 |
36 | public Transaction removeErrorTransaction(TransactionXid xid);
37 |
38 | public List getErrorTransactionList();
39 |
40 | public List getActiveTransactionList();
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/transaction/adapter/ResourceAdapterImpl.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2016 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.transaction.adapter;
17 |
18 | import java.util.ArrayList;
19 | import java.util.List;
20 |
21 | import javax.resource.ResourceException;
22 | import javax.resource.spi.ActivationSpec;
23 | import javax.resource.spi.BootstrapContext;
24 | import javax.resource.spi.ResourceAdapter;
25 | import javax.resource.spi.ResourceAdapterInternalException;
26 | import javax.resource.spi.endpoint.MessageEndpointFactory;
27 | import javax.resource.spi.work.Work;
28 | import javax.resource.spi.work.WorkException;
29 | import javax.resource.spi.work.WorkManager;
30 | import javax.transaction.xa.XAResource;
31 |
32 | import org.slf4j.Logger;
33 | import org.slf4j.LoggerFactory;
34 |
35 | public class ResourceAdapterImpl implements ResourceAdapter {
36 | static final Logger logger = LoggerFactory.getLogger(ResourceAdapterImpl.class);
37 |
38 | private List workList = new ArrayList();;
39 | private WorkManager workManager;
40 |
41 | public void start(BootstrapContext ctx) throws ResourceAdapterInternalException {
42 | this.workManager = ctx.getWorkManager();
43 | for (int i = 0; this.workList != null && i < this.workList.size(); i++) {
44 | Work work = this.workList.get(i);
45 | try {
46 | this.workManager.startWork(work);
47 | } catch (WorkException ex) {
48 | this.stop();
49 | throw new ResourceAdapterInternalException(ex);
50 | } catch (RuntimeException ex) {
51 | this.stop();
52 | throw new ResourceAdapterInternalException(ex);
53 | }
54 | }
55 | }
56 |
57 | public void stop() {
58 | for (int i = 0; this.workList != null && i < this.workList.size(); i++) {
59 | Work work = this.workList.get(i);
60 | try {
61 | work.release();
62 | } catch (RuntimeException rex) {
63 | logger.debug(rex.getMessage(), rex);
64 | }
65 | }
66 | }
67 |
68 | public void endpointActivation(MessageEndpointFactory endpointFactory, ActivationSpec spec) throws ResourceException {
69 | }
70 |
71 | public void endpointDeactivation(MessageEndpointFactory endpointFactory, ActivationSpec spec) {
72 | }
73 |
74 | public XAResource[] getXAResources(ActivationSpec[] specs) throws ResourceException {
75 | return new XAResource[0];
76 | }
77 |
78 | public List getWorkList() {
79 | return workList;
80 | }
81 |
82 | public void setWorkList(List workList) {
83 | this.workList = workList;
84 | }
85 |
86 | }
87 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/transaction/archive/TransactionArchive.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2016 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.transaction.archive;
17 |
18 | import java.util.ArrayList;
19 | import java.util.List;
20 |
21 | import javax.transaction.xa.Xid;
22 |
23 | public class TransactionArchive {
24 | private transient String endpoint;
25 | private Xid xid;
26 | private int status;
27 | private int vote;
28 | private boolean coordinator;
29 | private Object propagatedBy;
30 | private final List nativeResources = new ArrayList();
31 | private final List remoteResources = new ArrayList();
32 |
33 | private int transactionStrategyType;
34 | private XAResourceArchive optimizedResource;
35 |
36 | private int recoveredTimes;
37 | private long recoveredAt;
38 |
39 | public int getRecoveredTimes() {
40 | return recoveredTimes;
41 | }
42 |
43 | public void setRecoveredTimes(int recoveredTimes) {
44 | this.recoveredTimes = recoveredTimes;
45 | }
46 |
47 | public long getRecoveredAt() {
48 | return recoveredAt;
49 | }
50 |
51 | public void setRecoveredAt(long recoveredAt) {
52 | this.recoveredAt = recoveredAt;
53 | }
54 |
55 | public String getEndpoint() {
56 | return endpoint;
57 | }
58 |
59 | public void setEndpoint(String endpoint) {
60 | this.endpoint = endpoint;
61 | }
62 |
63 | public Xid getXid() {
64 | return xid;
65 | }
66 |
67 | public void setXid(Xid xid) {
68 | this.xid = xid;
69 | }
70 |
71 | public int getStatus() {
72 | return status;
73 | }
74 |
75 | public void setStatus(int status) {
76 | this.status = status;
77 | }
78 |
79 | public int getVote() {
80 | return vote;
81 | }
82 |
83 | public void setVote(int vote) {
84 | this.vote = vote;
85 | }
86 |
87 | public boolean isCoordinator() {
88 | return coordinator;
89 | }
90 |
91 | public void setCoordinator(boolean coordinator) {
92 | this.coordinator = coordinator;
93 | }
94 |
95 | public Object getPropagatedBy() {
96 | return propagatedBy;
97 | }
98 |
99 | public void setPropagatedBy(Object propagatedBy) {
100 | this.propagatedBy = propagatedBy;
101 | }
102 |
103 | public List getNativeResources() {
104 | return nativeResources;
105 | }
106 |
107 | public List getRemoteResources() {
108 | return remoteResources;
109 | }
110 |
111 | public XAResourceArchive getOptimizedResource() {
112 | return optimizedResource;
113 | }
114 |
115 | public void setOptimizedResource(XAResourceArchive optimizedResource) {
116 | this.optimizedResource = optimizedResource;
117 | }
118 |
119 | public int getTransactionStrategyType() {
120 | return transactionStrategyType;
121 | }
122 |
123 | public void setTransactionStrategyType(int transactionStrategyType) {
124 | this.transactionStrategyType = transactionStrategyType;
125 | }
126 |
127 | }
128 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/transaction/aware/TransactionBeanFactoryAware.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2016 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.transaction.aware;
17 |
18 | import org.bytesoft.transaction.TransactionBeanFactory;
19 |
20 | public interface TransactionBeanFactoryAware {
21 | public static final String BEAN_FACTORY_FIELD_NAME = "beanFactory";
22 |
23 | public TransactionBeanFactory getBeanFactory();
24 |
25 | public void setBeanFactory(TransactionBeanFactory tbf);
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/transaction/aware/TransactionDebuggable.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2016 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.transaction.aware;
17 |
18 | public interface TransactionDebuggable {
19 |
20 | public boolean isDebuggingEnabled();
21 |
22 | public void setDebuggingEnabled(boolean debuggingEnabled);
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/transaction/aware/TransactionEndpointAware.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2016 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.transaction.aware;
17 |
18 | public interface TransactionEndpointAware {
19 | public static final String ENDPOINT_FIELD_NAME = "endpoint";
20 |
21 | public String getEndpoint();
22 |
23 | public void setEndpoint(String identifier);
24 | }
25 |
--------------------------------------------------------------------------------
/bytejta-core/src/main/java/org/bytesoft/transaction/cmd/CommandDispatcher.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014-2018 yangming.liu.
3 | *
4 | * This copyrighted material is made available to anyone wishing to use, modify,
5 | * copy, or redistribute it subject to the terms and conditions of the GNU
6 | * Lesser General Public License, as published by the Free Software Foundation.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 | * for more details.
12 | *
13 | * You should have received a copy of the GNU Lesser General Public License
14 | * along with this distribution; if not, see .
15 | */
16 | package org.bytesoft.transaction.cmd;
17 |
18 | import java.util.concurrent.Callable;
19 |
20 | public interface CommandDispatcher {
21 |
22 | public Object dispatch(Callable