Repository: ignite
Updated Branches:
  refs/heads/ignite-843-rc2 87df9d4a5 -> 965e307e7


IGNITE-2346 Common class with datasource instances.


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

Branch: refs/heads/ignite-843-rc2
Commit: 965e307e7b71e71f7d3b1f2a79b7686b441d3f07
Parents: 87df9d4
Author: Vasiliy Sisko <[email protected]>
Authored: Thu Jan 21 10:08:37 2016 +0700
Committer: Andrey <[email protected]>
Committed: Thu Jan 21 10:08:37 2016 +0700

----------------------------------------------------------------------
 .../main/js/helpers/generator/generator-java.js | 29 +++++++++++++-------
 1 file changed, 19 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/965e307e/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 aae4a41..fe1bf4a 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
@@ -1036,13 +1036,11 @@ $generatorJava.cacheStoreDataSource = function 
(storeFactory, res) {
 
         var beanClassName = $commonUtils.toJavaName(varType, dataSourceBean);
 
-        res.line('/** Helper class for datasource creation. */');
-        res.startBlock('public static class ' + beanClassName + ' {');
-        res.line('public static final ' + varType + ' INSTANCE = 
createInstance();');
+        res.line('public static final ' + varType + ' INSTANCE_' + 
dataSourceBean + ' = create' + dataSourceBean + '();');
 
         res.needEmptyLine = true;
 
-        res.startBlock('private static ' + varType + ' createInstance() {');
+        res.startBlock('private static ' + varType + ' create' + 
dataSourceBean + '() {');
         if (dialect === 'Oracle')
             res.startBlock('try {');
 
@@ -1053,8 +1051,6 @@ $generatorJava.cacheStoreDataSource = function 
(storeFactory, res) {
         switch (dialect) {
             case 'Generic':
                 res.line(varName + '.setJdbcUrl(props.getProperty("' + 
dataSourceBean + '.jdbc.url"));');
-                res.line(varName + '.setUser(props.getProperty("' + 
dataSourceBean + '.jdbc.username"));');
-                res.line(varName + '.setPassword(props.getProperty("' + 
dataSourceBean + '.jdbc.password"));');
 
                 break;
 
@@ -1092,7 +1088,6 @@ $generatorJava.cacheStoreDataSource = function 
(storeFactory, res) {
         }
 
         res.endBlock('}');
-        res.endBlock('}');
 
         res.needEmptyLine = true;
 
@@ -1108,6 +1103,8 @@ $generatorJava.clusterDataSources = function (caches, 
res) {
 
     var datasources = [];
 
+    var storeFound = false;
+
     _.forEach(caches, function (cache) {
         var factoryKind = cache.cacheStoreFactory.kind;
 
@@ -1119,12 +1116,24 @@ $generatorJava.clusterDataSources = function (caches, 
res) {
             if (beanClassName && !_.contains(datasources, beanClassName)) {
                 datasources.push(beanClassName);
 
-                if (factoryKind === 'CacheJdbcPojoStoreFactory' || factoryKind 
=== 'CacheJdbcBlobStoreFactory')
+                if (factoryKind === 'CacheJdbcPojoStoreFactory' || factoryKind 
=== 'CacheJdbcBlobStoreFactory') {
+                    if (!storeFound) {
+                        res.line('/** Helper class for datasource creation. 
*/');
+                        res.startBlock('public static class DataSources {');
+
+                        storeFound = true;
+                    }
+
                     $generatorJava.cacheStoreDataSource(storeFactory, res);
+                }
             }
         }
     });
 
+    if (storeFound) {
+        res.endBlock('}');
+    }
+
     return res;
 };
 
@@ -1161,7 +1170,7 @@ $generatorJava.cacheStore = function (cache, domains, 
cacheVarName, res) {
 
                 var beanClassName = $generatorJava.dataSourceClassName(res, 
storeFactory);
 
-                res.line('setDataSource(' + beanClassName + '.INSTANCE);');
+                res.line('setDataSource(DataSources.INSTANCE_' + 
storeFactory.dataSourceBean + ');');
 
                 res.needEmptyLine = true;
 
@@ -1212,7 +1221,7 @@ $generatorJava.cacheStore = function (cache, domains, 
cacheVarName, res) {
 
                     beanClassName = $generatorJava.dataSourceClassName(res, 
storeFactory);
 
-                    res.line('setDataSource(' + beanClassName + '.INSTANCE);');
+                    res.line('setDataSource(DataSources.INSTANCE_' + 
storeFactory.dataSourceBean + ');');
 
                     res.needEmptyLine = true;
 

Reply via email to