mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-08-21 06:27:36 +00:00
perf[protocol]: all protocol files are generated in a single protocol file
This commit is contained in:
@@ -24,9 +24,12 @@ import java.util.Objects;
|
||||
public class NetConfig {
|
||||
private String id;
|
||||
private String protocolLocation;
|
||||
|
||||
/**
|
||||
* 协议生成属性变量对应于{@link GenerateOperation}
|
||||
* {@link GenerateOperation}
|
||||
*/
|
||||
private boolean oneProtocol;
|
||||
/**
|
||||
* {@link GenerateOperation}
|
||||
*/
|
||||
private boolean foldProtocol;
|
||||
private String protocolPath;
|
||||
@@ -78,6 +81,14 @@ public class NetConfig {
|
||||
this.protocolLocation = protocolLocation;
|
||||
}
|
||||
|
||||
public boolean isOneProtocol() {
|
||||
return oneProtocol;
|
||||
}
|
||||
|
||||
public void setOneProtocol(boolean oneProtocol) {
|
||||
this.oneProtocol = oneProtocol;
|
||||
}
|
||||
|
||||
public boolean isFoldProtocol() {
|
||||
return foldProtocol;
|
||||
}
|
||||
|
||||
@@ -92,6 +92,7 @@ public class PacketService implements IPacketService {
|
||||
var protocolLocation = netConfig.getProtocolLocation();
|
||||
|
||||
var generateOperation = new GenerateOperation();
|
||||
generateOperation.setOneProtocol(netConfig.isOneProtocol());
|
||||
generateOperation.setFoldProtocol(netConfig.isFoldProtocol());
|
||||
generateOperation.setProtocolPath(netConfig.getProtocolPath());
|
||||
generateOperation.setProtocolParam(netConfig.getProtocolParam());
|
||||
|
||||
@@ -101,6 +101,8 @@ public class NetDefinitionParser implements BeanDefinitionParser {
|
||||
// 协议protocol.xml文件的位置。 注意:直接写protocol.xml 则是从resources目录下读
|
||||
resolvePlaceholder("protocol-location", "protocolLocation", builder, element, parserContext);
|
||||
|
||||
// 协议文件是否生成在同一个协议文件中
|
||||
resolvePlaceholder("one-protocol", "oneProtocol", builder, element, parserContext);
|
||||
// 文件是否折叠
|
||||
resolvePlaceholder("fold-protocol", "foldProtocol", builder, element, parserContext);
|
||||
// 生成各种语言的协议列表
|
||||
|
||||
@@ -65,7 +65,8 @@
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="id" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="protocol-location" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="fold-protocol" type="xsd:string" default="false"/>
|
||||
<xsd:attribute name="one-protocol" type="xsd:boolean" default="false"/>
|
||||
<xsd:attribute name="fold-protocol" type="xsd:boolean" default="false"/>
|
||||
<xsd:attribute name="code-languages" type="xsd:string"/>
|
||||
<xsd:attribute name="protocol-path" type="xsd:string"/>
|
||||
<xsd:attribute name="protocol-param" type="xsd:string"/>
|
||||
|
||||
@@ -33,6 +33,12 @@ public class GenerateOperation {
|
||||
*/
|
||||
public static final GenerateOperation NO_OPERATION = new GenerateOperation();
|
||||
|
||||
/**
|
||||
* EN: All protocol files are generated in a single protocol file.
|
||||
* CN: 所有的协议文件生成在一个协议文件里
|
||||
*/
|
||||
private boolean oneProtocol;
|
||||
|
||||
/**
|
||||
* EN: Fold the protocol. The generated protocol file will maintain the same directory structure as the Java source file.
|
||||
* It will not be folded by default.
|
||||
@@ -66,6 +72,14 @@ public class GenerateOperation {
|
||||
this.protocolPath = protocolPath;
|
||||
}
|
||||
|
||||
public boolean isOneProtocol() {
|
||||
return oneProtocol;
|
||||
}
|
||||
|
||||
public void setOneProtocol(boolean oneProtocol) {
|
||||
this.oneProtocol = oneProtocol;
|
||||
}
|
||||
|
||||
public boolean isFoldProtocol() {
|
||||
return foldProtocol;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user