Better Java 8 map iteration
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/22900099 Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/22900099 Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/22900099 Branch: refs/heads/master Commit: 22900099e40b5b478f7085e5a838435f461fd6ad Parents: b36d348 Author: Francesco Chicchiriccò <[email protected]> Authored: Wed May 30 15:53:36 2018 +0200 Committer: Francesco Chicchiriccò <[email protected]> Committed: Wed May 30 15:53:36 2018 +0200 ---------------------------------------------------------------------- .../spring/DomainProcessEngineFactoryBean.java | 51 ++++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/22900099/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/spring/DomainProcessEngineFactoryBean.java ---------------------------------------------------------------------- diff --git a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/spring/DomainProcessEngineFactoryBean.java b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/spring/DomainProcessEngineFactoryBean.java index dba98e7..ed6cd25 100644 --- a/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/spring/DomainProcessEngineFactoryBean.java +++ b/core/workflow-flowable/src/main/java/org/apache/syncope/core/workflow/flowable/spring/DomainProcessEngineFactoryBean.java @@ -57,34 +57,33 @@ public class DomainProcessEngineFactoryBean if (engine == null) { Map<String, ProcessEngine> engines = new HashMap<>(); - ctx.getBeansOfType(DataSource.class).entrySet().stream(). - filter(entry -> (!entry.getKey().startsWith("local"))). - forEachOrdered(entry -> { - String domain = StringUtils.substringBefore(entry.getKey(), DataSource.class.getSimpleName()); - DataSource dataSource = entry.getValue(); - PlatformTransactionManager transactionManager = ctx.getBean( - domain + "TransactionManager", PlatformTransactionManager.class); - Object entityManagerFactory = ctx.getBean(domain + "EntityManagerFactory"); + ctx.getBeansOfType(DataSource.class).forEach((key, dataSource) -> { + if (!key.startsWith("local")) { + String domain = StringUtils.substringBefore(key, DataSource.class.getSimpleName()); + PlatformTransactionManager transactionManager = ctx.getBean( + domain + "TransactionManager", PlatformTransactionManager.class); + Object entityManagerFactory = ctx.getBean(domain + "EntityManagerFactory"); - SpringProcessEngineConfiguration conf = ctx.getBean(SpringProcessEngineConfiguration.class); - conf.setDataSource(dataSource); - conf.setTransactionManager(transactionManager); - conf.setTransactionsExternallyManaged(true); - conf.setJpaEntityManagerFactory(entityManagerFactory); - if (conf.getBeans() == null) { - conf.setBeans(new SpringBeanFactoryProxyMap(ctx)); - } - if (conf.getExpressionManager() == null) { - conf.setExpressionManager(new SpringExpressionManager(ctx, conf.getBeans())); - } - if (EngineServiceUtil.getIdmEngineConfiguration(conf) == null) { - conf.addEngineConfiguration( - EngineConfigurationConstants.KEY_IDM_ENGINE_CONFIG, - ctx.getBean(SpringIdmEngineConfiguration.class)); - } + SpringProcessEngineConfiguration conf = ctx.getBean(SpringProcessEngineConfiguration.class); + conf.setDataSource(dataSource); + conf.setTransactionManager(transactionManager); + conf.setTransactionsExternallyManaged(true); + conf.setJpaEntityManagerFactory(entityManagerFactory); + if (conf.getBeans() == null) { + conf.setBeans(new SpringBeanFactoryProxyMap(ctx)); + } + if (conf.getExpressionManager() == null) { + conf.setExpressionManager(new SpringExpressionManager(ctx, conf.getBeans())); + } + if (EngineServiceUtil.getIdmEngineConfiguration(conf) == null) { + conf.addEngineConfiguration( + EngineConfigurationConstants.KEY_IDM_ENGINE_CONFIG, + ctx.getBean(SpringIdmEngineConfiguration.class)); + } - engines.put(domain, conf.buildProcessEngine()); - }); + engines.put(domain, conf.buildProcessEngine()); + } + }); engine = new DomainProcessEngine(engines); }
