From 0a7ef76f2704c959d7411766f9c200ea9f28c755 Mon Sep 17 00:00:00 2001 From: Gavin Cornwell Date: Fri, 12 Aug 2011 14:07:43 +0000 Subject: [PATCH] Added code to create a transient ActivitiEngine to initialise the DB schema during bootstrap. Code is currently commented out though as it's still not working. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29720 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/bootstrap-context.xml | 5 --- .../repo/domain/schema/SchemaBootstrap.java | 43 +++++++++++++++---- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/config/alfresco/bootstrap-context.xml b/config/alfresco/bootstrap-context.xml index 9ec435c030..4429404dd3 100644 --- a/config/alfresco/bootstrap-context.xml +++ b/config/alfresco/bootstrap-context.xml @@ -57,11 +57,6 @@ - diff --git a/source/java/org/alfresco/repo/domain/schema/SchemaBootstrap.java b/source/java/org/alfresco/repo/domain/schema/SchemaBootstrap.java index a5f301c64c..6ebe88d582 100644 --- a/source/java/org/alfresco/repo/domain/schema/SchemaBootstrap.java +++ b/source/java/org/alfresco/repo/domain/schema/SchemaBootstrap.java @@ -42,6 +42,7 @@ import java.util.Properties; import javax.sql.DataSource; import org.activiti.engine.ProcessEngine; +import org.activiti.engine.ProcessEngineConfiguration; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.ibatis.SerializableTypeHandler; import org.alfresco.repo.admin.patch.Patch; @@ -195,7 +196,6 @@ public class SchemaBootstrap extends AbstractLifecycleBean private DataSource dataSource; private LocalSessionFactoryBean localSessionFactory; - private ProcessEngine activitiProcessEngine; private String schemaOuputFilename; private boolean updateSchema; private boolean stopAfterSchemaBootstrap; @@ -237,11 +237,6 @@ public class SchemaBootstrap extends AbstractLifecycleBean { return localSessionFactory; } - - public void setActivitiProcessEngine(ProcessEngine processEngine) - { - this.activitiProcessEngine = processEngine; - } /** * Set this to output the full database creation script @@ -796,12 +791,44 @@ public class SchemaBootstrap extends AbstractLifecycleBean checkSchemaPatchScripts(cfg, connection, postUpdateScriptPatches, true); } - // Ask emebedded Activiti to create or update it's schema -// activitiProcessEngine.getManagementService().databaseSchemaUpgrade(connection, null, null); + // initialise Activiti +// initialiseActivitiDBSchema(connection); return create; } + /** + * Initialises the Activiti DB schema, if not present it's created, if + * present it is upgraded appropriately if necessary. + * + * @param connection Connection to use the initialise DB schema + */ + private void initialiseActivitiDBSchema(Connection connection) + { + // create instance of activiti engine to initialise schema + ProcessEngine engine = null; + ProcessEngineConfiguration engineConfig = ProcessEngineConfiguration.createStandaloneProcessEngineConfiguration(); + try + { + // build the engine + engine = engineConfig.setDataSource(dataSource). + setDatabaseSchemaUpdate("none"). + setJobExecutorActivate(false). + buildProcessEngine(); + + // create or upgrade the DB schema + engine.getManagementService().databaseSchemaUpgrade(connection, null, null); + } + finally + { + if (engine != null) + { + // close the process engine + engine.close(); + } + } + } + /** * Check that the necessary scripts have been executed against the database */