Repository: alibaba/fescar
Pull request #583 (2019-03-12 12:55:52)

add TCC model to fescar, resolve conflicks  (#582)
<!-- Please make sure you have read and understood the contributing guidelines -->

### Ⅰ. Describe what this PR did


### Ⅱ. Does this pull request fix one issue?
<!-- If that, add "fixes #xxx" below in the next line, for example, fixes #97. -->


### Ⅲ. Why don't you add test cases (unit test/integration test)? 


### Ⅳ. Describe how to verify it


### Ⅴ. Special notes for reviews



codecov-io: # [Codecov](https://codecov.io/gh/alibaba/fescar/pull/583?src=pr&el=h1) Report
> Merging [#583](https://codecov.io/gh/alibaba/fescar/pull/583?src=pr&el=desc) into [develop](https://codecov.io/gh/alibaba/fescar/commit/34bef93c9c26b5bc766d757303cd51345f82b571?src=pr&el=desc) will **decrease** coverage by `1.26%`.
> The diff coverage is `20.64%`.

[![Impacted file tree graph](https://codecov.io/gh/alibaba/fescar/pull/583/graphs/tree.svg?width=650&token=Hy9a6MCc4p&height=150&src=pr)](https://codecov.io/gh/alibaba/fescar/pull/583?src=pr&el=tree)

```diff
@@              Coverage Diff              @@
##             develop     #583      +/-   ##
=============================================
- Coverage      31.93%   30.67%   -1.27%     
- Complexity       770      795      +25     
=============================================
  Files            200      222      +22     
  Lines           7917     8562     +645     
  Branches         938     1035      +97     
=============================================
+ Hits            2528     2626      +98     
- Misses          5129     5641     +512     
- Partials         260      295      +35
```


| [Impacted Files](https://codecov.io/gh/alibaba/fescar/pull/583?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| [...fescar/server/session/FileBasedSessionManager.java](https://codecov.io/gh/alibaba/fescar/pull/583/diff?src=pr&el=tree#diff-c2VydmVyL3NyYy9tYWluL2phdmEvY29tL2FsaWJhYmEvZmVzY2FyL3NlcnZlci9zZXNzaW9uL0ZpbGVCYXNlZFNlc3Npb25NYW5hZ2VyLmphdmE=) | `54.87% <ø> (ø)` | `15 <0> (ø)` | :arrow_down: |
| [...lTransactionWithGlobalLockDataSourceBasicTest.java](https://codecov.io/gh/alibaba/fescar/pull/583/diff?src=pr&el=tree#diff-dGVzdC9zcmMvbWFpbi9qYXZhL2NvbS9hbGliYWJhL2Zlc2Nhci90ZXN0L0xvY2FsVHJhbnNhY3Rpb25XaXRoR2xvYmFsTG9ja0RhdGFTb3VyY2VCYXNpY1Rlc3QuamF2YQ==) | `0% <ø> (ø)` | `0 <0> (ø)` | :arrow_down: |
| [...a/com/alibaba/fescar/test/DataSourceBasicTest.java](https://codecov.io/gh/alibaba/fescar/pull/583/diff?src=pr&el=tree#diff-dGVzdC9zcmMvbWFpbi9qYXZhL2NvbS9hbGliYWJhL2Zlc2Nhci90ZXN0L0RhdGFTb3VyY2VCYXNpY1Rlc3QuamF2YQ==) | `0% <ø> (ø)` | `0 <0> (ø)` | :arrow_down: |
| [...main/java/com/alibaba/fescar/common/Constants.java](https://codecov.io/gh/alibaba/fescar/pull/583/diff?src=pr&el=tree#diff-Y29tbW9uL3NyYy9tYWluL2phdmEvY29tL2FsaWJhYmEvZmVzY2FyL2NvbW1vbi9Db25zdGFudHMuamF2YQ==) | `0% <ø> (ø)` | `0 <0> (ø)` | :arrow_down: |
| [...ava/com/alibaba/fescar/rm/AbstractRMHandlerAT.java](https://codecov.io/gh/alibaba/fescar/pull/583/diff?src=pr&el=tree#diff-cm0tZGF0YXNvdXJjZS9zcmMvbWFpbi9qYXZhL2NvbS9hbGliYWJhL2Zlc2Nhci9ybS9BYnN0cmFjdFJNSGFuZGxlckFULmphdmE=) | `0% <ø> (ø)` | `0 <0> (ø)` | :arrow_down: |
| [...rc/main/java/com/alibaba/fescar/rm/RMClientAT.java](https://codecov.io/gh/alibaba/fescar/pull/583/diff?src=pr&el=tree#diff-cm0tZGF0YXNvdXJjZS9zcmMvbWFpbi9qYXZhL2NvbS9hbGliYWJhL2Zlc2Nhci9ybS9STUNsaWVudEFULmphdmE=) | `0% <ø> (ø)` | `0 <0> (ø)` | :arrow_down: |
| [...ibaba/fescar/rm/tcc/remoting/parser/DubboUtil.java](https://codecov.io/gh/alibaba/fescar/pull/583/diff?src=pr&el=tree#diff-dGNjL3NyYy9tYWluL2phdmEvY29tL2FsaWJhYmEvZmVzY2FyL3JtL3RjYy9yZW1vdGluZy9wYXJzZXIvRHViYm9VdGlsLmphdmE=) | `0% <0%> (ø)` | `0 <0> (?)` | |
| [.../rm/tcc/remoting/parser/SofaRpcRemotingParser.java](https://codecov.io/gh/alibaba/fescar/pull/583/diff?src=pr&el=tree#diff-dGNjL3NyYy9tYWluL2phdmEvY29tL2FsaWJhYmEvZmVzY2FyL3JtL3RjYy9yZW1vdGluZy9wYXJzZXIvU29mYVJwY1JlbW90aW5nUGFyc2VyLmphdmE=) | `0% <0%> (ø)` | `0 <0> (?)` | |
| [...libaba/fescar/rm/datasource/DataSourceManager.java](https://codecov.io/gh/alibaba/fescar/pull/583/diff?src=pr&el=tree#diff-cm0tZGF0YXNvdXJjZS9zcmMvbWFpbi9qYXZhL2NvbS9hbGliYWJhL2Zlc2Nhci9ybS9kYXRhc291cmNlL0RhdGFTb3VyY2VNYW5hZ2VyLmphdmE=) | `0% <0%> (ø)` | `0 <0> (ø)` | :arrow_down: |
| [.../alibaba/fescar/rm/datasource/DataSourceProxy.java](https://codecov.io/gh/alibaba/fescar/pull/583/diff?src=pr&el=tree#diff-cm0tZGF0YXNvdXJjZS9zcmMvbWFpbi9qYXZhL2NvbS9hbGliYWJhL2Zlc2Nhci9ybS9kYXRhc291cmNlL0RhdGFTb3VyY2VQcm94eS5qYXZh) | `18.18% <0%> (-0.87%)` | `0 <0> (ø)` | |
| ... and [65 more](https://codecov.io/gh/alibaba/fescar/pull/583/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/alibaba/fescar/pull/583?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/alibaba/fescar/pull/583?src=pr&el=footer). Last update [34bef93...635e3da](https://codecov.io/gh/alibaba/fescar/pull/583?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

github-ygy: > * 统一字段对齐风格，如BusinessActionContext 与其他对其风格不一致
> * TccResourceManager类名Tcc为小写，与其他不一致
> * Protocols 是否考虑使用常量定义而非枚举定义？这样以便于其他其他人员能在不修改fescar-tcc的基础上扩展实现
> * LocalTCCRemotingParser的getServiceDesc是否永远返回null,后续代码不起作用？
> * Tcc的Annotation放在fescar-spring里是否更好？
> * TC的Cacnel操作发起有可能先于实际业务的try的执行

LocalTCCRemotingParser会判断类是否有LocalTcc注解，不会永远为null，
但是DefaultRemotingParser#parserRemotingServiceInfo为何不对null值做校验，
如果这块处理空数据不抛异常的话，建议这段代码可以合并，以parserRemotingServiceInfo方法返回空数据来做判断
`protected boolean parserRemotingServiceInfo(Object bean, String beanName) {
        //是否是远程服务bean
        if(DefaultRemotingParser.get().isRemoting(bean, beanName)) {
            //解析remoting bean 信息
            DefaultRemotingParser.get().parserRemotingServiceInfo(bean, beanName);
            return true;
        }
        return false;
    }`
=>
`protected boolean parserRemotingServiceInfo(Object bean, String beanName) {
        //是否是远程服务bean
        if (DefaultRemotingParser.get().parserRemotingServiceInfo(bean, beanName) != null) {
            return true;
        }
        return false;
    }`

zhangthen: > * 统一字段对齐风格，如BusinessActionContext 与其他对其风格不一致
> * TccResourceManager类名Tcc为小写，与其他不一致
> * Protocols 是否考虑使用常量定义而非枚举定义？这样以便于其他其他人员能在不修改fescar-tcc的基础上扩展实现
> * LocalTCCRemotingParser的getServiceDesc是否永远返回null,后续代码不起作用？
> * Tcc的Annotation放在fescar-spring里是否更好？
> * TC的Cacnel操作发起有可能先于实际业务的try的执行

“统一字段对齐风格，如BusinessActionContext 与其他对其风格不一致”，“TccResourceManager类名Tcc为小写，与其他不一致” ，已经改了；

“ Protocols 是否考虑使用常量定义而非枚举定义？这样以便于其他其他人员能在不修改fescar-tcc的基础上扩展实现” ，这个见仁见智吧，目前能枚举出来的RPC框架可能不会超过10个吧，我可以现在就把你能枚举出来的RPC框架加进去，虽然现在不一定会全部去支持，但这个枚举类被动的频率非常低；另外，为了保障和我们商业版的兼容性，这个枚举也会打算动；

“ LocalTCCRemotingParser的getServiceDesc是否永远返回null,后续代码不起作用？”，LocalTCCRemotingParser.getServiceDesc 不是永远返回null的，你可以跑一下TCC的 localtcc demo验证一下；

“Tcc的Annotation放在fescar-spring里是否更好？”， 现在是fescar-spring依赖 fescar-tcc，把TCC的枚举移到 fescar-spring中的话，fescar-tcc里面就访问不到这些TCC的注解了；所以TCC的注解还是会放在fescar-tcc里面；

“TC的Cacnel操作发起有可能先于实际业务的try的执行”，确实有这个问题，这是TCC的另外一个功能解决的问题，这次没开出来；

zhangthen: > > * 统一字段对齐风格，如BusinessActionContext 与其他对其风格不一致
> > * TccResourceManager类名Tcc为小写，与其他不一致
> > * Protocols 是否考虑使用常量定义而非枚举定义？这样以便于其他其他人员能在不修改fescar-tcc的基础上扩展实现
> > * LocalTCCRemotingParser的getServiceDesc是否永远返回null,后续代码不起作用？
> > * Tcc的Annotation放在fescar-spring里是否更好？
> > * TC的Cacnel操作发起有可能先于实际业务的try的执行
> 
> LocalTCCRemotingParser会判断类是否有LocalTcc注解，不会永远为null，
> 但是DefaultRemotingParser#parserRemotingServiceInfo为何不对null值做校验，
> 如果这块处理空数据不抛异常的话，建议这段代码可以合并，以parserRemotingServiceInfo方法返回空数据来做判断
> `protected boolean parserRemotingServiceInfo(Object bean, String beanName) { //是否是远程服务bean if(DefaultRemotingParser.get().isRemoting(bean, beanName)) { //解析remoting bean 信息 DefaultRemotingParser.get().parserRemotingServiceInfo(bean, beanName); return true; } return false; }`
> =>
> `protected boolean parserRemotingServiceInfo(Object bean, String beanName) { //是否是远程服务bean if (DefaultRemotingParser.get().parserRemotingServiceInfo(bean, beanName) != null) { return true; } return false; }`

@github-ygy 

DefaultRemotingParser#parserRemotingServiceInfo 在被调用之前，会先调用 DefaultRemotingParser.get().isRemoting(bean, beanName)判断一下的，如果DefaultRemotingParser.get().isRemoting(bean, beanName)为true是不会发生你说的问题，如果我false也不会进入这段代码；所以你说的问题不存在；

不过我可以再在 DefaultRemotingParser#parserRemotingServiceInfo  做一次判断兜底。


github-ygy: > > > * 统一字段对齐风格，如BusinessActionContext 与其他对其风格不一致
> > > * TccResourceManager类名Tcc为小写，与其他不一致
> > > * Protocols 是否考虑使用常量定义而非枚举定义？这样以便于其他其他人员能在不修改fescar-tcc的基础上扩展实现
> > > * LocalTCCRemotingParser的getServiceDesc是否永远返回null,后续代码不起作用？
> > > * Tcc的Annotation放在fescar-spring里是否更好？
> > > * TC的Cacnel操作发起有可能先于实际业务的try的执行
> > 
> > 
> > LocalTCCRemotingParser会判断类是否有LocalTcc注解，不会永远为null，
> > 但是DefaultRemotingParser#parserRemotingServiceInfo为何不对null值做校验，
> > 如果这块处理空数据不抛异常的话，建议这段代码可以合并，以parserRemotingServiceInfo方法返回空数据来做判断
> > `protected boolean parserRemotingServiceInfo(Object bean, String beanName) { //是否是远程服务bean if(DefaultRemotingParser.get().isRemoting(bean, beanName)) { //解析remoting bean 信息 DefaultRemotingParser.get().parserRemotingServiceInfo(bean, beanName); return true; } return false; }`
> > =>
> > `protected boolean parserRemotingServiceInfo(Object bean, String beanName) { //是否是远程服务bean if (DefaultRemotingParser.get().parserRemotingServiceInfo(bean, beanName) != null) { return true; } return false; }`
> 
> @github-ygy
> 
> DefaultRemotingParser#parserRemotingServiceInfo 在被调用之前，会先调用 DefaultRemotingParser.get().isRemoting(bean, beanName)判断一下的，如果DefaultRemotingParser.get().isRemoting(bean, beanName)为true是不会发生你说的问题，如果我false也不会进入这段代码；所以你说的问题不存在；
> 
> 不过我可以再在 DefaultRemotingParser#parserRemotingServiceInfo 做一次判断兜底。

是的问题，不会出现，如果兜底判断了，可以把这段代码合并，因为后面的代码也会调用isRemoting
skyesx: “ Protocols 是否考虑使用常量定义而非枚举定义？这样以便于其他其他人员能在不修改fescar-tcc的基础上扩展实现” 

* 这个见仁见智吧，目前能枚举出来的RPC框架可能不会超过10个吧，我可以现在就把你能枚举出来的RPC框架加进去，虽然现在不一定会全部去支持，但这个枚举类被动的频率非常低；另外，为了保障和我们商业版的兼容性，这个枚举也不打算动；
    * 企业或许会有内部不开源的rpc框架，若枚举不打算变，建议增加一个表征用户自定义类型的枚举，用户需扩展时，就用这个枚举类型

“Tcc的Annotation放在fescar-spring里是否更好？”， 

* 现在是fescar-spring依赖 fescar-tcc，把TCC的枚举移到 fescar-spring中的话，fescar-tcc里面就访问不到这些TCC的注解了；所以TCC的注解还是会放在fescar-tcc里面；不过后续fescar的代码库结构可以再调整一下，现在缺一个“fescar-api ”包来存储所有api性质的类 ；
    * 现在是用了Annotation作为信息的载体，所以必须要在fescar-tcc里引入这个Annotation吧，如果有额外的载体是否annotation就可以迁移到fescar-spring。毕竟现有的@GlobalTransaction就是一个类似的做法，把Annotation仅作为用户便捷入口的封装形式，实际实现完全不依赖于Annotation，当然这个做法不一定最好，但若tcc做法不一致的话，会引起这个风格的不一致
  
zhangthen: > 2\. Format you code style with plugin?

"Format you code style with plugin?" , This is already planned, I will use maven plugin to reformat all projects with p3c codestyle in next PR, There is a miss of automatic reformat mechanism now.

zhangthen: > “ Protocols 是否考虑使用常量定义而非枚举定义？这样以便于其他其他人员能在不修改fescar-tcc的基础上扩展实现”
> 
> * 这个见仁见智吧，目前能枚举出来的RPC框架可能不会超过10个吧，我可以现在就把你能枚举出来的RPC框架加进去，虽然现在不一定会全部去支持，但这个枚举类被动的频率非常低；另外，为了保障和我们商业版的兼容性，这个枚举也不打算动；
>   
>   * 企业或许会有内部不开源的rpc框架，若枚举不打算变，建议增加一个表征用户自定义类型的枚举，用户需扩展时，就用这个枚举类型
> 
> “Tcc的Annotation放在fescar-spring里是否更好？”，
> 
> * 现在是fescar-spring依赖 fescar-tcc，把TCC的枚举移到 fescar-spring中的话，fescar-tcc里面就访问不到这些TCC的注解了；所以TCC的注解还是会放在fescar-tcc里面；不过后续fescar的代码库结构可以再调整一下，现在缺一个“fescar-api ”包来存储所有api性质的类 ；
>   
>   * 现在是用了Annotation作为信息的载体，所以必须要在fescar-tcc里引入这个Annotation吧，如果有额外的载体是否annotation就可以迁移到fescar-spring。毕竟现有的@GlobalTransaction就是一个类似的做法，把Annotation仅作为用户便捷入口的封装形式，实际实现完全不依赖于Annotation，当然这个做法不一定最好，但若tcc做法不一致的话，会引起这个风格的不一致

@skyesx  我在后面的PR中，重新对工程结构进行重排，现在缺一个类似“fescar-api”的包放所有api，把Annotation放在 fescar-spring也不是一个最优方式


zhangthen: > BusinessActionContextParameter#isShardingParam
> how it work ？

目前，当前开源的版本功能比较简单，这个属性是分库分表时才会用到的，当前版本还没用到；
skyesx: on the issue of annotation, i think we should get agreement as soon as possible. because it's user interface ， if we not change now，with later refactor, user code have to change too.

对于注解的位置问题，我觉得应该尽快统一思路，因为这是用户接口，若现在不改，后续要重构的话，用户代码也需要进行直接的变动 

@slievrly @zhangthen 
slievrly: > on the issue of annotation, i think we should get agreement as soon as possible. because it's user interface ， if we not change now，with later refactor, user code have to change too.
> 
> 对于注解的位置问题，我觉得应该尽快统一思路，因为这是用户接口，若现在不改，后续要重构的话，用户代码也需要进行直接的变动
> 
> @slievrly @zhangthen

I agree with this point, the annotation is an extension built on the api.

CLAassistant: [![CLA assistant check](https://cla-assistant.io/pull/badge/not_signed)](https://cla-assistant.io/alibaba/fescar?pullRequest=583) <br/>Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you all sign our [Contributor License Agreement](https://cla-assistant.io/alibaba/fescar?pullRequest=583) before we can accept your contribution.<br/>**1** out of **2** committers have signed the CLA.<br/><br/>:white_check_mark: zhangthen<br/>:x: ujjboy<br/><sub>You have signed the CLA already but the status is still pending? Let us [recheck](https://cla-assistant.io/check/alibaba/fescar?pullRequest=583) it.</sub>

Patch:
diff --git a/common/src/main/java/com/alibaba/fescar/common/Constants.java b/common/src/main/java/com/alibaba/fescar/common/Constants.java
index 2a5b43aa8..f84ed6efb 100644
--- a/common/src/main/java/com/alibaba/fescar/common/Constants.java
+++ b/common/src/main/java/com/alibaba/fescar/common/Constants.java
@@ -40,4 +40,62 @@ public class Constants {
      */
     public static final String DBKEYS_SPLIT_CHAR = ",";
 
+    /** the start time of transaction */
+    public static final String START_TIME  = "start-time";
+
+    /**
+     * app name
+     */
+    public static final String APP_NAME = "appName";
+
+    /**
+     * TCC start time
+     */
+    public static final String ACTION_START_TIME = "action-start-time";
+
+    /**
+     * TCC name
+     */
+    public final static String ACTION_NAME = "actionName";
+
+    /**
+     * phase one method name
+     */
+    public final static String PREPARE_METHOD = "sys::prepare";
+
+    /**
+     * phase two commit method name
+     */
+    public final static String COMMIT_METHOD = "sys::commit";
+
+    /**
+     * phase two rollback method name
+     */
+    public final static String ROLLBACK_METHOD = "sys::rollback";
+
+    /**
+     * host ip
+     */
+    public final static String HOST_NAME = "host-name";
+
+    /**
+     * The constant TCC_METHOD_RESULT.
+     */
+    public final static String TCC_METHOD_RESULT = "result";
+
+    /**
+     * The constant TCC_METHOD_ARGUMENTS.
+     */
+    public final static String TCC_METHOD_ARGUMENTS = "arguments";
+
+    /**
+     * transaction context
+     */
+    public final static String TCC_ACTIVITY_CONTEXT = "activityContext";
+
+    /**
+     * branch context
+     */
+    public final static String TCC_ACTION_CONTEXT = "actionContext";
+
 }
diff --git a/common/src/main/java/com/alibaba/fescar/common/executor/Callback.java b/common/src/main/java/com/alibaba/fescar/common/executor/Callback.java
new file mode 100644
index 000000000..607378cf2
--- /dev/null
+++ b/common/src/main/java/com/alibaba/fescar/common/executor/Callback.java
@@ -0,0 +1,36 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.common.executor;
+
+/**
+ * The interface Callback.
+ *
+ * @param <T> the type parameter
+ *
+ * @author zhangsen
+ */
+public interface Callback<T> {
+
+    /**
+     * Execute t.
+     *
+     * @return the t
+     * @throws Throwable the throwable
+     */
+    public T execute() throws Throwable;
+}
+
diff --git a/common/src/main/java/com/alibaba/fescar/common/executor/Initialize.java b/common/src/main/java/com/alibaba/fescar/common/executor/Initialize.java
new file mode 100644
index 000000000..441652777
--- /dev/null
+++ b/common/src/main/java/com/alibaba/fescar/common/executor/Initialize.java
@@ -0,0 +1,31 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.common.executor;
+
+/**
+ * The interface Initialize.
+ *
+ * @author zhangsen
+ */
+public interface Initialize {
+
+    /**
+     * init method
+     */
+    public void init();
+
+}
diff --git a/common/src/main/java/com/alibaba/fescar/common/loader/EnhancedServiceLoader.java b/common/src/main/java/com/alibaba/fescar/common/loader/EnhancedServiceLoader.java
index 9a4811e81..b8a8fc23c 100644
--- a/common/src/main/java/com/alibaba/fescar/common/loader/EnhancedServiceLoader.java
+++ b/common/src/main/java/com/alibaba/fescar/common/loader/EnhancedServiceLoader.java
@@ -16,6 +16,14 @@
 
 package com.alibaba.fescar.common.loader;
 
+import com.alibaba.fescar.common.executor.Initialize;
+import com.alibaba.fescar.common.util.CollectionUtils;
+import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
@@ -28,12 +36,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.apache.commons.lang.ObjectUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.exception.ExceptionUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 /**
  * The type Enhanced service loader.
  *
@@ -100,6 +102,29 @@ public class EnhancedServiceLoader {
         return loadFile(service, activateName, loader);
     }
 
+    /**
+     * get all implements
+     *
+     * @param <S>     the type parameter
+     * @param service the service
+     * @return list
+     */
+    public static <S> List<S> loadAll(Class<S> service){
+        List<S> allInstances = new ArrayList<>();
+        List<Class> allClazzs = getAllExtensionClass(service);
+        if(CollectionUtils.isEmpty(allClazzs)){
+            return allInstances;
+        }
+        try {
+            for(Class clazz : allClazzs){
+                allInstances.add(initInstance(service, clazz));
+            }
+        } catch (Throwable t) {
+            throw new EnhancedServiceNotFoundException(t);
+        }
+        return allInstances;
+    }
+
     /**
      * 获取所有的扩展类，按照{@linkplain LoadLevel}定义的order顺序进行排序
      *
@@ -163,20 +188,18 @@ public class EnhancedServiceLoader {
                     "not found service provider for : " + service.getName() + "[" + activateName
                         + "] and classloader : " + ObjectUtils.toString(loader));
             }
-            Class<?> extension = extensions.get(extensions.size() - 1);
-            S result = service.cast(extension.newInstance());
+            Class<?> extension = extensions.get(extensions.size() - 1);// 最大的一个
+            S result = initInstance(service, extension);
             if (!foundFromCache && LOGGER.isInfoEnabled()) {
-                LOGGER.info("load " + service.getSimpleName() + "[" + activateName + "] extension by class[" + extension
-                    .getName() + "]");
+                LOGGER.info("load " + service.getSimpleName() + "[" + activateName + "] extension by class[" + extension.getName() + "]");
             }
             return result;
         } catch (Throwable e) {
             if (e instanceof EnhancedServiceNotFoundException) {
-                throw (EnhancedServiceNotFoundException)e;
+                throw (EnhancedServiceNotFoundException) e;
             } else {
                 throw new EnhancedServiceNotFoundException(
-                    "not found service provider for : " + service.getName() + " caused by " + ExceptionUtils
-                        .getFullStackTrace(e));
+                    "not found service provider for : " + service.getName() + " caused by " + ExceptionUtils.getFullStackTrace(e));
             }
         }
     }
@@ -263,6 +286,24 @@ public class EnhancedServiceLoader {
         }
     }
 
+    /**
+     * init instance
+     *
+     * @param <S>       the type parameter
+     * @param service   the service
+     * @param implClazz the impl clazz
+     * @return s
+     * @throws IllegalAccessException the illegal access exception
+     * @throws InstantiationException the instantiation exception
+     */
+    protected static <S> S initInstance(Class<S> service, Class implClazz) throws IllegalAccessException, InstantiationException {
+        S s = service.cast(implClazz.newInstance());
+        if(s instanceof Initialize){
+            ((Initialize)s).init();
+        }
+        return s;
+    }
+
     private static ClassLoader findClassLoader() {
         // 不能使用TCCL,在pandora容器中会导致无法加载plugin中的类
         return EnhancedServiceLoader.class.getClassLoader();
diff --git a/common/src/main/java/com/alibaba/fescar/common/util/CollectionUtils.java b/common/src/main/java/com/alibaba/fescar/common/util/CollectionUtils.java
new file mode 100644
index 000000000..b5317cf7c
--- /dev/null
+++ b/common/src/main/java/com/alibaba/fescar/common/util/CollectionUtils.java
@@ -0,0 +1,47 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.common.util;
+
+import java.util.Collection;
+
+/**
+ * The type Collection utils.
+ *
+ * @author zhangsen
+ */
+public class CollectionUtils {
+
+    /**
+     * Is empty boolean.
+     *
+     * @param col the col
+     * @return the boolean
+     */
+    public static boolean isEmpty(Collection col){
+        return !isNotEmpty(col);
+    }
+
+    /**
+     * Is not empty boolean.
+     *
+     * @param col the col
+     * @return the boolean
+     */
+    public static boolean isNotEmpty(Collection col){
+        return col != null && col.size() > 0;
+    }
+}
diff --git a/common/src/main/java/com/alibaba/fescar/common/util/ReflectionUtil.java b/common/src/main/java/com/alibaba/fescar/common/util/ReflectionUtil.java
new file mode 100644
index 000000000..4299190bd
--- /dev/null
+++ b/common/src/main/java/com/alibaba/fescar/common/util/ReflectionUtil.java
@@ -0,0 +1,193 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.common.util;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * Reflection tools
+ *
+ * @author zhangsen
+ */
+public class ReflectionUtil {
+
+    /**
+     * The constant MAX_NEST_DEPTH.
+     */
+    public static int MAX_NEST_DEPTH = 20;
+
+    /**
+     * Gets class by name.
+     *
+     * @param className the class name
+     * @return the class by name
+     * @throws ClassNotFoundException the class not found exception
+     */
+    public static Class<?> getClassByName(String className) throws ClassNotFoundException{
+        return Class.forName(className, true, Thread.currentThread().getContextClassLoader());
+    }
+
+    /**
+     * get Field Value
+     *
+     * @param target the target
+     * @param fieldName the field name
+     * @return field value
+     * @throws NoSuchFieldException the no such field exception
+     * @throws SecurityException the security exception
+     * @throws IllegalArgumentException the illegal argument exception
+     * @throws IllegalAccessException the illegal access exception
+     */
+    public static Object getFieldValue (Object target, String fieldName) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
+        Class<?> cl = target.getClass();
+        int i = 0;
+        while((i++) < MAX_NEST_DEPTH && cl != null){
+            try{
+                Field field = cl.getDeclaredField(fieldName);
+                field.setAccessible(true);
+                return field.get(target);
+            }catch(Exception e){
+                cl = cl.getSuperclass();
+            }
+        }
+        throw new NoSuchFieldException("class:"+target.getClass() + ", field:" + fieldName);
+    }
+
+    /**
+     * invoke Method
+     *
+     * @param target the target
+     * @param methodName the method name
+     * @return object
+     * @throws NoSuchMethodException the no such method exception
+     * @throws SecurityException the security exception
+     * @throws IllegalAccessException the illegal access exception
+     * @throws IllegalArgumentException the illegal argument exception
+     * @throws InvocationTargetException the invocation target exception
+     */
+    public static Object invokeMethod(Object target, String methodName) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+        Class<?> cl = target.getClass();
+        int i = 0;
+        while((i++) < MAX_NEST_DEPTH && cl != null){
+            try{
+                Method m = cl.getDeclaredMethod(methodName);
+                m.setAccessible(true);
+                return m.invoke(target);
+            }catch(Exception e){
+                cl = cl.getSuperclass();
+            }
+        }
+        throw new NoSuchMethodException("class:"+target.getClass() + ", methodName:" + methodName);
+    }
+
+    /**
+     * invoke Method
+     *
+     * @param target the target
+     * @param methodName the method name
+     * @param parameterTypes the parameter types
+     * @param args the args
+     * @return object
+     * @throws NoSuchMethodException the no such method exception
+     * @throws SecurityException the security exception
+     * @throws IllegalAccessException the illegal access exception
+     * @throws IllegalArgumentException the illegal argument exception
+     * @throws InvocationTargetException the invocation target exception
+     */
+    public static Object invokeMethod(Object target, String methodName, Class<?>[] parameterTypes, Object[] args) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException{
+        Class<?> cl = target.getClass();
+        int i = 0;
+        while((i++) < MAX_NEST_DEPTH && cl != null){
+            try{
+                Method m = cl.getDeclaredMethod(methodName, parameterTypes);
+                m.setAccessible(true);
+                return m.invoke(target, args);
+            }catch(Exception e){
+                cl = cl.getSuperclass();
+            }
+        }
+        throw new NoSuchMethodException("class:"+target.getClass() + ", methodName:" + methodName);
+    }
+
+    /**
+     * invoke static Method
+     *
+     * @param targetClass the target class
+     * @param methodName the method name
+     * @param parameterTypes the parameter types
+     * @param parameterValues the parameter values
+     * @return object
+     * @throws NoSuchMethodException the no such method exception
+     * @throws SecurityException the security exception
+     * @throws IllegalAccessException the illegal access exception
+     * @throws IllegalArgumentException the illegal argument exception
+     * @throws InvocationTargetException the invocation target exception
+     */
+    public static Object invokeStaticMethod(Class<?> targetClass, String methodName, Class<?>[] parameterTypes , Object[] parameterValues) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException{
+        int i = 0;
+        while((i++) < MAX_NEST_DEPTH && targetClass != null){
+            try{
+                Method m = targetClass.getMethod(methodName, parameterTypes);
+                return m.invoke(null, parameterValues);
+            }catch(Exception e){
+                targetClass = targetClass.getSuperclass();
+            }
+        }
+        throw new NoSuchMethodException("class:"+targetClass + ", methodName:" + methodName);
+    }
+
+    /**
+     * get Method by name
+     *
+     * @param classType the class type
+     * @param methodName the method name
+     * @param parameterTypes the parameter types
+     * @return method
+     * @throws NoSuchMethodException the no such method exception
+     * @throws SecurityException the security exception
+     */
+    public static Method getMethod(Class<?> classType, String methodName, Class<?>[] parameterTypes) throws NoSuchMethodException, SecurityException{
+        return classType.getMethod(methodName, parameterTypes);
+    }
+
+    /**
+     * get all interface of the clazz
+     *
+     * @param clazz the clazz
+     * @return set
+     */
+    public static Set<Class<?>> getInterfaces(Class<?> clazz){
+        if (clazz.isInterface() ) {
+            return Collections.<Class<?>>singleton(clazz);
+        }
+        Set<Class<?>> interfaces = new LinkedHashSet<Class<?>>();
+        while (clazz != null) {
+            Class<?>[] ifcs = clazz.getInterfaces();
+            for (Class<?> ifc : ifcs) {
+                interfaces.addAll(getInterfaces(ifc));
+            }
+            clazz = clazz.getSuperclass();
+        }
+        return interfaces;
+    }
+
+}
diff --git a/common/src/main/java/com/alibaba/fescar/common/util/StringUtils.java b/common/src/main/java/com/alibaba/fescar/common/util/StringUtils.java
index 94a771031..7b2e1db79 100644
--- a/common/src/main/java/com/alibaba/fescar/common/util/StringUtils.java
+++ b/common/src/main/java/com/alibaba/fescar/common/util/StringUtils.java
@@ -45,6 +45,47 @@ public class StringUtils {
         return (str == null) || (str.isEmpty());
     }
 
+    /**
+     * Is blank string ?
+     *
+     * @param str the str
+     * @return boolean
+     */
+    public static boolean isBlank(String str) {
+        int length;
+
+        if ((str == null) || ((length = str.length()) == 0)) {
+            return true;
+        }
+        for (int i = 0; i < length; i++) {
+            if (!Character.isWhitespace(str.charAt(i))) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * Is Not blank string ?
+     *
+     * @param str the str
+     * @return boolean
+     */
+    public static boolean isNotBlank(String str) {
+        int length;
+
+        if ((str == null) || ((length = str.length()) == 0)) {
+            return false;
+        }
+
+        for (int i = 0; i < length; i++) {
+            if (!Character.isWhitespace(str.charAt(i))) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     /**
      * String 2 blob blob.
      *
diff --git a/core/src/main/java/com/alibaba/fescar/core/model/BranchType.java b/core/src/main/java/com/alibaba/fescar/core/model/BranchType.java
index 6a9f81b72..e0534f896 100644
--- a/core/src/main/java/com/alibaba/fescar/core/model/BranchType.java
+++ b/core/src/main/java/com/alibaba/fescar/core/model/BranchType.java
@@ -31,7 +31,12 @@ public enum BranchType {
      * The Mt.
      */
     // MT Branch
-    MT;
+    MT,
+    
+    /**
+     * The TCC.
+     */
+    TCC;
 
     /**
      * Get branch type.
diff --git a/core/src/main/java/com/alibaba/fescar/core/model/Resource.java b/core/src/main/java/com/alibaba/fescar/core/model/Resource.java
index 3827a45aa..9b3e433c7 100644
--- a/core/src/main/java/com/alibaba/fescar/core/model/Resource.java
+++ b/core/src/main/java/com/alibaba/fescar/core/model/Resource.java
@@ -37,4 +37,11 @@ public interface Resource {
      */
     String getResourceId();
 
+    /**
+     * get resource type, AT、TCC etc.
+     *
+     * @return
+     */
+    BranchType getBranchType();
+
 }
diff --git a/core/src/main/java/com/alibaba/fescar/core/model/ResourceManager.java b/core/src/main/java/com/alibaba/fescar/core/model/ResourceManager.java
index 5d9a6dd1c..09095fde3 100644
--- a/core/src/main/java/com/alibaba/fescar/core/model/ResourceManager.java
+++ b/core/src/main/java/com/alibaba/fescar/core/model/ResourceManager.java
@@ -43,4 +43,10 @@ public interface ResourceManager extends ResourceManagerInbound, ResourceManager
      * @return resourceId -> Resource Map
      */
     Map<String, Resource> getManagedResources();
+
+    /**
+     * get the BranchType
+     * @return
+     */
+    BranchType getBranchType();
 }
diff --git a/core/src/main/java/com/alibaba/fescar/core/model/ResourceManagerInbound.java b/core/src/main/java/com/alibaba/fescar/core/model/ResourceManagerInbound.java
index 242686923..1098bf8b5 100644
--- a/core/src/main/java/com/alibaba/fescar/core/model/ResourceManagerInbound.java
+++ b/core/src/main/java/com/alibaba/fescar/core/model/ResourceManagerInbound.java
@@ -26,6 +26,7 @@ public interface ResourceManagerInbound {
     /**
      * Commit a branch transaction.
      *
+     * s@param branchType the branch type
      * @param xid             Transaction id.
      * @param branchId        Branch id.
      * @param resourceId      Resource id.
@@ -34,12 +35,12 @@ public interface ResourceManagerInbound {
      * @throws TransactionException Any exception that fails this will be wrapped with TransactionException and thrown
      * out.
      */
-    BranchStatus branchCommit(String xid, long branchId, String resourceId, String applicationData)
-        throws TransactionException;
+    BranchStatus branchCommit(BranchType branchType, String xid, long branchId, String resourceId, String applicationData) throws TransactionException;
 
     /**
      * Rollback a branch transaction.
      *
+     * @param branchType the branch type
      * @param xid             Transaction id.
      * @param branchId        Branch id.
      * @param resourceId      Resource id.
@@ -48,6 +49,5 @@ public interface ResourceManagerInbound {
      * @throws TransactionException Any exception that fails this will be wrapped with TransactionException and thrown
      * out.
      */
-    BranchStatus branchRollback(String xid, long branchId, String resourceId, String applicationData)
-        throws TransactionException;
+    BranchStatus branchRollback(BranchType branchType, String xid, long branchId, String resourceId, String applicationData) throws TransactionException;
 }
diff --git a/core/src/main/java/com/alibaba/fescar/core/model/ResourceManagerOutbound.java b/core/src/main/java/com/alibaba/fescar/core/model/ResourceManagerOutbound.java
index ef6a12de0..6ae9ac27e 100644
--- a/core/src/main/java/com/alibaba/fescar/core/model/ResourceManagerOutbound.java
+++ b/core/src/main/java/com/alibaba/fescar/core/model/ResourceManagerOutbound.java
@@ -30,24 +30,25 @@ public interface ResourceManagerOutbound {
      * @param resourceId the resource id
      * @param clientId   the client id
      * @param xid        the xid
+     * @param applicationData the context
      * @param lockKeys   the lock keys
      * @return the long
      * @throws TransactionException the transaction exception
      */
-    Long branchRegister(BranchType branchType, String resourceId, String clientId, String xid, String lockKeys) throws
+    Long branchRegister(BranchType branchType, String resourceId, String clientId, String xid, String applicationData, String lockKeys) throws
         TransactionException;
 
     /**
      * Branch report.
      *
+     * @param branchType      the branch type
      * @param xid             the xid
      * @param branchId        the branch id
      * @param status          the status
      * @param applicationData the application data
      * @throws TransactionException the transaction exception
      */
-    void branchReport(String xid, long branchId, BranchStatus status, String applicationData)
-        throws TransactionException;
+    void branchReport(BranchType branchType, String xid, long branchId, BranchStatus status, String applicationData) throws TransactionException;
 
     /**
      * Lock query boolean.
diff --git a/core/src/main/java/com/alibaba/fescar/core/protocol/transaction/BranchRegisterRequest.java b/core/src/main/java/com/alibaba/fescar/core/protocol/transaction/BranchRegisterRequest.java
index 4262fbe41..a42b850e2 100644
--- a/core/src/main/java/com/alibaba/fescar/core/protocol/transaction/BranchRegisterRequest.java
+++ b/core/src/main/java/com/alibaba/fescar/core/protocol/transaction/BranchRegisterRequest.java
@@ -37,6 +37,8 @@ public class BranchRegisterRequest extends AbstractTransactionRequestToTC implem
 
     private String lockKey;
 
+    private String applicationData;
+
     /**
      * Gets transaction id.
      *
@@ -114,15 +116,32 @@ public class BranchRegisterRequest extends AbstractTransactionRequestToTC implem
         return TYPE_BRANCH_REGISTER;
     }
 
+    public String getApplicationData() {
+        return applicationData;
+    }
+
+    public void setApplicationData(String applicationData) {
+        this.applicationData = applicationData;
+    }
+
     @Override
     public byte[] encode() {
+        int byteLenth = 0;
         byte[] lockKeyBytes = null;
         if (this.lockKey != null) {
             lockKeyBytes = lockKey.getBytes(UTF8);
             if (lockKeyBytes.length > 512) {
-                byteBuffer = ByteBuffer.allocate(lockKeyBytes.length + 1024);
+                byteLenth += lockKeyBytes.length;
+            }
+        }
+        byte[] applicationDataBytes = null;
+        if (this.applicationData != null) {
+            applicationDataBytes = applicationData.getBytes(UTF8);
+            if (applicationDataBytes.length > 512) {
+                byteLenth += applicationDataBytes.length;
             }
         }
+        byteBuffer = ByteBuffer.allocate(byteLenth + 1024);
 
         // 1. Transaction Id
         byteBuffer.putLong(this.transactionId);
@@ -149,6 +168,16 @@ public class BranchRegisterRequest extends AbstractTransactionRequestToTC implem
             byteBuffer.putInt(0);
         }
 
+        //5. applicationData
+        if (this.applicationData != null) {
+            byteBuffer.putInt(applicationDataBytes.length);
+            if (applicationDataBytes.length > 0) {
+                byteBuffer.put(applicationDataBytes);
+            }
+        } else {
+            byteBuffer.putInt(0);
+        }
+
         byteBuffer.flip();
         byte[] content = new byte[byteBuffer.limit()];
         byteBuffer.get(content);
@@ -172,6 +201,13 @@ public class BranchRegisterRequest extends AbstractTransactionRequestToTC implem
             byteBuffer.get(bs);
             this.setLockKey(new String(bs, UTF8));
         }
+
+        int applicationDataLen = byteBuffer.getInt();
+        if (applicationDataLen > 0) {
+            byte[] bs = new byte[applicationDataLen];
+            byteBuffer.get(bs);
+            setApplicationData(new String(bs, UTF8));
+        }
     }
 
     @Override
diff --git a/core/src/main/java/com/alibaba/fescar/core/protocol/transaction/BranchReportRequest.java b/core/src/main/java/com/alibaba/fescar/core/protocol/transaction/BranchReportRequest.java
index 6dfce589b..7bae6e7d5 100644
--- a/core/src/main/java/com/alibaba/fescar/core/protocol/transaction/BranchReportRequest.java
+++ b/core/src/main/java/com/alibaba/fescar/core/protocol/transaction/BranchReportRequest.java
@@ -19,6 +19,7 @@ package com.alibaba.fescar.core.protocol.transaction;
 import java.nio.ByteBuffer;
 
 import com.alibaba.fescar.core.model.BranchStatus;
+import com.alibaba.fescar.core.model.BranchType;
 import com.alibaba.fescar.core.protocol.MergedMessage;
 import com.alibaba.fescar.core.rpc.RpcContext;
 
@@ -37,6 +38,8 @@ public class BranchReportRequest extends AbstractTransactionRequestToTC implemen
 
     private String applicationData;
 
+    private BranchType branchType = BranchType.AT;
+
     /**
      * Gets transaction id.
      *
@@ -91,6 +94,24 @@ public class BranchReportRequest extends AbstractTransactionRequestToTC implemen
         this.resourceId = resourceId;
     }
 
+    /**
+     * Gets branch type.
+     *
+     * @return the branch type
+     */
+    public BranchType getBranchType() {
+        return branchType;
+    }
+
+    /**
+     * Sets branch type.
+     *
+     * @param branchType the branch type
+     */
+    public void setBranchType(BranchType branchType) {
+        this.branchType = branchType;
+    }
+
     /**
      * Gets status.
      *
@@ -168,6 +189,8 @@ public class BranchReportRequest extends AbstractTransactionRequestToTC implemen
         } else {
             byteBuffer.putInt(0);
         }
+        //6. branchType
+        byteBuffer.put((byte) this.branchType.ordinal());
 
         byteBuffer.flip();
         byte[] content = new byte[byteBuffer.limit()];
@@ -193,6 +216,7 @@ public class BranchReportRequest extends AbstractTransactionRequestToTC implemen
             byteBuffer.get(bs);
             this.applicationData = new String(bs, UTF8);
         }
+        this.branchType = BranchType.get(byteBuffer.get());
     }
 
     @Override
diff --git a/core/src/main/java/com/alibaba/fescar/core/rpc/netty/RmRpcClient.java b/core/src/main/java/com/alibaba/fescar/core/rpc/netty/RmRpcClient.java
index 7990b0cea..f572db624 100644
--- a/core/src/main/java/com/alibaba/fescar/core/rpc/netty/RmRpcClient.java
+++ b/core/src/main/java/com/alibaba/fescar/core/rpc/netty/RmRpcClient.java
@@ -439,7 +439,7 @@ public final class RmRpcClient extends AbstractRpcRemotingClient {
                 String serverAddress = entry.getKey();
                 Channel rmChannel = entry.getValue();
                 if (LOGGER.isInfoEnabled()) {
-                    LOGGER.info("register AT resourceId:" + resourceId);
+                    LOGGER.info("register resource, resourceId:" + resourceId);
                 }
                 sendRegisterMessage(serverAddress, rmChannel, resourceId);
             }
@@ -502,6 +502,7 @@ public final class RmRpcClient extends AbstractRpcRemotingClient {
      * @return the merged resource keys
      */
     public String getMergedResourceKeys(ResourceManager resourceManager) {
+        //TODO
         Map<String, Resource> managedResources = resourceManager.getManagedResources();
         Set<String> resourceIds = managedResources.keySet();
         if (!resourceIds.isEmpty()) {
diff --git a/discovery/pom.xml b/discovery/pom.xml
index 407064bfe..9783500ac 100644
--- a/discovery/pom.xml
+++ b/discovery/pom.xml
@@ -68,4 +68,4 @@
             <artifactId>archaius-core</artifactId>
         </dependency>
     </dependencies>
-</project>
+</project>
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 8a5ae55fc..0306ee1a6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -35,6 +35,8 @@
         <module>discovery</module>
         <module>test</module>
         <module>dubbo-alibaba</module>
+        <module>tcc</module>
+        <module>rm</module>
     </modules>
     <packaging>pom</packaging>
 
@@ -172,6 +174,16 @@
                 <artifactId>fescar-discovery</artifactId>
                 <version>${project.version}</version>
             </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>fescar-tcc</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>fescar-rm</artifactId>
+                <version>${project.version}</version>
+            </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
                 <artifactId>fescar-test</artifactId>
@@ -436,6 +448,7 @@
                     </execution>
                 </executions>
             </plugin>
+
         </plugins>
     </build>
 
diff --git a/rm-datasource/pom.xml b/rm-datasource/pom.xml
index adf6194bd..1ea79b790 100644
--- a/rm-datasource/pom.xml
+++ b/rm-datasource/pom.xml
@@ -33,6 +33,10 @@
             <groupId>${project.groupId}</groupId>
             <artifactId>fescar-core</artifactId>
         </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>fescar-rm</artifactId>
+        </dependency>
         <dependency>
             <groupId>com.alibaba</groupId>
             <artifactId>druid</artifactId>
diff --git a/rm-datasource/src/main/java/com/alibaba/fescar/rm/AbstractRMHandlerAT.java b/rm-datasource/src/main/java/com/alibaba/fescar/rm/AbstractRMHandlerAT.java
index 1d81a3255..d5b0478d9 100644
--- a/rm-datasource/src/main/java/com/alibaba/fescar/rm/AbstractRMHandlerAT.java
+++ b/rm-datasource/src/main/java/com/alibaba/fescar/rm/AbstractRMHandlerAT.java
@@ -33,6 +33,7 @@ import com.alibaba.fescar.core.rpc.TransactionMessageHandler;
 /**
  * The type Abstract rm handler at.
  */
+@Deprecated
 public abstract class AbstractRMHandlerAT extends AbstractExceptionHandler
     implements RMInboundHandler, TransactionMessageHandler {
 
diff --git a/rm-datasource/src/main/java/com/alibaba/fescar/rm/RMClientAT.java b/rm-datasource/src/main/java/com/alibaba/fescar/rm/RMClientAT.java
index 7d1cd54f7..707ccce3b 100644
--- a/rm-datasource/src/main/java/com/alibaba/fescar/rm/RMClientAT.java
+++ b/rm-datasource/src/main/java/com/alibaba/fescar/rm/RMClientAT.java
@@ -18,12 +18,12 @@ package com.alibaba.fescar.rm;
 
 import com.alibaba.fescar.core.rpc.netty.RmMessageListener;
 import com.alibaba.fescar.core.rpc.netty.RmRpcClient;
-import com.alibaba.fescar.rm.datasource.AsyncWorker;
 import com.alibaba.fescar.rm.datasource.DataSourceManager;
 
 /**
  * The type Rm client at.
  */
+@Deprecated
 public class RMClientAT {
 
     /**
@@ -34,9 +34,9 @@ public class RMClientAT {
      */
     public static void init(String applicationId, String transactionServiceGroup) {
         RmRpcClient rmRpcClient = RmRpcClient.getInstance(applicationId, transactionServiceGroup);
-        AsyncWorker asyncWorker = new AsyncWorker();
-        asyncWorker.init();
-        DataSourceManager.init(asyncWorker);
+//        AsyncWorker asyncWorker = new AsyncWorker();
+//        asyncWorker.init();
+//        DataSourceManager.init(asyncWorker);
         rmRpcClient.setResourceManager(DataSourceManager.get());
         rmRpcClient.setClientMessageListener(new RmMessageListener(new RMHandlerAT()));
         rmRpcClient.init();
diff --git a/rm-datasource/src/main/java/com/alibaba/fescar/rm/RMHandlerAT.java b/rm-datasource/src/main/java/com/alibaba/fescar/rm/RMHandlerAT.java
index 67d540909..55fe234b2 100644
--- a/rm-datasource/src/main/java/com/alibaba/fescar/rm/RMHandlerAT.java
+++ b/rm-datasource/src/main/java/com/alibaba/fescar/rm/RMHandlerAT.java
@@ -16,53 +16,26 @@
 
 package com.alibaba.fescar.rm;
 
-import com.alibaba.fescar.core.exception.TransactionException;
-import com.alibaba.fescar.core.model.BranchStatus;
-import com.alibaba.fescar.core.protocol.transaction.BranchCommitRequest;
-import com.alibaba.fescar.core.protocol.transaction.BranchCommitResponse;
-import com.alibaba.fescar.core.protocol.transaction.BranchRollbackRequest;
-import com.alibaba.fescar.core.protocol.transaction.BranchRollbackResponse;
-import com.alibaba.fescar.core.protocol.transaction.RMInboundHandler;
-import com.alibaba.fescar.core.rpc.TransactionMessageHandler;
-import com.alibaba.fescar.rm.datasource.DataSourceManager;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.alibaba.fescar.core.model.BranchType;
+import com.alibaba.fescar.core.model.ResourceManager;
 
 /**
  * The type Rm handler at.
  */
-public class RMHandlerAT extends AbstractRMHandlerAT implements RMInboundHandler, TransactionMessageHandler {
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(RMHandlerAT.class);
-
-    private DataSourceManager dataSourceManager = DataSourceManager.get();
+public class RMHandlerAT extends AbstractRMHandler {
 
+    /**
+     * get AT resource managerDataSourceManager.java
+     * @return
+     */
     @Override
-    protected void doBranchCommit(BranchCommitRequest request, BranchCommitResponse response)
-        throws TransactionException {
-        String xid = request.getXid();
-        long branchId = request.getBranchId();
-        String resourceId = request.getResourceId();
-        String applicationData = request.getApplicationData();
-        LOGGER.info("AT Branch committing: " + xid + " " + branchId + " " + resourceId + " " + applicationData);
-        BranchStatus status = dataSourceManager.branchCommit(xid, branchId, resourceId, applicationData);
-        response.setBranchStatus(status);
-        LOGGER.info("AT Branch commit result: " + status);
-
+    protected ResourceManager getResourceManager() {
+        return DefaultResourceManager.get().getResourceManager(BranchType.AT);
     }
 
     @Override
-    protected void doBranchRollback(BranchRollbackRequest request, BranchRollbackResponse response)
-        throws TransactionException {
-        String xid = request.getXid();
-        long branchId = request.getBranchId();
-        String resourceId = request.getResourceId();
-        String applicationData = request.getApplicationData();
-        LOGGER.info("AT Branch rolling back: " + xid + " " + branchId + " " + resourceId);
-        BranchStatus status = dataSourceManager.branchRollback(xid, branchId, resourceId, applicationData);
-        response.setBranchStatus(status);
-        LOGGER.info("AT Branch rollback result: " + status);
-
+    public BranchType getBranchType(){
+        return BranchType.AT;
     }
+
 }
diff --git a/rm-datasource/src/main/java/com/alibaba/fescar/rm/datasource/AsyncWorker.java b/rm-datasource/src/main/java/com/alibaba/fescar/rm/datasource/AsyncWorker.java
index ac106c8d5..d94e77285 100644
--- a/rm-datasource/src/main/java/com/alibaba/fescar/rm/datasource/AsyncWorker.java
+++ b/rm-datasource/src/main/java/com/alibaba/fescar/rm/datasource/AsyncWorker.java
@@ -33,6 +33,7 @@ import com.alibaba.fescar.common.thread.NamedThreadFactory;
 import com.alibaba.fescar.config.ConfigurationFactory;
 import com.alibaba.fescar.core.exception.TransactionException;
 import com.alibaba.fescar.core.model.BranchStatus;
+import com.alibaba.fescar.core.model.BranchType;
 import com.alibaba.fescar.core.model.ResourceManagerInbound;
 import com.alibaba.fescar.rm.datasource.undo.UndoLogManager;
 
@@ -53,16 +54,18 @@ public class AsyncWorker implements ResourceManagerInbound {
         /**
          * Instantiates a new Phase 2 context.
          *
+         * @param branchType      the branchType
          * @param xid             the xid
          * @param branchId        the branch id
          * @param resourceId      the resource id
          * @param applicationData the application data
          */
-        public Phase2Context(String xid, long branchId, String resourceId, String applicationData) {
+        public Phase2Context(BranchType branchType, String xid, long branchId, String resourceId, String applicationData) {
             this.xid = xid;
             this.branchId = branchId;
             this.resourceId = resourceId;
             this.applicationData = applicationData;
+            this.branchType = branchType;
         }
 
         /**
@@ -81,6 +84,11 @@ public class AsyncWorker implements ResourceManagerInbound {
          * The Application data.
          */
         String applicationData;
+
+        /**
+         * the branch Type
+         */
+        BranchType branchType;
     }
 
     private static final List<Phase2Context> ASYNC_COMMIT_BUFFER = Collections.synchronizedList(
@@ -92,13 +100,11 @@ public class AsyncWorker implements ResourceManagerInbound {
     private static ScheduledExecutorService timerExecutor;
 
     @Override
-    public BranchStatus branchCommit(String xid, long branchId, String resourceId, String applicationData)
-        throws TransactionException {
+    public BranchStatus branchCommit(BranchType branchType, String xid, long branchId, String resourceId, String applicationData) throws TransactionException {
         if (ASYNC_COMMIT_BUFFER.size() < ASYNC_COMMIT_BUFFER_LIMIT) {
-            ASYNC_COMMIT_BUFFER.add(new Phase2Context(xid, branchId, resourceId, applicationData));
+            ASYNC_COMMIT_BUFFER.add(new Phase2Context(branchType, xid, branchId, resourceId, applicationData));
         } else {
-            LOGGER.warn("Async commit buffer is FULL. Rejected branch [" + branchId + "/" + xid
-                + "] will be handled by housekeeping later.");
+            LOGGER.warn("Async commit buffer is FULL. Rejected branch [" + branchId + "/" + xid + "] will be handled by housekeeping later.");
         }
         return BranchStatus.PhaseTwo_Committed;
     }
@@ -177,8 +183,7 @@ public class AsyncWorker implements ResourceManagerInbound {
     }
 
     @Override
-    public BranchStatus branchRollback(String xid, long branchId, String resourceId, String applicationData)
-        throws TransactionException {
+    public BranchStatus branchRollback(BranchType branchType, String xid, long branchId, String resourceId, String applicationData) throws TransactionException {
         throw new NotSupportYetException();
 
     }
diff --git a/rm-datasource/src/main/java/com/alibaba/fescar/rm/datasource/ConnectionProxy.java b/rm-datasource/src/main/java/com/alibaba/fescar/rm/datasource/ConnectionProxy.java
index 3289963ce..0599541cb 100644
--- a/rm-datasource/src/main/java/com/alibaba/fescar/rm/datasource/ConnectionProxy.java
+++ b/rm-datasource/src/main/java/com/alibaba/fescar/rm/datasource/ConnectionProxy.java
@@ -16,20 +16,20 @@
 
 package com.alibaba.fescar.rm.datasource;
 
-import java.sql.Connection;
-import java.sql.SQLException;
-
 import com.alibaba.fescar.core.exception.TransactionException;
 import com.alibaba.fescar.core.exception.TransactionExceptionCode;
 import com.alibaba.fescar.core.model.BranchStatus;
 import com.alibaba.fescar.core.model.BranchType;
+import com.alibaba.fescar.rm.DefaultResourceManager;
 import com.alibaba.fescar.rm.datasource.exec.LockConflictException;
 import com.alibaba.fescar.rm.datasource.undo.SQLUndoLog;
 import com.alibaba.fescar.rm.datasource.undo.UndoLogManager;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.sql.Connection;
+import java.sql.SQLException;
+
 /**
  * The type Connection proxy.
  */
@@ -93,8 +93,7 @@ public class ConnectionProxy extends AbstractConnectionProxy {
     public void checkLock(String lockKeys) throws SQLException {
         // Just check lock without requiring lock by now.
         try {
-            boolean lockable = DataSourceManager.get().lockQuery(BranchType.AT, getDataSourceProxy().getResourceId(),
-                context.getXid(), lockKeys);
+            boolean lockable = DefaultResourceManager.get().lockQuery(BranchType.AT, getDataSourceProxy().getResourceId(), context.getXid(), lockKeys);
             if (!lockable) {
                 throw new LockConflictException();
             }
@@ -112,8 +111,7 @@ public class ConnectionProxy extends AbstractConnectionProxy {
     public void register(String lockKeys) throws SQLException {
         // Just check lock without requiring lock by now.
         try {
-            DataSourceManager.get().branchRegister(BranchType.AT, getDataSourceProxy().getResourceId(), null,
-                context.getXid(), lockKeys);
+            DefaultResourceManager.get().branchRegister(BranchType.AT, getDataSourceProxy().getResourceId(), null, context.getXid(), null, lockKeys);
         } catch (TransactionException e) {
             recognizeLockKeyConflictException(e);
         }
@@ -191,8 +189,8 @@ public class ConnectionProxy extends AbstractConnectionProxy {
     }
 
     private void register() throws TransactionException {
-        Long branchId = DataSourceManager.get().branchRegister(BranchType.AT, getDataSourceProxy().getResourceId(),
-            null, context.getXid(), context.buildLockKeys());
+        Long branchId = DefaultResourceManager.get().branchRegister(BranchType.AT, getDataSourceProxy().getResourceId(),
+                null, context.getXid(), null, context.buildLockKeys());
         context.setBranchId(branchId);
     }
 
@@ -220,8 +218,8 @@ public class ConnectionProxy extends AbstractConnectionProxy {
         int retry = 5; // TODO: configure
         while (retry > 0) {
             try {
-                DataSourceManager.get().branchReport(context.getXid(), context.getBranchId(),
-                    (commitDone ? BranchStatus.PhaseOne_Done : BranchStatus.PhaseOne_Failed), null);
+                DefaultResourceManager.get().branchReport(BranchType.AT, context.getXid(), context.getBranchId(),
+                        (commitDone ? BranchStatus.PhaseOne_Done : BranchStatus.PhaseOne_Failed), null);
                 return;
             } catch (Throwable ex) {
                 LOGGER.error("Failed to report [" + context.getBranchId() + "/" + context.getXid() + "] commit done ["
diff --git a/rm-datasource/src/main/java/com/alibaba/fescar/rm/datasource/DataSourceManager.java b/rm-datasource/src/main/java/com/alibaba/fescar/rm/datasource/DataSourceManager.java
index 449ffea80..40f2e69d3 100644
--- a/rm-datasource/src/main/java/com/alibaba/fescar/rm/datasource/DataSourceManager.java
+++ b/rm-datasource/src/main/java/com/alibaba/fescar/rm/datasource/DataSourceManager.java
@@ -28,18 +28,14 @@ import com.alibaba.fescar.common.exception.NotSupportYetException;
 import com.alibaba.fescar.common.exception.ShouldNeverHappenException;
 import com.alibaba.fescar.common.util.NetUtil;
 import com.alibaba.fescar.core.context.RootContext;
+import com.alibaba.fescar.common.executor.Initialize;
 import com.alibaba.fescar.core.exception.TransactionException;
 import com.alibaba.fescar.core.exception.TransactionExceptionCode;
 import com.alibaba.fescar.core.model.BranchStatus;
 import com.alibaba.fescar.core.model.BranchType;
 import com.alibaba.fescar.core.model.Resource;
-import com.alibaba.fescar.core.model.ResourceManager;
 import com.alibaba.fescar.core.model.ResourceManagerInbound;
 import com.alibaba.fescar.core.protocol.ResultCode;
-import com.alibaba.fescar.core.protocol.transaction.BranchRegisterRequest;
-import com.alibaba.fescar.core.protocol.transaction.BranchRegisterResponse;
-import com.alibaba.fescar.core.protocol.transaction.BranchReportRequest;
-import com.alibaba.fescar.core.protocol.transaction.BranchReportResponse;
 import com.alibaba.fescar.core.protocol.transaction.GlobalLockQueryRequest;
 import com.alibaba.fescar.core.protocol.transaction.GlobalLockQueryResponse;
 import com.alibaba.fescar.core.rpc.netty.NettyClientConfig;
@@ -47,6 +43,7 @@ import com.alibaba.fescar.core.rpc.netty.RmRpcClient;
 import com.alibaba.fescar.core.rpc.netty.TmRpcClient;
 import com.alibaba.fescar.discovery.loadbalance.LoadBalanceFactory;
 import com.alibaba.fescar.discovery.registry.RegistryFactory;
+import com.alibaba.fescar.rm.AbstractResourceManager;
 import com.alibaba.fescar.rm.datasource.undo.UndoLogManager;
 
 import org.slf4j.Logger;
@@ -57,7 +54,7 @@ import static com.alibaba.fescar.common.exception.FrameworkErrorCode.NoAvailable
 /**
  * The type Data source manager.
  */
-public class DataSourceManager implements ResourceManager {
+public class DataSourceManager extends AbstractResourceManager implements Initialize {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(DataSourceManager.class);
 
@@ -74,54 +71,6 @@ public class DataSourceManager implements ResourceManager {
         this.asyncWorker = asyncWorker;
     }
 
-    @Override
-    public Long branchRegister(BranchType branchType, String resourceId, String clientId, String xid, String lockKeys)
-        throws TransactionException {
-        try {
-            BranchRegisterRequest request = new BranchRegisterRequest();
-            request.setTransactionId(XID.getTransactionId(xid));
-            request.setLockKey(lockKeys);
-            request.setResourceId(resourceId);
-            request.setBranchType(branchType);
-
-            BranchRegisterResponse response = (BranchRegisterResponse)RmRpcClient.getInstance().sendMsgWithResponse(
-                request);
-            if (response.getResultCode() == ResultCode.Failed) {
-                throw new TransactionException(response.getTransactionExceptionCode(),
-                    "Response[" + response.getMsg() + "]");
-            }
-            return response.getBranchId();
-        } catch (TimeoutException toe) {
-            throw new TransactionException(TransactionExceptionCode.IO, "RPC Timeout", toe);
-        } catch (RuntimeException rex) {
-            throw new TransactionException(TransactionExceptionCode.BranchRegisterFailed, "Runtime", rex);
-        }
-    }
-
-    @Override
-    public void branchReport(String xid, long branchId, BranchStatus status, String applicationData)
-        throws TransactionException {
-        try {
-            BranchReportRequest request = new BranchReportRequest();
-            request.setTransactionId(XID.getTransactionId(xid));
-            request.setBranchId(branchId);
-            request.setStatus(status);
-            request.setApplicationData(applicationData);
-
-            BranchReportResponse response = (BranchReportResponse)RmRpcClient.getInstance().sendMsgWithResponse(
-                request);
-            if (response.getResultCode() == ResultCode.Failed) {
-                throw new TransactionException(response.getTransactionExceptionCode(),
-                    "Response[" + response.getMsg() + "]");
-            }
-        } catch (TimeoutException toe) {
-            throw new TransactionException(TransactionExceptionCode.IO, "RPC Timeout", toe);
-        } catch (RuntimeException rex) {
-            throw new TransactionException(TransactionExceptionCode.BranchReportFailed, "Runtime", rex);
-        }
-
-    }
-
     @Override
     public boolean lockQuery(BranchType branchType, String resourceId, String xid, String lockKeys)
         throws TransactionException {
@@ -171,7 +120,7 @@ public class DataSourceManager implements ResourceManager {
     }
 
     private static class SingletonHolder {
-        private static DataSourceManager INSTANCE = new DataSourceManager();
+        private static DataSourceManager INSTANCE = new DataSourceManager(true);
     }
 
     /**
@@ -197,23 +146,35 @@ public class DataSourceManager implements ResourceManager {
      *
      * @param asyncWorker the async worker
      */
-    public static synchronized void init(ResourceManagerInbound asyncWorker) {
-        get().setAsyncWorker(asyncWorker);
+    public synchronized void initAsyncWorker(ResourceManagerInbound asyncWorker) {
+        setAsyncWorker(asyncWorker);
     }
 
     /**
      * Instantiates a new Data source manager.
      */
-    protected DataSourceManager() {
+    public DataSourceManager() {
+    }
+
+    public DataSourceManager(boolean isInit) {
+        if(isInit){
+            init();
+        }
+
+    }
+
+    @Override
+    public void init(){
+        AsyncWorker asyncWorker = new AsyncWorker();
+        asyncWorker.init();
+        initAsyncWorker(asyncWorker);
     }
 
     @Override
     public void registerResource(Resource resource) {
-        DataSourceProxy dataSourceProxy = (DataSourceProxy)resource;
+        DataSourceProxy dataSourceProxy = (DataSourceProxy) resource;
         dataSourceCache.put(dataSourceProxy.getResourceId(), dataSourceProxy);
-        RmRpcClient.getInstance().registerResource(dataSourceProxy.getResourceGroupId(),
-            dataSourceProxy.getResourceId());
-
+        super.registerResource(dataSourceProxy);
     }
 
     @Override
@@ -232,14 +193,12 @@ public class DataSourceManager implements ResourceManager {
     }
 
     @Override
-    public BranchStatus branchCommit(String xid, long branchId, String resourceId, String applicationData)
-        throws TransactionException {
-        return asyncWorker.branchCommit(xid, branchId, resourceId, applicationData);
+    public BranchStatus branchCommit(BranchType branchType, String xid, long branchId, String resourceId, String applicationData) throws TransactionException {
+        return asyncWorker.branchCommit(branchType, xid, branchId, resourceId, applicationData);
     }
 
     @Override
-    public BranchStatus branchRollback(String xid, long branchId, String resourceId, String applicationData)
-        throws TransactionException {
+    public BranchStatus branchRollback(BranchType branchType, String xid, long branchId, String resourceId, String applicationData) throws TransactionException {
         DataSourceProxy dataSourceProxy = get(resourceId);
         if (dataSourceProxy == null) {
             throw new ShouldNeverHappenException();
@@ -261,4 +220,10 @@ public class DataSourceManager implements ResourceManager {
     public Map<String, Resource> getManagedResources() {
         return dataSourceCache;
     }
+
+    @Override
+    public BranchType getBranchType(){
+        return BranchType.AT;
+    }
+
 }
diff --git a/rm-datasource/src/main/java/com/alibaba/fescar/rm/datasource/DataSourceProxy.java b/rm-datasource/src/main/java/com/alibaba/fescar/rm/datasource/DataSourceProxy.java
index 6bf8542f2..a5ff85e44 100644
--- a/rm-datasource/src/main/java/com/alibaba/fescar/rm/datasource/DataSourceProxy.java
+++ b/rm-datasource/src/main/java/com/alibaba/fescar/rm/datasource/DataSourceProxy.java
@@ -20,7 +20,9 @@ import java.sql.Connection;
 import java.sql.SQLException;
 
 import com.alibaba.druid.pool.DruidDataSource;
+import com.alibaba.fescar.core.model.BranchType;
 import com.alibaba.fescar.core.model.Resource;
+import com.alibaba.fescar.rm.DefaultResourceManager;
 
 /**
  * The type Data source proxy.
@@ -53,7 +55,7 @@ public class DataSourceProxy extends AbstractDataSourceProxy implements Resource
 
     private void assertManaged() {
         if (!managed) {
-            DataSourceManager.get().registerResource(this);
+            DefaultResourceManager.get().registerResource(this);
             managed = true;
         }
     }
@@ -100,4 +102,9 @@ public class DataSourceProxy extends AbstractDataSourceProxy implements Resource
     public String getResourceId() {
         return targetDataSource.getUrl();
     }
+
+    @Override
+    public BranchType getBranchType() {
+        return BranchType.AT;
+    }
 }
diff --git a/rm-datasource/src/main/resources/META-INF/services/com.alibaba.fescar.core.model.ResourceManager b/rm-datasource/src/main/resources/META-INF/services/com.alibaba.fescar.core.model.ResourceManager
new file mode 100644
index 000000000..cf116efa1
--- /dev/null
+++ b/rm-datasource/src/main/resources/META-INF/services/com.alibaba.fescar.core.model.ResourceManager
@@ -0,0 +1,1 @@
+com.alibaba.fescar.rm.datasource.DataSourceManager
\ No newline at end of file
diff --git a/rm-datasource/src/main/resources/META-INF/services/com.alibaba.fescar.rm.AbstractRMHandler b/rm-datasource/src/main/resources/META-INF/services/com.alibaba.fescar.rm.AbstractRMHandler
new file mode 100644
index 000000000..53cb52c34
--- /dev/null
+++ b/rm-datasource/src/main/resources/META-INF/services/com.alibaba.fescar.rm.AbstractRMHandler
@@ -0,0 +1,1 @@
+com.alibaba.fescar.rm.RMHandlerAT
\ No newline at end of file
diff --git a/rm/pom.xml b/rm/pom.xml
new file mode 100644
index 000000000..16df92a63
--- /dev/null
+++ b/rm/pom.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~  Copyright 1999-2018 Alibaba Group Holding Ltd.
+  ~
+  ~  Licensed under the Apache License, Version 2.0 (the "License");
+  ~  you may not use this file except in compliance with the License.
+  ~  You may obtain a copy of the License at
+  ~
+  ~       http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing, software
+  ~  distributed under the License is distributed on an "AS IS" BASIS,
+  ~  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~  See the License for the specific language governing permissions and
+  ~  limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>fescar-all</artifactId>
+        <groupId>com.alibaba.fescar</groupId>
+        <version>0.4.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>fescar-rm</artifactId>
+    <packaging>jar</packaging>
+    <name>fescar-rm ${project.version}</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>fescar-core</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>cglib</groupId>
+            <artifactId>cglib</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+
+</project>
diff --git a/rm/src/main/java/com/alibaba/fescar/rm/AbstractRMHandler.java b/rm/src/main/java/com/alibaba/fescar/rm/AbstractRMHandler.java
new file mode 100644
index 000000000..7d15f0eac
--- /dev/null
+++ b/rm/src/main/java/com/alibaba/fescar/rm/AbstractRMHandler.java
@@ -0,0 +1,126 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm;
+
+import com.alibaba.fescar.common.exception.ShouldNeverHappenException;
+import com.alibaba.fescar.core.exception.AbstractExceptionHandler;
+import com.alibaba.fescar.core.exception.TransactionException;
+import com.alibaba.fescar.core.model.BranchStatus;
+import com.alibaba.fescar.core.model.BranchType;
+import com.alibaba.fescar.core.model.ResourceManager;
+import com.alibaba.fescar.core.protocol.AbstractMessage;
+import com.alibaba.fescar.core.protocol.AbstractResultMessage;
+import com.alibaba.fescar.core.protocol.transaction.*;
+import com.alibaba.fescar.core.rpc.RpcContext;
+import com.alibaba.fescar.core.rpc.TransactionMessageHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The Abstract RM event handler
+ */
+public abstract class AbstractRMHandler extends AbstractExceptionHandler
+        implements RMInboundHandler, TransactionMessageHandler {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(AbstractRMHandler.class);
+
+    @Override
+    public BranchCommitResponse handle(BranchCommitRequest request) {
+        BranchCommitResponse response = new BranchCommitResponse();
+        exceptionHandleTemplate(new AbstractExceptionHandler.Callback<BranchCommitRequest, BranchCommitResponse>() {
+            @Override
+            public void execute(BranchCommitRequest request, BranchCommitResponse response) throws TransactionException {
+                doBranchCommit(request, response);
+            }
+        }, request, response);
+        return response;
+    }
+
+
+    @Override
+    public BranchRollbackResponse handle(BranchRollbackRequest request) {
+        BranchRollbackResponse response = new BranchRollbackResponse();
+        exceptionHandleTemplate(new Callback<BranchRollbackRequest, BranchRollbackResponse>() {
+            @Override
+            public void execute(BranchRollbackRequest request, BranchRollbackResponse response) throws TransactionException {
+                doBranchRollback(request, response);
+            }
+        }, request, response);
+        return response;
+    }
+
+    /**
+     * Do branch commit.
+     *
+     * @param request  the request
+     * @param response the response
+     * @throws TransactionException the transaction exception
+     */
+    protected void doBranchCommit(BranchCommitRequest request, BranchCommitResponse response) throws TransactionException {
+        String xid = request.getXid();
+        long branchId = request.getBranchId();
+        String resourceId = request.getResourceId();
+        String applicationData = request.getApplicationData();
+        LOGGER.info("Branch committing: " + xid + " " + branchId + " " + resourceId + " " + applicationData);
+        BranchStatus status = getResourceManager().branchCommit(request.getBranchType(), xid, branchId, resourceId, applicationData);
+        response.setBranchStatus(status);
+        LOGGER.info("Branch commit result: " + status);
+
+    }
+
+    /**
+     * Do branch rollback.
+     *
+     * @param request  the request
+     * @param response the response
+     * @throws TransactionException the transaction exception
+     */
+    protected void doBranchRollback(BranchRollbackRequest request, BranchRollbackResponse response) throws TransactionException {
+        String xid = request.getXid();
+        long branchId = request.getBranchId();
+        String resourceId = request.getResourceId();
+        String applicationData = request.getApplicationData();
+        LOGGER.info("Branch rolling back: " + xid + " " + branchId + " " + resourceId);
+        BranchStatus status = getResourceManager().branchRollback(request.getBranchType(), xid, branchId, resourceId, applicationData);
+        response.setBranchStatus(status);
+        LOGGER.info("Branch rollback result: " + status);
+    }
+
+    /**
+     * get resource manager implement
+     * @return
+     */
+    protected abstract ResourceManager getResourceManager() ;
+
+    @Override
+    public AbstractResultMessage onRequest(AbstractMessage request, RpcContext context) {
+        if (!(request instanceof AbstractTransactionRequestToRM)) {
+            throw new IllegalArgumentException();
+        }
+        AbstractTransactionRequestToRM transactionRequest = (AbstractTransactionRequestToRM) request;
+        transactionRequest.setRMInboundMessageHandler(this);
+
+        return transactionRequest.handle(context);
+    }
+
+    @Override
+    public void onResponse(AbstractResultMessage response, RpcContext context) {
+        throw new ShouldNeverHappenException();
+    }
+
+    public abstract BranchType getBranchType();
+}
diff --git a/rm/src/main/java/com/alibaba/fescar/rm/AbstractResourceManager.java b/rm/src/main/java/com/alibaba/fescar/rm/AbstractResourceManager.java
new file mode 100644
index 000000000..2518bf45f
--- /dev/null
+++ b/rm/src/main/java/com/alibaba/fescar/rm/AbstractResourceManager.java
@@ -0,0 +1,122 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm;
+
+import com.alibaba.fescar.common.XID;
+import com.alibaba.fescar.common.exception.NotSupportYetException;
+import com.alibaba.fescar.core.exception.TransactionException;
+import com.alibaba.fescar.core.exception.TransactionExceptionCode;
+import com.alibaba.fescar.core.model.BranchStatus;
+import com.alibaba.fescar.core.model.BranchType;
+import com.alibaba.fescar.core.model.Resource;
+import com.alibaba.fescar.core.model.ResourceManager;
+import com.alibaba.fescar.core.protocol.ResultCode;
+import com.alibaba.fescar.core.protocol.transaction.BranchRegisterRequest;
+import com.alibaba.fescar.core.protocol.transaction.BranchRegisterResponse;
+import com.alibaba.fescar.core.protocol.transaction.BranchReportRequest;
+import com.alibaba.fescar.core.protocol.transaction.BranchReportResponse;
+import com.alibaba.fescar.core.rpc.netty.RmRpcClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.TimeoutException;
+
+/**
+ * abstract ResourceManager
+ *
+ * @author zhangsen
+ */
+public abstract class AbstractResourceManager implements ResourceManager {
+
+    protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractResourceManager.class);
+
+    /**
+     * registry branch record
+     * @param branchType the branch type
+     * @param resourceId the resource id
+     * @param clientId   the client id
+     * @param xid        the xid
+     * @param lockKeys   the lock keys
+     * @return
+     * @throws TransactionException
+     */
+    @Override
+    public Long branchRegister(BranchType branchType, String resourceId, String clientId, String xid, String applicationData, String lockKeys) throws TransactionException {
+        try {
+            BranchRegisterRequest request = new BranchRegisterRequest();
+            request.setTransactionId(XID.getTransactionId(xid));
+            request.setLockKey(lockKeys);
+            request.setResourceId(resourceId);
+            request.setBranchType(branchType);
+            request.setApplicationData(applicationData);
+
+            BranchRegisterResponse response = (BranchRegisterResponse) RmRpcClient.getInstance().sendMsgWithResponse(request);
+            if (response.getResultCode() == ResultCode.Failed) {
+                throw new TransactionException(response.getTransactionExceptionCode(), "Response[" + response.getMsg() + "]");
+            }
+            return response.getBranchId();
+        } catch (TimeoutException toe) {
+            throw new TransactionException(TransactionExceptionCode.IO, "RPC Timeout", toe);
+        } catch (RuntimeException rex) {
+            throw new TransactionException(TransactionExceptionCode.BranchRegisterFailed, "Runtime", rex);
+        }
+    }
+
+    /**
+     * report branch status
+     * @param branchType      the branch type
+     * @param xid             the xid
+     * @param branchId        the branch id
+     * @param status          the status
+     * @param applicationData the application data
+     * @throws TransactionException
+     */
+    @Override
+    public void branchReport(BranchType branchType, String xid, long branchId, BranchStatus status, String applicationData) throws TransactionException {
+        try {
+            BranchReportRequest request = new BranchReportRequest();
+            request.setTransactionId(XID.getTransactionId(xid));
+            request.setBranchId(branchId);
+            request.setStatus(status);
+            request.setApplicationData(applicationData);
+
+            BranchReportResponse response = (BranchReportResponse) RmRpcClient.getInstance().sendMsgWithResponse(request);
+            if (response.getResultCode() == ResultCode.Failed) {
+                throw new TransactionException(response.getTransactionExceptionCode(), "Response[" + response.getMsg() + "]");
+            }
+        } catch (TimeoutException toe) {
+            throw new TransactionException(TransactionExceptionCode.IO, "RPC Timeout", toe);
+        } catch (RuntimeException rex) {
+            throw new TransactionException(TransactionExceptionCode.BranchReportFailed, "Runtime", rex);
+        }
+    }
+
+    @Override
+    public boolean lockQuery(BranchType branchType, String resourceId, String xid, String lockKeys) throws TransactionException {
+        return false;
+    }
+
+    @Override
+    public void unregisterResource(Resource resource) {
+        throw new NotSupportYetException("unregister a resource");
+    }
+
+    @Override
+    public void registerResource(Resource resource) {
+        RmRpcClient.getInstance().registerResource(resource.getResourceGroupId(), resource.getResourceId());
+    }
+}
diff --git a/rm/src/main/java/com/alibaba/fescar/rm/DefaultRMHandler.java b/rm/src/main/java/com/alibaba/fescar/rm/DefaultRMHandler.java
new file mode 100644
index 000000000..62db7cd5f
--- /dev/null
+++ b/rm/src/main/java/com/alibaba/fescar/rm/DefaultRMHandler.java
@@ -0,0 +1,91 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm;
+
+import com.alibaba.fescar.common.exception.FrameworkException;
+import com.alibaba.fescar.common.loader.EnhancedServiceLoader;
+import com.alibaba.fescar.common.util.CollectionUtils;
+import com.alibaba.fescar.core.model.BranchType;
+import com.alibaba.fescar.core.model.ResourceManager;
+import com.alibaba.fescar.core.protocol.transaction.BranchCommitRequest;
+import com.alibaba.fescar.core.protocol.transaction.BranchCommitResponse;
+import com.alibaba.fescar.core.protocol.transaction.BranchRollbackRequest;
+import com.alibaba.fescar.core.protocol.transaction.BranchRollbackResponse;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * the default RM event handler implement, deal with the phase two events
+ *
+ * @author zhangsen
+ */
+public class DefaultRMHandler extends AbstractRMHandler {
+
+    protected static Map<BranchType, AbstractRMHandler> allRMHandlersMap = new ConcurrentHashMap<BranchType, AbstractRMHandler>();
+
+    protected DefaultRMHandler(){
+        initRMHandlers();
+    }
+
+    protected void initRMHandlers(){
+        List<AbstractRMHandler> allRMHandlers = EnhancedServiceLoader.loadAll(AbstractRMHandler.class);
+        if(CollectionUtils.isNotEmpty(allRMHandlers)){
+            for(AbstractRMHandler rmHandler : allRMHandlers){
+                allRMHandlersMap.put(rmHandler.getBranchType(), rmHandler);
+            }
+        }
+    }
+
+    @Override
+    public BranchCommitResponse handle(BranchCommitRequest request) {
+        return getRMHandler(request.getBranchType()).handle(request);
+    }
+
+    @Override
+    public BranchRollbackResponse handle(BranchRollbackRequest request) {
+        return getRMHandler(request.getBranchType()).handle(request);
+    }
+
+    protected AbstractRMHandler getRMHandler(BranchType branchType){
+        return allRMHandlersMap.get(branchType);
+    }
+
+    @Override
+    protected ResourceManager getResourceManager() {
+        throw new FrameworkException("DefaultRMHandler isn't a real AbstractRMHandler");
+    }
+
+    private static class SingletonHolder {
+        private static AbstractRMHandler INSTANCE = new DefaultRMHandler();
+    }
+
+    /**
+     * Get resource manager.
+     *
+     * @return the resource manager
+     */
+    public static AbstractRMHandler get() {
+        return DefaultRMHandler.SingletonHolder.INSTANCE;
+    }
+
+    @Override
+    public BranchType getBranchType() {
+        throw new FrameworkException("DefaultRMHandler isn't a real AbstractRMHandler");
+    }
+}
diff --git a/rm/src/main/java/com/alibaba/fescar/rm/DefaultResourceManager.java b/rm/src/main/java/com/alibaba/fescar/rm/DefaultResourceManager.java
new file mode 100644
index 000000000..7325f6254
--- /dev/null
+++ b/rm/src/main/java/com/alibaba/fescar/rm/DefaultResourceManager.java
@@ -0,0 +1,145 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm;
+
+import com.alibaba.fescar.common.exception.FrameworkException;
+import com.alibaba.fescar.common.exception.ShouldNeverHappenException;
+import com.alibaba.fescar.common.loader.EnhancedServiceLoader;
+import com.alibaba.fescar.common.util.CollectionUtils;
+import com.alibaba.fescar.core.exception.TransactionException;
+import com.alibaba.fescar.core.model.BranchStatus;
+import com.alibaba.fescar.core.model.BranchType;
+import com.alibaba.fescar.core.model.Resource;
+import com.alibaba.fescar.core.model.ResourceManager;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * default resource manager, adapt all resource managers
+ * @author zhangsen
+ */
+public class DefaultResourceManager implements ResourceManager {
+
+	/**
+	 * all resource managers
+	 */
+	protected static Map<BranchType, ResourceManager> resourceManagers = new ConcurrentHashMap<BranchType, ResourceManager>();
+	
+	private static class SingletonHolder {
+        private static DefaultResourceManager INSTANCE = new DefaultResourceManager();
+    }
+
+    /**
+     * Get resource manager.
+     *
+     * @return the resource manager
+     */
+    public static DefaultResourceManager get() {
+        return SingletonHolder.INSTANCE;
+    }
+
+    private DefaultResourceManager() {
+		initResourceManagers();
+    }
+
+    protected void initResourceManagers(){
+		//init all resource managers
+		List<ResourceManager> allResourceManagers = EnhancedServiceLoader.loadAll(ResourceManager.class);
+		if(CollectionUtils.isNotEmpty(allResourceManagers)){
+			for(ResourceManager rm : allResourceManagers){
+				resourceManagers.put(rm.getBranchType(), rm);
+			}
+		}
+	}
+	
+	@Override
+	public BranchStatus branchCommit(BranchType branchType, String xid, long branchId,
+			String resourceId, String applicationData)
+			throws TransactionException {
+		return getResourceManager(branchType).branchCommit(branchType, xid, branchId, resourceId, applicationData);
+	}
+
+	@Override
+	public BranchStatus branchRollback(BranchType branchType, String xid, long branchId,
+			String resourceId, String applicationData)
+			throws TransactionException {
+		return getResourceManager(branchType).branchRollback(branchType, xid, branchId, resourceId, applicationData);
+	}
+
+	@Override
+	public Long branchRegister(BranchType branchType, String resourceId,
+			String clientId, String xid, String applicationData, String lockKeys)
+			throws TransactionException {
+		return getResourceManager(branchType).branchRegister(branchType, resourceId, clientId, xid, applicationData, lockKeys);
+	}
+
+	@Override
+	public void branchReport(BranchType branchType, String xid, long branchId, BranchStatus status,
+			String applicationData) throws TransactionException {
+		getResourceManager(branchType).branchReport(branchType, xid, branchId, status, applicationData);
+	}
+
+	@Override
+	public boolean lockQuery(BranchType branchType, String resourceId,
+			String xid, String lockKeys) throws TransactionException {
+		return getResourceManager(branchType).lockQuery(branchType, resourceId, xid, lockKeys);
+	}
+
+	@Override
+	public void registerResource(Resource resource) {
+		getResourceManager(resource.getBranchType()).registerResource(resource);
+	}
+
+	@Override
+	public void unregisterResource(Resource resource) {
+		getResourceManager(resource.getBranchType()).unregisterResource(resource);
+	}
+
+	@Override
+	public Map<String, Resource> getManagedResources() {
+		Map<String, Resource> allResource = new HashMap<String, Resource>();
+		for(ResourceManager rm : resourceManagers.values()){
+			Map<String, Resource> tempResources = rm.getManagedResources();
+			if(tempResources != null){
+				allResource.putAll(tempResources);
+			}
+		}
+    	return allResource;
+	}
+
+	/**
+	 * get ResourceManager by Resource Type
+	 * @param branchType
+	 * @return
+	 */
+	public ResourceManager getResourceManager(BranchType branchType){
+		ResourceManager rm = resourceManagers.get(branchType);
+		if(rm == null){
+			throw new FrameworkException("No ResourceManager for BranchType:" + branchType.name());
+		}
+		return rm;
+	}
+
+	@Override
+	public BranchType getBranchType(){
+		throw new FrameworkException("DefaultResourceManager isn't a real ResourceManager");
+	}
+
+}
diff --git a/rm/src/main/java/com/alibaba/fescar/rm/RMClient.java b/rm/src/main/java/com/alibaba/fescar/rm/RMClient.java
new file mode 100644
index 000000000..6f6c69595
--- /dev/null
+++ b/rm/src/main/java/com/alibaba/fescar/rm/RMClient.java
@@ -0,0 +1,41 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm;
+
+import com.alibaba.fescar.core.rpc.netty.RmMessageListener;
+import com.alibaba.fescar.core.rpc.netty.RmRpcClient;
+
+/**
+ * The Rm client Initiator.
+ *
+ */
+public class RMClient {
+
+    /**
+     * Init.
+     *
+     * @param applicationId           the application id
+     * @param transactionServiceGroup the transaction service group
+     */
+    public static void init(String applicationId, String transactionServiceGroup) {
+        RmRpcClient rmRpcClient = RmRpcClient.getInstance(applicationId, transactionServiceGroup);
+        rmRpcClient.setResourceManager(DefaultResourceManager.get());
+        rmRpcClient.setClientMessageListener(new RmMessageListener(DefaultRMHandler.get()));
+        rmRpcClient.init();
+    }
+
+}
diff --git a/server/src/main/java/com/alibaba/fescar/server/coordinator/DefaultCoordinator.java b/server/src/main/java/com/alibaba/fescar/server/coordinator/DefaultCoordinator.java
index aa869adf1..b3692a3f9 100644
--- a/server/src/main/java/com/alibaba/fescar/server/coordinator/DefaultCoordinator.java
+++ b/server/src/main/java/com/alibaba/fescar/server/coordinator/DefaultCoordinator.java
@@ -16,16 +16,11 @@
 
 package com.alibaba.fescar.server.coordinator;
 
-import java.io.IOException;
-import java.util.Collection;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
 import com.alibaba.fescar.common.XID;
 import com.alibaba.fescar.common.thread.NamedThreadFactory;
 import com.alibaba.fescar.core.exception.TransactionException;
 import com.alibaba.fescar.core.model.BranchStatus;
+import com.alibaba.fescar.core.model.BranchType;
 import com.alibaba.fescar.core.model.GlobalStatus;
 import com.alibaba.fescar.core.model.ResourceManagerInbound;
 import com.alibaba.fescar.core.protocol.AbstractMessage;
@@ -57,10 +52,15 @@ import com.alibaba.fescar.server.AbstractTCInboundHandler;
 import com.alibaba.fescar.server.session.BranchSession;
 import com.alibaba.fescar.server.session.GlobalSession;
 import com.alibaba.fescar.server.session.SessionHolder;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.IOException;
+import java.util.Collection;
+import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
 import static com.alibaba.fescar.core.exception.TransactionExceptionCode.FailedToSendBranchCommitRequest;
 import static com.alibaba.fescar.core.exception.TransactionExceptionCode.FailedToSendBranchRollbackRequest;
 
@@ -119,14 +119,14 @@ public class DefaultCoordinator extends AbstractTCInboundHandler
         response.setTransactionId(request.getTransactionId());
         response.setBranchId(
             core.branchRegister(request.getBranchType(), request.getResourceId(), rpcContext.getClientId(),
-                XID.generateXID(request.getTransactionId()), request.getLockKey()));
+                XID.generateXID(request.getTransactionId()), request.getApplicationData(), request.getLockKey()));
 
     }
 
     @Override
     protected void doBranchReport(BranchReportRequest request, BranchReportResponse response, RpcContext rpcContext)
         throws TransactionException {
-        core.branchReport(XID.generateXID(request.getTransactionId()), request.getBranchId(), request.getStatus(),
+        core.branchReport(request.getBranchType(), XID.generateXID(request.getTransactionId()), request.getBranchId(), request.getStatus(),
             request.getApplicationData());
 
     }
@@ -139,15 +139,15 @@ public class DefaultCoordinator extends AbstractTCInboundHandler
     }
 
     @Override
-    public BranchStatus branchCommit(String xid, long branchId, String resourceId, String applicationData)
+    public BranchStatus branchCommit(BranchType branchType, String xid, long branchId, String resourceId, String applicationData)
         throws TransactionException {
         try {
-            BranchCommitRequest
-                request = new BranchCommitRequest();
+            BranchCommitRequest request = new BranchCommitRequest();
             request.setXid(xid);
             request.setBranchId(branchId);
             request.setResourceId(resourceId);
             request.setApplicationData(applicationData);
+            request.setBranchType(branchType);
 
             GlobalSession globalSession = SessionHolder.findGlobalSession(XID.getTransactionId(xid));
             BranchSession branchSession = globalSession.getBranch(branchId);
@@ -163,7 +163,7 @@ public class DefaultCoordinator extends AbstractTCInboundHandler
     }
 
     @Override
-    public BranchStatus branchRollback(String xid, long branchId, String resourceId, String applicationData)
+    public BranchStatus branchRollback(BranchType branchType, String xid, long branchId, String resourceId, String applicationData)
         throws TransactionException {
         try {
             BranchRollbackRequest
@@ -172,6 +172,7 @@ public class DefaultCoordinator extends AbstractTCInboundHandler
             request.setBranchId(branchId);
             request.setResourceId(resourceId);
             request.setApplicationData(applicationData);
+            request.setBranchType(branchType);
 
             GlobalSession globalSession = SessionHolder.findGlobalSession(XID.getTransactionId(xid));
             BranchSession branchSession = globalSession.getBranch(branchId);
diff --git a/server/src/main/java/com/alibaba/fescar/server/coordinator/DefaultCore.java b/server/src/main/java/com/alibaba/fescar/server/coordinator/DefaultCore.java
index d59b14e24..454bdde1e 100644
--- a/server/src/main/java/com/alibaba/fescar/server/coordinator/DefaultCore.java
+++ b/server/src/main/java/com/alibaba/fescar/server/coordinator/DefaultCore.java
@@ -56,12 +56,10 @@ public class DefaultCore implements Core {
     }
 
     @Override
-    public Long branchRegister(BranchType branchType, String resourceId, String clientId, String xid, String lockKeys)
-        throws TransactionException {
+    public Long branchRegister(BranchType branchType, String resourceId, String clientId, String xid, String applicationData, String lockKeys) throws TransactionException {
         GlobalSession globalSession = assertGlobalSession(XID.getTransactionId(xid), GlobalStatus.Begin);
 
-        BranchSession branchSession = SessionHelper.newBranchByGlobal(globalSession, branchType, resourceId, lockKeys,
-            clientId);
+        BranchSession branchSession = SessionHelper.newBranchByGlobal(globalSession, branchType, resourceId, applicationData, lockKeys, clientId);
 
         if (!branchSession.lock()) {
             throw new TransactionException(LockKeyConflict);
@@ -91,12 +89,10 @@ public class DefaultCore implements Core {
     }
 
     @Override
-    public void branchReport(String xid, long branchId, BranchStatus status, String applicationData)
-        throws TransactionException {
+    public void branchReport(BranchType branchType, String xid, long branchId, BranchStatus status, String applicationData) throws TransactionException {
         GlobalSession globalSession = SessionHolder.findGlobalSession(XID.getTransactionId(xid));
         if (globalSession == null) {
-            throw new TransactionException(TransactionExceptionCode.GlobalTransactionNotExist,
-                "" + XID.getTransactionId(xid) + "");
+            throw new TransactionException(TransactionExceptionCode.GlobalTransactionNotExist, "" + XID.getTransactionId(xid) + "");
         }
         BranchSession branchSession = globalSession.getBranch(branchId);
         if (branchSession == null) {
@@ -106,8 +102,7 @@ public class DefaultCore implements Core {
     }
 
     @Override
-    public boolean lockQuery(BranchType branchType, String resourceId, String xid, String lockKeys)
-        throws TransactionException {
+    public boolean lockQuery(BranchType branchType, String resourceId, String xid, String lockKeys) throws TransactionException {
         if (branchType == BranchType.AT) {
             return lockManager.isLockable(XID.getTransactionId(xid), resourceId, lockKeys);
         } else {
@@ -117,8 +112,7 @@ public class DefaultCore implements Core {
     }
 
     @Override
-    public String begin(String applicationId, String transactionServiceGroup, String name, int timeout)
-        throws TransactionException {
+    public String begin(String applicationId, String transactionServiceGroup, String name, int timeout) throws TransactionException {
         GlobalSession session = GlobalSession.createGlobalSession(
             applicationId, transactionServiceGroup, name, timeout);
         session.addSessionLifecycleListener(SessionHolder.getRootSessionManager());
@@ -158,8 +152,7 @@ public class DefaultCore implements Core {
                 continue;
             }
             try {
-                BranchStatus branchStatus = resourceManagerInbound.branchCommit(
-                    XID.generateXID(branchSession.getTransactionId()), branchSession.getBranchId(),
+                BranchStatus branchStatus = resourceManagerInbound.branchCommit(branchSession.getBranchType(), XID.generateXID(branchSession.getTransactionId()), branchSession.getBranchId(),
                     branchSession.getResourceId(), branchSession.getApplicationData());
 
                 switch (branchStatus) {
@@ -264,8 +257,7 @@ public class DefaultCore implements Core {
                 continue;
             }
             try {
-                BranchStatus branchStatus = resourceManagerInbound.branchRollback(
-                    XID.generateXID(branchSession.getTransactionId()), branchSession.getBranchId(),
+                BranchStatus branchStatus = resourceManagerInbound.branchRollback(branchSession.getBranchType(), XID.generateXID(branchSession.getTransactionId()), branchSession.getBranchId(),
                     branchSession.getResourceId(), branchSession.getApplicationData());
 
                 switch (branchStatus) {
diff --git a/server/src/main/java/com/alibaba/fescar/server/session/GlobalSession.java b/server/src/main/java/com/alibaba/fescar/server/session/GlobalSession.java
index 061541164..5d73c9b2f 100644
--- a/server/src/main/java/com/alibaba/fescar/server/session/GlobalSession.java
+++ b/server/src/main/java/com/alibaba/fescar/server/session/GlobalSession.java
@@ -79,7 +79,8 @@ public class GlobalSession implements SessionLifecycle, SessionStorable {
      */
     public boolean canBeCommittedAsync() {
         for (BranchSession branchSession : branchSessions) {
-            if (branchSession.getBranchType() == BranchType.MT) {
+            if (branchSession.getBranchType() == BranchType.MT
+                    || branchSession.getBranchType() == BranchType.TCC) {
                 return false;
             }
         }
diff --git a/server/src/main/java/com/alibaba/fescar/server/session/SessionHelper.java b/server/src/main/java/com/alibaba/fescar/server/session/SessionHelper.java
index 64177062e..1d0cfbab1 100644
--- a/server/src/main/java/com/alibaba/fescar/server/session/SessionHelper.java
+++ b/server/src/main/java/com/alibaba/fescar/server/session/SessionHelper.java
@@ -28,6 +28,10 @@ public class SessionHelper {
 
     private SessionHelper() {}
 
+    public static BranchSession newBranchByGlobal(GlobalSession globalSession, BranchType branchType, String resourceId, String lockKeys, String clientId) {
+        return newBranchByGlobal(globalSession, branchType, resourceId, null, lockKeys, clientId);
+    }
+
     /**
      * New branch by global branch session.
      *
@@ -39,7 +43,7 @@ public class SessionHelper {
      * @return the branch session
      */
     public static BranchSession newBranchByGlobal(GlobalSession globalSession, BranchType branchType, String resourceId,
-                                                  String lockKeys, String clientId) {
+            String applicationData, String lockKeys, String clientId) {
         BranchSession branchSession = new BranchSession();
 
         branchSession.setTransactionId(globalSession.getTransactionId());
@@ -48,6 +52,7 @@ public class SessionHelper {
         branchSession.setResourceId(resourceId);
         branchSession.setLockKey(lockKeys);
         branchSession.setClientId(clientId);
+        branchSession.setApplicationData(applicationData);
 
         return branchSession;
     }
diff --git a/server/src/main/java/com/alibaba/fescar/server/store/FileTransactionStoreManager.java b/server/src/main/java/com/alibaba/fescar/server/store/FileTransactionStoreManager.java
index ad54ee67c..9a55ba55a 100644
--- a/server/src/main/java/com/alibaba/fescar/server/store/FileTransactionStoreManager.java
+++ b/server/src/main/java/com/alibaba/fescar/server/store/FileTransactionStoreManager.java
@@ -98,6 +98,10 @@ public class FileTransactionStoreManager implements TransactionStoreManager {
         try {
             currDataFile = new File(currFullFileName);
             if (!currDataFile.exists()) {
+                //create parent dir first
+                if (currDataFile.getParentFile() != null && !currDataFile.getParentFile().exists()) {
+                    currDataFile.getParentFile().mkdirs();
+                }
                 currDataFile.createNewFile();
                 trxStartTimeMills = System.currentTimeMillis();
             } else {
diff --git a/spring/pom.xml b/spring/pom.xml
index fb6496e26..de91707a2 100644
--- a/spring/pom.xml
+++ b/spring/pom.xml
@@ -36,6 +36,15 @@
             <groupId>${project.groupId}</groupId>
             <artifactId>fescar-rm-datasource</artifactId>
         </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>fescar-tcc</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>fescar-rm</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring</artifactId>
diff --git a/spring/src/main/java/com/alibaba/fescar/spring/annotation/GlobalTransactionScanner.java b/spring/src/main/java/com/alibaba/fescar/spring/annotation/GlobalTransactionScanner.java
index 205a06ce2..79a82efa9 100644
--- a/spring/src/main/java/com/alibaba/fescar/spring/annotation/GlobalTransactionScanner.java
+++ b/spring/src/main/java/com/alibaba/fescar/spring/annotation/GlobalTransactionScanner.java
@@ -16,19 +16,19 @@
 
 package com.alibaba.fescar.spring.annotation;
 
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.HashSet;
-import java.util.Set;
-
-import com.alibaba.fescar.common.exception.NotSupportYetException;
 import com.alibaba.fescar.common.util.StringUtils;
 import com.alibaba.fescar.config.ConfigurationFactory;
-import com.alibaba.fescar.rm.RMClientAT;
+import com.alibaba.fescar.rm.RMClient;
+import com.alibaba.fescar.spring.tcc.TccActionInterceptor;
+import com.alibaba.fescar.spring.util.SpringProxyUtils;
+import com.alibaba.fescar.spring.util.TCCBeanParserUtils;
 import com.alibaba.fescar.tm.TMClient;
 import com.alibaba.fescar.tm.api.DefaultFailureHandlerImpl;
 import com.alibaba.fescar.tm.api.FailureHandler;
-
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Set;
+import org.aopalliance.intercept.MethodInterceptor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.aop.Advisor;
@@ -38,6 +38,8 @@ import org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator;
 import org.springframework.aop.support.AopUtils;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
 
 /**
  * The type Global transaction scanner.
@@ -45,7 +47,7 @@ import org.springframework.beans.factory.InitializingBean;
  * @author jimin.jm @alibaba-inc.com
  * @date 2018 /12/28
  */
-public class GlobalTransactionScanner extends AbstractAutoProxyCreator implements InitializingBean {
+public class GlobalTransactionScanner extends AbstractAutoProxyCreator implements InitializingBean,ApplicationContextAware {
 
     /**
      *
@@ -58,12 +60,12 @@ public class GlobalTransactionScanner extends AbstractAutoProxyCreator implement
     private static final int MT_MODE = 2;
 
     private static final int ORDER_NUM = 1024;
-    private static final int DEFAULT_MODE = AT_MODE;
+    private static final int DEFAULT_MODE = AT_MODE + MT_MODE;
 
     private static final Set<String> PROXYED_SET = new HashSet<>();
     private static final FailureHandler DEFAULT_FAIL_HANDLER = new DefaultFailureHandlerImpl();
 
-    private GlobalTransactionalInterceptor interceptor;
+    private MethodInterceptor interceptor;
 
     private final String applicationId;
     private final String txServiceGroup;
@@ -73,6 +75,8 @@ public class GlobalTransactionScanner extends AbstractAutoProxyCreator implement
 
     private final FailureHandler failureHandlerHook;
 
+    private ApplicationContext applicationContext;
+
     /**
      * Instantiates a new Global transaction scanner.
      *
@@ -86,7 +90,7 @@ public class GlobalTransactionScanner extends AbstractAutoProxyCreator implement
      * Instantiates a new Global transaction scanner.
      *
      * @param txServiceGroup the tx service group
-     * @param mode           the mode
+     * @param mode the mode
      */
     public GlobalTransactionScanner(String txServiceGroup, int mode) {
         this(txServiceGroup, txServiceGroup, mode);
@@ -95,7 +99,7 @@ public class GlobalTransactionScanner extends AbstractAutoProxyCreator implement
     /**
      * Instantiates a new Global transaction scanner.
      *
-     * @param applicationId  the application id
+     * @param applicationId the application id
      * @param txServiceGroup the default server group
      */
     public GlobalTransactionScanner(String applicationId, String txServiceGroup) {
@@ -105,9 +109,9 @@ public class GlobalTransactionScanner extends AbstractAutoProxyCreator implement
     /**
      * Instantiates a new Global transaction scanner.
      *
-     * @param applicationId  the application id
+     * @param applicationId the application id
      * @param txServiceGroup the tx service group
-     * @param mode           the mode
+     * @param mode the mode
      */
     public GlobalTransactionScanner(String applicationId, String txServiceGroup, int mode) {
         this(applicationId, txServiceGroup, mode, DEFAULT_FAIL_HANDLER);
@@ -116,8 +120,8 @@ public class GlobalTransactionScanner extends AbstractAutoProxyCreator implement
     /**
      * Instantiates a new Global transaction scanner.
      *
-     * @param applicationId      the application id
-     * @param txServiceGroup     the tx service group
+     * @param applicationId the application id
+     * @param txServiceGroup the tx service group
      * @param failureHandlerHook the failure handler hook
      */
     public GlobalTransactionScanner(String applicationId, String txServiceGroup, FailureHandler failureHandlerHook) {
@@ -127,9 +131,9 @@ public class GlobalTransactionScanner extends AbstractAutoProxyCreator implement
     /**
      * Instantiates a new Global transaction scanner.
      *
-     * @param applicationId      the application id
-     * @param txServiceGroup     the tx service group
-     * @param mode               the mode
+     * @param applicationId the application id
+     * @param txServiceGroup the tx service group
+     * @param mode the mode
      * @param failureHandlerHook the failure handler hook
      */
     public GlobalTransactionScanner(String applicationId, String txServiceGroup, int mode,
@@ -150,24 +154,19 @@ public class GlobalTransactionScanner extends AbstractAutoProxyCreator implement
             throw new IllegalArgumentException(
                 "applicationId: " + applicationId + ", txServiceGroup: " + txServiceGroup);
         }
+        //init TM
         TMClient.init(applicationId, txServiceGroup);
         if (LOGGER.isInfoEnabled()) {
             LOGGER.info(
                 "Transaction Manager Client is initialized. applicationId[" + applicationId + "] txServiceGroup["
                     + txServiceGroup + "]");
         }
-        if ((AT_MODE & mode) > 0) {
-            RMClientAT.init(applicationId, txServiceGroup);
-            if (LOGGER.isInfoEnabled()) {
-                LOGGER.info(
-                    "Resource Manager for AT Client is initialized. applicationId[" + applicationId
-                        + "] txServiceGroup["
-                        + txServiceGroup + "]");
-            }
-        }
-        if ((MT_MODE & mode) > 0) {
-            throw new NotSupportYetException();
+        //init RM
+        RMClient.init(applicationId, txServiceGroup);
+        if (LOGGER.isInfoEnabled()) {
+            LOGGER.info("Resource Manager is initialized. applicationId[" + applicationId  + "] txServiceGroup["  + txServiceGroup + "]");
         }
+
         if (LOGGER.isInfoEnabled()) {
             LOGGER.info("Global Transaction Clients are initialized. ");
         }
@@ -183,34 +182,43 @@ public class GlobalTransactionScanner extends AbstractAutoProxyCreator implement
                 if (PROXYED_SET.contains(beanName)) {
                     return bean;
                 }
-                Class<?> serviceInterface = findTargetClass(bean);
-                Method[] methods = serviceInterface.getMethods();
-                boolean shouldSkip = true;
-                for (Method method : methods) {
-                    GlobalTransactional trxAnno = method.getAnnotation(GlobalTransactional.class);
-                    if (trxAnno != null) {
-                        shouldSkip = false;
-                        break;
+                interceptor = null;
+                //check TCC proxy
+                if(TCCBeanParserUtils.isTccAutoProxy(bean, beanName, applicationContext)){
+                    //TCC interceptor， proxy bean of sofa:reference/dubbo:reference, and LocalTCC
+                    interceptor = new TccActionInterceptor(TCCBeanParserUtils.getRemotingDesc(beanName));
+                }else {
+                    Class<?> serviceInterface = SpringProxyUtils.findTargetClass(bean);
+                    Method[] methods = serviceInterface.getMethods();
+                    boolean shouldSkip = true;
+                    for (Method method : methods) {
+                        GlobalTransactional trxAnno = method.getAnnotation(GlobalTransactional.class);
+                        if (trxAnno != null) {
+                            shouldSkip = false;
+                            break;
+                        }
+
+                        GlobalLock lockAnno = method.getAnnotation(GlobalLock.class);
+                        if (lockAnno != null) {
+                            shouldSkip = false;
+                            break;
+                        }
                     }
 
-                    GlobalLock lockAnno = method.getAnnotation(GlobalLock.class);
-                    if (lockAnno != null) {
-                        shouldSkip = false;
-                        break;
+                    if (shouldSkip) {
+                        return bean;
                     }
-                }
 
-                if (shouldSkip) {
-                    return bean;
+                    if (interceptor == null) {
+                        interceptor = new GlobalTransactionalInterceptor(failureHandlerHook);
+                    }
                 }
 
-                if (interceptor == null) {
-                    interceptor = new GlobalTransactionalInterceptor(failureHandlerHook);
-                }
+                LOGGER.info("Bean["+ bean.getClass().getName() +"] with name ["+beanName+"] would use interceptor [" + interceptor.getClass().getName()  + "]");
                 if (!AopUtils.isAopProxy(bean)) {
                     bean = super.wrapIfNecessary(bean, beanName, cacheKey);
                 } else {
-                    AdvisedSupport advised = getAdvisedSupport(bean);
+                    AdvisedSupport advised = SpringProxyUtils.getAdvisedSupport(bean);
                     Advisor[] advisor = buildAdvisors(beanName, getAdvicesAndAdvisorsForBean(null, null, null));
                     for (Advisor avr : advisor) {
                         advised.addAdvisor(0, avr);
@@ -228,29 +236,6 @@ public class GlobalTransactionScanner extends AbstractAutoProxyCreator implement
         return new MethodDesc(anno, method);
     }
 
-    private Class<?> findTargetClass(Object proxy) throws Exception {
-        if (AopUtils.isAopProxy(proxy)) {
-            AdvisedSupport advised = getAdvisedSupport(proxy);
-            Object target = advised.getTargetSource().getTarget();
-            return findTargetClass(target);
-        } else {
-            return proxy.getClass();
-        }
-    }
-
-    private AdvisedSupport getAdvisedSupport(Object proxy) throws Exception {
-        Field h;
-        if (AopUtils.isJdkDynamicProxy(proxy)) {
-            h = proxy.getClass().getSuperclass().getDeclaredField("h");
-        } else {
-            h = proxy.getClass().getDeclaredField("CGLIB$CALLBACK_0");
-        }
-        h.setAccessible(true);
-        Object dynamicAdvisedInterceptor = h.get(proxy);
-        Field advised = dynamicAdvisedInterceptor.getClass().getDeclaredField("advised");
-        advised.setAccessible(true);
-        return (AdvisedSupport)advised.get(dynamicAdvisedInterceptor);
-    }
 
     @Override
     protected Object[] getAdvicesAndAdvisorsForBean(Class beanClass, String beanName, TargetSource customTargetSource)
@@ -269,4 +254,9 @@ public class GlobalTransactionScanner extends AbstractAutoProxyCreator implement
         initClient();
 
     }
+
+    @Override
+    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+        this.applicationContext = applicationContext;
+    }
 }
diff --git a/spring/src/main/java/com/alibaba/fescar/spring/tcc/TccActionInterceptor.java b/spring/src/main/java/com/alibaba/fescar/spring/tcc/TccActionInterceptor.java
new file mode 100644
index 000000000..9e1c8e2bf
--- /dev/null
+++ b/spring/src/main/java/com/alibaba/fescar/spring/tcc/TccActionInterceptor.java
@@ -0,0 +1,142 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.spring.tcc;
+
+import com.alibaba.fescar.common.Constants;
+import com.alibaba.fescar.common.executor.Callback;
+import com.alibaba.fescar.common.util.StringUtils;
+import com.alibaba.fescar.core.context.RootContext;
+import com.alibaba.fescar.rm.tcc.api.TwoPhaseBusinessAction;
+import com.alibaba.fescar.rm.tcc.interceptor.ActionInterceptorHandler;
+import com.alibaba.fescar.rm.tcc.remoting.RemotingDesc;
+import com.alibaba.fescar.rm.tcc.remoting.parser.DubboUtil;
+import com.alibaba.fescar.spring.util.SpringProxyUtils;
+import org.aopalliance.intercept.MethodInterceptor;
+import org.aopalliance.intercept.MethodInvocation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+
+/**
+ * TCC Interceptor
+ *
+ * @author zhangsen
+ */
+public class TccActionInterceptor implements MethodInterceptor {
+	
+    private static final Logger LOGGER = LoggerFactory.getLogger(TccActionInterceptor.class);
+
+	private ActionInterceptorHandler actionInterceptorHandler = new ActionInterceptorHandler();
+
+	/**
+	 * remoting bean info
+	 */
+	protected RemotingDesc remotingDesc;
+
+	/**
+	 * Instantiates a new Tcc action interceptor.
+	 */
+	public TccActionInterceptor(){
+	}
+
+	/**
+	 * Instantiates a new Tcc action interceptor.
+	 *
+	 * @param remotingDesc the remoting desc
+	 */
+	public TccActionInterceptor(RemotingDesc remotingDesc){
+		this.remotingDesc = remotingDesc;
+	}
+
+	@Override
+	public Object invoke(final MethodInvocation invocation) throws Throwable {
+		Method method = getActionInterfaceMethod(invocation);
+		TwoPhaseBusinessAction businessAction = method.getAnnotation(TwoPhaseBusinessAction.class);	
+		//try method
+	    if(businessAction != null) {
+			if(StringUtils.isBlank(RootContext.getXID())){
+				//not in distribute transaction
+				return invocation.proceed();
+			}
+	    	Object[] methodArgs = invocation.getArguments();
+	    	//Handler the TCC Aspect
+			Map<String, Object> ret = actionInterceptorHandler.proceed(method, methodArgs, businessAction, new Callback<Object>(){
+				@Override
+				public Object execute() throws Throwable {
+					return invocation.proceed();
+				}
+	    	});
+	    	//reset the parameters of try method
+	    	Object[] targetArguments = (Object[]) ret.get(Constants.TCC_METHOD_ARGUMENTS);
+	    	if(targetArguments != null && methodArgs != null){
+	    		for(int i = 0; i < targetArguments.length; i ++){
+	    			methodArgs[i] = targetArguments[i];
+	    		}
+	    	}
+	    	//return the final result
+	    	return ret.get(Constants.TCC_METHOD_RESULT);
+	    }
+		return invocation.proceed();
+	}
+
+	/**
+	 * get the method from interface
+	 *
+	 * @param invocation the invocation
+	 * @return the action interface method
+	 */
+	protected Method getActionInterfaceMethod(MethodInvocation invocation) {
+		try {
+			Class<?> interfaceType  = null;
+			if(remotingDesc == null){
+				interfaceType = getProxyInterface(invocation.getThis());
+			}else {
+				interfaceType = remotingDesc.getInterfaceClass();
+			}
+			if(interfaceType == null && remotingDesc.getInterfaceClassName() != null){
+				interfaceType = Class.forName(remotingDesc.getInterfaceClassName(), true, Thread.currentThread().getContextClassLoader());
+			}
+			if(interfaceType == null){
+				return invocation.getMethod();
+			}
+			Method method = interfaceType.getMethod(invocation.getMethod().getName(), invocation.getMethod().getParameterTypes());
+			return method;
+		} catch (Exception e) {
+			LOGGER.warn("get Method from interface failed", e);
+			return invocation.getMethod();
+		}
+    }
+
+	/**
+	 * get the interface of proxy
+	 *
+	 * @param proxyBean the proxy bean
+	 * @return proxy interface
+	 * @throws Exception the exception
+	 */
+	protected Class<?> getProxyInterface(Object proxyBean) throws Exception {
+		if(proxyBean.getClass().getName().startsWith("com.alibaba.dubbo.common.bytecode.proxy")){
+			//dubbo javaassist proxy
+			return DubboUtil.getAssistInterface(proxyBean);
+		}else {
+			//jdk/cglib proxy
+			return SpringProxyUtils.getTargetInterface(proxyBean);
+		}
+	}
+}
diff --git a/spring/src/main/java/com/alibaba/fescar/spring/util/SpringProxyUtils.java b/spring/src/main/java/com/alibaba/fescar/spring/util/SpringProxyUtils.java
new file mode 100644
index 000000000..9459a38b5
--- /dev/null
+++ b/spring/src/main/java/com/alibaba/fescar/spring/util/SpringProxyUtils.java
@@ -0,0 +1,140 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.spring.util;
+
+import org.springframework.aop.framework.AdvisedSupport;
+import org.springframework.aop.support.AopUtils;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Proxy;
+
+/**
+ * Proxy tools base on spring
+ *
+ * @author zhangsen
+ */
+public class SpringProxyUtils {
+
+    /**
+     * Find target class class.
+     *
+     * @param proxy the proxy
+     * @return the class
+     * @throws Exception the exception
+     */
+    public static Class<?> findTargetClass(Object proxy) throws Exception {
+        if (AopUtils.isAopProxy(proxy)) {
+            AdvisedSupport advised = getAdvisedSupport(proxy);
+            Object target = advised.getTargetSource().getTarget();
+            return findTargetClass(target);
+        } else {
+            return proxy.getClass();
+        }
+    }
+
+    /**
+     * Gets advised support.
+     *
+     * @param proxy the proxy
+     * @return the advised support
+     * @throws Exception the exception
+     */
+    public static AdvisedSupport getAdvisedSupport(Object proxy) throws Exception {
+        Field h;
+        if (AopUtils.isJdkDynamicProxy(proxy)) {
+            h = proxy.getClass().getSuperclass().getDeclaredField("h");
+        } else {
+            h = proxy.getClass().getDeclaredField("CGLIB$CALLBACK_0");
+        }
+        h.setAccessible(true);
+        Object dynamicAdvisedInterceptor = h.get(proxy);
+        Field advised = dynamicAdvisedInterceptor.getClass().getDeclaredField("advised");
+        advised.setAccessible(true);
+        return (AdvisedSupport)advised.get(dynamicAdvisedInterceptor);
+    }
+
+    /**
+     * Is proxy boolean.
+     *
+     * @param bean the bean
+     * @return the boolean
+     */
+    public static boolean isProxy(Object bean){
+        if(bean == null){
+            return false;
+        }
+        if (Proxy.class.isAssignableFrom(bean.getClass()) || AopUtils.isAopProxy(bean)) {
+            return true;
+        }else{
+            return false;
+        }
+    }
+
+    /**
+     * Get the target class , get the interface of its agent if it is a Proxy
+     *
+     * @param proxy the proxy
+     * @return target interface
+     * @throws Exception the exception
+     */
+    public static Class<?> getTargetInterface(Object proxy) throws Exception {
+        if(proxy == null){
+            throw new java.lang.IllegalArgumentException("proxy can not be null");
+        }
+
+        //jdk proxy
+        if (Proxy.class.isAssignableFrom(proxy.getClass())) {
+            Proxy p = (Proxy) proxy;
+            return p.getClass().getInterfaces()[0];
+        }
+
+        return getTargetClass(proxy);
+    }
+
+    /**
+     * Get the class type of the proxy target object, if hadn't a target object, return the interface of the proxy
+     *
+     * @param proxy
+     * @return
+     * @throws Exception
+     */
+    protected static Class getTargetClass(Object proxy) throws Exception {
+        if(proxy == null){
+            throw new java.lang.IllegalArgumentException("proxy can not be null");
+        }
+        //not proxy
+        if(!AopUtils.isAopProxy(proxy)) {
+            return proxy.getClass();
+        }
+        AdvisedSupport advisedSupport = getAdvisedSupport(proxy);
+        Object target = advisedSupport.getTargetSource().getTarget();
+        /**
+         * the Proxy of sofa:reference has no target
+         */
+        if (target == null ) {
+            if(advisedSupport.getProxiedInterfaces() != null && advisedSupport.getProxiedInterfaces().length > 0){
+                return advisedSupport.getProxiedInterfaces()[0];
+            }else{
+                //拿不到interface，返回原对象
+                return proxy.getClass();
+            }
+        }else{
+            return getTargetClass(target);
+        }
+    }
+
+}
diff --git a/spring/src/main/java/com/alibaba/fescar/spring/util/TCCBeanParserUtils.java b/spring/src/main/java/com/alibaba/fescar/spring/util/TCCBeanParserUtils.java
new file mode 100644
index 000000000..e27626c90
--- /dev/null
+++ b/spring/src/main/java/com/alibaba/fescar/spring/util/TCCBeanParserUtils.java
@@ -0,0 +1,145 @@
+package com.alibaba.fescar.spring.util;
+
+import com.alibaba.fescar.rm.tcc.api.TwoPhaseBusinessAction;
+import com.alibaba.fescar.rm.tcc.remoting.Protocols;
+import com.alibaba.fescar.rm.tcc.remoting.RemotingDesc;
+import com.alibaba.fescar.rm.tcc.remoting.parser.DefaultRemotingParser;
+import org.springframework.context.ApplicationContext;
+
+import java.lang.reflect.Method;
+
+/**
+ * parser TCC bean
+ *
+ * @author zhangsen
+ * @data 2019 /3/18
+ */
+public class TCCBeanParserUtils {
+
+    /**
+     * is auto proxy TCC bean
+     *
+     * @param bean               the bean
+     * @param beanName           the bean name
+     * @param applicationContext the application context
+     * @return boolean boolean
+     */
+    public static boolean isTccAutoProxy(Object bean, String beanName, ApplicationContext applicationContext){
+        RemotingDesc remotingDesc = null;
+        boolean isRemotingBean = parserRemotingServiceInfo(bean, beanName);
+        //is remoting bean
+        if(isRemotingBean) {
+            remotingDesc = DefaultRemotingParser.get().getRemotingBeanDesc(beanName);
+            if(remotingDesc != null && remotingDesc.getProtocol() == Protocols.IN_JVM){
+                //LocalTCC
+                return isTccProxyTargetBean(remotingDesc);
+            }else {
+                // sofa:reference / dubbo:reference, factory bean 不代理
+                return false;
+            }
+        }else{
+            //get RemotingBean description
+            remotingDesc = DefaultRemotingParser.get().getRemotingBeanDesc(beanName);
+            if(remotingDesc == null){
+                //check FactoryBean
+                if(isRemotingFactoryBean(bean, beanName, applicationContext)){
+                    remotingDesc = DefaultRemotingParser.get().getRemotingBeanDesc(beanName);
+                    return isTccProxyTargetBean(remotingDesc);
+                }else {
+                    return false;
+                }
+            }else {
+                //判断是否需要代理
+                return isTccProxyTargetBean(remotingDesc);
+            }
+        }
+    }
+
+    /**
+     * if it is proxy bean, check if the FactoryBean is Remoting bean
+     *
+     * @param bean               the bean
+     * @param beanName           the bean name
+     * @param applicationContext the application context
+     * @return boolean boolean
+     */
+    protected static boolean isRemotingFactoryBean(Object bean, String beanName, ApplicationContext applicationContext) {
+        if(!SpringProxyUtils.isProxy(bean)){
+            return false;
+        }
+        //the FactoryBean of proxy bean
+        String factoryBeanName = new StringBuilder().append("&").append(beanName).toString();
+        Object factoryBean = null;
+        if(applicationContext != null && applicationContext.containsBean(factoryBeanName)){
+            factoryBean = applicationContext.getBean(factoryBeanName);
+        }
+        //not factory bean，needn't proxy
+        if(factoryBean == null ){
+            return false;
+        }
+        //get FactoryBean info
+        return parserRemotingServiceInfo(factoryBean, beanName);
+    }
+
+    /**
+     * is TCC proxy-bean/target-bean: LocalTCC , the proxy bean of sofa:reference/dubbo:reference
+     *
+     * @param remotingDesc the remoting desc
+     * @return boolean boolean
+     */
+    protected static boolean isTccProxyTargetBean(RemotingDesc remotingDesc){
+        if(remotingDesc == null) {
+            return false;
+        }
+        //check if it is TCC bean
+        boolean isTccClazz = false;
+        Class<?> tccInterfaceClazz = remotingDesc.getInterfaceClass();
+        Method[] methods = tccInterfaceClazz.getMethods();
+        TwoPhaseBusinessAction twoPhaseBusinessAction = null;
+        for (Method method : methods) {
+            twoPhaseBusinessAction = method.getAnnotation(TwoPhaseBusinessAction.class);
+            if(twoPhaseBusinessAction != null ){
+                isTccClazz = true;
+                break;
+            }
+        }
+        if(!isTccClazz){
+            return false;
+        }
+        short protocols = remotingDesc.getProtocol();
+        //LocalTCC
+        if(Protocols.IN_JVM == protocols){
+            //in jvm TCC bean , AOP
+            return true;
+        }
+        // sofa:reference /  dubbo:reference, AOP
+        if(remotingDesc.isReference()){
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * get remoting bean info: sofa:service、sofa:reference、dubbo:reference、dubbo:service
+     *
+     * @param bean     the bean
+     * @param beanName the bean name
+     * @return if sofa:service、sofa:reference、dubbo:reference、dubbo:service return true，else return false
+     */
+    protected static boolean parserRemotingServiceInfo(Object bean, String beanName) {
+        if(DefaultRemotingParser.get().isRemoting(bean, beanName)) {
+            return null != DefaultRemotingParser.get().parserRemotingServiceInfo(bean, beanName);
+        }
+        return false;
+    }
+
+    /**
+     * get the remoting description of TCC bean
+     *
+     * @param beanName the bean name
+     * @return remoting desc
+     */
+    public static  RemotingDesc getRemotingDesc(String beanName){
+        return DefaultRemotingParser.get().getRemotingBeanDesc(beanName);
+    }
+}
diff --git a/tcc/README.MD b/tcc/README.MD
new file mode 100644
index 000000000..20366fdd9
--- /dev/null
+++ b/tcc/README.MD
@@ -0,0 +1,69 @@
+### TCC
+
+
+#### TCC 简介
+
+在2PC（两阶段提交）协议中，事务管理器分两阶段协调资源管理，资源管理器对外提供了3个操作，分别是一阶段的准备操作，二阶段的提交操作和回滚操作；
+
+TCC服务作为一种事务资源，遵循两阶段提交协议，由业务层面自定义，需要用户根据业务逻辑编码实现；其包含Try、Confirm 和 Cancel 3个操作，其中Try操作对应分布式事务一阶段的准备，Confirm操作对应分布式事务二阶段提交，Cancel对应分布式事务二阶段回滚：
+
+- Try：
+
+资源的检查和预留；
+
+- Comfirm：
+
+使用预留的资源，完成真正的业务操作；要求Try成功Confirm 一定要能成功；
+
+- Cancel：
+
+释放预留资源；
+
+
+TCC的3个方法均由用户根据业务场景编码实现，并对外发布成微服务，供事务管理器调用；事务管理器在一阶段调用TCC的Try方法，在二阶段提交时调用Confirm方法，在二阶段回滚时调用Cancel方法。
+
+
+#### TCC实现
+
+##### 1、TCC微服务
+
+TCC服务由用户编码实现并对外发布成微服务，目前支持3种形式的TCC微服务，分别是：
+
+- SofaRpc 服务
+
+用户将实现的TCC操作对外发布成 SofaRpc 服务，事务管理器通过订阅SofaRpc服务，来协调TCC资源；
+
+- Dubbo 服务
+
+将TCC发布成dubbo服务，事务管理器订阅dubbo服务，来协调TCC资源；
+
+- Local TCC
+
+本地普通的TCC Bean，非远程服务；事务管理器通过本地方法调用，来协调TCC 资源；
+
+##### 2、TCC资源动态代理
+
+对TCC服务进行动态代理，GlobalTransactionScanner中当扫描到TCC 服务的 ‘reference’时，会对其进行动态代理；
+
+TCC 动态代理的主要功能是：生成TCC运行时上下文、透传业务参数、注册分支事务记录；
+
+#### 模块说明
+
+fescar-tcc 包含TCC主要代码：
+
+- interceptor：TCC 动态代理；
+
+- remoting：TCC微服务扫描、RPC协议解析、TCC资源注册；
+
+- TccResourceManager、RMHandlerTCC： TCC资源管理器；
+
+
+
+
+#### 其他说明：
+
+本此为了区分AT、TCC 2种资源类型，在客户端和服务端通信的接口中，均添加了 BranchType 参数；
+
+
+
+
diff --git a/tcc/pom.xml b/tcc/pom.xml
new file mode 100644
index 000000000..3274e7353
--- /dev/null
+++ b/tcc/pom.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~  Copyright 1999-2018 Alibaba Group Holding Ltd.
+  ~
+  ~  Licensed under the Apache License, Version 2.0 (the "License");
+  ~  you may not use this file except in compliance with the License.
+  ~  You may obtain a copy of the License at
+  ~
+  ~       http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing, software
+  ~  distributed under the License is distributed on an "AS IS" BASIS,
+  ~  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~  See the License for the specific language governing permissions and
+  ~  limitations under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>fescar-all</artifactId>
+        <groupId>com.alibaba.fescar</groupId>
+        <version>0.4.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>fescar-tcc</artifactId>
+    <packaging>jar</packaging>
+    <name>fescar-tcc ${project.version}</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>fescar-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>fescar-rm</artifactId>
+        </dependency>
+        
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>${junit.version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+
+</project>
diff --git a/tcc/src/main/java/com/alibaba/fescar/rm/tcc/RMHandlerTCC.java b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/RMHandlerTCC.java
new file mode 100644
index 000000000..a4a1aa7c7
--- /dev/null
+++ b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/RMHandlerTCC.java
@@ -0,0 +1,45 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc;
+
+import com.alibaba.fescar.core.model.BranchType;
+import com.alibaba.fescar.core.model.ResourceManager;
+import com.alibaba.fescar.rm.AbstractRMHandler;
+import com.alibaba.fescar.rm.DefaultResourceManager;
+
+/**
+ * The type Rm handler tcc.
+ *
+ * @author zhangsen
+ */
+public class RMHandlerTCC extends AbstractRMHandler {
+
+    /**
+     * get TCC resource manager
+     * @return
+     */
+    @Override
+    protected ResourceManager getResourceManager() {
+        return DefaultResourceManager.get().getResourceManager(BranchType.TCC);
+    }
+
+    @Override
+    public BranchType getBranchType(){
+        return BranchType.TCC;
+    }
+
+}
diff --git a/tcc/src/main/java/com/alibaba/fescar/rm/tcc/TCCResource.java b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/TCCResource.java
new file mode 100644
index 000000000..551377314
--- /dev/null
+++ b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/TCCResource.java
@@ -0,0 +1,254 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc;
+
+import com.alibaba.fescar.core.model.BranchType;
+import com.alibaba.fescar.core.model.Resource;
+
+import java.lang.reflect.Method;
+
+/**
+ * The type Tcc resource.
+ *
+ * @author zhangsen
+ */
+public class TCCResource implements Resource {
+
+    private String resourceGroupId = "DEFAULT";
+
+    /**
+     * 应用名称
+     */
+    private String appName;
+
+    /**
+     * TCC 参与者名称，全局唯一
+     */
+    private String actionName;
+
+    /**
+     * TCC 服务实现类
+     */
+    private Object targetBean;
+
+    /**
+     * Prepare method
+     */
+    private Method prepareMethod;
+
+    /**
+     * 提交方法
+     */
+    private String commitMethodName;
+
+    /**
+     * 提交方法
+     */
+    private Method commitMethod;
+
+    /**
+     * 回滚方法
+     */
+    private String rollbackMethodName;
+
+    /**
+     * 回滚方法
+     */
+    private Method rollbackMethod;
+
+
+    @Override
+    public String getResourceGroupId() {
+        return resourceGroupId;
+    }
+
+    /**
+     * Sets resource group id.
+     *
+     * @param resourceGroupId the resource group id
+     */
+    public void setResourceGroupId(String resourceGroupId) {
+        this.resourceGroupId = resourceGroupId;
+    }
+
+    @Override
+    public String getResourceId() {
+        return actionName;
+    }
+
+    @Override
+    public BranchType getBranchType() {
+        return BranchType.TCC;
+    }
+
+    /**
+     * Gets app name.
+     *
+     * @return the app name
+     */
+    public String getAppName() {
+        return appName;
+    }
+
+    /**
+     * Sets app name.
+     *
+     * @param appName the app name
+     */
+    public void setAppName(String appName) {
+        this.appName = appName;
+    }
+
+    /**
+     * Gets action name.
+     *
+     * @return the action name
+     */
+    public String getActionName() {
+        return actionName;
+    }
+
+    /**
+     * Sets action name.
+     *
+     * @param actionName the action name
+     */
+    public void setActionName(String actionName) {
+        this.actionName = actionName;
+    }
+
+    /**
+     * Gets target bean.
+     *
+     * @return the target bean
+     */
+    public Object getTargetBean() {
+        return targetBean;
+    }
+
+    /**
+     * Sets target bean.
+     *
+     * @param targetBean the target bean
+     */
+    public void setTargetBean(Object targetBean) {
+        this.targetBean = targetBean;
+    }
+
+    /**
+     * Gets prepare method.
+     *
+     * @return the prepare method
+     */
+    public Method getPrepareMethod() {
+        return prepareMethod;
+    }
+
+    /**
+     * Sets prepare method.
+     *
+     * @param prepareMethod the prepare method
+     */
+    public void setPrepareMethod(Method prepareMethod) {
+        this.prepareMethod = prepareMethod;
+    }
+
+    /**
+     * Gets commit method.
+     *
+     * @return the commit method
+     */
+    public Method getCommitMethod() {
+        return commitMethod;
+    }
+
+    /**
+     * Sets commit method.
+     *
+     * @param commitMethod the commit method
+     */
+    public void setCommitMethod(Method commitMethod) {
+        this.commitMethod = commitMethod;
+    }
+
+    /**
+     * Gets rollback method.
+     *
+     * @return the rollback method
+     */
+    public Method getRollbackMethod() {
+        return rollbackMethod;
+    }
+
+    /**
+     * Sets rollback method.
+     *
+     * @param rollbackMethod the rollback method
+     */
+    public void setRollbackMethod(Method rollbackMethod) {
+        this.rollbackMethod = rollbackMethod;
+    }
+
+    /**
+     * Gets commit method name.
+     *
+     * @return the commit method name
+     */
+    public String getCommitMethodName() {
+        return commitMethodName;
+    }
+
+    /**
+     * Sets commit method name.
+     *
+     * @param commitMethodName the commit method name
+     */
+    public void setCommitMethodName(String commitMethodName) {
+        this.commitMethodName = commitMethodName;
+    }
+
+    /**
+     * Gets rollback method name.
+     *
+     * @return the rollback method name
+     */
+    public String getRollbackMethodName() {
+        return rollbackMethodName;
+    }
+
+    /**
+     * Sets rollback method name.
+     *
+     * @param rollbackMethodName the rollback method name
+     */
+    public void setRollbackMethodName(String rollbackMethodName) {
+        this.rollbackMethodName = rollbackMethodName;
+    }
+
+    @Override
+    public int hashCode() {
+        return actionName.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if(!(obj instanceof TCCResource)){
+            return false;
+        }
+        return this.actionName.equals(((TCCResource)obj).actionName);
+    }
+}
diff --git a/tcc/src/main/java/com/alibaba/fescar/rm/tcc/TCCResourceManager.java b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/TCCResourceManager.java
new file mode 100644
index 000000000..30693b5d0
--- /dev/null
+++ b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/TCCResourceManager.java
@@ -0,0 +1,173 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fescar.common.Constants;
+import com.alibaba.fescar.common.exception.FrameworkException;
+import com.alibaba.fescar.common.exception.ShouldNeverHappenException;
+import com.alibaba.fescar.common.util.StringUtils;
+import com.alibaba.fescar.core.exception.TransactionException;
+import com.alibaba.fescar.core.model.BranchStatus;
+import com.alibaba.fescar.core.model.BranchType;
+import com.alibaba.fescar.core.model.Resource;
+import com.alibaba.fescar.rm.AbstractResourceManager;
+import com.alibaba.fescar.rm.tcc.api.BusinessActionContext;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * TCC resource manager
+ *
+ * @author zhangsen
+ */
+public class TCCResourceManager extends AbstractResourceManager {
+
+	/**
+	 * TCC resource cache
+	 */
+	private Map<String, Resource> tccResourceCache = new ConcurrentHashMap<String, Resource>();
+
+    /**
+     * Instantiates a new Tcc resource manager.
+     */
+    public TCCResourceManager(){
+	}
+
+	/**
+	 * registry TCC resource
+	 * @param resource The resource to be managed.
+	 */
+	@Override
+	public void registerResource(Resource resource) {
+		TCCResource tccResource = (TCCResource) resource;
+		tccResourceCache.put(tccResource.getResourceId(), tccResource);
+		super.registerResource(tccResource);
+	}
+
+	@Override
+	public Map<String, Resource> getManagedResources() {
+		return tccResourceCache;
+	}
+
+	/**
+	 * TCC branch commit
+	 * @param branchType
+	 * @param xid             Transaction id.
+	 * @param branchId        Branch id.
+	 * @param resourceId      Resource id.
+	 * @param applicationData Application data bind with this branch.
+	 * @return
+	 * @throws TransactionException
+	 */
+	@Override
+	public BranchStatus branchCommit(BranchType branchType, String xid, long branchId, String resourceId, String applicationData) throws TransactionException {
+		TCCResource tccResource = (TCCResource) tccResourceCache.get(resourceId);
+		if(tccResource == null){
+			throw new ShouldNeverHappenException("TCC resource is not exist, resourceId:" + resourceId);
+		}
+		Object targetTCCBean = tccResource.getTargetBean();
+		Method commitMethod = tccResource.getCommitMethod();
+		if(targetTCCBean == null || commitMethod == null){
+			throw new ShouldNeverHappenException("TCC resource is not available, resourceId:" + resourceId);
+		}
+		try {
+			boolean result = false;
+			//BusinessActionContext
+			BusinessActionContext businessActionContext = getBusinessActionContext(xid, branchId, resourceId, applicationData);
+			Object ret = commitMethod.invoke(targetTCCBean, businessActionContext);
+			LOGGER.info("TCC resource commit result :" + ret + ", xid:" + xid + ", branchId:" + branchId + ", resourceId:" + resourceId);
+			if(ret != null && ret instanceof TwoPhaseResult){
+				result = ((TwoPhaseResult)ret).isSuccess();
+			}else {
+				result = (boolean) ret;
+			}
+			return result ? BranchStatus.PhaseTwo_Committed:BranchStatus.PhaseTwo_CommitFailed_Retryable;
+		}catch (Throwable t){
+			String msg = String.format("commit TCC resource error, resourceId: %s, xid: %s.", resourceId, xid);
+			LOGGER.error(msg , t);
+			throw new FrameworkException(t, msg);
+		}
+	}
+
+	/**
+	 * TCC branch rollback
+	 * @param branchType the branch type
+	 * @param xid             Transaction id.
+	 * @param branchId        Branch id.
+	 * @param resourceId      Resource id.
+	 * @param applicationData Application data bind with this branch.
+	 * @return
+	 * @throws TransactionException
+	 */
+	@Override
+	public BranchStatus branchRollback(BranchType branchType, String xid, long branchId, String resourceId, String applicationData) throws TransactionException {
+		TCCResource tccResource = (TCCResource) tccResourceCache.get(resourceId);
+		if (tccResource == null) {
+			throw new ShouldNeverHappenException("TCC resource is not exist, resourceId:" + resourceId);
+		}
+		Object targetTCCBean = tccResource.getTargetBean();
+		Method rollbackMethod = tccResource.getRollbackMethod();
+		if (targetTCCBean == null || rollbackMethod == null) {
+			throw new ShouldNeverHappenException("TCC resource is not available, resourceId:" + resourceId);
+		}
+		try {
+			boolean result = false;
+			//BusinessActionContext
+			BusinessActionContext businessActionContext = getBusinessActionContext(xid, branchId, resourceId, applicationData);
+			Object ret = rollbackMethod.invoke(targetTCCBean, businessActionContext);
+			LOGGER.info("TCC resource rollback result :" + ret + ", xid:" + xid + ", branchId:" + branchId + ", resourceId:" + resourceId);
+			if (ret != null && ret instanceof TwoPhaseResult) {
+				result = ((TwoPhaseResult) ret).isSuccess();
+			} else {
+				result = (boolean) ret;
+			}
+			return result ? BranchStatus.PhaseTwo_Rollbacked : BranchStatus.PhaseTwo_RollbackFailed_Retryable;
+		} catch (Throwable t) {
+			String msg = String.format("rollback TCC resource error, resourceId: %s, xid: %s.", resourceId, xid);
+			LOGGER.error(msg, t);
+			throw new FrameworkException(t, msg);
+		}
+	}
+
+    /**
+     * transfer tcc applicationData to BusinessActionContext
+     *
+     * @param xid the xid
+     * @param branchId the branch id
+     * @param resourceId the resource id
+     * @param applicationData the application data
+     * @return business action context
+     */
+    protected BusinessActionContext getBusinessActionContext(String xid, long branchId, String resourceId, String applicationData){
+		//transfer tcc applicationData to Context
+		Map tccContext = StringUtils.isBlank(applicationData)?new HashMap():(Map) JSON.parse(applicationData);
+		Map actionContextMap = (Map) tccContext.get(Constants.TCC_ACTION_CONTEXT);
+		BusinessActionContext businessActionContext = new BusinessActionContext(
+				xid, String.valueOf(branchId),  actionContextMap);
+		businessActionContext.setActionName(resourceId);
+		return businessActionContext;
+	}
+
+	@Override
+	public BranchType getBranchType(){
+		return BranchType.TCC;
+	}
+}
diff --git a/tcc/src/main/java/com/alibaba/fescar/rm/tcc/TwoPhaseResult.java b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/TwoPhaseResult.java
new file mode 100644
index 000000000..6d7b40eb8
--- /dev/null
+++ b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/TwoPhaseResult.java
@@ -0,0 +1,99 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc;
+
+import com.alibaba.fescar.common.util.StringUtils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * the TCC method result
+ *
+ * @author zhangsen
+ */
+public class TwoPhaseResult {
+
+    /**
+     * is Success ?
+     */
+    private boolean             isSuccess = false;
+
+    /**
+     * result message
+     */
+    private String              message;
+
+    /**
+     * Instantiates a new Two phase result.
+     *
+     * @param isSuccess the is success
+     * @param msg       the msg
+     */
+    public TwoPhaseResult(boolean isSuccess, String msg) {
+        this.isSuccess = isSuccess;
+        this.message = msg;
+    }
+
+    /**
+     * Is success boolean.
+     *
+     * @return the boolean
+     */
+    public boolean isSuccess() {
+        return isSuccess;
+    }
+
+    /**
+     * Sets success.
+     *
+     * @param isSuccess the is success
+     */
+    public void setSuccess(boolean isSuccess) {
+        this.isSuccess = isSuccess;
+    }
+
+    /**
+     * Gets message.
+     *
+     * @return the message
+     */
+    public String getMessage() {
+        return message;
+    }
+
+    /**
+     * Sets message.
+     *
+     * @param msg the message
+     */
+    public void setMessage(String msg) {
+        this.message = msg;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("[");
+        sb.append("isSuccess:").append(isSuccess);
+        if(StringUtils.isNotBlank(message)){
+            sb.append(", msg").append(message);
+        }
+        sb.append("]");
+        return sb.toString();
+    }
+}
diff --git a/tcc/src/main/java/com/alibaba/fescar/rm/tcc/api/BusinessActionContext.java b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/api/BusinessActionContext.java
new file mode 100644
index 000000000..6799a9abc
--- /dev/null
+++ b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/api/BusinessActionContext.java
@@ -0,0 +1,171 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc.api;
+
+import java.io.Serializable;
+import java.util.Map;
+
+/**
+ * TCC Method context
+ *
+ * @author zhangsen
+ */
+public class BusinessActionContext implements Serializable {
+
+    /**  */
+    private static final long serialVersionUID = 6539226288677737991L;
+
+    /**
+     * xid
+     */
+    private String xid;
+
+    /**
+     * the branch id
+     */
+    private String branchId;
+
+    /**
+     * tcc bean name
+     */
+    private String actionName;
+
+    /**
+     * TCC's parameters witch is set by @BusinessActionContextParameter
+     */
+    private Map<String, Object> actionContext;
+
+    /**
+     * Instantiates a new Business action context.
+     */
+    public BusinessActionContext() {
+    }
+
+    /**
+     * Instantiates a new Business action context.
+     *
+     * @param xid           the xid
+     * @param actionName    the action name
+     * @param actionContext the action context
+     */
+    public BusinessActionContext(String xid, String actionName, Map<String, Object> actionContext) {
+        this.xid = xid;
+        this.actionName = actionName;
+        this.setActionContext(actionContext);
+    }
+
+    /**
+     * 获取action级别的参数
+     *
+     * @param key the key
+     * @return action context
+     */
+    public Object getActionContext(String key) {
+        return actionContext.get(key);
+    }
+
+    /**
+     * Gets branch id.
+     *
+     * @return the branch id
+     */
+    public long getBranchId() {
+        return branchId!=null?Long.valueOf(branchId):-1;
+    }
+
+    /**
+     * Sets branch id.
+     *
+     * @param branchId the branch id
+     */
+    public void setBranchId(long branchId) {
+        this.branchId = String.valueOf(branchId);
+    }
+
+    /**
+     * Gets action context.
+     *
+     * @return the action context
+     */
+    public Map<String, Object> getActionContext() {
+        return actionContext;
+    }
+
+    /**
+     * Sets action context.
+     *
+     * @param actionContext the action context
+     */
+    public void setActionContext(Map<String, Object> actionContext) {
+        this.actionContext = actionContext;
+    }
+
+    /**
+     * Gets xid.
+     *
+     * @return the xid
+     */
+    public String getXid() {
+        return xid;
+    }
+
+    /**
+     * Sets xid.
+     *
+     * @param xid the xid
+     */
+    public void setXid(String xid) {
+        this.xid = xid;
+    }
+
+    /**
+     * Sets branch id.
+     *
+     * @param branchId the branch id
+     */
+    public void setBranchId(String branchId) {
+        this.branchId = branchId;
+    }
+
+    /**
+     * Gets action name.
+     *
+     * @return the action name
+     */
+    public String getActionName() {
+        return actionName;
+    }
+
+    /**
+     * Sets action name.
+     *
+     * @param actionName the action name
+     */
+    public void setActionName(String actionName) {
+        this.actionName = actionName;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("[xid:").append(xid)
+            .append(",branch_Id:").append(branchId).append(",action_name:").append(actionName)
+            .append(",action_context:")
+            .append(actionContext).append("]");
+        return sb.toString();
+    }
+}
diff --git a/tcc/src/main/java/com/alibaba/fescar/rm/tcc/api/BusinessActionContextParameter.java b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/api/BusinessActionContextParameter.java
new file mode 100644
index 000000000..2849812c5
--- /dev/null
+++ b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/api/BusinessActionContextParameter.java
@@ -0,0 +1,64 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc.api;
+
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * the TCC parameters that need to be passed to  the BusinessActivityContext；
+ * <p>
+ * add this annotation on the parameters of the try method, and the parameters will be passed to  the
+ * BusinessActivityContext；
+ *
+ * @author zhangsen
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ ElementType.PARAMETER, ElementType.FIELD })
+public @interface BusinessActionContextParameter {
+
+    /**
+     * parameter's name
+     *
+     * @return the string
+     */
+    String paramName() default "";
+
+    /**
+     * if it is a sharding param ?
+     *
+     * @return boolean boolean
+     */
+    boolean isShardingParam() default false;
+
+    /**
+     * Specify the index of the parameter in the List
+     *
+     * @return int int
+     */
+    int index() default -1;
+
+    /**
+     * if get the parameter from the property of the object ?
+     *
+     * @return boolean boolean
+     */
+    boolean isParamInProperty() default false;
+}
\ No newline at end of file
diff --git a/tcc/src/main/java/com/alibaba/fescar/rm/tcc/api/BusinessActivityContext.java b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/api/BusinessActivityContext.java
new file mode 100644
index 000000000..2f9d29fc4
--- /dev/null
+++ b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/api/BusinessActivityContext.java
@@ -0,0 +1,104 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc.api;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.alibaba.fescar.common.Constants;
+
+/**
+ * 主事务记录上下文信息
+ *
+ * @author zhangsen
+ */
+public class BusinessActivityContext implements Serializable {
+
+    /**  */
+    private static final long   serialVersionUID = 6539226288677737992L;
+
+    private Map<String, Object> context = new HashMap<String, Object>();
+
+    /**
+     * Instantiates a new Business activity context.
+     */
+    public BusinessActivityContext() {
+    }
+
+    /**
+     * Instantiates a new Business activity context.
+     *
+     * @param context the context
+     */
+    public BusinessActivityContext(Map<String, Object> context) {
+        this.context = context;
+    }
+
+    /**
+     * Add context.
+     *
+     * @param key   the key
+     * @param value the value
+     */
+    public void addContext(String key, Object value) {
+        context.put(key, value);
+    }
+
+    /**
+     * 获取本次分布式事务的开启时间
+     *
+     * @return long long
+     */
+    public Long fetchStartTime() {
+        return (Long) context.get(Constants.START_TIME);
+    }
+
+    /**
+     * 获取应用自定义的参数
+     *
+     * @param key the key
+     * @return the object
+     */
+    public Object getContext(String key){
+        return context.get(key);
+    }
+
+    /**
+     * Gets context.
+     *
+     * @return the context
+     */
+    public Map<String, Object> getContext() {
+        return context;
+    }
+
+    /**
+     * Sets context.
+     *
+     * @param context the context
+     */
+    public void setContext(Map<String, Object> context) {
+        this.context = context;
+    }
+
+    @Override
+    public String toString() {
+        return context.toString();
+    }
+
+}
diff --git a/tcc/src/main/java/com/alibaba/fescar/rm/tcc/api/LocalTCC.java b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/api/LocalTCC.java
new file mode 100644
index 000000000..f76930976
--- /dev/null
+++ b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/api/LocalTCC.java
@@ -0,0 +1,30 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc.api;
+
+import java.lang.annotation.*;
+
+/**
+ * Local TCC bean annotation, add on the TCC interface
+ *
+ * @author zhangsen
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+@Inherited
+public @interface LocalTCC {
+}
diff --git a/tcc/src/main/java/com/alibaba/fescar/rm/tcc/api/TwoPhaseBusinessAction.java b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/api/TwoPhaseBusinessAction.java
new file mode 100644
index 000000000..e23b8bc73
--- /dev/null
+++ b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/api/TwoPhaseBusinessAction.java
@@ -0,0 +1,56 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc.api;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * TCC annotation, Define a TCC interface，which added on the try method
+ *
+ * @author zhangsen
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ ElementType.METHOD })
+@Inherited
+public @interface TwoPhaseBusinessAction {
+
+    /**
+     * TCC bean name, must be unique
+     *
+     * @return the string
+     */
+    String name() ;
+
+    /**
+     * commit methed name
+     *
+     * @return the string
+     */
+    String commitMethod() default "commit";
+
+    /**
+     * rollback method name
+     *
+     * @return the string
+     */
+    String rollbackMethod() default "rollback";
+
+}
\ No newline at end of file
diff --git a/tcc/src/main/java/com/alibaba/fescar/rm/tcc/interceptor/ActionContextFilter.java b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/interceptor/ActionContextFilter.java
new file mode 100644
index 000000000..69a47ef16
--- /dev/null
+++ b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/interceptor/ActionContextFilter.java
@@ -0,0 +1,36 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc.interceptor;
+
+import com.alibaba.fescar.rm.tcc.api.BusinessActionContextParameter;
+
+/**
+ * The interface Action context filter.
+ *
+ * @author zhangsen
+ */
+public interface ActionContextFilter {
+
+    /**
+     * Need filter boolean.
+     *
+     * @param parameter the parameter
+     * @return the boolean
+     */
+    public boolean needFilter(BusinessActionContextParameter parameter);
+
+}
diff --git a/tcc/src/main/java/com/alibaba/fescar/rm/tcc/interceptor/ActionContextUtil.java b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/interceptor/ActionContextUtil.java
new file mode 100644
index 000000000..3f650de7b
--- /dev/null
+++ b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/interceptor/ActionContextUtil.java
@@ -0,0 +1,111 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc.interceptor;
+
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.alibaba.fescar.common.exception.FrameworkException;
+import com.alibaba.fescar.common.util.StringUtils;
+import com.alibaba.fescar.rm.tcc.api.BusinessActionContextParameter;
+
+/**
+ * Extracting TCC Context from Method
+ *
+ * @author zhangsen
+ */
+public class ActionContextUtil {
+
+    /**
+     * Extracting context data from parameters
+     *
+     * @param targetParam the target param
+     * @return map map
+     */
+    public static Map<String, Object> fetchContextFromObject(Object targetParam) {
+        try {
+            Map<String, Object> context = new HashMap<String, Object>(8);
+            List<Field> fields = new ArrayList<Field>();
+            getAllField(targetParam.getClass(), fields);
+            for (Field f : fields) {
+                String fieldName = f.getName();
+                //1、获取属性上的指定类型的注释
+                Annotation annotation = f.getAnnotation(BusinessActionContextParameter.class);
+
+                //打了注解
+                if (annotation != null) {
+                    BusinessActionContextParameter param = (BusinessActionContextParameter) annotation;
+                    f.setAccessible(true);
+                    Object paramObject = f.get(targetParam);
+                    int index = param.index();
+                    //如果是，则找到特定参数
+                    if (index >= 0) {
+                        @SuppressWarnings("unchecked")
+						Object targetObject = ((List<Object>) paramObject).get(index);
+                        if (param.isParamInProperty()) {
+                            context.putAll(fetchContextFromObject(targetObject));
+                        } else {
+                            if (StringUtils.isBlank(param.paramName())) {
+                                context.put(fieldName, paramObject);
+                            } else {
+                                context.put(param.paramName(), paramObject);
+                            }
+                        }
+                    } else {
+                        if (param.isParamInProperty()) {
+                            context.putAll(fetchContextFromObject(paramObject));
+                        } else {
+                            if (StringUtils.isBlank(param.paramName())) {
+                                context.put(fieldName, paramObject);
+                            } else {
+                                context.put(param.paramName(), paramObject);
+                            }
+                        }
+                    }
+                }
+            }
+            return context;
+        } catch (Throwable t) {
+            throw new FrameworkException(t, "fetchContextFromObject failover");
+        }
+    }
+
+    /**
+     * Gets all field.
+     *
+     * @param interFace the inter face
+     * @param fields    the fields
+     */
+    public static void getAllField(Class<?> interFace, List<Field> fields) {
+        if (interFace == Object.class || interFace.isInterface()) {
+            return;
+        }
+        Field[] field = interFace.getDeclaredFields();
+        if (field != null) {
+            fields.addAll(Arrays.asList(field));
+        }
+        getAllField(interFace.getSuperclass(), fields);
+    }
+
+
+}
diff --git a/tcc/src/main/java/com/alibaba/fescar/rm/tcc/interceptor/ActionInterceptorHandler.java b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/interceptor/ActionInterceptorHandler.java
new file mode 100644
index 000000000..6cca65f8e
--- /dev/null
+++ b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/interceptor/ActionInterceptorHandler.java
@@ -0,0 +1,203 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc.interceptor;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fescar.common.Constants;
+import com.alibaba.fescar.common.exception.FrameworkException;
+import com.alibaba.fescar.common.executor.Callback;
+import com.alibaba.fescar.common.util.NetUtil;
+import com.alibaba.fescar.core.context.RootContext;
+import com.alibaba.fescar.core.model.BranchType;
+import com.alibaba.fescar.rm.DefaultResourceManager;
+import com.alibaba.fescar.rm.tcc.api.BusinessActionContext;
+import com.alibaba.fescar.rm.tcc.api.BusinessActionContextParameter;
+import com.alibaba.fescar.rm.tcc.api.TwoPhaseBusinessAction;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Handler the TCC Participant Aspect : Setting Context, Creating Branch Record
+ *
+ * @author zhangsen
+ */
+public class ActionInterceptorHandler {
+	
+    private static final Logger LOGGER = LoggerFactory.getLogger(ActionInterceptorHandler.class);
+
+    /**
+     * Handler the TCC Aspect
+     *
+     * @param method         the method
+     * @param arguments      the arguments
+     * @param businessAction the business action
+     * @param targetCallback the target callback
+     * @return map map
+     * @throws Throwable the throwable
+     */
+    public Map<String, Object> proceed(Method method, Object[] arguments, TwoPhaseBusinessAction businessAction, Callback<Object> targetCallback) throws Throwable {
+		Map<String, Object> ret = new HashMap<String, Object>(16);
+		
+		//TCC name
+        String actionName = businessAction.name();
+        String xid = RootContext.getXID();
+        BusinessActionContext actionContext = new BusinessActionContext();
+        actionContext.setXid(xid);
+        //set action anme
+        actionContext.setActionName(actionName);
+        //TODO fescar当前版本暂无主事务记录上下文
+        
+        //Creating Branch Record
+        String branchId = doTccActionLogStore(method, arguments, businessAction, actionContext);
+        actionContext.setBranchId(branchId);
+        
+        //set the parameter whose type is BusinessActionContext
+        Class<?>[] types = method.getParameterTypes();
+        int argIndex = 0;
+        for (Class<?> cls : types) {
+            if (cls.getName().equals(BusinessActionContext.class.getName())) {
+            	arguments[argIndex] = actionContext;
+                break;
+            }
+            argIndex++;
+        }
+        //the final parameters of the try method
+        ret.put(Constants.TCC_METHOD_ARGUMENTS, arguments);
+        //the final result
+        ret.put(Constants.TCC_METHOD_RESULT, targetCallback.execute());
+        return ret;
+	}
+
+    /**
+     * Creating Branch Record
+     *
+     * @param method         the method
+     * @param arguments      the arguments
+     * @param businessAction the business action
+     * @param actionContext  the action context
+     * @return the string
+     */
+    protected String doTccActionLogStore(Method method, Object[] arguments, TwoPhaseBusinessAction businessAction, BusinessActionContext actionContext) {
+		String actionName = actionContext.getActionName();
+        String xid = actionContext.getXid();
+        //
+        Map<String, Object> context = fetchActionRequestContext(method, arguments);
+        context.put(Constants.ACTION_START_TIME, System.currentTimeMillis());
+        
+        //init business context
+        initBusinessContext(context, method, businessAction);
+        //Init running environment context
+        initFrameworkContext(context);
+        actionContext.setActionContext(context);
+
+        //init applicationData
+        Map<String, Object> applicationContext = new HashMap<String, Object>(4);
+        applicationContext.put(Constants.TCC_ACTION_CONTEXT, context);
+        String applicationContextStr = JSON.toJSONString(applicationContext);
+        try {
+        	//registry branch record
+        	Long branchId = DefaultResourceManager.get().branchRegister(BranchType.TCC, actionName, null, xid, applicationContextStr, null);
+        	return String.valueOf(branchId);
+        }catch(Throwable t){
+            String msg = "TCC branch Register error, xid:" + xid;
+        	LOGGER.error(msg, t);
+        	throw new FrameworkException(t, msg);
+        }
+	}
+
+    /**
+     * Init running environment context
+     *
+     * @param context the context
+     */
+    protected void initFrameworkContext(Map<String, Object> context){
+        try {
+            context.put(Constants.HOST_NAME, NetUtil.getLocalIp());
+        } catch (Throwable t) {
+        	LOGGER.warn("getLocalIP error", t);
+        }
+    }
+
+    /**
+     * Init business context
+     *
+     * @param context        the context
+     * @param method         the method
+     * @param businessAction the business action
+     */
+    protected void initBusinessContext(Map<String,Object> context, Method method, TwoPhaseBusinessAction businessAction) {
+    	if(method != null){
+        	//the phase one method name
+            context.put(Constants.PREPARE_METHOD, method.getName());
+        }
+        if(businessAction != null){
+        	//the phase two method name
+            context.put(Constants.COMMIT_METHOD, businessAction.commitMethod());
+            context.put(Constants.ROLLBACK_METHOD, businessAction.rollbackMethod());
+            context.put(Constants.ACTION_NAME, businessAction.name());
+        }
+    }
+
+    /**
+     * Extracting context data from parameters, add them to the context
+     *
+     * @param method    the method
+     * @param arguments the arguments
+     * @return map map
+     */
+    protected Map<String, Object> fetchActionRequestContext(Method method, Object[] arguments) {
+        Map<String, Object> context = new HashMap<String, Object>(8);
+
+        Annotation[][] parameterAnnotations = method.getParameterAnnotations();
+        for (int i = 0; i < parameterAnnotations.length; i++) {
+            for (int j = 0; j < parameterAnnotations[i].length; j++) {
+                if (parameterAnnotations[i][j] instanceof BusinessActionContextParameter) {
+                    BusinessActionContextParameter param = (BusinessActionContextParameter) parameterAnnotations[i][j];
+                    if (null == arguments[i]) {
+                        throw new IllegalArgumentException("@BusinessActionContextParameter 's params can not null");
+                    }
+                    Object paramObject = arguments[i];
+                    int index = param.index();
+                    //List, get by index
+                    if (index >= 0) {
+						Object targetParam = ((List<Object>) paramObject).get(index);
+                        if (param.isParamInProperty()) {
+                            context.putAll(ActionContextUtil.fetchContextFromObject(targetParam));
+                        } else {
+                            context.put(param.paramName(), targetParam);
+                        }
+                    } else {
+                        if (param.isParamInProperty()) {
+                            context.putAll(ActionContextUtil.fetchContextFromObject(paramObject));
+                        } else {
+                            context.put(param.paramName(), paramObject);
+                        }
+                    }
+                }
+            }
+        }
+        return context;
+    }
+	
+
+}
diff --git a/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/Protocols.java b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/Protocols.java
new file mode 100644
index 000000000..2cdd86b71
--- /dev/null
+++ b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/Protocols.java
@@ -0,0 +1,53 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc.remoting;
+
+import com.alibaba.fescar.common.exception.FrameworkException;
+
+/**
+ * remoting protocols enum
+ *
+ * @author zhangsen
+ */
+public class Protocols {
+
+	/**
+	 * sofa-rpc service
+	 */
+	public static short SOFA_RPC = 2;
+
+	/**
+	 * dubbo service
+	 */
+	public static short DUBBO = 3;
+
+	/**
+	 * restful service
+	 */
+	public static short RESTFUL = 4;
+
+	/**
+	 * local bean
+	 */
+	public static short IN_JVM = 5;
+
+	/**
+	 * hsf service
+	 */
+	public static short HSF = 8;
+
+}
diff --git a/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/RemotingDesc.java b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/RemotingDesc.java
new file mode 100644
index 000000000..72e492ef2
--- /dev/null
+++ b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/RemotingDesc.java
@@ -0,0 +1,186 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc.remoting;
+
+/**
+ * remoting bean info
+ *
+ * @author zhangsen
+ */
+public class RemotingDesc {
+
+	/**
+	 * is referenc bean ?
+	 */
+	private boolean isReference = false;
+	
+	/**
+	 * rpc target bean, the service bean has this property
+	 */
+	private Object targetBean;
+	
+	/**
+	 * the tcc interface tyep
+	 */
+	private Class<?> interfaceClass ;
+	
+	/**
+	 * interface class name
+	 */
+	private String interfaceClassName ;
+	
+	/**
+	 * rpc uniqueId: hsf、dubbo的version、sofa-rpc 的 uniqueId
+	 */
+	private String uniqueId ;
+	
+	/**
+	 * dubbo/hsf 的group 分组
+	 */
+	private String group;
+	
+	/**
+	 * protocol: sofa-rpc、dubbo、injvm 等
+	 */
+	private short protocol;
+
+    /**
+     * Gets target bean.
+     *
+     * @return the target bean
+     */
+    public Object getTargetBean() {
+		return targetBean;
+	}
+
+    /**
+     * Sets target bean.
+     *
+     * @param targetBean the target bean
+     */
+    public void setTargetBean(Object targetBean) {
+		this.targetBean = targetBean;
+	}
+
+    /**
+     * Gets interface class.
+     *
+     * @return the interface class
+     */
+    public Class<?> getInterfaceClass() {
+		return interfaceClass;
+	}
+
+    /**
+     * Sets interface class.
+     *
+     * @param interfaceClass the interface class
+     */
+    public void setInterfaceClass(Class<?> interfaceClass) {
+		this.interfaceClass = interfaceClass;
+	}
+
+    /**
+     * Gets interface class name.
+     *
+     * @return the interface class name
+     */
+    public String getInterfaceClassName() {
+		return interfaceClassName;
+	}
+
+    /**
+     * Sets interface class name.
+     *
+     * @param interfaceClassName the interface class name
+     */
+    public void setInterfaceClassName(String interfaceClassName) {
+		this.interfaceClassName = interfaceClassName;
+	}
+
+    /**
+     * Gets unique id.
+     *
+     * @return the unique id
+     */
+    public String getUniqueId() {
+		return uniqueId;
+	}
+
+    /**
+     * Sets unique id.
+     *
+     * @param uniqueId the unique id
+     */
+    public void setUniqueId(String uniqueId) {
+		this.uniqueId = uniqueId;
+	}
+
+    /**
+     * Gets group.
+     *
+     * @return the group
+     */
+    public String getGroup() {
+		return group;
+	}
+
+    /**
+     * Sets group.
+     *
+     * @param group the group
+     */
+    public void setGroup(String group) {
+		this.group = group;
+	}
+
+    /**
+     * Gets protocol.
+     *
+     * @return the protocol
+     */
+    public short getProtocol() {
+		return protocol;
+	}
+
+    /**
+     * Sets protocol.
+     *
+     * @param protocol the protocol
+     */
+    public void setProtocol(short protocol) {
+		this.protocol = protocol;
+	}
+
+    /**
+     * Is reference boolean.
+     *
+     * @return the boolean
+     */
+    public boolean isReference() {
+		return isReference;
+	}
+
+    /**
+     * Sets reference.
+     *
+     * @param reference the reference
+     */
+    public void setReference(boolean reference) {
+		isReference = reference;
+	}
+}
diff --git a/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/RemotingParser.java b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/RemotingParser.java
new file mode 100644
index 000000000..b1f89a2ba
--- /dev/null
+++ b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/RemotingParser.java
@@ -0,0 +1,78 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc.remoting;
+
+import com.alibaba.fescar.common.exception.FrameworkException;
+
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * extract remoting bean info
+ *
+ * @author zhangsen
+ */
+public interface RemotingParser {
+
+    /**
+     * if it is remoting bean ?
+     *
+     * @param bean     the bean
+     * @param beanName the bean name
+     * @return boolean boolean
+     * @throws FrameworkException the framework exception
+     */
+    boolean isRemoting(Object bean, String beanName) throws FrameworkException;
+
+    /**
+     * if it is reference bean ?
+     *
+     * @param bean     the bean
+     * @param beanName the bean name
+     * @return boolean boolean
+     * @throws FrameworkException the framework exception
+     */
+    boolean isReference(Object bean, String beanName) throws FrameworkException;
+
+    /**
+     * if it is service bean ?
+     *
+     * @param bean     the bean
+     * @param beanName the bean name
+     * @return boolean boolean
+     * @throws FrameworkException the framework exception
+     */
+    boolean isService(Object bean, String beanName) throws FrameworkException;
+
+    /**
+     * get the remoting bean info
+     *
+     * @param bean     the bean
+     * @param beanName the bean name
+     * @return service desc
+     * @throws FrameworkException the framework exception
+     */
+    RemotingDesc getServiceDesc(Object bean, String beanName) throws FrameworkException;
+
+    /**
+     * the remoting protocol
+     *
+     * @return protocol
+     */
+    short getProtocol();
+
+
+}
diff --git a/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/parser/AbstractedRemotingParser.java b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/parser/AbstractedRemotingParser.java
new file mode 100644
index 000000000..cb708e333
--- /dev/null
+++ b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/parser/AbstractedRemotingParser.java
@@ -0,0 +1,35 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc.remoting.parser;
+
+import com.alibaba.fescar.common.exception.FrameworkException;
+import com.alibaba.fescar.rm.tcc.remoting.RemotingParser;
+
+/**
+ * The type Abstracted remoting parser.
+ *
+ * @author zhangsen
+ */
+public abstract class AbstractedRemotingParser implements RemotingParser {
+
+
+    @Override
+    public boolean isRemoting(Object bean, String beanName) throws FrameworkException {
+        return isReference(bean, beanName) || isService(bean, beanName);
+    }
+
+}
diff --git a/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/parser/DefaultRemotingParser.java b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/parser/DefaultRemotingParser.java
new file mode 100644
index 000000000..ee939b302
--- /dev/null
+++ b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/parser/DefaultRemotingParser.java
@@ -0,0 +1,215 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc.remoting.parser;
+
+import com.alibaba.fescar.common.exception.FrameworkException;
+import com.alibaba.fescar.common.loader.EnhancedServiceLoader;
+import com.alibaba.fescar.common.util.CollectionUtils;
+import com.alibaba.fescar.common.util.ReflectionUtil;
+import com.alibaba.fescar.rm.DefaultResourceManager;
+import com.alibaba.fescar.rm.tcc.TCCResource;
+import com.alibaba.fescar.rm.tcc.api.BusinessActionContext;
+import com.alibaba.fescar.rm.tcc.api.TwoPhaseBusinessAction;
+import com.alibaba.fescar.rm.tcc.remoting.RemotingDesc;
+import com.alibaba.fescar.rm.tcc.remoting.RemotingParser;
+
+import java.lang.reflect.Method;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * parsing remoting bean
+ *
+ * @author zhangsen
+ */
+public class DefaultRemotingParser {
+
+    /**
+     * all remoting bean parser
+     */
+    protected static List<RemotingParser> allRemotingParsers = new ArrayList<RemotingParser>();
+
+    /**
+     * all remoting beans beanName -> RemotingDesc
+     */
+    protected static Map<String, RemotingDesc> remotingServiceMap = new ConcurrentHashMap<String,RemotingDesc>();
+
+
+    /**
+     * 单实例
+     */
+    private static class SingletonHolder {
+        private static DefaultRemotingParser INSTANCE = new DefaultRemotingParser();
+    }
+
+    /**
+     * Get resource manager.
+     *
+     * @return the resource manager
+     */
+    public static DefaultRemotingParser get() {
+        return DefaultRemotingParser.SingletonHolder.INSTANCE;
+    }
+
+    /**
+     * Instantiates a new Default remoting parser.
+     */
+    protected DefaultRemotingParser(){
+        initRemotingParser();
+    }
+
+    /**
+     * init parsers
+     */
+    protected void initRemotingParser() {
+        //init all resource managers
+        List<RemotingParser> remotingParsers = EnhancedServiceLoader.loadAll(RemotingParser.class);
+        if(CollectionUtils.isNotEmpty(remotingParsers)){
+            allRemotingParsers.addAll(remotingParsers);
+        }
+    }
+
+    /**
+     * is remoting bean ?
+     *
+     * @param bean     the bean
+     * @param beanName the bean name
+     * @return boolean boolean
+     */
+    public boolean isRemoting(Object bean, String beanName) {
+        for(RemotingParser remotingParser : allRemotingParsers){
+            if(remotingParser.isRemoting(bean, beanName)){
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * is reference bean?
+     *
+     * @param bean     the bean
+     * @param beanName the bean name
+     * @return boolean boolean
+     */
+    public boolean isReference(Object bean, String beanName) {
+        for(RemotingParser remotingParser : allRemotingParsers){
+            if(remotingParser.isReference(bean, beanName)){
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * is service bean ?
+     *
+     * @param bean     the bean
+     * @param beanName the bean name
+     * @return boolean boolean
+     */
+    public boolean isService(Object bean, String beanName) {
+        for(RemotingParser remotingParser : allRemotingParsers){
+            if(remotingParser.isService(bean, beanName)){
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * get the remoting Service desc
+     *
+     * @param bean     the bean
+     * @param beanName the bean name
+     * @return service desc
+     */
+    public RemotingDesc getServiceDesc(Object bean, String beanName)  {
+        List<RemotingDesc>  ret = new ArrayList<RemotingDesc>();
+        for(RemotingParser remotingParser : allRemotingParsers){
+            RemotingDesc s = remotingParser.getServiceDesc(bean, beanName);
+            if(s != null){
+                ret.add(s);
+            }
+        }
+        if(ret.size() == 1){
+            return ret.get(0);
+        }else if(ret.size() > 1){
+            throw new FrameworkException("More than one RemotingParser for bean:" + beanName);
+        }else{
+            return null;
+        }
+    }
+
+    /**
+     * parse the remoting bean info
+     *
+     * @param bean     the bean
+     * @param beanName the bean name
+     * @return remoting desc
+     */
+    public RemotingDesc parserRemotingServiceInfo(Object bean, String beanName)  {
+        RemotingDesc remotingBeanDesc = getServiceDesc(bean, beanName);
+        if(remotingBeanDesc == null){
+            return null;
+        }
+        remotingServiceMap.put(beanName, remotingBeanDesc);
+
+        Class<?> interfaceClass = remotingBeanDesc.getInterfaceClass();
+        Method[] methods = interfaceClass.getMethods();
+        if(isService(bean, beanName)){
+            try {
+                //service bean， registry resource
+                Object targetBean = remotingBeanDesc.getTargetBean();
+                for(Method m : methods){
+                    TwoPhaseBusinessAction twoPhaseBusinessAction = m.getAnnotation(TwoPhaseBusinessAction.class);
+                    if(twoPhaseBusinessAction != null){
+                        //
+                        TCCResource tccResource = new TCCResource();
+                        tccResource.setActionName(twoPhaseBusinessAction.name());
+                        tccResource.setTargetBean(targetBean);
+                        tccResource.setPrepareMethod(m);
+                        tccResource.setCommitMethodName(twoPhaseBusinessAction.commitMethod());
+                        tccResource.setCommitMethod(ReflectionUtil.getMethod(interfaceClass, twoPhaseBusinessAction.commitMethod(), new Class[]{BusinessActionContext.class}));
+                        tccResource.setRollbackMethodName(twoPhaseBusinessAction.rollbackMethod());
+                        tccResource.setRollbackMethod(ReflectionUtil.getMethod(interfaceClass, twoPhaseBusinessAction.rollbackMethod(), new Class[]{BusinessActionContext.class}));
+                        //registry tcc resource
+                        DefaultResourceManager.get().registerResource(tccResource);
+                    }
+                }
+            }catch (Throwable t){
+                throw new FrameworkException(t, "parser remting service error");
+            }
+        }
+        if(isReference(bean, beanName)){
+            //reference bean， TCC proxy
+            remotingBeanDesc.setReference(true);
+        }
+        return remotingBeanDesc;
+    }
+
+    /**
+     * Get remoting bean desc remoting desc.
+     *
+     * @param beanName the bean name
+     * @return the remoting desc
+     */
+    public RemotingDesc getRemotingBeanDesc(String beanName){
+        return remotingServiceMap.get(beanName);
+    }
+
+}
diff --git a/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/parser/DubboRemotingParser.java b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/parser/DubboRemotingParser.java
new file mode 100644
index 000000000..fcb078ab4
--- /dev/null
+++ b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/parser/DubboRemotingParser.java
@@ -0,0 +1,81 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc.remoting.parser;
+
+import com.alibaba.fescar.common.exception.FrameworkException;
+import com.alibaba.fescar.common.util.ReflectionUtil;
+import com.alibaba.fescar.rm.tcc.remoting.Protocols;
+import com.alibaba.fescar.rm.tcc.remoting.RemotingDesc;
+
+/**
+ * dubbo  remoting bean parsing
+ *
+ * @author zhangsen
+ */
+public class DubboRemotingParser extends AbstractedRemotingParser {
+
+    @Override
+    public boolean isReference(Object bean, String beanName) throws FrameworkException {
+        Class<?> c = bean.getClass();
+        if("com.alibaba.dubbo.config.spring.ReferenceBean".equals(c.getName())
+                || "org.apache.dubbo.config.spring.ReferenceBean".equals(c.getName())){
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public boolean isService(Object bean, String beanName) throws FrameworkException {
+        Class<?> c = bean.getClass();
+        if("com.alibaba.dubbo.config.spring.ServiceBean".equals(c.getName())
+                || "org.apache.dubbo.config.spring.ServiceBean".equals(c.getName())){
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public RemotingDesc getServiceDesc(Object bean, String beanName) throws FrameworkException {
+        if(!this.isRemoting(bean, beanName)){
+            return null;
+        }
+        try{
+            RemotingDesc serviceBeanDesc = new RemotingDesc();
+            Class<?> interfaceClass = (Class<?>) ReflectionUtil.invokeMethod(bean, "getInterfaceClass");
+            String interfaceClassName = (String) ReflectionUtil.getFieldValue(bean, "interfaceName");
+            String version = (String) ReflectionUtil.invokeMethod(bean, "getVersion");
+            String group = (String)ReflectionUtil.invokeMethod(bean, "getGroup");
+            serviceBeanDesc.setInterfaceClass(interfaceClass);
+            serviceBeanDesc.setInterfaceClassName(interfaceClassName);
+            serviceBeanDesc.setUniqueId(version);
+            serviceBeanDesc.setGroup(group);
+            serviceBeanDesc.setProtocol(Protocols.DUBBO);
+            if(isService(bean, beanName)){
+                Object targetBean = ReflectionUtil.getFieldValue(bean, "ref");
+                serviceBeanDesc.setTargetBean(targetBean);
+            }
+            return serviceBeanDesc;
+        }catch (Throwable t){
+            throw new FrameworkException(t);
+        }
+    }
+
+    @Override
+    public short getProtocol() {
+        return Protocols.DUBBO;
+    }
+}
diff --git a/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/parser/DubboUtil.java b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/parser/DubboUtil.java
new file mode 100644
index 000000000..4dad5879d
--- /dev/null
+++ b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/parser/DubboUtil.java
@@ -0,0 +1,64 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc.remoting.parser;
+
+import com.alibaba.fescar.common.util.ReflectionUtil;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+
+/**
+ * dubbo attribute analysis
+ *
+ * @author zhangsen
+ */
+public class DubboUtil {
+
+    /**
+     * get the interface class of the dubbo proxy which be  generated by javaassist
+     *
+     * @param proxyBean the proxy bean
+     * @return the assist interface
+     * @throws NoSuchFieldException      the no such field exception
+     * @throws SecurityException         the security exception
+     * @throws IllegalArgumentException  the illegal argument exception
+     * @throws IllegalAccessException    the illegal access exception
+     * @throws NoSuchMethodException     the no such method exception
+     * @throws InvocationTargetException the invocation target exception
+     */
+    public static Class<?> getAssistInterface(Object proxyBean) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+		if(proxyBean == null){
+			return null;
+		}
+		if(!proxyBean.getClass().getName().startsWith("com.alibaba.dubbo.common.bytecode.proxy")
+				&&  !proxyBean.getClass().getName().startsWith("org.apache.dubbo.common.bytecode.proxy")){
+			return null;
+		}
+		Field handlerField=proxyBean.getClass().getDeclaredField("handler");  
+        handlerField.setAccessible(true);  
+        Object invokerInvocationHandler = handlerField.get(proxyBean);  
+        Field invokerField = invokerInvocationHandler.getClass().getDeclaredField("invoker");  
+        invokerField.setAccessible(true);  
+        Object invoker =  invokerField.get(invokerInvocationHandler);  
+        Field failoverClusterInvokerField=invoker.getClass().getDeclaredField("invoker");  
+        failoverClusterInvokerField.setAccessible(true);
+        Object failoverClusterInvoker = failoverClusterInvokerField.get(invoker);  
+        Class failoverClusterInvokerInterfaceClass = (Class) ReflectionUtil.invokeMethod(failoverClusterInvoker, "getInterface");
+        return failoverClusterInvokerInterfaceClass;
+	}
+
+}
diff --git a/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/parser/LocalTCCRemotingParser.java b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/parser/LocalTCCRemotingParser.java
new file mode 100644
index 000000000..685c7f58f
--- /dev/null
+++ b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/parser/LocalTCCRemotingParser.java
@@ -0,0 +1,83 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc.remoting.parser;
+
+import com.alibaba.fescar.common.exception.FrameworkException;
+import com.alibaba.fescar.common.util.ReflectionUtil;
+import com.alibaba.fescar.rm.tcc.api.LocalTCC;
+import com.alibaba.fescar.rm.tcc.remoting.Protocols;
+import com.alibaba.fescar.rm.tcc.remoting.RemotingDesc;
+
+import java.util.Set;
+
+/**
+ * local tcc bean parsing
+ *
+ * @author zhangsen
+ */
+public class LocalTCCRemotingParser extends AbstractedRemotingParser {
+
+    @Override
+    public boolean isReference(Object bean, String beanName)  {
+        Class<?> classType = bean.getClass();
+        Set<Class<?>> interfaceClasses = ReflectionUtil.getInterfaces(classType);
+        for(Class<?> interClass : interfaceClasses){
+            if(interClass.isAnnotationPresent(LocalTCC.class)){
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public boolean isService(Object bean, String beanName) {
+        Class<?> classType = bean.getClass();
+        Set<Class<?>> interfaceClasses = ReflectionUtil.getInterfaces(classType);
+        for(Class<?> interClass : interfaceClasses){
+            if(interClass.isAnnotationPresent(LocalTCC.class)){
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public RemotingDesc getServiceDesc(Object bean, String beanName) throws FrameworkException {
+        if(!this.isRemoting(bean, beanName)){
+            return null;
+        }
+        RemotingDesc remotingDesc = new RemotingDesc();
+        remotingDesc.setReference(true);
+        remotingDesc.setProtocol(Protocols.IN_JVM);
+        Class<?> classType = bean.getClass();
+        Set<Class<?>> interfaceClasses = ReflectionUtil.getInterfaces(classType);
+        for(Class<?> interClass : interfaceClasses){
+            if(interClass.isAnnotationPresent(LocalTCC.class)){
+                remotingDesc.setInterfaceClassName(interClass.getName());
+                remotingDesc.setInterfaceClass(interClass);
+                remotingDesc.setTargetBean(bean);
+                return remotingDesc;
+            }
+        }
+        throw new FrameworkException("Couldn't parser any Remoting info");
+    }
+
+    @Override
+    public short getProtocol() {
+        return Protocols.IN_JVM;
+    }
+}
diff --git a/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/parser/SofaRpcRemotingParser.java b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/parser/SofaRpcRemotingParser.java
new file mode 100644
index 000000000..287047a55
--- /dev/null
+++ b/tcc/src/main/java/com/alibaba/fescar/rm/tcc/remoting/parser/SofaRpcRemotingParser.java
@@ -0,0 +1,92 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc.remoting.parser;
+
+import com.alibaba.fescar.common.exception.FrameworkException;
+import com.alibaba.fescar.common.util.ReflectionUtil;
+import com.alibaba.fescar.rm.tcc.remoting.Protocols;
+import com.alibaba.fescar.rm.tcc.remoting.RemotingDesc;
+
+/**
+ * sofa-rpc remoting bean parsing
+ *
+ * @author zhangsen
+ */
+public class SofaRpcRemotingParser extends AbstractedRemotingParser {
+
+    /**
+     * is reference bean ?
+     * @param bean
+     * @param beanName
+     * @return
+     * @throws FrameworkException
+     */
+    @Override
+    public boolean isReference(Object bean, String beanName)
+            throws FrameworkException {
+		String beanClassName = bean.getClass().getName();
+        if("com.alipay.sofa.runtime.spring.factory.ReferenceFactoryBean".equals(beanClassName) ){
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * is service bean ?
+     * @param bean
+     * @param beanName
+     * @return
+     * @throws FrameworkException
+     */
+    @Override
+    public boolean isService(Object bean, String beanName) 	throws FrameworkException {
+		String beanClassName = bean.getClass().getName();
+        if("com.alipay.sofa.runtime.spring.factory.ServiceFactoryBean".equals(beanClassName) ){
+            return true;
+        }
+        return false;
+    }
+
+    @Override
+    public RemotingDesc getServiceDesc(Object bean, String beanName) throws FrameworkException {
+        if(!this.isRemoting(bean, beanName)){
+            return null;
+        }
+        try{
+            RemotingDesc serviceBeanDesc = new RemotingDesc();
+            Class<?> interfaceClass = (Class<?>) ReflectionUtil.invokeMethod(bean, "getInterfaceClass");
+            String interfaceClassName = (String) ReflectionUtil.getFieldValue(bean, "interfaceType");
+            String uniqueId = (String) ReflectionUtil.getFieldValue(bean, "uniqueId");
+            serviceBeanDesc.setInterfaceClass(interfaceClass);
+            serviceBeanDesc.setInterfaceClassName(interfaceClassName);
+            serviceBeanDesc.setUniqueId(uniqueId);
+            serviceBeanDesc.setProtocol(Protocols.SOFA_RPC);
+            if(isService(bean, beanName)){
+                Object targetBean = ReflectionUtil.getFieldValue(bean, "ref");
+                serviceBeanDesc.setTargetBean(targetBean);
+            }
+            return serviceBeanDesc;
+        }catch (Throwable t){
+            throw new FrameworkException(t);
+        }
+    }
+
+    @Override
+    public short getProtocol() {
+        return Protocols.SOFA_RPC;
+    }
+}
diff --git a/tcc/src/main/resources/META-INF/services/com.alibaba.fescar.core.model.ResourceManager b/tcc/src/main/resources/META-INF/services/com.alibaba.fescar.core.model.ResourceManager
new file mode 100644
index 000000000..03abe02f8
--- /dev/null
+++ b/tcc/src/main/resources/META-INF/services/com.alibaba.fescar.core.model.ResourceManager
@@ -0,0 +1,1 @@
+com.alibaba.fescar.rm.tcc.TCCResourceManager
diff --git a/tcc/src/main/resources/META-INF/services/com.alibaba.fescar.rm.AbstractRMHandler b/tcc/src/main/resources/META-INF/services/com.alibaba.fescar.rm.AbstractRMHandler
new file mode 100644
index 000000000..f44ce7567
--- /dev/null
+++ b/tcc/src/main/resources/META-INF/services/com.alibaba.fescar.rm.AbstractRMHandler
@@ -0,0 +1,1 @@
+com.alibaba.fescar.rm.tcc.RMHandlerTCC
\ No newline at end of file
diff --git a/tcc/src/main/resources/META-INF/services/com.alibaba.fescar.rm.tcc.remoting.RemotingParser b/tcc/src/main/resources/META-INF/services/com.alibaba.fescar.rm.tcc.remoting.RemotingParser
new file mode 100644
index 000000000..abfe7ffdd
--- /dev/null
+++ b/tcc/src/main/resources/META-INF/services/com.alibaba.fescar.rm.tcc.remoting.RemotingParser
@@ -0,0 +1,3 @@
+com.alibaba.fescar.rm.tcc.remoting.parser.DubboRemotingParser
+com.alibaba.fescar.rm.tcc.remoting.parser.LocalTCCRemotingParser
+com.alibaba.fescar.rm.tcc.remoting.parser.SofaRpcRemotingParser
\ No newline at end of file


Test patch:
diff --git a/core/src/test/java/com/alibaba/fescar/core/message/BranchCommitRequestTest.java b/core/src/test/java/com/alibaba/fescar/core/message/BranchCommitRequestTest.java
index 6263414e0..7cba6d44a 100644
--- a/core/src/test/java/com/alibaba/fescar/core/message/BranchCommitRequestTest.java
+++ b/core/src/test/java/com/alibaba/fescar/core/message/BranchCommitRequestTest.java
@@ -18,6 +18,8 @@ package com.alibaba.fescar.core.message;
 import com.alibaba.fescar.core.model.BranchType;
 import com.alibaba.fescar.core.protocol.transaction.BranchCommitRequest;
 
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.UnpooledByteBufAllocator;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -48,4 +50,29 @@ public class BranchCommitRequestTest {
             + "resourceId=resource1,applicationData=app1", branchCommitRequest.toString());
 
     }
+
+    @Test
+    public void testDecode(){
+        BranchCommitRequest branchCommitRequest = new BranchCommitRequest();
+
+        branchCommitRequest.setXid("127.0.0.1:9999:39875642");
+        branchCommitRequest.setBranchId(1);
+        branchCommitRequest.setBranchType(BranchType.TCC);
+        branchCommitRequest.setResourceId("resource1");
+        branchCommitRequest.setApplicationData("app1");
+
+        byte[] encodeResult = branchCommitRequest.encode();
+
+        ByteBuf byteBuffer = UnpooledByteBufAllocator.DEFAULT.directBuffer(encodeResult.length);
+        byteBuffer.writeBytes(encodeResult);
+
+        BranchCommitRequest decodeBranchCommitRequest = new BranchCommitRequest();
+        decodeBranchCommitRequest.decode(byteBuffer);
+        System.out.println(decodeBranchCommitRequest);
+        Assert.assertEquals(decodeBranchCommitRequest.getXid(), decodeBranchCommitRequest.getXid());
+        Assert.assertEquals(decodeBranchCommitRequest.getBranchId(), decodeBranchCommitRequest.getBranchId());
+        Assert.assertEquals(decodeBranchCommitRequest.getResourceId(), decodeBranchCommitRequest.getResourceId());
+        Assert.assertEquals(decodeBranchCommitRequest.getApplicationData(), decodeBranchCommitRequest.getApplicationData());
+        Assert.assertEquals(decodeBranchCommitRequest.getBranchType(), decodeBranchCommitRequest.getBranchType());
+    }
 }
\ No newline at end of file
diff --git a/core/src/test/java/com/alibaba/fescar/core/message/BranchRegisterRequestTest.java b/core/src/test/java/com/alibaba/fescar/core/message/BranchRegisterRequestTest.java
index 84ef9e8ca..8b16d74b3 100644
--- a/core/src/test/java/com/alibaba/fescar/core/message/BranchRegisterRequestTest.java
+++ b/core/src/test/java/com/alibaba/fescar/core/message/BranchRegisterRequestTest.java
@@ -13,6 +13,7 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
+
 package com.alibaba.fescar.core.message;
 
 import com.alibaba.fescar.core.model.BranchType;
@@ -21,6 +22,8 @@ import com.alibaba.fescar.core.protocol.transaction.BranchRegisterRequest;
 import org.junit.Assert;
 import org.junit.Test;
 
+import java.nio.ByteBuffer;
+
 /**
  * The type Branch register request test.
  *
@@ -48,4 +51,35 @@ public class BranchRegisterRequestTest {
             branchRegisterRequest.toString());
 
     }
+
+
+    /**
+     * Test decode.
+     *
+     * @throws Exception the exception
+     */
+    @Test
+    public void testDecode() throws Exception {
+        BranchRegisterRequest branchRegisterRequest = new BranchRegisterRequest();
+
+        branchRegisterRequest.setTransactionId(123456);
+        branchRegisterRequest.setBranchType(BranchType.AT);
+        branchRegisterRequest.setResourceId("resource1");
+        branchRegisterRequest.setLockKey("lock_key_1");
+        branchRegisterRequest.setApplicationData("test app data");
+
+        byte[] encodeResult = branchRegisterRequest.encode();
+
+        ByteBuffer byteBuffer = ByteBuffer.allocate(encodeResult.length);
+        byteBuffer.put(encodeResult);
+        byteBuffer.flip();
+
+        BranchRegisterRequest decodeBranchRegisterRequest = new BranchRegisterRequest();
+        decodeBranchRegisterRequest.decode(byteBuffer);
+        System.out.println(decodeBranchRegisterRequest);
+        Assert.assertEquals(branchRegisterRequest.getTransactionId(), decodeBranchRegisterRequest.getTransactionId());
+        Assert.assertEquals(branchRegisterRequest.getLockKey(), decodeBranchRegisterRequest.getLockKey());
+        Assert.assertEquals(branchRegisterRequest.getResourceId(), decodeBranchRegisterRequest.getResourceId());
+        Assert.assertEquals(branchRegisterRequest.getApplicationData(), decodeBranchRegisterRequest.getApplicationData());
+    }
 }
diff --git a/core/src/test/java/com/alibaba/fescar/core/message/BranchReportRequestTest.java b/core/src/test/java/com/alibaba/fescar/core/message/BranchReportRequestTest.java
index 5af99f8e0..f808c4605 100644
--- a/core/src/test/java/com/alibaba/fescar/core/message/BranchReportRequestTest.java
+++ b/core/src/test/java/com/alibaba/fescar/core/message/BranchReportRequestTest.java
@@ -19,6 +19,7 @@ import java.nio.ByteBuffer;
 import java.util.Arrays;
 
 import com.alibaba.fescar.core.model.BranchStatus;
+import com.alibaba.fescar.core.model.BranchType;
 import com.alibaba.fescar.core.protocol.transaction.BranchReportRequest;
 
 import org.junit.Assert;
@@ -75,7 +76,7 @@ public class BranchReportRequestTest {
 
         Assert.assertEquals(
             "[0, 0, 0, 0, 0, 19, 18, 61, 0, 0, 0, 0, 0, 0, 0, 3, 4, 0, 11, 114, 101, 115, 111, 117, 114, 99, 101, 48,"
-                + " 48, 51, 0, 0, 0, 13, 116, 101, 115, 116, 32, 97, 112, 112, 32, 100, 97, 116, 97]",
+                + " 48, 51, 0, 0, 0, 13, 116, 101, 115, 116, 32, 97, 112, 112, 32, 100, 97, 116, 97, 0]",
             encodeResultStr);
     }
 
@@ -93,6 +94,7 @@ public class BranchReportRequestTest {
         branchReportRequest.setResourceId("resource003");
         branchReportRequest.setStatus(BranchStatus.PhaseOne_Timeout);
         branchReportRequest.setApplicationData("test app data");
+        branchReportRequest.setBranchType(BranchType.AT);
 
         byte[] encodeResult = branchReportRequest.encode();
 
@@ -108,5 +110,6 @@ public class BranchReportRequestTest {
         Assert.assertEquals(branchReportRequest.getResourceId(), decodeBranchReportRequest.getResourceId());
         Assert.assertEquals(branchReportRequest.getStatus(), decodeBranchReportRequest.getStatus());
         Assert.assertEquals(branchReportRequest.getApplicationData(), decodeBranchReportRequest.getApplicationData());
+        Assert.assertEquals(branchReportRequest.getBranchType(), decodeBranchReportRequest.getBranchType());
     }
 }
\ No newline at end of file
diff --git a/server/src/test/java/com/alibaba/fescar/server/coordinator/DefaultCoreTest.java b/server/src/test/java/com/alibaba/fescar/server/coordinator/DefaultCoreTest.java
index 83c9abcbf..e32aa11ab 100644
--- a/server/src/test/java/com/alibaba/fescar/server/coordinator/DefaultCoreTest.java
+++ b/server/src/test/java/com/alibaba/fescar/server/coordinator/DefaultCoreTest.java
@@ -77,7 +77,7 @@ public class DefaultCoreTest {
      */
     @Test(dataProvider = "xidProvider")
     public void branchRegisterTest(String xid) throws Exception {
-        core.branchRegister(BranchType.AT, resourceId, clientId, xid, lockKeys_1);
+        core.branchRegister(BranchType.AT, resourceId, clientId, xid, "abc", lockKeys_1);
 
         long transactionId = XID.getTransactionId(xid);
         GlobalSession globalSession = SessionHolder.findGlobalSession(transactionId);
@@ -93,7 +93,7 @@ public class DefaultCoreTest {
      */
     @Test(dataProvider = "xidAndBranchIdProvider")
     public void branchReportTest(String xid, Long branchId) throws Exception {
-        core.branchReport(xid, branchId, BranchStatus.PhaseOne_Done, applicationData);
+        core.branchReport(BranchType.AT, xid, branchId, BranchStatus.PhaseOne_Done, applicationData);
 
         long transactionId = XID.getTransactionId(xid);
         GlobalSession globalSession = SessionHolder.findGlobalSession(transactionId);
@@ -186,7 +186,7 @@ public class DefaultCoreTest {
     @DataProvider
     public static Object[][] xidAndBranchIdProvider() throws Exception {
         String xid = core.begin(applicationId, txServiceGroup, txName, timeout);
-        Long branchId = core.branchRegister(BranchType.AT, resourceId, clientId, xid, lockKeys_2);
+        Long branchId = core.branchRegister(BranchType.AT, resourceId, clientId, xid, null, lockKeys_2);
         return new Object[][] {{xid, branchId}};
     }
 
diff --git a/spring/src/test/java/com/alibaba/fescar/spring/annotation/Business.java b/spring/src/test/java/com/alibaba/fescar/spring/annotation/Business.java
index f6d9e7197..3d9a636da 100644
--- a/spring/src/test/java/com/alibaba/fescar/spring/annotation/Business.java
+++ b/spring/src/test/java/com/alibaba/fescar/spring/annotation/Business.java
@@ -16,6 +16,15 @@
 
 package com.alibaba.fescar.spring.annotation;
 
+/**
+ * The interface Business.
+ */
 public interface Business {
+    /**
+     * Do biz string.
+     *
+     * @param msg the msg
+     * @return the string
+     */
     String doBiz(String msg);
 }
diff --git a/spring/src/test/java/com/alibaba/fescar/spring/annotation/BusinessImpl.java b/spring/src/test/java/com/alibaba/fescar/spring/annotation/BusinessImpl.java
index 5f87ac928..e0e0668bb 100644
--- a/spring/src/test/java/com/alibaba/fescar/spring/annotation/BusinessImpl.java
+++ b/spring/src/test/java/com/alibaba/fescar/spring/annotation/BusinessImpl.java
@@ -19,6 +19,9 @@ package com.alibaba.fescar.spring.annotation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+/**
+ * The type Business.
+ */
 public class BusinessImpl implements Business {
     private static final Logger LOGGER = LoggerFactory.getLogger(BusinessImpl.class);
 
diff --git a/spring/src/test/java/com/alibaba/fescar/spring/annotation/GlobalTransactionScannerTest.java b/spring/src/test/java/com/alibaba/fescar/spring/annotation/GlobalTransactionScannerTest.java
index 88ccd2648..ac393b2dd 100644
--- a/spring/src/test/java/com/alibaba/fescar/spring/annotation/GlobalTransactionScannerTest.java
+++ b/spring/src/test/java/com/alibaba/fescar/spring/annotation/GlobalTransactionScannerTest.java
@@ -16,6 +16,10 @@
 
 package com.alibaba.fescar.spring.annotation;
 
+import com.alibaba.fescar.spring.tcc.LocalTccAction;
+import com.alibaba.fescar.spring.tcc.LocalTccActionImpl;
+import com.alibaba.fescar.spring.tcc.TccAction;
+import com.alibaba.fescar.spring.tcc.TccActionImpl;
 import org.testng.Assert;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
@@ -24,25 +28,94 @@ import org.testng.annotations.Test;
  * GlobalTransactionScanner Unit Test
  */
 public class GlobalTransactionScannerTest {
-    private GlobalTransactionScanner globalTransactionScanner = new GlobalTransactionScanner(
-        "global-trans-scanner-test");
+    /**
+     * The Global transaction scanner.
+     */
+    protected GlobalTransactionScanner globalTransactionScanner = new GlobalTransactionScanner("global-trans-scanner-test");
 
+    /**
+     * Test wrap normal bean.
+     *
+     * @param bean the bean
+     * @param beanName the bean name
+     * @param cacheKey the cache key
+     */
     @Test(dataProvider = "normalBeanProvider")
     public void testWrapNormalBean(Object bean, String beanName, Object cacheKey) {
         Object result = globalTransactionScanner.wrapIfNecessary(bean, beanName, cacheKey);
         Assert.assertNotSame(result, bean);
     }
 
+    /**
+     * wrap nothing
+     *
+     * @param bean the bean
+     * @param beanName the bean name
+     * @param cacheKey the cache key
+     */
+    @Test(dataProvider = "normalTccBeanProvider")
+    public void testWrapNormalTccBean(Object bean, String beanName, Object cacheKey){
+        Object result = globalTransactionScanner.wrapIfNecessary(bean, beanName, cacheKey);
+        Assert.assertSame(result, bean);
+    }
+
+    /**
+     * wrapped
+     *
+     * @param bean the bean
+     * @param beanName the bean name
+     * @param cacheKey the cache key
+     */
+    @Test(dataProvider = "localTccBeanProvider")
+    public void testWrapLocalTccBean(Object bean, String beanName, Object cacheKey){
+        TccAction result = (LocalTccAction) globalTransactionScanner.wrapIfNecessary(bean, beanName, cacheKey);
+        Assert.assertNotSame(result, bean);
+    }
+
+    /**
+     * Test after properties set.
+     */
     @Test
     public void testAfterPropertiesSet() {
         globalTransactionScanner.afterPropertiesSet();
     }
 
+    /**
+     * Normal bean provider object [ ] [ ].
+     *
+     * @return the object [ ] [ ]
+     */
     @DataProvider
     public static Object[][] normalBeanProvider() {
         Business business = new BusinessImpl();
         String beanName = "business";
         String cacheKey = "business-key";
-        return new Object[][] {{business, beanName, cacheKey}};
+        return new Object[][]{{business, beanName, cacheKey}};
+    }
+
+    /**
+     * Normal tcc bean provider object [ ] [ ].
+     *
+     * @return the object [ ] [ ]
+     */
+    @DataProvider
+    public static Object[][] normalTccBeanProvider() {
+        TccAction tccAction = new TccActionImpl();
+        String beanName = "tccBean";
+        String cacheKey = "tccBean-key";
+        return new Object[][]{{tccAction, beanName, cacheKey}};
+    }
+
+    /**
+     * Local tcc bean provider object [ ] [ ].
+     *
+     * @return the object [ ] [ ]
+     */
+    @DataProvider
+    public static Object[][] localTccBeanProvider() {
+        LocalTccAction localTccAction = new LocalTccActionImpl();
+        String beanName = "lcoalTccBean";
+        String cacheKey = "lcoalTccBean-key";
+        return new Object[][]{{localTccAction, beanName, cacheKey}};
     }
 }
diff --git a/spring/src/test/java/com/alibaba/fescar/spring/tcc/LocalTccAction.java b/spring/src/test/java/com/alibaba/fescar/spring/tcc/LocalTccAction.java
new file mode 100644
index 000000000..ca06a6124
--- /dev/null
+++ b/spring/src/test/java/com/alibaba/fescar/spring/tcc/LocalTccAction.java
@@ -0,0 +1,28 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.spring.tcc;
+
+import com.alibaba.fescar.rm.tcc.api.LocalTCC;
+
+/**
+ * The interface Local tcc action.
+ *
+ * @author zhangsen
+ */
+@LocalTCC
+public interface LocalTccAction extends TccAction {
+}
diff --git a/spring/src/test/java/com/alibaba/fescar/spring/tcc/LocalTccActionImpl.java b/spring/src/test/java/com/alibaba/fescar/spring/tcc/LocalTccActionImpl.java
new file mode 100644
index 000000000..cfacac4c8
--- /dev/null
+++ b/spring/src/test/java/com/alibaba/fescar/spring/tcc/LocalTccActionImpl.java
@@ -0,0 +1,26 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.spring.tcc;
+
+/**
+ * The type Local tcc action.
+ *
+ * @author zhangsen
+ */
+public class LocalTccActionImpl extends TccActionImpl implements LocalTccAction {
+
+}
diff --git a/spring/src/test/java/com/alibaba/fescar/spring/tcc/TccAction.java b/spring/src/test/java/com/alibaba/fescar/spring/tcc/TccAction.java
new file mode 100644
index 000000000..4f133cfe8
--- /dev/null
+++ b/spring/src/test/java/com/alibaba/fescar/spring/tcc/TccAction.java
@@ -0,0 +1,54 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.spring.tcc;
+
+import com.alibaba.fescar.rm.tcc.api.BusinessActionContext;
+import com.alibaba.fescar.rm.tcc.api.TwoPhaseBusinessAction;
+
+/**
+ * The interface Tcc action.
+ *
+ * @author zhangsen
+ */
+public interface TccAction {
+
+    /**
+     * Prepare boolean.
+     *
+     * @param actionContext the action context
+     * @param i the
+     * @return the boolean
+     */
+    @TwoPhaseBusinessAction(name = "tccActionForSpringTest" , commitMethod = "commit", rollbackMethod = "rollback")
+    public boolean prepare(BusinessActionContext actionContext, int i);
+
+    /**
+     * Commit boolean.
+     *
+     * @param actionContext the action context
+     * @return the boolean
+     */
+    public boolean commit(BusinessActionContext actionContext);
+
+    /**
+     * Rollback boolean.
+     *
+     * @param actionContext the action context
+     * @return the boolean
+     */
+    public boolean rollback(BusinessActionContext actionContext);
+}
diff --git a/spring/src/test/java/com/alibaba/fescar/spring/tcc/TccActionImpl.java b/spring/src/test/java/com/alibaba/fescar/spring/tcc/TccActionImpl.java
new file mode 100644
index 000000000..2e238bb9f
--- /dev/null
+++ b/spring/src/test/java/com/alibaba/fescar/spring/tcc/TccActionImpl.java
@@ -0,0 +1,42 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.spring.tcc;
+
+import com.alibaba.fescar.rm.tcc.api.BusinessActionContext;
+
+/**
+ * The type Tcc action.
+ *
+ * @author zhangsen
+ */
+public class TccActionImpl implements TccAction {
+
+    @Override
+    public boolean prepare(BusinessActionContext actionContext, int i) {
+        return true;
+    }
+
+    @Override
+    public boolean commit(BusinessActionContext actionContext) {
+        return true;
+    }
+
+    @Override
+    public boolean rollback(BusinessActionContext actionContext) {
+        return true;
+    }
+}
diff --git a/tcc/src/test/java/com/alibaba/fescar/rm/tcc/TccAction.java b/tcc/src/test/java/com/alibaba/fescar/rm/tcc/TccAction.java
new file mode 100644
index 000000000..1653a5dee
--- /dev/null
+++ b/tcc/src/test/java/com/alibaba/fescar/rm/tcc/TccAction.java
@@ -0,0 +1,64 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc;
+
+import com.alibaba.fescar.rm.tcc.api.BusinessActionContext;
+import com.alibaba.fescar.rm.tcc.api.BusinessActionContextParameter;
+import com.alibaba.fescar.rm.tcc.api.LocalTCC;
+import com.alibaba.fescar.rm.tcc.api.TwoPhaseBusinessAction;
+
+import java.util.List;
+
+/**
+ * The interface Tcc action.
+ *
+ * @author zhangsen
+ */
+@LocalTCC
+public interface TccAction {
+
+    /**
+     * Prepare boolean.
+     *
+     * @param actionContext the action context
+     * @param a             the a
+     * @param b             the b
+     * @param tccParam      the tcc param
+     * @return the boolean
+     */
+    @TwoPhaseBusinessAction(name = "tccActionForTest" , commitMethod = "commit", rollbackMethod = "rollback")
+    public boolean prepare(BusinessActionContext actionContext,
+                           @BusinessActionContextParameter(paramName = "a") int a,
+                           @BusinessActionContextParameter(paramName = "b", index = 0) List b,
+                           @BusinessActionContextParameter(isParamInProperty = true) TccParam tccParam);
+
+    /**
+     * Commit boolean.
+     *
+     * @param actionContext the action context
+     * @return the boolean
+     */
+    public boolean commit(BusinessActionContext actionContext);
+
+    /**
+     * Rollback boolean.
+     *
+     * @param actionContext the action context
+     * @return the boolean
+     */
+    public boolean rollback(BusinessActionContext actionContext);
+}
diff --git a/tcc/src/test/java/com/alibaba/fescar/rm/tcc/TccActionImpl.java b/tcc/src/test/java/com/alibaba/fescar/rm/tcc/TccActionImpl.java
new file mode 100644
index 000000000..ee0b18390
--- /dev/null
+++ b/tcc/src/test/java/com/alibaba/fescar/rm/tcc/TccActionImpl.java
@@ -0,0 +1,47 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc;
+
+import com.alibaba.fescar.rm.tcc.api.BusinessActionContext;
+
+import java.util.List;
+
+/**
+ * The type Tcc action.
+ *
+ * @author zhangsen
+ */
+public class TccActionImpl implements TccAction {
+
+    @Override
+    public boolean prepare(BusinessActionContext actionContext,
+                           int a,
+                           List b,
+                           TccParam TccParam  ) {
+        return true;
+    }
+
+    @Override
+    public boolean commit(BusinessActionContext actionContext) {
+        return true;
+    }
+
+    @Override
+    public boolean rollback(BusinessActionContext actionContext) {
+        return true;
+    }
+}
diff --git a/tcc/src/test/java/com/alibaba/fescar/rm/tcc/TccParam.java b/tcc/src/test/java/com/alibaba/fescar/rm/tcc/TccParam.java
new file mode 100644
index 000000000..f7befb023
--- /dev/null
+++ b/tcc/src/test/java/com/alibaba/fescar/rm/tcc/TccParam.java
@@ -0,0 +1,67 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc;
+
+import com.alibaba.fescar.rm.tcc.api.BusinessActionContextParameter;
+
+/**
+ * The type Tcc param.
+ *
+ * @author zhangsen
+ */
+public class TccParam {
+
+    /**
+     * The Num.
+     */
+    protected int num;
+
+    /**
+     * The Email.
+     */
+    @BusinessActionContextParameter(paramName = "email")
+    protected String email;
+
+    /**
+     * Instantiates a new Tcc param.
+     *
+     * @param num   the num
+     * @param email the email
+     */
+    public TccParam(int num, String email) {
+        this.num = num;
+        this.email = email;
+    }
+
+    /**
+     * Gets num.
+     *
+     * @return the num
+     */
+    public int getNum() {
+        return num;
+    }
+
+    /**
+     * Sets num.
+     *
+     * @param num the num
+     */
+    public void setNum(int num) {
+        this.num = num;
+    }
+}
diff --git a/tcc/src/test/java/com/alibaba/fescar/rm/tcc/interceptor/ActionInterceptorHandlerTest.java b/tcc/src/test/java/com/alibaba/fescar/rm/tcc/interceptor/ActionInterceptorHandlerTest.java
new file mode 100644
index 000000000..b666e80fd
--- /dev/null
+++ b/tcc/src/test/java/com/alibaba/fescar/rm/tcc/interceptor/ActionInterceptorHandlerTest.java
@@ -0,0 +1,64 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc.interceptor;
+
+import com.alibaba.fescar.rm.tcc.TccAction;
+import com.alibaba.fescar.rm.tcc.TccParam;
+import com.alibaba.fescar.rm.tcc.api.BusinessActionContext;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The type Action interceptor handler test.
+ *
+ * @author zhangsen
+ */
+public class ActionInterceptorHandlerTest {
+
+    /**
+     * The Action interceptor handler.
+     */
+    protected  ActionInterceptorHandler actionInterceptorHandler = new ActionInterceptorHandler();
+
+    /**
+     * Test business action context.
+     *
+     * @throws NoSuchMethodException the no such method exception
+     */
+    @Test
+    public void testBusinessActionContext() throws NoSuchMethodException {
+        Method prepareMethod = TccAction.class.getDeclaredMethod("prepare",
+                new Class[]{BusinessActionContext.class, int.class, List.class, TccParam.class});
+        List list = new ArrayList();
+        list.add("b");
+        TccParam tccParam = new TccParam (1, "abc@ali.com");
+
+        Map<String, Object>  paramContext = actionInterceptorHandler.fetchActionRequestContext(prepareMethod,
+                new Object[]{null, 10, list, tccParam});
+        System.out.println(paramContext);
+
+        Assert.assertEquals(10, paramContext.get("a"));
+        Assert.assertEquals("b", paramContext.get("b"));
+        Assert.assertEquals("abc@ali.com", paramContext.get("email"));
+    }
+
+}
\ No newline at end of file
diff --git a/tcc/src/test/java/com/alibaba/fescar/rm/tcc/remoting/parser/LocalTCCRemotingParserTest.java b/tcc/src/test/java/com/alibaba/fescar/rm/tcc/remoting/parser/LocalTCCRemotingParserTest.java
new file mode 100644
index 000000000..8737d9875
--- /dev/null
+++ b/tcc/src/test/java/com/alibaba/fescar/rm/tcc/remoting/parser/LocalTCCRemotingParserTest.java
@@ -0,0 +1,75 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.rm.tcc.remoting.parser;
+
+import com.alibaba.fescar.rm.tcc.TccAction;
+import com.alibaba.fescar.rm.tcc.TccActionImpl;
+import com.alibaba.fescar.rm.tcc.remoting.RemotingDesc;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+/**
+ * The type Local tcc remoting parser test.
+ *
+ * @author zhangsen
+ */
+public class LocalTCCRemotingParserTest {
+
+    /**
+     * The Local tcc remoting parser.
+     */
+    LocalTCCRemotingParser localTCCRemotingParser = new LocalTCCRemotingParser();
+
+    /**
+     * Test service parser.
+     */
+    @Test
+    public void testServiceParser(){
+        TccActionImpl tccAction = new TccActionImpl();
+
+        boolean result = localTCCRemotingParser.isService(tccAction, "a");
+        Assert.assertTrue(result);
+    }
+
+    /**
+     * Test reference parser.
+     */
+    @Test
+    public void testReferenceParser(){
+        TccActionImpl tccAction = new TccActionImpl();
+
+        boolean result = localTCCRemotingParser.isReference(tccAction, "b");
+        Assert.assertTrue(result);
+    }
+
+    /**
+     * Test service desc.
+     */
+    @Test
+    public void testServiceDesc(){
+        TccActionImpl tccAction = new TccActionImpl();
+
+        RemotingDesc remotingDesc = localTCCRemotingParser.getServiceDesc(tccAction, "c");
+        Assert.assertNotNull(remotingDesc);
+
+        Assert.assertEquals(remotingDesc.getInterfaceClassName(), "com.alibaba.fescar.rm.tcc.TccAction");
+        Assert.assertEquals(remotingDesc.getInterfaceClass(), TccAction.class);
+        Assert.assertEquals(remotingDesc.getTargetBean(), tccAction);
+    }
+
+}
\ No newline at end of file
diff --git a/test/src/main/java/com/alibaba/fescar/common/loader/LoaderTestImpl1.java b/test/src/main/java/com/alibaba/fescar/common/loader/LoaderTestImpl1.java
new file mode 100644
index 000000000..dd960d763
--- /dev/null
+++ b/test/src/main/java/com/alibaba/fescar/common/loader/LoaderTestImpl1.java
@@ -0,0 +1,28 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.common.loader;
+
+/**
+ * @author zhangsen
+ */
+@LoadLevel(name = "one", order = 1)
+public class LoaderTestImpl1 implements LoaderTestSPI {
+    @Override
+    public String echo() {
+        return "impl_1";
+    }
+}
diff --git a/test/src/main/java/com/alibaba/fescar/common/loader/LoaderTestImpl2.java b/test/src/main/java/com/alibaba/fescar/common/loader/LoaderTestImpl2.java
new file mode 100644
index 000000000..8984adaee
--- /dev/null
+++ b/test/src/main/java/com/alibaba/fescar/common/loader/LoaderTestImpl2.java
@@ -0,0 +1,28 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.common.loader;
+
+/**
+ * @author zhangsen
+ */
+@LoadLevel(name = "two", order = 2)
+public class LoaderTestImpl2 implements LoaderTestSPI {
+    @Override
+    public String echo() {
+        return "impl_2";
+    }
+}
diff --git a/test/src/main/java/com/alibaba/fescar/common/loader/LoaderTestSPI.java b/test/src/main/java/com/alibaba/fescar/common/loader/LoaderTestSPI.java
new file mode 100644
index 000000000..7198d40ce
--- /dev/null
+++ b/test/src/main/java/com/alibaba/fescar/common/loader/LoaderTestSPI.java
@@ -0,0 +1,25 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.common.loader;
+
+/**
+ * @author zhangsen
+ */
+public interface LoaderTestSPI {
+
+    String echo();
+}
diff --git a/test/src/main/java/com/alibaba/fescar/test/DataSourceBasicTest.java b/test/src/main/java/com/alibaba/fescar/test/DataSourceBasicTest.java
index 63d069c0c..bcee1e6c8 100644
--- a/test/src/main/java/com/alibaba/fescar/test/DataSourceBasicTest.java
+++ b/test/src/main/java/com/alibaba/fescar/test/DataSourceBasicTest.java
@@ -16,15 +16,12 @@
 
 package com.alibaba.fescar.test;
 
-import java.util.Date;
-
 import com.alibaba.fescar.core.context.RootContext;
 import com.alibaba.fescar.core.exception.TransactionException;
 import com.alibaba.fescar.core.model.BranchStatus;
 import com.alibaba.fescar.core.model.BranchType;
 import com.alibaba.fescar.core.model.Resource;
 import com.alibaba.fescar.rm.datasource.DataSourceManager;
-
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Ignore;
@@ -32,6 +29,8 @@ import org.junit.Test;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 import org.springframework.jdbc.core.JdbcTemplate;
 
+import java.util.Date;
+
 /**
  * The type Data source basic test.
  */
@@ -129,12 +128,12 @@ public class DataSourceBasicTest {
 
             @Override
             public Long branchRegister(BranchType branchType, String resourceId, String clientId, String xid,
-                                       String lockKeys) throws TransactionException {
+                                       String applicationData, String lockKeys) throws TransactionException {
                 return 123456L;
             }
 
             @Override
-            public void branchReport(String xid, long branchId, BranchStatus status, String applicationData)
+            public void branchReport(BranchType branchType, String xid, long branchId, BranchStatus status, String applicationData)
                 throws TransactionException {
 
             }
@@ -156,13 +155,13 @@ public class DataSourceBasicTest {
             }
 
             @Override
-            public BranchStatus branchCommit(String xid, long branchId, String resourceId, String applicationData)
+            public BranchStatus branchCommit(BranchType branchType, String xid, long branchId, String resourceId, String applicationData)
                 throws TransactionException {
                 return BranchStatus.PhaseTwo_Committed;
             }
 
             @Override
-            public BranchStatus branchRollback(String xid, long branchId, String resourceId, String applicationData)
+            public BranchStatus branchRollback(BranchType branchType, String xid, long branchId, String resourceId, String applicationData)
                 throws TransactionException {
                 return BranchStatus.PhaseTwo_Rollbacked;
             }
diff --git a/test/src/main/java/com/alibaba/fescar/test/LocalTransactionWithGlobalLockDataSourceBasicTest.java b/test/src/main/java/com/alibaba/fescar/test/LocalTransactionWithGlobalLockDataSourceBasicTest.java
index ca7c7043b..e18205e82 100644
--- a/test/src/main/java/com/alibaba/fescar/test/LocalTransactionWithGlobalLockDataSourceBasicTest.java
+++ b/test/src/main/java/com/alibaba/fescar/test/LocalTransactionWithGlobalLockDataSourceBasicTest.java
@@ -205,14 +205,13 @@ public class LocalTransactionWithGlobalLockDataSourceBasicTest {
     public static class MockDataSourceManager extends DataSourceManager {
 
         @Override
-        public Long branchRegister(BranchType branchType, String resourceId, String clientId, String xid,
-                                   String lockKeys) throws TransactionException {
+        public Long branchRegister(BranchType branchType, String resourceId, String clientId, String xid, String applicationData, String lockKeys)
+                throws TransactionException {
             throw new RuntimeException("this method should not be called!");
         }
 
         @Override
-        public void branchReport(String xid, long branchId, BranchStatus status, String applicationData)
-            throws TransactionException {
+        public void branchReport(BranchType branchType, String xid, long branchId, BranchStatus status, String applicationData) throws TransactionException {
             throw new RuntimeException("this method should not be called!");
         }
 
@@ -233,13 +232,12 @@ public class LocalTransactionWithGlobalLockDataSourceBasicTest {
         }
 
         @Override
-        public BranchStatus branchCommit(String xid, long branchId, String resourceId, String applicationData)
-            throws TransactionException {
+        public BranchStatus branchCommit(BranchType branchType, String xid, long branchId, String resourceId, String applicationData) throws TransactionException {
             throw new RuntimeException("this method should not be called!");
         }
 
         @Override
-        public BranchStatus branchRollback(String xid, long branchId, String resourceId, String applicationData)
+        public BranchStatus branchRollback(BranchType branchType, String xid, long branchId, String resourceId, String applicationData)
             throws TransactionException {
             throw new RuntimeException("this method should not be called!");
         }
diff --git a/test/src/main/resources/META-INF/services/com.alibaba.fescar.common.loader.LoaderTestSPI b/test/src/main/resources/META-INF/services/com.alibaba.fescar.common.loader.LoaderTestSPI
new file mode 100644
index 000000000..4ca1f609f
--- /dev/null
+++ b/test/src/main/resources/META-INF/services/com.alibaba.fescar.common.loader.LoaderTestSPI
@@ -0,0 +1,2 @@
+com.alibaba.fescar.common.loader.LoaderTestImpl1
+com.alibaba.fescar.common.loader.LoaderTestImpl2
\ No newline at end of file
diff --git a/test/src/test/java/com/alibaba/fescar/common/loader/EnhancedServiceLoaderTest.java b/test/src/test/java/com/alibaba/fescar/common/loader/EnhancedServiceLoaderTest.java
new file mode 100644
index 000000000..2fb1ed1c3
--- /dev/null
+++ b/test/src/test/java/com/alibaba/fescar/common/loader/EnhancedServiceLoaderTest.java
@@ -0,0 +1,45 @@
+/*
+ *  Copyright 1999-2018 Alibaba Group Holding Ltd.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package com.alibaba.fescar.common.loader;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.List;
+
+/**
+ * test  EnhancedServiceLoader
+ * @author zhangsen
+ */
+public class EnhancedServiceLoaderTest {
+
+    @Test
+    public void testLoadBeanByOrder(){
+        LoaderTestSPI loader  = EnhancedServiceLoader.load(LoaderTestSPI.class, EnhancedServiceLoaderTest.class.getClassLoader());
+        System.out.println(loader.echo());
+        Assert.assertEquals("impl_2", loader.echo());
+    }
+
+    @Test
+    public void testLoadAll(){
+        List<LoaderTestSPI> list = EnhancedServiceLoader.loadAll(LoaderTestSPI.class);
+        Assert.assertEquals(2, list.size());
+    }
+
+
+}
+