ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [1/2] ignite git commit: IGNITE-1867 Fixed java code generation.
Date Fri, 13 Nov 2015 08:09:27 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-843-rc1 10d9ba529 -> d5412a5f7


IGNITE-1867 Fixed java code generation.


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

Branch: refs/heads/ignite-843-rc1
Commit: fbf6a04de4b3046dc98dd2e1afd80ed1a056adac
Parents: 10d9ba5
Author: vsisko <vsisko@gridgain.com>
Authored: Fri Nov 13 15:06:50 2015 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Fri Nov 13 15:06:50 2015 +0700

----------------------------------------------------------------------
 .../main/js/controllers/summary-controller.js   |  6 +--
 .../main/js/helpers/generator/generator-java.js | 55 ++++++++++++++++++--
 2 files changed, 55 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/fbf6a04d/modules/control-center-web/src/main/js/controllers/summary-controller.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/summary-controller.js b/modules/control-center-web/src/main/js/controllers/summary-controller.js
index ff621b9..c4dad61 100644
--- a/modules/control-center-web/src/main/js/controllers/summary-controller.js
+++ b/modules/control-center-web/src/main/js/controllers/summary-controller.js
@@ -93,7 +93,7 @@ consoleModule.controller('summaryController', [
 
     $scope.generateJavaServer = function () {
         $scope.javaServer = $generatorJava.cluster($scope.selectedItem,
-            $scope.configServer.javaClassServer === 2 ? 'ServerConfigurationFactory' : false,
false);
+            $scope.configServer.javaClassServer === 2 ? 'ServerConfigurationFactory' : false,
null, false);
     };
 
     function selectPojoClass(config) {
@@ -214,8 +214,8 @@ consoleModule.controller('summaryController', [
         zip.file('config/' + cluster.name + '-server.xml', $generatorXml.cluster(cluster));
         zip.file('config/' + cluster.name + '-client.xml', $generatorXml.cluster(cluster,
clientNearConfiguration));
 
-        zip.file(srcPath + 'ServerConfigurationFactory.java', $generatorJava.cluster(cluster,
'ServerConfigurationFactory'));
-        zip.file(srcPath + 'ClientConfigurationFactory.java', $generatorJava.cluster(cluster,
'ClientConfigurationFactory', clientNearConfiguration));
+        zip.file(srcPath + 'ServerConfigurationFactory.java', $generatorJava.cluster(cluster,
'ServerConfigurationFactory', null, false));
+        zip.file(srcPath + 'ClientConfigurationFactory.java', $generatorJava.cluster(cluster,
'ClientConfigurationFactory', clientNearConfiguration, true));
         zip.file(srcPath + 'NodeStartup.java', $generatorJava.nodeStartup(cluster));
 
         zip.file('pom.xml', $generatorPom.pom(cluster.caches, '1.5.0-IWC').asString());

http://git-wip-us.apache.org/repos/asf/ignite/blob/fbf6a04d/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 6f34424..169f52d 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
@@ -98,6 +98,15 @@ $generatorJava.declareVariable = function (res, varName, varFullType, varFullAct
 };
 
 /**
+ * Clear list of declared variables.
+ *
+ * @param res
+ */
+$generatorJava.resetVariables = function (res) {
+    res.vars = {};
+};
+
+/**
  * Add property via setter / property name.
  *
  * @param res Resulting output with generated code.
@@ -1879,6 +1888,31 @@ $generatorJava.cluster = function (cluster, javaClass, clientNearCfg,
clientMode
 
             res.needEmptyLine = true;
 
+            if (clientMode && clientNearCfg) {
+                res.line('/**');
+                res.line(' * Configure client near cache configuration.');
+                res.line(' *');
+                res.line(' * @return Near cache configuration.');
+                res.line(' * @throws Exception If failed to construct near cache configuration
instance.');
+                res.line(' */');
+                res.startBlock('public static NearCacheConfiguration createNearCacheConfiguration()
throws Exception {');
+
+                $generatorJava.resetVariables(res);
+
+                $generatorJava.declareVariable(res, 'nearCfg', 'org.apache.ignite.configuration.NearCacheConfiguration');
+
+                if (clientNearCfg.nearStartSize)
+                    $generatorJava.property(res, 'nearCfg', clientNearCfg, 'nearStartSize');
+
+                if (clientNearCfg.nearEvictionPolicy && clientNearCfg.nearEvictionPolicy.kind)
+                    $generatorJava.evictionPolicy(res, 'nearCfg', clientNearCfg.nearEvictionPolicy,
'nearEvictionPolicy');
+
+                res.line('return nearCfg;');
+                res.endBlock('}')
+            }
+
+            res.needEmptyLine = true;
+
             res.line('/**');
             res.line(' * Sample usage of ' + javaClass + '.');
             res.line(' *');
@@ -1887,9 +1921,24 @@ $generatorJava.cluster = function (cluster, javaClass, clientNearCfg,
clientMode
             res.line(' */');
 
             res.startBlock('public static void main(String[] args) throws Exception {');
-            res.startBlock('try (Ignite ignite = Ignition.start(' + javaClass + '.createConfiguration()))
{');
-            res.line('System.out.println("Write some code here...");');
-            res.endBlock('}');
+
+            if (clientMode) {
+                res.startBlock('try (Ignite ignite = Ignition.start(' + javaClass + '.createConfiguration()))
{');
+
+                if ($commonUtils.isDefinedAndNotEmpty(cluster.caches)) {
+                    res.line('// Example of near cache creation on client node.');
+                    res.line('ignite.getOrCreateNearCache("' + cluster.caches[0].name + '",
' + javaClass + '.createNearCacheConfiguration());');
+
+                    res.needEmptyLine = true;
+                }
+
+                res.line('System.out.println("Write some code here...");');
+
+                res.endBlock('}');
+            }
+            else
+                res.line('Ignition.start(' + javaClass + '.createConfiguration());');
+
             res.endBlock('}');
 
             res.endBlock('}');


Mime
View raw message