[
https://issues.apache.org/jira/browse/IGNITE-14715?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Aleksandr Polovtcev updated IGNITE-14715:
-----------------------------------------
Release Note: (was: Introduced two new annotations:
1. `AutoMessage` marks a message interface as a candidate for implementation
generation. `autoSerializable` parameter can be used to avoid generating
serialization classes (e.g. for compatibility with Raft messages).
2. `ModuleMessageTypes` declares a module descriptor containing a module name
and a module type.
Generated message implementations are immutable, new message instances can be
created using the generated Builder interfaces and a Factory.)
> Create an annotation processor for generating network message implementations
> -----------------------------------------------------------------------------
>
> Key: IGNITE-14715
> URL: https://issues.apache.org/jira/browse/IGNITE-14715
> Project: Ignite
> Issue Type: Sub-task
> Components: networking
> Reporter: Aleksandr Polovtcev
> Assignee: Aleksandr Polovtcev
> Priority: Minor
> Fix For: 3.0.0-alpha3
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> Currently all {{NetworkMessage}} implementations are created by hand which is
> inconvenient (e.g. one needs to declare constructors and getters). It is
> proposed to automatically generate these implementations using an annotation
> processor.
> h3. Implementation details
> * Custom messages should be declared as interfaces extending
> {{NetworkMessage}}. Methods in these interfaces should correspond to the
> message fields, for example:
> {code:java}
> @Message(type = ACTION_REQUEST)
> public interface ActionRequest extends NetworkMessage {
> String groupId();
> Command command();
> }
> {code}
> * Every message interface should be annotated with the {{@Message}}
> interface, with a *message type* parameter of type {{short}}, unique across a
> *module*. All message types should be manually listed in an interface marked
> with the {{@MessageTypes}} annotation with a *module identifier*. For example:
> {code:java}
> @MessageTypes(moduleType = 10)
> class RaftMessageTypes {
> public final short ACTION_REQUEST = 1;
> }
> {code}
> * Message implementations should have a generated {{Builder}} interface for
> creating new messages:
> {code:java}
> public interface Builder {
> Builder command(Command cmd);
> Builder groupId(String groupId);
> ActionRequest build();
> }
> {code}
> * {{Builder}} instances should be obtained using a generated factory, based
> on the current module type:
> {code:java}
> public interface RaftClientMessageFactory {
> ActionRequestBuilder actionRequest();
> ActionResponseBuilder actionResponse();
> // ...
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)