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

@@ -57,11 +57,6 @@
<property name="localSessionFactory"> <property name="localSessionFactory">
<ref bean="&amp;sessionFactory"></ref> <!-- inject the actual factory, not a session --> <ref bean="&amp;sessionFactory"></ref> <!-- inject the actual factory, not a session -->
</property> </property>
<!--
<property name="activitiProcessEngine">
<ref bean="activitiProcessEngine" />
</property>
-->
<property name="dialect"> <property name="dialect">
<ref bean="dialect" /> <ref bean="dialect" />
</property> </property>

View File

@@ -42,6 +42,7 @@ import java.util.Properties;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.activiti.engine.ProcessEngine; import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.ibatis.SerializableTypeHandler; import org.alfresco.ibatis.SerializableTypeHandler;
import org.alfresco.repo.admin.patch.Patch; import org.alfresco.repo.admin.patch.Patch;
@@ -195,7 +196,6 @@ public class SchemaBootstrap extends AbstractLifecycleBean
private DataSource dataSource; private DataSource dataSource;
private LocalSessionFactoryBean localSessionFactory; private LocalSessionFactoryBean localSessionFactory;
private ProcessEngine activitiProcessEngine;
private String schemaOuputFilename; private String schemaOuputFilename;
private boolean updateSchema; private boolean updateSchema;
private boolean stopAfterSchemaBootstrap; private boolean stopAfterSchemaBootstrap;
@@ -238,11 +238,6 @@ public class SchemaBootstrap extends AbstractLifecycleBean
return localSessionFactory; return localSessionFactory;
} }
public void setActivitiProcessEngine(ProcessEngine processEngine)
{
this.activitiProcessEngine = processEngine;
}
/** /**
* Set this to output the full database creation script * Set this to output the full database creation script
* *
@@ -796,12 +791,44 @@ public class SchemaBootstrap extends AbstractLifecycleBean
checkSchemaPatchScripts(cfg, connection, postUpdateScriptPatches, true); checkSchemaPatchScripts(cfg, connection, postUpdateScriptPatches, true);
} }
// Ask emebedded Activiti to create or update it's schema // initialise Activiti
// activitiProcessEngine.getManagementService().databaseSchemaUpgrade(connection, null, null); // initialiseActivitiDBSchema(connection);
return create; 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 * Check that the necessary scripts have been executed against the database
*/ */