Change in ovirt-engine-sdk-java[master]: sdk: Introduce ApiBuilder

juan.hernandez at redhat.com juan.hernandez at redhat.com
Wed Oct 8 17:14:11 UTC 2014


Juan Hernandez has submitted this change and it was merged.

Change subject: sdk: Introduce ApiBuilder
......................................................................


sdk: Introduce ApiBuilder

Currently the Api class has a collection of constructor, with different
combinations as parameters. Using this constructors renders code that is
difficult to read, as many of the parameters are usually null. For
example, the call to create a SSL connection without server certificate
validation looks like this:

  Api api = new Api(
    "https://fedora.example.com:443/ovirt-engine/api",
    "admin at internal",
    "******",
    null,
    null,
    null,
    null,
    true,
    true,
    false,
    true
  );

The nulls and the magic values in this type of call make it hard to
understand what it is really doing. To simplify this kind of calls this
patch introduces a new ApiBuilder class that can be used with a fluent
style. For example, for the same use case:

  Api api = new ApiBuilder()
    .url("https://fedora.example.com:443/ovirt-engine/api")
    .user("admin at internal")
    .password("******")
    .noHostVerification(true)
    .debug(true)
    .build();

This is much easier to read.

Change-Id: I251070c8888046bfbac90c16306168318528b464
Related-To: https://bugzilla.redhat.com/1145237
Signed-off-by: Juan Hernandez <juan.hernandez at redhat.com>
---
M ovirt-engine-sdk-java-codegen/src/main/java/org/ovirt/engine/sdk/codegen/templates/ApiTemplate
M ovirt-engine-sdk-java/src/main/java/org/ovirt/engine/sdk/Api.java
A ovirt-engine-sdk-java/src/main/java/org/ovirt/engine/sdk/ApiBuilder.java
M ovirt-engine-sdk-java/src/main/java/org/ovirt/engine/sdk/web/ConnectionsPoolBuilder.java
4 files changed, 604 insertions(+), 241 deletions(-)

Approvals:
  Juan Hernandez: Verified; Looks good to me, approved



-- 
To view, visit http://gerrit.ovirt.org/33503
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I251070c8888046bfbac90c16306168318528b464
Gerrit-PatchSet: 1
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: Ravi Nori <rnori at redhat.com>
Gerrit-Reviewer: automation at ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server



More information about the Engine-commits mailing list