You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2019/03/20 07:33:45 UTC

[syncope] branch master updated: Flowable: allow to configure IdGenerator

This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git


The following commit(s) were added to refs/heads/master by this push:
     new 114c412  Flowable: allow to configure IdGenerator
114c412 is described below

commit 114c412afbfba24ffb4fbc804e5308a823a16a78
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Wed Mar 20 08:33:31 2019 +0100

    Flowable: allow to configure IdGenerator
---
 .../syncope/core/flowable/WorkflowFlowableContext.java  | 17 +++++++++++++++++
 .../apache/syncope/core/logic/init/FlowableLoader.java  | 13 +++++++------
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/WorkflowFlowableContext.java b/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/WorkflowFlowableContext.java
index ff072db..9871471 100644
--- a/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/WorkflowFlowableContext.java
+++ b/ext/flowable/flowable-bpmn/src/main/java/org/apache/syncope/core/flowable/WorkflowFlowableContext.java
@@ -28,7 +28,9 @@ import org.apache.syncope.core.flowable.support.SyncopeIdmIdentityService;
 import org.apache.syncope.core.spring.ResourceWithFallbackLoader;
 import org.apache.syncope.core.workflow.java.WorkflowContext;
 import org.flowable.common.engine.impl.AbstractEngineConfiguration;
+import org.flowable.common.engine.impl.cfg.IdGenerator;
 import org.flowable.common.engine.impl.history.HistoryLevel;
+import org.flowable.engine.impl.db.DbIdGenerator;
 import org.flowable.idm.spring.SpringIdmEngineConfiguration;
 import org.flowable.idm.spring.configurator.SpringIdmEngineConfigurator;
 import org.flowable.spring.SpringProcessEngineConfiguration;
@@ -103,6 +105,20 @@ public class WorkflowFlowableContext {
         return new SyncopeEntitiesVariableType();
     }
 
+    /**
+     * This is called to generate unique identifiers for database entities used by Flowable.
+     *
+     * Consider to switch to {@link import org.flowable.common.engine.impl.persistence.StrongUuidGenerator} in
+     * high-demanding production environments.
+     *
+     * @return {@link IdGenerator} used by Flowable
+     */
+    @ConditionalOnMissingBean
+    @Bean
+    public IdGenerator idGenerator() {
+        return new DbIdGenerator();
+    }
+
     @ConditionalOnMissingBean
     @Bean
     @Scope("prototype")
@@ -115,6 +131,7 @@ public class WorkflowFlowableContext {
         conf.setIdmEngineConfigurator(syncopeIdmEngineConfigurator());
         conf.setCustomPreVariableTypes(Arrays.asList(syncopeEntitiesVariableType()));
         conf.setFormHandlerHelper(syncopeFormHandlerHelper());
+        conf.setIdGenerator(idGenerator());
         return conf;
     }
 
diff --git a/ext/flowable/logic/src/main/java/org/apache/syncope/core/logic/init/FlowableLoader.java b/ext/flowable/logic/src/main/java/org/apache/syncope/core/logic/init/FlowableLoader.java
index 070c167..c8dee7a 100644
--- a/ext/flowable/logic/src/main/java/org/apache/syncope/core/logic/init/FlowableLoader.java
+++ b/ext/flowable/logic/src/main/java/org/apache/syncope/core/logic/init/FlowableLoader.java
@@ -33,8 +33,8 @@ import org.apache.syncope.core.persistence.api.SyncopeCoreLoader;
 import org.apache.syncope.core.provisioning.api.EntitlementsHolder;
 import org.apache.syncope.core.spring.ResourceWithFallbackLoader;
 import org.flowable.engine.ProcessEngine;
+import org.flowable.engine.impl.db.DbIdGenerator;
 import org.flowable.engine.repository.ProcessDefinition;
-import org.flowable.spring.SpringProcessEngineConfiguration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -92,12 +92,13 @@ public class FlowableLoader implements SyncopeCoreLoader {
                 FlowableDeployUtils.deployModel(processEngine, procDef);
 
                 LOG.debug("Flowable Workflow definition loaded for domain {}", domain);
-            }
 
-            // jump to the next ID block
-            for (int i = 0; i < processEngine.getProcessEngineConfiguration().getIdBlockSize(); i++) {
-                SpringProcessEngineConfiguration.class.cast(processEngine.getProcessEngineConfiguration()).
-                        getIdGenerator().getNextId();
+                if (processEngine.getProcessEngineConfiguration().getIdGenerator() instanceof DbIdGenerator) {
+                    // jump to the next ID block
+                    for (int i = 0; i < processEngine.getProcessEngineConfiguration().getIdBlockSize(); i++) {
+                        processEngine.getProcessEngineConfiguration().getIdGenerator().getNextId();
+                    }
+                }
             }
         }
     }