diff --git a/protocol/src/main/java/com/zfoo/protocol/serializer/scala/CodeGenerateScala.java b/protocol/src/main/java/com/zfoo/protocol/serializer/scala/CodeGenerateScala.java index 210d61b2e..9731b46d0 100644 --- a/protocol/src/main/java/com/zfoo/protocol/serializer/scala/CodeGenerateScala.java +++ b/protocol/src/main/java/com/zfoo/protocol/serializer/scala/CodeGenerateScala.java @@ -90,7 +90,7 @@ public void mergerProtocol(List registrations) throws IOEx for (var registration : registrations) { var protocol_id = registration.protocolId(); var protocol_name = registration.protocolConstructor().getDeclaringClass().getSimpleName(); - protocol_manager_registrations.append(StringUtils.format("protocols({}) = Registration{}", protocol_id, protocol_name)).append(LS); + protocol_manager_registrations.append(StringUtils.format("protocols({}) = {}Registration", protocol_id, protocol_name)).append(LS); protocol_manager_registrations.append(StringUtils.format("protocolIdMap.put(classOf[{}], {})", protocol_name, protocol_id)).append(LS); } @@ -135,8 +135,8 @@ public void foldProtocol(List registrations) throws IOExce var protocol_id = registration.protocolId(); var protocol_name = registration.protocolConstructor().getDeclaringClass().getSimpleName(); protocol_imports.append(StringUtils.format("import {}.{}.{}", protocolPackage, GenerateProtocolPath.protocolPathPeriod(protocol_id), protocol_name)).append(LS); - protocol_imports.append(StringUtils.format("import {}.{}.Registration{}", protocolPackage, GenerateProtocolPath.protocolPathPeriod(protocol_id), protocol_name)).append(LS); - protocol_manager_registrations.append(StringUtils.format("protocols({}) = Registration{}", protocol_id, protocol_name)).append(LS); + protocol_imports.append(StringUtils.format("import {}.{}.{}Registration", protocolPackage, GenerateProtocolPath.protocolPathPeriod(protocol_id), protocol_name)).append(LS); + protocol_manager_registrations.append(StringUtils.format("protocols({}) = {}Registration", protocol_id, protocol_name)).append(LS); protocol_manager_registrations.append(StringUtils.format("protocolIdMap.put(classOf[{}], {})", protocol_name, protocol_id)).append(LS); } @@ -178,7 +178,7 @@ public void defaultProtocol(List registrations) throws IOE for (var registration : registrations) { var protocol_id = registration.protocolId(); var protocol_name = registration.protocolConstructor().getDeclaringClass().getSimpleName(); - protocol_manager_registrations.append(StringUtils.format("protocols({}) = Registration{}", protocol_id, protocol_name)).append(LS); + protocol_manager_registrations.append(StringUtils.format("protocols({}) = {}Registration", protocol_id, protocol_name)).append(LS); protocol_manager_registrations.append(StringUtils.format("protocolIdMap.put(classOf[{}], {})", protocol_name, protocol_id)).append(LS); } diff --git a/protocol/src/main/resources/scala/ProtocolRegistrationTemplate.scala b/protocol/src/main/resources/scala/ProtocolRegistrationTemplate.scala index 39767ca28..83c3e3d99 100644 --- a/protocol/src/main/resources/scala/ProtocolRegistrationTemplate.scala +++ b/protocol/src/main/resources/scala/ProtocolRegistrationTemplate.scala @@ -1,4 +1,4 @@ -object Registration${protocol_name} extends IProtocolRegistration { +object ${protocol_name}Registration extends IProtocolRegistration { override def protocolId: Short = ${protocol_id} override def write(buffer: ByteBuffer, packet: Any): Unit = {