ALF-9258: Added isEngineEnabled check to the Activiti engine initialisation so the JobExecuterThread is not started when it doesn't need to be.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29897 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2011-08-18 19:41:52 +00:00
parent 355cfd4f95
commit d093b6a8e4
3 changed files with 30 additions and 21 deletions

View File

@@ -45,7 +45,7 @@
<property name="databaseSchemaUpdate" value="none" />
<property name="history" value="full" />
<!-- Job-executor will be enabled once has been SchemaAvailableEvent fired -->
<!-- Job-executor will be enabled once the SchemaAvailableEvent has been fired -->
<property name="jobExecutorActivate" value="false" />
<!-- Limit the visible beans in expressions -->
@@ -191,6 +191,7 @@
<!-- Starting job-executor, after SchemaAvailableEvent has been broadcasted -->
<bean id="activitiEngineInitializer" class="org.alfresco.repo.workflow.activiti.ActivitiEngineInitializer">
<property name="processEngine" ref="activitiProcessEngine" />
<property name="workflowAdminService" ref="workflowAdminService" />
</bean>
</beans>

View File

@@ -1697,14 +1697,15 @@ public class SchemaBootstrap extends AbstractLifecycleBean
*
* @author Frederik Heremans
*/
public class UnclosableConnection implements Connection {
public class UnclosableConnection implements Connection
{
private Connection wrapped;
public UnclosableConnection(Connection wrappedConnection)
{
this.wrapped = wrappedConnection;
}
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException
{
@@ -2007,6 +2008,5 @@ public class SchemaBootstrap extends AbstractLifecycleBean
{
wrapped.setTypeMap(map);
}
}
}

View File

@@ -21,6 +21,7 @@ package org.alfresco.repo.workflow.activiti;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.impl.ProcessEngineImpl;
import org.alfresco.repo.domain.schema.SchemaAvailableEvent;
import org.alfresco.service.cmr.workflow.WorkflowAdminService;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
@@ -33,19 +34,26 @@ import org.springframework.context.ApplicationListener;
public class ActivitiEngineInitializer implements ApplicationListener<ApplicationEvent>
{
private ProcessEngine processEngine;
@Override
public void onApplicationEvent(ApplicationEvent event)
{
if(event instanceof SchemaAvailableEvent && processEngine instanceof ProcessEngineImpl)
{
// Start the job-executor
((ProcessEngineImpl)processEngine).getProcessEngineConfiguration().getJobExecutor().start();
}
}
private WorkflowAdminService workflowAdminService;
public void setProcessEngine(ProcessEngine processEngine)
{
this.processEngine = processEngine;
}
public void setWorkflowAdminService(WorkflowAdminService workflowAdminService)
{
this.workflowAdminService = workflowAdminService;
}
@Override
public void onApplicationEvent(ApplicationEvent event)
{
if (event instanceof SchemaAvailableEvent && processEngine instanceof ProcessEngineImpl &&
workflowAdminService.isEngineEnabled(ActivitiConstants.ENGINE_ID))
{
// Start the job-executor
((ProcessEngineImpl)processEngine).getProcessEngineConfiguration().getJobExecutor().start();
}
}
}