ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject ignite git commit: IGNITE-2039 reworked generation of factory and node startup java files.
Date Wed, 02 Dec 2015 09:42:58 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-843-rc2 7530ec1c9 -> cc06ba1ca


IGNITE-2039 reworked generation of factory and node startup java files.


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

Branch: refs/heads/ignite-843-rc2
Commit: cc06ba1ca54e33e1a485ee93f3a8a1832465e729
Parents: 7530ec1
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Wed Dec 2 16:43:36 2015 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Wed Dec 2 16:43:36 2015 +0700

----------------------------------------------------------------------
 .../main/js/controllers/summary-controller.js   | 30 +++++---
 .../main/js/helpers/generator/generator-java.js | 72 +++++++++-----------
 2 files changed, 54 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/cc06ba1c/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 c2bb1d7..0b5b8b2 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
@@ -92,8 +92,8 @@ consoleModule.controller('summaryController', [
     };
 
     $scope.generateJavaServer = function () {
-        $scope.javaServer = $generatorJava.cluster($scope.selectedItem,
-            $scope.configServer.javaClassServer === 2 ? 'ServerConfigurationFactory' : false,
null, false);
+        $scope.javaServer = $generatorJava.cluster($scope.selectedItem, 'factory',
+            $scope.configServer.javaClassServer === 2 ? 'ServerConfigurationFactory' : false,
null);
     };
 
     function selectPojoClass(config) {
@@ -166,9 +166,9 @@ consoleModule.controller('summaryController', [
 
     $scope.generateClient = function () {
         $scope.xmlClient = $generatorXml.cluster($scope.selectedItem, $scope.backupItem.nearConfiguration);
-        $scope.javaClient = $generatorJava.cluster($scope.selectedItem,
+        $scope.javaClient = $generatorJava.cluster($scope.selectedItem, 'factory',
             $scope.backupItem.javaClassClient === 2 ? 'ClientConfigurationFactory' : false,
-            $scope.backupItem.nearConfiguration, true);
+            $scope.backupItem.nearConfiguration);
     };
 
     $scope.$watch('backupItem', $scope.generateClient, true);
@@ -198,7 +198,7 @@ consoleModule.controller('summaryController', [
 
     $scope.downloadConfiguration = function () {
         var cluster = $scope.selectedItem;
-        var clientNearConfiguration = $scope.backupItem.nearConfiguration;
+        var clientNearCfg = $scope.backupItem.nearConfiguration;
 
         var zip = new JSZip();
 
@@ -211,12 +211,22 @@ consoleModule.controller('summaryController', [
 
         var srcPath = 'src/main/java/';
 
-        zip.file('config/' + cluster.name + '-server.xml', $generatorXml.cluster(cluster));
-        zip.file('config/' + cluster.name + '-client.xml', $generatorXml.cluster(cluster,
clientNearConfiguration));
+        var serverXml = 'config/' + cluster.name + '-server.xml';
+        var clientXml = 'config/' + cluster.name + '-client.xml';
 
-        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(serverXml, $generatorXml.cluster(cluster));
+        zip.file(clientXml , $generatorXml.cluster(cluster, clientNearCfg));
+
+        zip.file(srcPath + '/factory/ServerConfigurationFactory.java', $generatorJava.cluster(cluster,
'factory', 'ServerConfigurationFactory', null));
+        zip.file(srcPath + '/factory/ClientConfigurationFactory.java', $generatorJava.cluster(cluster,
'factory', 'ClientConfigurationFactory', clientNearCfg));
+
+        zip.file(srcPath + '/startup/ServerNodeSpringStartup.java', $generatorJava.nodeStartup(cluster,
'startup', 'ServerNodeSpringStartup', '"' + serverXml + '"'));
+        zip.file(srcPath + '/startup/ClientNodeSpringStartup.java', $generatorJava.nodeStartup(cluster,
'startup', 'ClientNodeSpringStartup', '"' + clientXml + '"'));
+
+        zip.file(srcPath + '/startup/ServerNodeCodeStartup.java', $generatorJava.nodeStartup(cluster,
'startup', 'ServerNodeStartup',
+            'ServerConfigurationFactory.createConfiguration()', 'factory.ServerConfigurationFactory'));
+        zip.file(srcPath + '/startup/ClientNodeCodeStartup.java', $generatorJava.nodeStartup(cluster,
'startup', 'ClientNodeStartup',
+            'ClientConfigurationFactory.createConfiguration()', 'factory.ClientConfigurationFactory',
clientNearCfg));
 
         zip.file('pom.xml', $generatorPom.pom(cluster, igniteVersion).asString());
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/cc06ba1c/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 1ea01ae..bd3d579 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
@@ -1868,11 +1868,11 @@ $generatorJava.clusterConfiguration = function (cluster, clientNearCfg,
res) {
  * Function to generate java code for cluster configuration.
  *
  * @param cluster Cluster to process.
+ * @param pkg Package name.
  * @param javaClass Class name for generate factory class otherwise generate code snippet.
- * @param clientNearCfg Near cache configuration for client node.
- * @param clientMode If `true` generates code for client mode or server mode otherwise.
+ * @param clientNearCfg Optional near cache configuration for client node.
  */
-$generatorJava.cluster = function (cluster, javaClass, clientNearCfg, clientMode) {
+$generatorJava.cluster = function (cluster, pkg, javaClass, clientNearCfg) {
     var res = $generatorCommon.builder();
 
     if (cluster) {
@@ -1881,7 +1881,7 @@ $generatorJava.cluster = function (cluster, javaClass, clientNearCfg,
clientMode
         res.mergeProps(resCfg);
 
         if (javaClass) {
-            if (clientMode)
+            if (clientNearCfg)
                 res.importClass('org.apache.ignite.Ignite');
 
             res.importClass('org.apache.ignite.Ignition');
@@ -1926,7 +1926,7 @@ $generatorJava.cluster = function (cluster, javaClass, clientNearCfg,
clientMode
             res.needEmptyLine = true;
         }
 
-        if (clientMode && clientNearCfg) {
+        if (clientNearCfg) {
             if (javaClass) {
                 res.line('/**');
                 res.line(' * Configure client near cache configuration.');
@@ -1959,37 +1959,11 @@ $generatorJava.cluster = function (cluster, javaClass, clientNearCfg,
clientMode
         }
 
         if (javaClass) {
-            res.line('/**');
-            res.line(' * Sample usage of ' + javaClass + '.');
-            res.line(' *');
-            res.line(' * @param args Command line arguments, none required.');
-            res.line(' * @throws Exception If sample execution failed.');
-            res.line(' */');
-
-            res.startBlock('public static void main(String[] args) throws Exception {');
-
-            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('}');
 
-            return res.generateImports() + '\n\n' + res.asString();
+            return 'package ' + pkg + ';\n\n' + res.generateImports() + '\n\n' + res.asString();
         }
     }
 
@@ -1997,32 +1971,54 @@ $generatorJava.cluster = function (cluster, javaClass, clientNearCfg,
clientMode
 };
 
 /**
- * Function to generate java code for cluster configuration.
+ * Function to generate java class for node startup with cluster configuration.
+ *
  * @param cluster Cluster to process.
+ * @param pkg Class package name.
+ * @param cls Class name.
+ * @param cfg Config.
+ * @param factoryCls Optional fully qualified class name of configuration factory.
+ * @param clientNearCfg Optional near cache configuration for client node.
  */
-$generatorJava.nodeStartup = function (cluster) {
+$generatorJava.nodeStartup = function (cluster, pkg, cls, cfg, factoryCls, clientNearCfg)
{
     var res = $generatorCommon.builder();
 
     res.importClass('org.apache.ignite.IgniteException');
     res.importClass('org.apache.ignite.Ignition');
 
+    if (factoryCls)
+      res.importClass(factoryCls);
+
     res.line('/**');
     res.line(' * ' + $generatorCommon.mainComment());
     res.line(' */');
-    res.startBlock('public class NodeStartup {');
+    res.startBlock('public class ' + cls + ' {');
 
     res.line('/**');
-    res.line(' * Start up an server node.');
+    res.line(' * Start up node with specified configuration.');
     res.line(' *');
     res.line(' * @param args Command line arguments, none required.');
     res.line(' * @throws IgniteException If failed.');
     res.line(' */');
 
     res.startBlock('public static void main(String[] args) throws IgniteException {');
-    res.line('Ignition.start("config/' + cluster.name + '-server.xml");');
+
+    if (clientNearCfg) {
+        res.line('Ignite ignite = Ignition.start(' + cfg + ');');
+
+        if ($commonUtils.isDefinedAndNotEmpty(cluster.caches)) {
+            res.line('// Example of near cache creation on client node.');
+            res.line('ignite.getOrCreateNearCache("' + cluster.caches[0].name + '", ' + cls
+ '.createNearCacheConfiguration());');
+
+            res.needEmptyLine = true;
+        }
+    }
+    else
+        res.line('Ignition.start(' + cfg + ');');
+
     res.endBlock('}');
 
     res.endBlock('}');
 
-    return res.generateImports() + '\n\n' + res.asString();
+    return 'package ' + pkg + ';\n\n' + res.generateImports() + '\n\n' + res.asString();
 };


Mime
View raw message