funky-eyes commented on code in PR #5399:
URL: https://github.com/apache/incubator-seata/pull/5399#discussion_r1435629799
##########
tcc/src/main/java/io/seata/rm/tcc/interceptor/parser/TccActionInterceptorParser.java:
##########
@@ -38,39 +38,46 @@ public class TccActionInterceptorParser implements
InterfaceParser {
@Override
public ProxyInvocationHandler parserInterfaceToProxy(Object target) {
- boolean isTxRemotingBean = TxBeanParserUtils.isTxRemotingBean(target,
target.toString());
- if (isTxRemotingBean) {
- RemotingDesc remotingDesc =
DefaultRemotingParser.get().getRemotingBeanDesc(target);
- if (remotingDesc != null) {
- if (remotingDesc.isService()) {
-
DefaultResourceRegisterParser.get().registerResource(target);
- }
- if (remotingDesc.isReference()) {
- //if it is a tcc remote reference
- Set<String> methodsToProxy =
tccProxyTargetMethod(remotingDesc);
- if (remotingDesc != null && !methodsToProxy.isEmpty()) {
- ProxyInvocationHandler proxyInvocationHandler = new
TccActionInterceptorHandler(remotingDesc, methodsToProxy);
- return proxyInvocationHandler;
- }
- }
+
+ // below only enhance the native business bean.
+ // eliminate without two phase annotation bean.
+ Set<String> methodsToProxy = this.tccProxyTargetMethod(target);
+ if (methodsToProxy.isEmpty()) {
+ return null;
+ }
+
+ // eliminate aop proxy.
+ if (AopUtils.isAopProxy(target)) {
+ return null;
+ }
+
+ // eliminate dubbo etc proxy bean.
+ Field[] fields = ReflectionUtil.getAllFields(target.getClass());
+ for (Field field : fields) {
+ if (field.getGenericType().equals(InvocationHandler.class)) {
+ return null;
}
}
- return null;
+
+ // register resource and enhance with interceptor
+ DefaultResourceRegisterParser.get().registerResource(target);
+ return new TccActionInterceptorHandler(target, methodsToProxy);
}
/**
* is TCC proxy-bean/target-bean: LocalTCC , the proxy bean of
sofa:reference/dubbo:reference
*
- * @param remotingDesc the remoting desc
+ * @param target the target bean
* @return boolean boolean
*/
- private Set<String> tccProxyTargetMethod(RemotingDesc remotingDesc) {
- if (!remotingDesc.isReference() || remotingDesc == null) {
+
+ private Set<String> tccProxyTargetMethod(Object target) {
Review Comment:
> How to handle method overloading with the same method name
>
> 如何处理方法名相同都标注TwoPhaseBusinessAction注解的方法重载问题。
这个问题将由后续pr解决
This issue will be addressed by a follow-up PR
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]