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-1714 Added support for JDBC drivers in pom.xml and fixed java code generation of datasources.
Date Tue, 20 Oct 2015 04:06:30 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-843-rc1 3507435e3 -> 4cc2dc98a


IGNITE-1714 Added support for JDBC drivers in pom.xml and fixed java code generation of datasources.


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

Branch: refs/heads/ignite-843-rc1
Commit: 4c35575b2e6c10cd563ad2b5d0024ea9ffe947d4
Parents: 432e556
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Tue Oct 20 11:06:08 2015 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Tue Oct 20 11:06:08 2015 +0700

----------------------------------------------------------------------
 .../main/js/routes/generator/generator-java.js  | 32 +++++++-------
 .../main/js/routes/generator/generator-pom.js   | 45 ++++++++++++++++++--
 .../js/routes/generator/generator-readme.js     |  5 +++
 .../src/main/js/routes/summary.js               |  3 +-
 4 files changed, 66 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/4c35575b/modules/control-center-web/src/main/js/routes/generator/generator-java.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/generator/generator-java.js b/modules/control-center-web/src/main/js/routes/generator/generator-java.js
index b6f5c3c..4c4ca38 100644
--- a/modules/control-center-web/src/main/js/routes/generator/generator-java.js
+++ b/modules/control-center-web/src/main/js/routes/generator/generator-java.js
@@ -878,18 +878,18 @@ $generatorJava.cacheStore = function (cache, varName, res) {
 
                     switch (storeFactory.dialect) {
                         case 'DB2':
-                            res.line(dsVarName + '.setServerName(_SERVER_NAME_);');
-                            res.line(dsVarName + '.setPortNumber(_PORT_NUMBER_);');
-                            res.line(dsVarName + '.setDatabaseName(_DATABASE_NAME_);');
-                            res.line(dsVarName + '.setDriverType(_DRIVER_TYPE_);');
+                            res.line(dsVarName + '.setServerName("_SERVER_NAME_");');
+                            res.line('// ' + dsVarName + '.setPortNumber("_PORT_NUMBER_");
// 50000 by default');
+                            res.line(dsVarName + '.setDatabaseName("_DATABASE_NAME_");');
+                            res.line('// ' + dsVarName + '.setDriverType(_DRIVER_TYPE_);
// 4 by default');
                             break;
 
                         default:
-                            res.line(dsVarName + '.setURL(_URL_);');
+                            res.line(dsVarName + '.setURL("_URL_");');
                     }
 
-                    res.line(dsVarName + '.setUsername(_User_Name_);');
-                    res.line(dsVarName + '.setPassword(_Password_);');
+                    res.line(dsVarName + '.setUser("_USER_NAME_");');
+                    res.line(dsVarName + '.setPassword("_PASSWORD_");');
                 }
             }
 
@@ -1535,8 +1535,11 @@ $generatorJava.cluster = function (cluster, javaClass, clientNearCfg)
{
             res.startBlock('public class ConfigurationFactory {');
             res.line('/**');
             res.line(' * Configure grid.');
+            res.line(' *');
+            res.line(' * @return Ignite configuration.');
+            res.line(' * @throws Exception If failed to construct Ignite configuration instance.');
             res.line(' */');
-            res.startBlock('public static IgniteConfiguration createConfiguration() {');
+            res.startBlock('public static IgniteConfiguration createConfiguration() throws
Exception {');
         }
 
         $generatorJava.clusterGeneral(cluster, clientNearCfg, res);
@@ -1567,20 +1570,19 @@ $generatorJava.cluster = function (cluster, javaClass, clientNearCfg)
{
 
         if (javaClass) {
             res.importClass('org.apache.ignite.Ignite');
-            res.importClass('org.apache.ignite.IgniteException');
             res.importClass('org.apache.ignite.Ignition');
 
             res.line('return cfg;');
             res.endBlock('}');
 
             res.line('/**');
-            res.line('* Sample usage of ConfigurationFactory.');
-            res.line('*');
-            res.line('* @param args Command line arguments, none required.');
-            res.line('* @throws IgniteException If example execution failed.');
-            res.line('*/');
+            res.line(' * Sample usage of ConfigurationFactory.');
+            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 IgniteException
{');
+            res.startBlock('public static void main(String[] args) throws Exception {');
             res.startBlock('try (Ignite ignite = Ignition.start(ConfigurationFactory.createConfiguration()))
{');
             res.line('System.out.println("Write some code here...");');
             res.endBlock('}');

http://git-wip-us.apache.org/repos/asf/ignite/blob/4c35575b/modules/control-center-web/src/main/js/routes/generator/generator-pom.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/generator/generator-pom.js b/modules/control-center-web/src/main/js/routes/generator/generator-pom.js
index fec7288..b7bd05e 100644
--- a/modules/control-center-web/src/main/js/routes/generator/generator-pom.js
+++ b/modules/control-center-web/src/main/js/routes/generator/generator-pom.js
@@ -17,6 +17,8 @@
 
 // For server side we should load required libraries.
 if (typeof window === 'undefined') {
+    _ = require('lodash');
+
     $generatorCommon = require('./generator-common');
 }
 
@@ -26,23 +28,40 @@ $generatorPom = {};
 /**
  * Generate pom.xml.
  *
- * @param res Resulting output with generated pom.
+ * @param caches Collection of caches to take info about used JDBC dialects.
  * @param igniteVersion Ignite version for Ignite dependencies.
+ * @param res Resulting output with generated pom.
  * @returns {string} Generated content.
  */
-$generatorPom.pom = function (igniteVersion, res) {
+$generatorPom.pom = function (caches, igniteVersion, res) {
     if (!res)
         res = $generatorCommon.builder();
 
+    var dialect = {};
+
+    _.forEach(caches, function (cache) {
+        if (cache.cacheStoreFactory && cache.cacheStoreFactory.kind == 'CacheJdbcPojoStoreFactory')
{
+            if (cache.cacheStoreFactory.CacheJdbcPojoStoreFactory) {
+                dialect[cache.cacheStoreFactory.CacheJdbcPojoStoreFactory.dialect] = true;
+            }
+        }
+    });
+
     function addProperty(tag, val) {
         res.line('<' + tag + '>' + val + '</' + tag + '>');
     }
 
-    function addDependency(groupId, artifactId, version) {
+    function addDependency(groupId, artifactId, version, jar) {
         res.startBlock('<dependency>');
         addProperty('groupId', groupId);
         addProperty('artifactId', artifactId);
         addProperty('version', version);
+
+        if (jar) {
+            addProperty('scope', 'system');
+            addProperty('systemPath', '${project.basedir}/jdbc-drivers/' + jar);
+        }
+
         res.endBlock('</dependency>');
     }
 
@@ -81,10 +100,30 @@ $generatorPom.pom = function (igniteVersion, res) {
     res.needEmptyLine = true;
 
     res.startBlock('<dependencies>');
+
     addDependency('org.apache.ignite', 'ignite-core', igniteVersion);
     addDependency('org.apache.ignite', 'ignite-spring', igniteVersion);
     addDependency('org.apache.ignite', 'ignite-indexing', igniteVersion);
     addDependency('org.apache.ignite', 'ignite-rest-http', igniteVersion);
+
+    if (dialect.MySQL)
+        addDependency('mysql', 'mysql-connector-java', '5.1.37');
+
+    if (dialect.PosgreSQL)
+        addDependency('org.postgresql', 'postgresql', '9.4-1204-jdbc42');
+
+    if (dialect.H2)
+        addDependency('com.h2database', 'h2', '1.3.175');
+
+    if (dialect.Oracle)
+        addDependency('oracle', 'jdbc', '11.2', 'ojdbc6.jar');
+
+    if (dialect.DB2)
+        addDependency('ibm', 'jdbc', '4.19.26', 'db2jcc4.jar');
+
+    if (dialect.SQLServer)
+        addDependency('microsoft', 'jdbc', '4.1', 'sqljdbc41.jar');
+
     res.endBlock('</dependencies>');
 
     res.needEmptyLine = true;

http://git-wip-us.apache.org/repos/asf/ignite/blob/4c35575b/modules/control-center-web/src/main/js/routes/generator/generator-readme.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/generator/generator-readme.js b/modules/control-center-web/src/main/js/routes/generator/generator-readme.js
index d39cf64..aa90b64 100644
--- a/modules/control-center-web/src/main/js/routes/generator/generator-readme.js
+++ b/modules/control-center-web/src/main/js/routes/generator/generator-readme.js
@@ -46,6 +46,11 @@ $generatorReadme.readme = function (res) {
 
     res.line('You can use generated configuration and POJO classes as part of your application.');
 
+    res.needEmptyLine = true;
+
+    res.line('Note, in case of using proprietary JDBC drivers (Oracle, IBM DB2, Microsoft
SQL Server)');
+    res.line('you should download them and copy into /jdbc-drivers folder.)');
+
     return res;
 };
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/4c35575b/modules/control-center-web/src/main/js/routes/summary.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/summary.js b/modules/control-center-web/src/main/js/routes/summary.js
index ca2e141..12e7062 100644
--- a/modules/control-center-web/src/main/js/routes/summary.js
+++ b/modules/control-center-web/src/main/js/routes/summary.js
@@ -69,9 +69,10 @@ router.post('/download', function (req, res) {
 
         zip.file('config/' + cluster.name + '.xml', $generatorXml.cluster(cluster, clientNearConfiguration));
         zip.file(srcPath + 'ConfigurationFactory.java', $generatorJava.cluster(cluster, true,
clientNearConfiguration));
-        zip.file('pom.xml', $generatorPom.pom('1.5.0').asString());
+        zip.file('pom.xml', $generatorPom.pom(cluster.caches, '1.5.0').asString());
 
         zip.file('README.txt', $generatorReadme.readme().asString());
+        zip.file('jdbc-drivers/README.txt', 'Copy proprietary JDBC drivers to this folder.');
 
         $generatorJava.pojos(cluster.caches, req.body.useConstructor, req.body.includeKeyFields);
 


Mime
View raw message