You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2015/12/25 11:22:43 UTC
ignite git commit: IGNITE-2217 Fixed Binary code generation.
Repository: ignite
Updated Branches:
refs/heads/ignite-843-rc2 2a9c5d3f0 -> 3b2ca7a80
IGNITE-2217 Fixed Binary code generation.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3b2ca7a8
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3b2ca7a8
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3b2ca7a8
Branch: refs/heads/ignite-843-rc2
Commit: 3b2ca7a80dfb59e648577772979f259c7e4ab780
Parents: 2a9c5d3
Author: vsisko <vs...@gridgain.com>
Authored: Fri Dec 25 17:23:06 2015 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Fri Dec 25 17:23:29 2015 +0700
----------------------------------------------------------------------
.../js/helpers/generator/generator-common.js | 6 ++
.../main/js/helpers/generator/generator-java.js | 98 +++++++++++++++-----
.../main/js/helpers/generator/generator-xml.js | 3 +-
3 files changed, 80 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3b2ca7a8/modules/control-center-web/src/main/js/helpers/generator/generator-common.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/helpers/generator/generator-common.js b/modules/control-center-web/src/main/js/helpers/generator/generator-common.js
index cc8bdcf..dfe66c7 100644
--- a/modules/control-center-web/src/main/js/helpers/generator/generator-common.js
+++ b/modules/control-center-web/src/main/js/helpers/generator/generator-common.js
@@ -459,3 +459,9 @@ $generatorCommon.cacheHasDatasource = function (cache) {
$generatorCommon.secretPropertiesNeeded = function (cluster, res) {
return $commonUtils.isDefined(_.find(cluster.caches, $generatorCommon.cacheHasDatasource)) || cluster.sslEnabled;
};
+
+// Check that binary is configured.
+$generatorCommon.binaryIsDefined = function (binary) {
+ return binary && ($commonUtils.isDefinedAndNotEmpty(binary.idMapper) || $commonUtils.isDefinedAndNotEmpty(binary.serializer) ||
+ $commonUtils.isDefinedAndNotEmpty(binary.typeConfigurations) || ($commonUtils.isDefined(binary.compactFooter) && !binary.compactFooter))
+};
http://git-wip-us.apache.org/repos/asf/ignite/blob/3b2ca7a8/modules/control-center-web/src/main/js/helpers/generator/generator-java.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/helpers/generator/generator-java.js b/modules/control-center-web/src/main/js/helpers/generator/generator-java.js
index 5b9eb56..fea1d1f 100644
--- a/modules/control-center-web/src/main/js/helpers/generator/generator-java.js
+++ b/modules/control-center-web/src/main/js/helpers/generator/generator-java.js
@@ -548,8 +548,7 @@ $generatorJava.clusterBinary = function (cluster, res) {
var binary = cluster.binaryConfiguration;
- if (binary && ($commonUtils.isDefinedAndNotEmpty(binary.idMapper) || $commonUtils.isDefinedAndNotEmpty(binary.serializer) ||
- $commonUtils.isDefinedAndNotEmpty(binary.typeConfigurations) || !binary.compactFooter)) {
+ if ($generatorCommon.binaryIsDefined(binary)) {
var varName = 'binary';
$generatorJava.declareVariable(res, varName, 'org.apache.ignite.configuration.BinaryConfiguration');
@@ -568,38 +567,85 @@ $generatorJava.clusterBinary = function (cluster, res) {
$generatorJava.declareVariable(res, arrVar, 'java.util.Collection', 'java.util.ArrayList', 'org.apache.ignite.binary.BinaryTypeConfiguration');
_.forEach(binary.typeConfigurations, function (type) {
- var typeVar = 'typeCfg';
+ // TODO IGNITE-2269 Replace using of separated methods for binary type configurations to extended constructors.
+ res.line(arrVar + '.add(' + $generatorJava.binaryTypeFunctionName(type.typeName) + '());');
+ });
- $generatorJava.declareVariable(res, typeVar, 'org.apache.ignite.binary.BinaryTypeConfiguration');
+ res.needEmptyLine = true;
- $generatorJava.property(res, typeVar, type, 'typeName');
+ res.line(varName + '.setTypeConfigurations(' + arrVar + ');');
- if ($commonUtils.isDefinedAndNotEmpty(type.idMapper))
- res.line(typeVar + '.setIdMapper(new ' + res.importClass(type.idMapper) + '());');
+ res.needEmptyLine = true;
+ }
- if ($commonUtils.isDefinedAndNotEmpty(type.serializer))
- res.line(typeVar + '.setSerializer(new ' + res.importClass(type.serializer) + '());');
+ $generatorJava.property(res, varName, binary, 'compactFooter', undefined, undefined, true);
+ res.needEmptyLine = true;
- $generatorJava.property(res, typeVar, type, 'enum', undefined, undefined, false);
+ res.line('cfg.setBinaryConfiguration(' + varName + ');');
- res.needEmptyLine = true;
+ res.needEmptyLine = true;
+ }
+
+ return res;
+};
- res.line(arrVar + '.add(' + typeVar + ');');
+// TODO IGNITE-2269 Remove specified methods after implamentation of extended constructors.
+// Construct binary type configuration factory method name.
+$generatorJava.binaryTypeFunctionName = function (typeName) {
+ var dotIdx = typeName.lastIndexOf('.');
- res.needEmptyLine = true;
- });
+ var shortName = dotIdx > 0 ? typeName.substr(dotIdx + 1) : typeName;
- res.line(varName + '.setTypeConfigurations(' + arrVar + ');');
+ return $commonUtils.toJavaName('binaryType', shortName);
+};
- res.needEmptyLine = true;
- }
+// TODO IGNITE-2269 Remove specified methods after implamentation of extended constructors.
+// Generate factory method for specified BinaryTypeConfiguration.
+$generatorJava.binaryTypeConfiguration = function (type, res) {
+ var typeName = type.typeName;
- $generatorJava.property(res, binary, 'compactFooter', undefined, true);
+ res.line('/**');
+ res.line(' * Create binary type configuration for ' + typeName + '.');
+ res.line(' *');
+ res.line(' * @return Configured binary type.');
+ res.line(' */');
+ res.startBlock('private static BinaryTypeConfiguration ' + $generatorJava.binaryTypeFunctionName(typeName) + '() {');
- res.line('cfg.setBinaryConfiguration(' + varName + ')');
+ $generatorJava.resetVariables(res);
- res.needEmptyLine = true;
+ var typeVar = 'typeCfg';
+
+ $generatorJava.declareVariable(res, typeVar, 'org.apache.ignite.binary.BinaryTypeConfiguration');
+
+ $generatorJava.property(res, typeVar, type, 'typeName');
+
+ if ($commonUtils.isDefinedAndNotEmpty(type.idMapper))
+ res.line(typeVar + '.setIdMapper(new ' + res.importClass(type.idMapper) + '());');
+
+ if ($commonUtils.isDefinedAndNotEmpty(type.serializer))
+ res.line(typeVar + '.setSerializer(new ' + res.importClass(type.serializer) + '());');
+
+ $generatorJava.property(res, typeVar, type, 'enum', undefined, undefined, false);
+
+ res.needEmptyLine = true;
+
+ res.line('return ' + typeVar + ';');
+ res.endBlock('}');
+
+ res.needEmptyLine = true;
+};
+
+// TODO IGNITE-2269 Remove specified methods after implamentation of extended constructors.
+// Generates binary type configuration factory methods.
+$generatorJava.binaryTypeConfigurations = function (binary, res) {
+ if (!res)
+ res = $generatorCommon.builder();
+
+ if ($commonUtils.isDefined(binary)) {
+ _.forEach(binary.typeConfigurations, function (type) {
+ $generatorJava.binaryTypeConfiguration(type, res);
+ });
}
return res;
@@ -2205,6 +2251,9 @@ $generatorJava.cluster = function (cluster, pkg, javaClass, clientNearCfg) {
$generatorJava.clusterCaches(cluster.caches, cluster.igfss, isSrvCfg, res);
+ // TODO IGNITE-2269 Remove specified methods after implamentation of extended constructors.
+ $generatorJava.binaryTypeConfigurations(cluster.binaryConfiguration, res);
+
res.needEmptyLine = true;
if (clientNearCfg) {
@@ -2270,6 +2319,9 @@ $generatorJava.nodeStartup = function (cluster, pkg, cls, cfg, factoryCls, clien
res.startBlock('public static void main(String[] args) throws Exception {');
+ if (factoryCls)
+ res.importClass(factoryCls);
+
if (clientNearCfg) {
res.line(res.importClass('org.apache.ignite.Ignite') + ' ignite = ' +
res.importClass('org.apache.ignite.Ignition') + '.start(' + cfg + ');');
@@ -2294,12 +2346,8 @@ $generatorJava.nodeStartup = function (cluster, pkg, cls, cfg, factoryCls, clien
res.needEmptyLine = true;
}
}
- else {
- if (factoryCls)
- res.importClass(factoryCls);
-
+ else
res.line(res.importClass('org.apache.ignite.Ignition') + '.start(' + cfg + ');');
- }
res.endBlock('}');
http://git-wip-us.apache.org/repos/asf/ignite/blob/3b2ca7a8/modules/control-center-web/src/main/js/helpers/generator/generator-xml.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/helpers/generator/generator-xml.js b/modules/control-center-web/src/main/js/helpers/generator/generator-xml.js
index 4305736..95d055d 100644
--- a/modules/control-center-web/src/main/js/helpers/generator/generator-xml.js
+++ b/modules/control-center-web/src/main/js/helpers/generator/generator-xml.js
@@ -401,8 +401,7 @@ $generatorXml.clusterBinary = function (cluster, res) {
var binary = cluster.binaryConfiguration;
- if (binary && ($commonUtils.isDefinedAndNotEmpty(binary.idMapper) || $commonUtils.isDefinedAndNotEmpty(binary.serializer) ||
- $commonUtils.isDefinedAndNotEmpty(binary.typeConfigurations) || !binary.compactFooter)) {
+ if ($generatorCommon.binaryIsDefined(binary)) {
res.startBlock('<property name="binaryConfiguration">');
res.startBlock('<bean class="org.apache.ignite.configuration.BinaryConfiguration">');