Juan Hernandez has uploaded a new change for review.

Change subject: codegen: Use SDK specific JAXB bindings
......................................................................

codegen: Use SDK specific JAXB bindings

Currently the SDK uses the same JAXB global bindings used by the engine,
because used to be identical. But recently (in commit a57a6a) the engine
started to use global bindings tha aren't suitable for the SDK. These
bindings used by tne engine already been moved to a separate file in
commit 8acd13. This means that they won't be present in the XML schema
generated by the engine. But some of these global bindings are needed by
the SDK as well, in particular the setting that enables generation of
"isSet" methods. This patch adds a bindings file specific to the SDK,
that contains only the global bindings needed by the SDK.

Change-Id: I946db48bee9d5b9fc6d33ade2fa26b0891f99aaa
Signed-off-by: Juan Hernandez <juan.hernan...@redhat.com>
---
M ovirt-engine-sdk-java-codegen/pom.xml
M 
ovirt-engine-sdk-java-codegen/src/main/java/org/ovirt/engine/sdk/codegen/Main.java
M 
ovirt-engine-sdk-java-codegen/src/main/java/org/ovirt/engine/sdk/codegen/xsd/XsdCodegen.java
A ovirt-engine-sdk-java-codegen/src/main/resources/api.xjb
M ovirt-engine-sdk-java-codegen/src/main/resources/api.xsd
5 files changed, 30 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine-sdk-java 
refs/changes/00/24300/1

diff --git a/ovirt-engine-sdk-java-codegen/pom.xml 
b/ovirt-engine-sdk-java-codegen/pom.xml
index 36e5e46..67d9ac9 100644
--- a/ovirt-engine-sdk-java-codegen/pom.xml
+++ b/ovirt-engine-sdk-java-codegen/pom.xml
@@ -182,6 +182,8 @@
                   <arguments>
                     <argument>--xsd</argument>
                     <argument>${basedir}/src/main/resources/api.xsd</argument>
+                    <argument>--xjb</argument>
+                    <argument>${basedir}/src/main/resources/api.xjb</argument>
                     <argument>--rsdl</argument>
                     <argument>${basedir}/src/main/resources/api.rsdl</argument>
                   </arguments>
diff --git 
a/ovirt-engine-sdk-java-codegen/src/main/java/org/ovirt/engine/sdk/codegen/Main.java
 
b/ovirt-engine-sdk-java-codegen/src/main/java/org/ovirt/engine/sdk/codegen/Main.java
index d1ef967..4e86e90 100644
--- 
a/ovirt-engine-sdk-java-codegen/src/main/java/org/ovirt/engine/sdk/codegen/Main.java
+++ 
b/ovirt-engine-sdk-java-codegen/src/main/java/org/ovirt/engine/sdk/codegen/Main.java
@@ -30,6 +30,7 @@
     public static void main(String[] args) throws IOException, JAXBException {
         // Parse the command line parameters:
         String xsdPath = null;
+        String xjbPath = null;
         String rsdlPath = null;
         for (int i = 0; i < args.length; i++) {
             switch (args[i]) {
@@ -37,6 +38,12 @@
                 i++;
                 if (i < args.length) {
                     xsdPath = args[i];
+                }
+                break;
+            case "--xjb":
+                i++;
+                if (i < args.length) {
+                    xjbPath = args[i];
                 }
                 break;
             case "--rsdl":
@@ -50,13 +57,13 @@
                 System.exit(1);
             }
         }
-        if (xsdPath == null || rsdlPath == null) {
+        if (xsdPath == null || xjbPath == null || rsdlPath == null) {
             System.err.println("Missing required parameters.");
             System.exit(1);
         }
 
         // #1 - generate api entities from the XSD schema
-        new XsdCodegen(xsdPath).generate();
+        new XsdCodegen(xsdPath, xjbPath).generate();
 
         // #2 - generate api entities decorators by RSDL and SDK entry point
         new RsdlCodegen(xsdPath, rsdlPath).generate();
diff --git 
a/ovirt-engine-sdk-java-codegen/src/main/java/org/ovirt/engine/sdk/codegen/xsd/XsdCodegen.java
 
b/ovirt-engine-sdk-java-codegen/src/main/java/org/ovirt/engine/sdk/codegen/xsd/XsdCodegen.java
index 09bede6..6022e93 100644
--- 
a/ovirt-engine-sdk-java-codegen/src/main/java/org/ovirt/engine/sdk/codegen/xsd/XsdCodegen.java
+++ 
b/ovirt-engine-sdk-java-codegen/src/main/java/org/ovirt/engine/sdk/codegen/xsd/XsdCodegen.java
@@ -53,9 +53,15 @@
      */
     private String xsdPath;
 
-    public XsdCodegen(String xsdPath) {
+    /**
+     * The location of the JAXB bindings file.
+     */  
+    private String xjbPath;
+
+    public XsdCodegen(String xsdPath, String xjbPath) {
         super(getEntitiesPath());
         this.xsdPath = xsdPath;
+        this.xjbPath = xjbPath;
     }
 
     /**
@@ -74,10 +80,10 @@
 
         if (OsUtil.isWindows()) {
             xjcOutput = runCommand(WINDOWS_XJC_PATH + " -d " + distPath +
-                    " -p " + ENTITIES_PACKAGE + XJC_FLAGS + xsdPath);
+                    " -p " + ENTITIES_PACKAGE + XJC_FLAGS + xsdPath + " -b " + 
xjbPath);
         } else if (OsUtil.isMac() || OsUtil.isUnix() || OsUtil.isSolaris()) {
             xjcOutput = runCommand(NX_XJC_PATH + " -d " + distPath +
-                    " -p " + ENTITIES_PACKAGE + XJC_FLAGS + xsdPath);
+                    " -p " + ENTITIES_PACKAGE + XJC_FLAGS + xsdPath + " -b " + 
xjbPath);
         } else {
             throw new RuntimeException("unsupported OS.");
         }
@@ -265,7 +271,7 @@
     }
 
     public static void main(String[] args) throws JAXBException, IOException {
-        XsdCodegen generator = new XsdCodegen(args[0]);
+        XsdCodegen generator = new XsdCodegen(args[0], args[1]);
         generator.generate();
     }
 }
diff --git a/ovirt-engine-sdk-java-codegen/src/main/resources/api.xjb 
b/ovirt-engine-sdk-java-codegen/src/main/resources/api.xjb
new file mode 100644
index 0000000..0da7306
--- /dev/null
+++ b/ovirt-engine-sdk-java-codegen/src/main/resources/api.xjb
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jaxb:bindings
+  xmlns:jaxb="http://java.sun.com/xml/ns/jaxb";
+  version="2.0">
+
+  <jaxb:globalBindings generateIsSetMethod="true"/>
+
+</jaxb:bindings>
diff --git a/ovirt-engine-sdk-java-codegen/src/main/resources/api.xsd 
b/ovirt-engine-sdk-java-codegen/src/main/resources/api.xsd
index 012dd94..f9981b6 100644
--- a/ovirt-engine-sdk-java-codegen/src/main/resources/api.xsd
+++ b/ovirt-engine-sdk-java-codegen/src/main/resources/api.xsd
@@ -4,12 +4,6 @@
            xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc";
            jaxb:version="2.1" jaxb:extensionBindingPrefixes="xjc">
 
-  <xs:annotation>
-    <xs:appinfo>
-      <jaxb:globalBindings generateIsSetMethod="true"/>
-    </xs:appinfo>
-  </xs:annotation>
-
   <!-- Links -->
   <xs:element name="keyValuePair" type="KeyValuePair"/>
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I946db48bee9d5b9fc6d33ade2fa26b0891f99aaa
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine-sdk-java
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <juan.hernan...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to