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
This commit is contained in:
Gavin Cornwell
2011-08-12 14:07:43 +00:00
parent 16d2b34261
commit 0a7ef76f27
2 changed files with 35 additions and 13 deletions

View File

@@ -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
*/