Search in sources :

Example 1 with MultiSchemaMultiTenantProcessDefinitionCache

use of org.activiti.engine.impl.persistence.deploy.MultiSchemaMultiTenantProcessDefinitionCache in project Activiti by Activiti.

the class MultiSchemaMultiTenantProcessEngineConfiguration method buildProcessEngine.

@Override
public ProcessEngine buildProcessEngine() {
    if (databaseType == null) {
        throw new ActivitiException("Setting the databaseType is mandatory when using MultiSchemaMultiTenantProcessEngineConfiguration");
    }
    // Disable schema creation/validation by setting it to null.
    // We'll do it manually, see buildProcessEngine() method (hence why it's copied first)
    String originalDatabaseSchemaUpdate = this.databaseSchemaUpdate;
    this.databaseSchemaUpdate = null;
    // Using a cache / tenant to avoid process definition id conflicts
    this.processDefinitionCache = new MultiSchemaMultiTenantProcessDefinitionCache(tenantInfoHolder, this.processDefinitionCacheLimit);
    // Also, we shouldn't start the async executor until *after* the schema's have been created
    boolean originalIsAutoActivateAsyncExecutor = this.asyncExecutorActivate;
    this.asyncExecutorActivate = false;
    ProcessEngine processEngine = super.buildProcessEngine();
    // Reset to original values
    this.databaseSchemaUpdate = originalDatabaseSchemaUpdate;
    this.asyncExecutorActivate = originalIsAutoActivateAsyncExecutor;
    // Create tenant schema
    for (String tenantId : tenantInfoHolder.getAllTenants()) {
        createTenantSchema(tenantId);
    }
    // Start async executor
    if (asyncExecutor != null && originalIsAutoActivateAsyncExecutor) {
        asyncExecutor.start();
    }
    booted = true;
    return processEngine;
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) MultiSchemaMultiTenantProcessDefinitionCache(org.activiti.engine.impl.persistence.deploy.MultiSchemaMultiTenantProcessDefinitionCache) ProcessEngine(org.activiti.engine.ProcessEngine)

Aggregations

ActivitiException (org.activiti.engine.ActivitiException)1 ProcessEngine (org.activiti.engine.ProcessEngine)1 MultiSchemaMultiTenantProcessDefinitionCache (org.activiti.engine.impl.persistence.deploy.MultiSchemaMultiTenantProcessDefinitionCache)1