Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CE2D418DF2 for ; Thu, 21 Jan 2016 03:08:19 +0000 (UTC) Received: (qmail 90433 invoked by uid 500); 21 Jan 2016 03:08:19 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 90398 invoked by uid 500); 21 Jan 2016 03:08:19 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 90389 invoked by uid 99); 21 Jan 2016 03:08:19 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Jan 2016 03:08:19 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6EF0BDFF93; Thu, 21 Jan 2016 03:08:19 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: anovikov@apache.org To: commits@ignite.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: ignite git commit: IGNITE-2346 Common class with datasource instances. Date: Thu, 21 Jan 2016 03:08:19 +0000 (UTC) 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 Authored: Thu Jan 21 10:08:37 2016 +0700 Committer: Andrey 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;