Change in ovirt-engine-sdk-java[master]: codegen: Sort and remember header parameters

juan.hernandez at redhat.com juan.hernandez at redhat.com
Mon Apr 6 08:23:17 UTC 2015


Juan Hernandez has submitted this change and it was merged.

Change subject: codegen: Sort and remember header parameters
......................................................................


codegen: Sort and remember header parameters

Currently the order of parameters corresponding to headers in generated
code is the same that the order of those parameters in the RSDL
metadata. This means that adding new parameters or reordering them in
the RSDL metadata produces the same reordering in the parameters of the
methods of the generated code. For example, one of the methods to add a
cluster has currently the following signature:

  Cluster add(Cluster cluster, String expect, String correlationId)

The order is "expect" and then "correlation-id" because that is the
order in the RSDL.

If the RSDL changes in such a way that the parameters have a different
order (because a new parameter is added, or just because the RSDL is
generated with a different algorithm) then the method could become
something like this:

  Cluster add(Cluster cluster, String correlationId, String expect)

This is extremelly dangerous, as it it is swapping the parameters but it
will compile just fine.

To avoid this issue this patch changes the generator so that the
parameters are always sorted by name before generating the code. This is
not enough, as it doesn't solve the issue when new parameters are added.
To solve that as well this patch introduces a "memory" (stored in a
properties file) where the generator remembers what was the order of the
previous execution. That order will be respected regardless of changes
in the RSDL.

Change-Id: I4a3916a04e8475f105099836de67ab85d3fb3feb
Signed-off-by: Juan Hernandez <juan.hernandez at redhat.com>
---
M generator/pom.xml
A generator/src/main/java/org/ovirt/engine/sdk/generator/Memory.java
M generator/src/main/java/org/ovirt/engine/sdk/generator/java/Main.java
A generator/src/main/java/org/ovirt/engine/sdk/generator/java/utils/ExceptionsAwareComparator.java
M generator/src/main/java/org/ovirt/engine/sdk/generator/java/utils/LinkUtils.java
A generator/src/main/resources/README.md
A generator/src/main/resources/memory.properties
M sdk/README.md
8 files changed, 657 insertions(+), 5 deletions(-)

Approvals:
  Martin Peřina: Looks good to me, but someone else must approve
  Juan Hernandez: Verified; Looks good to me, approved



-- 
To view, visit https://gerrit.ovirt.org/39459
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4a3916a04e8475f105099836de67ab85d3fb3feb
Gerrit-PatchSet: 4
Gerrit-Project: ovirt-engine-sdk-java
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <juan.hernandez at redhat.com>
Gerrit-Reviewer: Juan Hernandez <juan.hernandez at redhat.com>
Gerrit-Reviewer: Martin Peřina <mperina at redhat.com>
Gerrit-Reviewer: Ori Liel <oliel at redhat.com>
Gerrit-Reviewer: automation at ovirt.org



More information about the Engine-commits mailing list