ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject incubator-ignite git commit: IGNITE-843 Finished cache type metadata java code generation.
Date Wed, 29 Jul 2015 17:19:38 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-843 cc88167f2 -> 779825515


IGNITE-843 Finished cache type metadata java code generation.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/77982551
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/77982551
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/77982551

Branch: refs/heads/ignite-843
Commit: 77982551530dbf39379d7af514f681d10b9d936e
Parents: cc88167
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Thu Jul 30 00:19:28 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Thu Jul 30 00:19:28 2015 +0700

----------------------------------------------------------------------
 .../src/main/js/routes/generator/common.js      |  20 +-
 .../src/main/js/routes/generator/docker.js      |  70 +++---
 .../src/main/js/routes/generator/java.js        | 240 ++++++++++---------
 .../src/main/js/routes/generator/xml.js         |  16 +-
 4 files changed, 175 insertions(+), 171 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/77982551/modules/control-center-web/src/main/js/routes/generator/common.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/generator/common.js b/modules/control-center-web/src/main/js/routes/generator/common.js
index 859f28c..54e3197 100644
--- a/modules/control-center-web/src/main/js/routes/generator/common.js
+++ b/modules/control-center-web/src/main/js/routes/generator/common.js
@@ -116,23 +116,19 @@ exports.builder = function () {
 
     res.imports = {};
 
-    res.importClass = function (fullClassName) {
-        var dotIdx = fullClassName.lastIndexOf('.');
+    res.importClass = function (className) {
+        var fullClassName = javaBuildInClass(className);
 
-        var shortName;
+        var dotIdx = fullClassName.lastIndexOf('.');
 
-        if (dotIdx > 0)
-            shortName = fullClassName.substr(dotIdx + 1);
-        else
-            shortName = fullClassName;
+        var shortName = dotIdx > 0 ? fullClassName.substr(dotIdx + 1) : fullClassName;
 
         if (this.imports[shortName]) {
             if (this.imports[shortName] != fullClassName)
                 throw "Class name conflict: " + this.imports[shortName] + ' and ' + fullClassName;
         }
-        else {
+        else
             this.imports[shortName] = fullClassName;
-        }
 
         return shortName;
     };
@@ -195,14 +191,16 @@ var javaBuildInClasses = {
     UUID: {className: 'java.util.UUID'}
 };
 
-exports.javaBuildInClass = function (className) {
+function javaBuildInClass(className) {
     var fullClassName = javaBuildInClasses[className];
 
     if (fullClassName)
         return fullClassName.className;
 
     return className;
-};
+}
+
+exports.javaBuildInClass = javaBuildInClass;
 
 exports.knownClasses = {
     Oracle: new ClassDescriptor('org.apache.ignite.cache.store.jdbc.dialect.OracleDialect',
{}),

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/77982551/modules/control-center-web/src/main/js/routes/generator/docker.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/generator/docker.js b/modules/control-center-web/src/main/js/routes/generator/docker.js
index 93faf8e..997a7ce 100644
--- a/modules/control-center-web/src/main/js/routes/generator/docker.js
+++ b/modules/control-center-web/src/main/js/routes/generator/docker.js
@@ -15,44 +15,44 @@
  * limitations under the License.
  */
 
-exports.generateClusterConfiguration = function(cluster, os) {
+exports.generateClusterConfiguration = function (cluster, os) {
     if (!os)
         os = 'debian:8';
 
     return "" +
-        "# Start from a OS image.\n"+
-        "FROM " + os + "\n"+
-        "\n"+
-        "# Install tools.\n"+
-        "RUN apt-get update && apt-get install -y --fix-missing \\\n"+
-        "  wget \\\n"+
-        "  dstat \\\n"+
-        "  maven \\\n"+
-        "  git\n"+
-        "\n"+
-        "# Install Oracle JDK.\n"+
-        "RUN mkdir /opt/jdk\n"+
-        "\n"+
-        "RUN wget --header \"Cookie: oraclelicense=accept-securebackup-cookie\" \\\n"+
-        "  http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz\n"+
-        "\n"+
-        "RUN tar -zxf jdk-7u79-linux-x64.tar.gz -C /opt/jdk\n"+
-        "\n"+
-        "RUN rm jdk-7u79-linux-x64.tar.gz\n"+
-        "\n"+
-        "RUN update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.7.0_79/bin/java
100\n"+
-        "\n"+
-        "RUN update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.7.0_79/bin/javac
100\n"+
-        "\n"+
-        "# Sets java variables.\n"+
-        "ENV JAVA_HOME /opt/jdk/jdk1.7.0_79/\n"+
-        "\n"+
-        "# Create working directory\n"+
-        "WORKDIR /home\n"+
-        "\n"+
-        "RUN wget -O ignite.zip http://tiny.cc/updater/download_ignite.php && unzip
ignite.zip && rm ignite.zip\n"+
-        "\n"+
-        "COPY *.xml /tmp/\n"+
-        "\n"+
+        "# Start from a OS image.\n" +
+        "FROM " + os + "\n" +
+        "\n" +
+        "# Install tools.\n" +
+        "RUN apt-get update && apt-get install -y --fix-missing \\\n" +
+        "  wget \\\n" +
+        "  dstat \\\n" +
+        "  maven \\\n" +
+        "  git\n" +
+        "\n" +
+        "# Install Oracle JDK.\n" +
+        "RUN mkdir /opt/jdk\n" +
+        "\n" +
+        "RUN wget --header \"Cookie: oraclelicense=accept-securebackup-cookie\" \\\n" +
+        "  http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz\n"
+
+        "\n" +
+        "RUN tar -zxf jdk-7u79-linux-x64.tar.gz -C /opt/jdk\n" +
+        "\n" +
+        "RUN rm jdk-7u79-linux-x64.tar.gz\n" +
+        "\n" +
+        "RUN update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.7.0_79/bin/java
100\n" +
+        "\n" +
+        "RUN update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.7.0_79/bin/javac
100\n" +
+        "\n" +
+        "# Sets java variables.\n" +
+        "ENV JAVA_HOME /opt/jdk/jdk1.7.0_79/\n" +
+        "\n" +
+        "# Create working directory\n" +
+        "WORKDIR /home\n" +
+        "\n" +
+        "RUN wget -O ignite.zip http://tiny.cc/updater/download_ignite.php && unzip
ignite.zip && rm ignite.zip\n" +
+        "\n" +
+        "COPY *.xml /tmp/\n" +
+        "\n" +
         "RUN mv /tmp/*.xml /home/$(ls)/config";
 };

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/77982551/modules/control-center-web/src/main/js/routes/generator/java.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/generator/java.js b/modules/control-center-web/src/main/js/routes/generator/java.js
index 3293af2..d017901 100644
--- a/modules/control-center-web/src/main/js/routes/generator/java.js
+++ b/modules/control-center-web/src/main/js/routes/generator/java.js
@@ -55,7 +55,7 @@ exports.generateClusterConfiguration = function (cluster, javaClass, clientMode)
         res.startBlock('public IgniteConfiguration createConfiguration() {');
     }
 
-    declareVariable(res, true, 'org.apache.ignite.configuration.IgniteConfiguration', 'cfg');
+    declareVariable(res, true, 'cfg', 'org.apache.ignite.configuration.IgniteConfiguration');
     res.line();
 
     if (clientMode) {
@@ -66,7 +66,7 @@ exports.generateClusterConfiguration = function (cluster, javaClass, clientMode)
     if (cluster.discovery) {
         var d = cluster.discovery;
 
-        declareVariable(res, true, 'org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi',
'discovery');
+        declareVariable(res, true, 'discovery', 'org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi');
 
         switch (d.kind) {
             case 'Multicast':
@@ -135,7 +135,7 @@ exports.generateClusterConfiguration = function (cluster, javaClass, clientMode)
             case 'Jdbc':
                 res.line();
 
-                declareVariable(res, true, 'org.apache.ignite.spi.discovery.tcp.ipfinder.jdbc.TcpDiscoveryJdbcIpFinder',
'ipFinder');
+                declareVariable(res, true, 'ipFinder', 'org.apache.ignite.spi.discovery.tcp.ipfinder.jdbc.TcpDiscoveryJdbcIpFinder');
 
                 res.line('ipFinder.setInitSchema(' + (d.Jdbc.initSchema != null || d.Jdbc.initSchema)
+ ');');
                 res.line('discovery.setIpFinder(ipFinder);');
@@ -162,30 +162,30 @@ exports.generateClusterConfiguration = function (cluster, javaClass,
clientMode)
         res.needEmptyLine = true;
     }
 
-    if (cluster.caches && cluster.caches.length > 0) {
+    var caches = cluster.caches;
+
+    if (caches && caches.length > 0) {
         res.emptyLineIfNeeded();
 
         var names = [];
 
-        for (var i = 0; i < cluster.caches.length; i++) {
+        _.forEach(caches, function (cache) {
             res.emptyLineIfNeeded();
 
-            var cache = cluster.caches[i];
-
             var cacheName = toJavaName('cache', cache.name);
 
             names.push(cacheName);
 
-            generateCacheConfiguration(res, cache, cacheName);
+            addCacheConfiguration(res, cache, cacheName);
 
             res.needEmptyLine = true;
-        }
+        });
 
         res.emptyLineIfNeeded();
 
         res.append('cfg.setCacheConfiguration(');
 
-        for (i = 0; i < names.length; i++) {
+        for (var i = 0; i < names.length; i++) {
             if (i > 0)
                 res.append(', ');
 
@@ -326,7 +326,15 @@ exports.generateClusterConfiguration = function (cluster, javaClass,
clientMode)
     return res.join('');
 };
 
-function createEvictionPolicy(res, varName, evictionPolicy, propertyName) {
+/**
+ * Add eviction policy.
+ *
+ * @param res Resulting output with generated code.
+ * @param varName Current using variable name.
+ * @param evictionPolicy Data to add.
+ * @param propertyName Name in source data.
+ */
+function addEvictionPolicy(res, varName, evictionPolicy, propertyName) {
     if (evictionPolicy && evictionPolicy.kind) {
         var e = generatorUtils.evictionPolicies[evictionPolicy.kind];
 
@@ -336,25 +344,16 @@ function createEvictionPolicy(res, varName, evictionPolicy, propertyName)
{
     }
 }
 
-function addCacheTypeMetadataDatabaseFields(res, varName, meta, fieldProperty) {
-    var fields = meta[fieldProperty];
-
-    if (fields && fields.length > 0) {
-        res.emptyLineIfNeeded();
-
-        var varDbFields = fieldProperty;
-
-        var varNew = !res[fieldProperty];
+function addCacheTypeMetadataDatabaseFields(res, meta, fieldProperty) {
+    var dbFields = meta[fieldProperty];
 
-        if (varNew)
-            res[fieldProperty] = true;
-
-        declareVariable(res, varNew, 'java.util.Collection', varDbFields, 'java.util.ArrayList',
'org.apache.ignite.cache.CacheTypeFieldMetadata');
+    if (dbFields && dbFields.length > 0) {
+        res.line();
 
-        res.importClass('org.apache.ignite.cache.CacheTypeFieldMetadata');
+        declareVariable(res, needNewVariable(res, fieldProperty), fieldProperty, 'java.util.Collection',
'java.util.ArrayList', 'org.apache.ignite.cache.CacheTypeFieldMetadata');
 
-        _.forEach(fields, function (field) {
-            res.line(varDbFields + '.add(new CacheTypeFieldMetadata(' +
+        _.forEach(dbFields, function (field) {
+            res.line(fieldProperty + '.add(new CacheTypeFieldMetadata(' +
                 '"' + field.databaseName + '", ' +
                 'java.sql.Types.' + field.databaseType + ', ' +
                 '"' + field.javaName + '", ' +
@@ -362,110 +361,95 @@ function addCacheTypeMetadataDatabaseFields(res, varName, meta, fieldProperty)
{
                 + '));');
         });
 
-        res.line(varName + '.' + toJavaName('set', fieldProperty) + '(' + varDbFields + ');');
+        res.line('typeMeta.' + toJavaName('set', fieldProperty) + '(' + fieldProperty + ');');
     }
 }
 
-function addCacheTypeMetadataQueryFields(res, varType, meta, fieldProperty) {
+function addCacheTypeMetadataQueryFields(res, meta, fieldProperty) {
     var fields = meta[fieldProperty];
 
     if (fields && fields.length > 0) {
-        res.emptyLineIfNeeded();
-
-        var varQryFields = fieldProperty;
-
-        var varNew = !res[fieldProperty];
-
-        if (varNew)
-            res[fieldProperty] = true;
+        res.line();
 
-        declareVariable(res, varNew, 'java.util.Map', varQryFields, 'java.util.LinkedHashMap',
'java.lang.String', 'java.lang.Class<?>');
+        declareVariable(res, needNewVariable(res, fieldProperty), fieldProperty, 'java.util.Map',
'java.util.LinkedHashMap', 'java.lang.String', 'java.lang.Class<?>');
 
         _.forEach(fields, function (field) {
-            var cls = res.importClass(generatorUtils.javaBuildInClass(field.className));
-
-            res.line(varQryFields + '.put("' + field.name + '", ' + cls + '.class);');
+            res.line(fieldProperty + '.put("' + field.name + '", ' + res.importClass(field.className)
+ '.class);');
         });
 
-        res.line(varType + '.' + toJavaName('set', fieldProperty) + '(' + varQryFields +
');');
+        res.line('typeMeta.' + toJavaName('set', fieldProperty) + '(' + fieldProperty + ');');
     }
 }
 
-function addCacheTypeMetadataGroups(res, meta, varName) {
+function addCacheTypeMetadataGroups(res, meta) {
     var groups = meta.groups;
 
     if (groups && groups.length > 0) {
-        res.line('addCacheTypeMetadataGroups for ' + varName);
-        //res.startBlock('<property name="groups">');
-        //res.startBlock('<map>');
-        //
-        //_.forEach(groups, function (group) {
-        //    var fields = group.fields;
-        //
-        //    if (fields && fields.length > 0) {
-        //        res.startBlock('<entry key="' + group.name + '">');
-        //        res.startBlock('<map>');
-        //
-        //        _.forEach(fields, function (field) {
-        //            res.startBlock('<entry key="' + field.name + '">');
-        //
-        //            res.startBlock('<bean class="org.apache.ignite.lang.IgniteBiTuple">');
-        //            res.line('<constructor-arg value="' + generatorUtils.javaBuildInClass(field.className)
+ '"/>');
-        //            res.line('<constructor-arg value="' + field.direction + '"/>');
-        //            res.endBlock('</bean>');
-        //
-        //            res.endBlock('</entry>');
-        //        });
-        //
-        //        res.endBlock('</map>');
-        //        res.endBlock('</entry>');
-        //    }
-        //});
-        //
-        //res.endBlock('</map>');
-        //res.endBlock('</property>');
-    }
-}
+        _.forEach(groups, function (group) {
+            var fields = group.fields;
 
-function generateCacheTypeMetadataConfiguration(res, cache, meta) {
-    var varType = 'meta';
+            if (fields && fields.length > 0) {
+                res.importClass('java.util.Map');
+                res.importClass('java.util.LinkedHashMap');
+                res.importClass('org.apache.ignite.lang.IgniteBiTuple');
 
-    var varNew = !res[varType];
+                var varNew = !res.groups;
 
-    if (varNew)
-        res[varType] = true;
+                res.line();
+                res.line((varNew ? 'Map<String, LinkedHashMap<String, IgniteBiTuple<Class<?>,
Boolean>>> ' : '') +
+                    "groups = new LinkedHashMap<>();");
 
-    declareVariable(res, varNew, 'org.apache.ignite.cache.CacheTypeMetadata', varType);
+                if (varNew)
+                    res.groups = true;
 
-    addProperty(res, varType, meta, 'databaseSchema');
-    addProperty(res, varType, meta, 'databaseTable');
+                varNew = !res.groupItems;
 
-    addProperty(res, varType, meta, 'keyType');
-    addProperty(res, varType, meta, 'valueType');
+                res.line((varNew ? 'LinkedHashMap<String, IgniteBiTuple<Class<?>,
Boolean>> ' : '') +
+                    'groupItems = new LinkedHashMap<>();');
 
-    addCacheTypeMetadataDatabaseFields(res, varType, meta, 'keyFields');
-    res.needEmptyLine = true;
+                if (varNew)
+                    res.groupItems = true;
 
-    addCacheTypeMetadataDatabaseFields(res, varType, meta, 'valueFields');
-    res.needEmptyLine = true;
+                _.forEach(fields, function (field) {
+                    res.line('groupItems.put("' + field.name + '", ' +
+                        'new IgniteBiTuple<Class<?>, Boolean>(' + res.importClass(field.className)
+ '.class, ' + field.direction + '));');
+                });
 
-    addCacheTypeMetadataQueryFields(res, varType, meta, 'queryFields');
-    res.needEmptyLine = true;
+                res.line('groups.put("' + group.name + '", groupItems);');
+            }
+        });
 
-    addCacheTypeMetadataQueryFields(res, varType, meta, 'ascendingFields');
-    res.needEmptyLine = true;
+        res.line('typeMeta.setGroups(groups);');
+    }
+}
 
-    addCacheTypeMetadataQueryFields(res, varType, meta, 'descendingFields');
-    res.needEmptyLine = true;
+function addCacheTypeMetadataConfiguration(res, meta) {
+    declareVariable(res, needNewVariable(res, 'typeMeta'), 'typeMeta', 'org.apache.ignite.cache.CacheTypeMetadata');
+
+    addProperty(res, 'typeMeta', meta, 'databaseSchema');
+    addProperty(res, 'typeMeta', meta, 'databaseTable');
+
+    addClassProperty(res, 'typeMeta', meta, 'keyType');
+    addClassProperty(res, 'typeMeta', meta, 'valueType');
+
+    addCacheTypeMetadataDatabaseFields(res, meta, 'keyFields');
+
+    addCacheTypeMetadataDatabaseFields(res, meta, 'valueFields');
+
+    addCacheTypeMetadataQueryFields(res, meta, 'queryFields');
+
+    addCacheTypeMetadataQueryFields(res, meta, 'ascendingFields');
+
+    addCacheTypeMetadataQueryFields(res, meta, 'descendingFields');
 
-    addListProperty(res, varType, meta, 'textFields');
     res.needEmptyLine = true;
+    addListProperty(res, 'typeMeta', meta, 'textFields');
 
-    addCacheTypeMetadataGroups(res, varType, meta);
+    addCacheTypeMetadataGroups(res, meta);
 
     res.line();
-
-    return varType;
+    res.line('types.add(typeMeta);');
+    res.line();
 }
 
 /**
@@ -476,13 +460,13 @@ function generateCacheTypeMetadataConfiguration(res, cache, meta) {
  * @param res Result builder.
  * @returns {*} Append generated java code to builder and return it.
  */
-function generateCacheConfiguration(res, cache, varName) {
+function addCacheConfiguration(res, cache, varName) {
     res.emptyLineIfNeeded();
 
     res.importClass('org.apache.ignite.cache.CacheAtomicityMode');
     res.importClass('org.apache.ignite.cache.CacheMode');
 
-    declareVariable(res, true, 'org.apache.ignite.configuration.CacheConfiguration', varName);
+    declareVariable(res, true, varName, 'org.apache.ignite.configuration.CacheConfiguration');
 
     res.needEmptyLine = true;
 
@@ -504,7 +488,7 @@ function generateCacheConfiguration(res, cache, varName) {
 
     res.needEmptyLine = true;
 
-    createEvictionPolicy(res, varName, cache.evictionPolicy, 'evictionPolicy');
+    addEvictionPolicy(res, varName, cache.evictionPolicy, 'evictionPolicy');
 
     if (cache.nearCacheEnabled) {
         res.needEmptyLine = true;
@@ -515,7 +499,7 @@ function generateCacheConfiguration(res, cache, varName) {
             'NearCacheConfiguration', {nearStartSize: null}, true);
 
         if (cache.nearConfiguration && cache.nearConfiguration.nearEvictionPolicy
&& cache.nearConfiguration.nearEvictionPolicy.kind) {
-            createEvictionPolicy(res, 'nearConfiguration', cache.nearConfiguration.nearEvictionPolicy,
'nearEvictionPolicy');
+            addEvictionPolicy(res, 'nearConfiguration', cache.nearConfiguration.nearEvictionPolicy,
'nearEvictionPolicy');
         }
     }
 
@@ -575,7 +559,7 @@ function generateCacheConfiguration(res, cache, varName) {
 
                 res.line();
 
-                declareVariable(res, true, dataSource.className, dsVarName);
+                declareVariable(res, true, dsVarName, dataSource.className);
 
                 res.line(dsVarName + '.setURL(_URL_);');
                 res.line(dsVarName + '.setUsername(_User_Name_);');
@@ -626,14 +610,7 @@ function generateCacheConfiguration(res, cache, varName) {
         (cache.storeMetadata && cache.storeMetadata.length > 0)) {
         res.emptyLineIfNeeded();
 
-        var varTypes = 'types';
-
-        var varNew = !res[varTypes];
-
-        if (varNew)
-            res[varTypes] = true;
-
-        declareVariable(res, varNew, 'java.util.Collection', varTypes, 'java.util.ArrayList',
'org.apache.ignite.cache.CacheTypeMetadata');
+        declareVariable(res, needNewVariable(res, 'types'), 'types', 'java.util.Collection',
'java.util.ArrayList', 'org.apache.ignite.cache.CacheTypeMetadata');
         res.line();
 
         var metaNames = [];
@@ -643,8 +620,7 @@ function generateCacheConfiguration(res, cache, varName) {
                 if (!_.contains(metaNames, meta.name)) {
                     metaNames.push(meta.name);
 
-                    res.line(varTypes + '.add(' + generateCacheTypeMetadataConfiguration(res,
cache, meta) + ');');
-                    res.line();
+                    addCacheTypeMetadataConfiguration(res, meta);
                 }
             });
         }
@@ -654,13 +630,12 @@ function generateCacheConfiguration(res, cache, varName) {
                 if (!_.contains(metaNames, meta.name)) {
                     metaNames.push(meta.name);
 
-                    res.line(varTypes + '.add(' + generateCacheTypeMetadataConfiguration(res,
cache, meta) + ');');
-                    res.line();
+                    addCacheTypeMetadataConfiguration(res, meta);
                 }
             });
         }
 
-        res.line(varName + '.setCacheTypeMetadata(' + varTypes + ');');
+        res.line(varName + '.setTypeMetadata(types);');
     }
 }
 
@@ -686,18 +661,27 @@ function toJavaCode(val, type) {
     throw "Unknown type: " + typeof(val) + ' (' + val + ')';
 }
 
+function needNewVariable(res, varName) {
+    var needNew = !res[varName];
+
+    if (needNew)
+        res[varName] = true;
+
+    return needNew;
+}
+
 /**
  * Add variable declaration.
  *
  * @param res Resulting output with generated code.
  * @param varNew If 'true' then declare new variable otherwise reuse previously declared
variable.
- * @param varFullType Variable full class name to be added to imports.
  * @param varName Variable name.
+ * @param varFullType Variable full class name to be added to imports.
  * @param varFullActualType Variable actual full class name to be added to imports.
  * @param varFullGenericType1 Optional full class name of first generic.
  * @param varFullGenericType2 Optional full class name of second generic.
  */
-function declareVariable(res, varNew, varFullType, varName, varFullActualType, varFullGenericType1,
varFullGenericType2) {
+function declareVariable(res, varNew, varName, varFullType, varFullActualType, varFullGenericType1,
varFullGenericType2) {
     var varType = res.importClass(varFullType);
 
     if (varFullActualType && varFullGenericType1) {
@@ -735,6 +719,24 @@ function addProperty(res, varName, obj, propName, enumType, setterName)
{
 }
 
 /**
+ * Add property via setter assuming that it is a 'Class'.
+ *
+ * @param res Resulting output with generated code.
+ * @param varName Variable name.
+ * @param obj Source object with data.
+ * @param propName Property name to take from source object.
+ */
+function addClassProperty(res, varName, obj, propName) {
+    var val = obj[propName];
+
+    if (generatorUtils.isDefined(val)) {
+        res.emptyLineIfNeeded();
+
+        res.line(varName + '.' + getSetterName(propName) + '(' + res.importClass(val) + '.class);');
+    }
+}
+
+/**
  * @param propName Property name
  * @returns Property setter with name by java conventions.
  */
@@ -748,6 +750,8 @@ function addListProperty(res, varName, obj, propName, enumType, setterName)
{
     if (val && val.length > 0) {
         res.emptyLineIfNeeded();
 
+        res.importClass('java.util.Arrays');
+
         res.append(varName + '.' + getSetterName(setterName ? setterName : propName) + '(Arrays.asList(');
 
         for (var i = 0; i < val.length; i++) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/77982551/modules/control-center-web/src/main/js/routes/generator/xml.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/generator/xml.js b/modules/control-center-web/src/main/js/routes/generator/xml.js
index 318aed5..271d79c 100644
--- a/modules/control-center-web/src/main/js/routes/generator/xml.js
+++ b/modules/control-center-web/src/main/js/routes/generator/xml.js
@@ -20,7 +20,7 @@ var _ = require('lodash');
 var generatorUtils = require("./common");
 var dataStructures = require("../../helpers/data-structures.js");
 
-exports.generateClusterConfiguration = function(cluster, clientNearConfiguration) {
+exports.generateClusterConfiguration = function (cluster, clientNearConfiguration) {
     var res = generatorUtils.builder();
 
     res.datasources = [];
@@ -174,9 +174,9 @@ exports.generateClusterConfiguration = function(cluster, clientNearConfiguration
     // Generate events group.
     if (cluster.includeEventTypes && cluster.includeEventTypes.length > 0) {
         res.emptyLineIfNeeded();
-        
+
         res.startBlock('<property name="includeEventTypes">');
-        
+
         if (cluster.includeEventTypes.length == 1)
             res.line('<util:constant static-field="org.apache.ignite.events.EventType.'
+ cluster.includeEventTypes[0] + '"/>');
         else {
@@ -199,7 +199,7 @@ exports.generateClusterConfiguration = function(cluster, clientNearConfiguration
 
             res.endBlock('</array>');
         }
-        
+
         res.endBlock('</property>');
 
         res.needEmptyLine = true;
@@ -307,7 +307,7 @@ exports.generateClusterConfiguration = function(cluster, clientNearConfiguration
 
         xml += '    <!-- Data source beans will be initialized from external properties
file. -->\n';
 
-        _.forEach(res.datasources, function(item) {
+        _.forEach(res.datasources, function (item) {
             var beanId = item.dataSourceBean;
 
             xml += '    <bean id= "' + beanId + '" class="' + item.className + '">\n';
@@ -672,7 +672,7 @@ function addBeanWithProperties(res, bean, beanPropName, beanClass, props,
create
                                 var eqIndex = nameAndValue.indexOf('=');
                                 if (eqIndex >= 0) {
                                     res.line('<prop key="' + escapeAttr(nameAndValue.substring(0,
eqIndex)) + '">' +
-                                            + escape(nameAndValue.substr(eqIndex + 1)) +
'</prop>');
+                                        escape(nameAndValue.substr(eqIndex + 1)) + '</prop>');
                                 }
                             }
 
@@ -708,7 +708,9 @@ function addListProperty(res, obj, propName, listType, rowFactory) {
             listType = 'list';
 
         if (!rowFactory)
-            rowFactory = function(val) { return '<value>' + escape(val) + '</value>'
};
+            rowFactory = function (val) {
+                return '<value>' + escape(val) + '</value>'
+            };
 
         res.startBlock('<property name="' + propName + '">');
         res.startBlock('<' + listType + '>');


Mime
View raw message