slievrly commented on code in PR #6342: URL: https://github.com/apache/incubator-seata/pull/6342#discussion_r1490952276
########## compatible/src/main/java/io/seata/integration/tx/api/interceptor/ActionInterceptorHandler.java: ########## @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 io.seata.integration.tx.api.interceptor; + +import io.seata.rm.tcc.api.BusinessActionContextParameter; +import org.apache.seata.rm.tcc.api.ParamType; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +/** + * Handler the Tx Participant Aspect : Setting Context, Creating Branch Record + */ +public class ActionInterceptorHandler extends org.apache.seata.integration.tx.api.interceptor.ActionInterceptorHandler { + + + /** + * Extracting context data from parameters, add them to the context + * + * @param method the method + * @param arguments the arguments + * @return the context + */ + @Override + protected Map<String, Object> fetchActionRequestContext(Method method, Object[] arguments) { + Map<String, Object> context = new HashMap<>(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) { + // get annotation + BusinessActionContextParameter annotation = (BusinessActionContextParameter) parameterAnnotations[i][j]; + if (arguments[i] == null) { + throw new IllegalArgumentException("@BusinessActionContextParameter 's params can not null"); + } + + // get param + Object paramObject = arguments[i]; + if (paramObject == null) { + continue; + } + + // load param by the config of annotation, and then put into the context + ActionContextUtil.loadParamByAnnotationAndPutToContext(ParamType.PARAM, "", paramObject, annotation, context); + } else if (parameterAnnotations[i][j] instanceof org.apache.seata.rm.tcc.api.BusinessActionContextParameter) { + // get annotation + org.apache.seata.rm.tcc.api.BusinessActionContextParameter annotation = (org.apache.seata.rm.tcc.api.BusinessActionContextParameter) parameterAnnotations[i][j]; Review Comment: I think just check `io.seata... annotation` here. For `org.apache.seata.rm.tcc.api.BusinessActionContextParameter` should by the `org. apache. seata. Integration.tx. api.interceptor. ActionInterceptorHandler` to deal with, because here is override the parent method. -- 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]
