Skip to content

Commit

Permalink
Merge branch 'refactoring-1.6.x' into master-1.6.x
Browse files Browse the repository at this point in the history
* refactoring-1.6.x:
  update the tcc transaction dubbo, remove tccJavassist and tccJdk.
  update the TransactionContextEditor
  fix sample error.
  add CompensableTransactionFilter, remove TccJavassist.
  add dubbo filter

# Conflicts:
#	tcc-transaction-dubbo/src/main/java/org/mengyun/tcctransaction/dubbo/filter/CompensableTransactionFilter.java
#	tcc-transaction-dubbo/src/main/resources/META-INF/dubbo/org.apache.dubbo.rpc.Filter
  • Loading branch information
changming.xie committed Aug 5, 2021
2 parents c3cf0aa + af7b32f commit 545bb1b
Show file tree
Hide file tree
Showing 50 changed files with 670 additions and 1,541 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<properties>

<java.version>1.8</java.version>
<revision>1.6.3</revision>
<revision>1.7.0</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.source>${java.version}</maven.compiler.source>
Expand Down
3 changes: 1 addition & 2 deletions tcc-transaction-admin-web/src/App.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import {Provider} from 'react-redux';
import {Layout, Menu} from 'antd';
import {Link, BrowserRouter as Router, Route, Switch} from 'react-router-dom';
import {BrowserRouter as Router, Link, Route, Switch} from 'react-router-dom';
import 'antd/dist/antd.css';
import './App.css';
import Domain from './pages/tcc/domain/index';
Expand Down
3 changes: 1 addition & 2 deletions tcc-transaction-admin-web/src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { render } from '@testing-library/react';
import {render} from '@testing-library/react';
import App from './App';

test('renders learn react link', () => {
Expand Down
1 change: 0 additions & 1 deletion tcc-transaction-admin-web/src/common/constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import {Button, Modal} from 'antd';
import ReactJson from 'react-json-view';

Expand Down
9 changes: 4 additions & 5 deletions tcc-transaction-admin-web/src/components/DeletedKey.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import { Space, Table, Button } from 'antd';
import { columns as originColumns } from '../common/constants';
import { restore } from '../common/api';
import {Button, Space, Table} from 'antd';
import {columns as originColumns} from '../common/constants';
import {restore} from '../common/api';

const columns = originColumns.concat({
title: 'Operation',
Expand Down Expand Up @@ -31,4 +30,4 @@ const DeletedKey = ({ data }) => {
}


export default DeletedKey;
export default DeletedKey;
7 changes: 3 additions & 4 deletions tcc-transaction-admin-web/src/components/Normal.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { Button, Table, Space } from 'antd';
import { columns as originColumns } from '../common/constants';
import {Button, Space, Table} from 'antd';
import {columns as originColumns} from '../common/constants';
import * as api from '../common/api';

const columns = originColumns.concat({
Expand Down Expand Up @@ -50,4 +49,4 @@ const Normal = ({ data }) => {
)
}

export default Normal
export default Normal
8 changes: 4 additions & 4 deletions tcc-transaction-admin-web/src/components/SearchBox.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
import { Button, Cascader } from 'antd';
import {useState} from 'react';
import {Button, Cascader} from 'antd';

const SearchBox = ({
onChange,
Expand All @@ -13,7 +13,7 @@ const SearchBox = ({
};

const handleAdd = () => {}

return (
<div className="search-box">
<Cascader
Expand All @@ -33,4 +33,4 @@ const SearchBox = ({
)
}

export default SearchBox;
export default SearchBox;
1 change: 0 additions & 1 deletion tcc-transaction-admin-web/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
Expand Down
12 changes: 6 additions & 6 deletions tcc-transaction-admin-web/src/pages/agg/Degrade.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useEffect } from 'react';
import { Switch, Row, Col, Divider } from 'antd';
import { getDegradeList, degrade } from '../../api/agg';
import {useEffect, useState} from 'react';
import {Col, Divider, Row, Switch} from 'antd';
import {degrade, getDegradeList} from '../../api/agg';

const Page = () => {
const [domains, setDomains] = useState([]);
Expand Down Expand Up @@ -36,7 +36,7 @@ const Page = () => {
return (
<>
<div className="tab-3-body">

<Row>
<Col flex="auto" style={{ paddingLeft: 12, fontWeight: 'bolder' }}>Domain</Col>
<Col flex="200px" style={{ fontWeight: 'bolder' }}>状态</Col>
Expand Down Expand Up @@ -65,10 +65,10 @@ const Page = () => {
}
</div>
<div>

</div>
</>
)
}

export default Page;
export default Page;
6 changes: 3 additions & 3 deletions tcc-transaction-admin-web/src/pages/agg/Normal.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
import { Table, Button, Cascader, Modal, message, Form } from 'antd';
import {useEffect, useState} from 'react';
import {Button, Cascader, Form, message, Modal, Table} from 'antd';
import ReactJson from 'react-json-view';
import * as api from '../../api/agg';
import CreateModal from './modal';
Expand Down Expand Up @@ -202,4 +202,4 @@ const Normal = () => {
);
}

export default Normal;
export default Normal;
7 changes: 3 additions & 4 deletions tcc-transaction-admin-web/src/pages/agg/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { Layout, Menu } from 'antd';
import { Switch, Route, Link } from 'react-router-dom';
import {Layout, Menu} from 'antd';
import {Link, Route, Switch} from 'react-router-dom';
import Normal from './Normal';
import Degrade from './Degrade';

Expand Down Expand Up @@ -31,4 +30,4 @@ const Page = () => (
</Layout>
)

export default Page;
export default Page;
2 changes: 1 addition & 1 deletion tcc-transaction-admin-web/src/pages/agg/modal.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { Form, Input, message, Modal } from "antd";
import {Form, Input, message, Modal} from "antd";
import * as api from "../../api/agg";


Expand Down
10 changes: 5 additions & 5 deletions tcc-transaction-admin-web/src/pages/tcc/Degrade.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState, useEffect } from 'react';
import { Switch, Row, Col, Divider } from 'antd';
import { getDegradeList, degrade } from '../../common/api';
import {useEffect, useState} from 'react';
import {Col, Divider, Row, Switch} from 'antd';
import {degrade, getDegradeList} from '../../common/api';

const Page = () => {
const [domains, setDomains] = useState([]);
Expand Down Expand Up @@ -64,10 +64,10 @@ const Page = () => {
}
</div>
<div>

</div>
</>
)
}

export default Page;
export default Page;
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from "react";
import { useDispatch, useSelector } from "react-redux";
import { Domain } from "../../../store/actions/domain";
import {useDispatch, useSelector} from "react-redux";
import {Domain} from "../../../store/actions/domain";
import * as api from "../../../common/api";
import { Row, Col, Button, Popconfirm, message } from "antd";
import {Button, Col, message, Popconfirm, Row} from "antd";

const DrawerDomainList = () => {
const { domainData } = useSelector(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {useState} from 'react';
import {Button, Form, Select, Drawer} from 'antd';
import {Button, Drawer, Form, Select} from 'antd';
import {useDispatch, useSelector} from 'react-redux';
import {Domain} from '../../../store/actions/domain';
import DrawerDomainList from './DrawerDomainList';
Expand Down
2 changes: 1 addition & 1 deletion tcc-transaction-admin-web/src/pages/tcc/domain/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useState, useEffect} from 'react';
import React, {useEffect, useState} from 'react';
import {Tabs} from 'antd';
import * as api from '../../../common/api';
import SearchBox from './SearchBox';
Expand Down
5 changes: 2 additions & 3 deletions tcc-transaction-admin-web/src/pages/tcc/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { Layout, Menu } from 'antd';
import { Switch, Route, Link } from 'react-router-dom';
import {Layout, Menu} from 'antd';
import {Link, Route, Switch} from 'react-router-dom';
// @ts-ignore
import Domain from './domain';
import Degrade from './Degrade';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Method;

/**
* Created by changmingxie on 10/25/15.
Expand All @@ -19,72 +18,9 @@

public String cancelMethod() default "";

public Class<? extends TransactionContextEditor> transactionContextEditor() default DefaultTransactionContextEditor.class;

public boolean asyncConfirm() default false;

public boolean asyncCancel() default false;

class NullableTransactionContextEditor implements TransactionContextEditor {

@Override
public TransactionContext get(Object target, Method method, Object[] args) {
return null;
}

@Override
public void set(TransactionContext transactionContext, Object target, Method method, Object[] args) {

}
}

class DefaultTransactionContextEditor implements TransactionContextEditor {

public static int getTransactionContextParamPosition(Class<?>[] parameterTypes) {

int position = -1;

for (int i = 0; i < parameterTypes.length; i++) {
if (parameterTypes[i].equals(org.mengyun.tcctransaction.api.TransactionContext.class)) {
position = i;
break;
}
}
return position;
}

public static TransactionContext getTransactionContextFromArgs(Object[] args) {

TransactionContext transactionContext = null;

for (Object arg : args) {
if (arg != null && org.mengyun.tcctransaction.api.TransactionContext.class.isAssignableFrom(arg.getClass())) {

transactionContext = (org.mengyun.tcctransaction.api.TransactionContext) arg;
}
}

return transactionContext;
}

@Override
public TransactionContext get(Object target, Method method, Object[] args) {
int position = getTransactionContextParamPosition(method.getParameterTypes());

if (position >= 0) {
return (TransactionContext) args[position];
}

return null;
}

@Override
public void set(TransactionContext transactionContext, Object target, Method method, Object[] args) {

int position = getTransactionContextParamPosition(method.getParameterTypes());
if (position >= 0) {
args[position] = transactionContext;
}
}
}
public Class<? extends TransactionContextEditor> transactionContextEditor() default NullableTransactionContextEditor.class;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.mengyun.tcctransaction.api;


import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface EnableTcc {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.mengyun.tcctransaction.api;

import java.lang.reflect.Method;

public class NullableTransactionContextEditor implements TransactionContextEditor {

@Override
public TransactionContext get(Object target, Method method, Object[] args) {
return null;
}

@Override
public void set(TransactionContext transactionContext, Object target, Method method, Object[] args) {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package org.mengyun.tcctransaction.api;

import java.lang.reflect.Method;

public class ParameterTransactionContextEditor implements TransactionContextEditor {

public static int getTransactionContextParamPosition(Class<?>[] parameterTypes) {

int position = -1;

for (int i = 0; i < parameterTypes.length; i++) {
if (parameterTypes[i].equals(org.mengyun.tcctransaction.api.TransactionContext.class)) {
position = i;
break;
}
}
return position;
}

public static boolean hasTransactionContextParameter(Class<?>[] parameterTypes) {
return getTransactionContextParamPosition(parameterTypes) >= 0;
}

public static TransactionContext getTransactionContextFromArgs(Object[] args) {

TransactionContext transactionContext = null;

for (Object arg : args) {
if (arg != null && org.mengyun.tcctransaction.api.TransactionContext.class.isAssignableFrom(arg.getClass())) {

transactionContext = (org.mengyun.tcctransaction.api.TransactionContext) arg;
}
}

return transactionContext;
}

@Override
public TransactionContext get(Object target, Method method, Object[] args) {
int position = getTransactionContextParamPosition(method.getParameterTypes());

if (position >= 0) {
return (TransactionContext) args[position];
} else {
throw new RuntimeException("No TransactionContext parameter exist while get TransactionContext with ParameterTransactionContextEditor!");
}
}

@Override
public void set(TransactionContext transactionContext, Object target, Method method, Object[] args) {

int position = getTransactionContextParamPosition(method.getParameterTypes());
if (position >= 0) {
args[position] = transactionContext;
} else {
throw new RuntimeException("No TransactionContext parameter exist while set TransactionContext with ParameterTransactionContextEditor!");
}
}
}
Loading

0 comments on commit 545bb1b

Please sign in to comment.