diff --git a/java/core/src/main/java/com/qq/tars/protocol/util/TarsHelper.java b/java/core/src/main/java/com/qq/tars/protocol/util/TarsHelper.java index 65f29a121..1d6aa6c5c 100644 --- a/java/core/src/main/java/com/qq/tars/protocol/util/TarsHelper.java +++ b/java/core/src/main/java/com/qq/tars/protocol/util/TarsHelper.java @@ -190,6 +190,9 @@ public static String getParameterName(Annotation[] annotations) { if (annotation.annotationType() == TarsMethodParameter.class) { TarsMethodParameter parameter = (TarsMethodParameter) annotation; return parameter.name(); + } else if (annotation.annotationType() == TarsHolder.class) { + TarsHolder tarsHolder = (TarsHolder) annotation; + return tarsHolder.name(); } } return null; diff --git a/java/tools/tars-maven-plugin/src/main/java/com/qq/tars/maven/gensrc/Tars2JavaConfig.java b/java/tools/tars-maven-plugin/src/main/java/com/qq/tars/maven/gensrc/Tars2JavaConfig.java index 834ba9f46..93d47aef5 100644 --- a/java/tools/tars-maven-plugin/src/main/java/com/qq/tars/maven/gensrc/Tars2JavaConfig.java +++ b/java/tools/tars-maven-plugin/src/main/java/com/qq/tars/maven/gensrc/Tars2JavaConfig.java @@ -43,6 +43,9 @@ public class Tars2JavaConfig { @Parameter public boolean servant; + @Parameter + public boolean tup; + public String getSrcPath() { return srcPath; } @@ -106,4 +109,12 @@ public boolean isServant() { public void setServant(boolean servant) { this.servant = servant; } + + public boolean isTup() { + return tup; + } + + public void setTup(boolean tup) { + this.tup = tup; + } } diff --git a/java/tools/tars-maven-plugin/src/main/java/com/qq/tars/maven/gensrc/Tars2JavaMojo.java b/java/tools/tars-maven-plugin/src/main/java/com/qq/tars/maven/gensrc/Tars2JavaMojo.java index abd66edf4..21b0e8181 100644 --- a/java/tools/tars-maven-plugin/src/main/java/com/qq/tars/maven/gensrc/Tars2JavaMojo.java +++ b/java/tools/tars-maven-plugin/src/main/java/com/qq/tars/maven/gensrc/Tars2JavaMojo.java @@ -841,10 +841,18 @@ public String opertaionParams(List beforeParams, List paramLi } if (p.isOut()) { sb.append(isFirst ? "" : ", "); - sb.append("@TarsHolder Holder<").append(type(p.paramType(), true, nsMap)).append("> ").append(p.paramName()); + if (tars2JavaConfig.isServant() && tars2JavaConfig.isTup()) { + sb.append("@TarsHolder(name=\"").append(p.paramName()).append("\") Holder<").append(type(p.paramType(), true, nsMap)).append("> ").append(p.paramName()); + } else { + sb.append("@TarsHolder Holder<").append(type(p.paramType(), true, nsMap)).append("> ").append(p.paramName()); + } } else { sb.append(isFirst ? "" : ", "); - sb.append(type(p.paramType(), nsMap)).append(" ").append(p.paramName()); + if (tars2JavaConfig.isServant() && tars2JavaConfig.isTup()) { + sb.append("@TarsMethodParameter(name=\"").append(p.paramName()).append("\")").append(type(p.paramType(), nsMap)).append(" ").append(p.paramName()); + } else { + sb.append(type(p.paramType(), nsMap)).append(" ").append(p.paramName()); + } } if (isFirst) { isFirst = false;