From d093b6a8e4bd4bbe342027a0795b8bcc34b9ec36 Mon Sep 17 00:00:00 2001 From: Gavin Cornwell Date: Thu, 18 Aug 2011 19:41:52 +0000 Subject: [PATCH] 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 --- config/alfresco/activiti-context.xml | 17 +++++------ .../repo/domain/schema/SchemaBootstrap.java | 6 ++-- .../activiti/ActivitiEngineInitializer.java | 28 ++++++++++++------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/config/alfresco/activiti-context.xml b/config/alfresco/activiti-context.xml index 0cada51dd5..78aea7b39c 100644 --- a/config/alfresco/activiti-context.xml +++ b/config/alfresco/activiti-context.xml @@ -2,10 +2,10 @@ @@ -45,11 +45,11 @@ - + - - + + @@ -190,7 +190,8 @@ - + + diff --git a/source/java/org/alfresco/repo/domain/schema/SchemaBootstrap.java b/source/java/org/alfresco/repo/domain/schema/SchemaBootstrap.java index 52233a6eaf..88f03c41ed 100644 --- a/source/java/org/alfresco/repo/domain/schema/SchemaBootstrap.java +++ b/source/java/org/alfresco/repo/domain/schema/SchemaBootstrap.java @@ -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); } - } } diff --git a/source/java/org/alfresco/repo/workflow/activiti/ActivitiEngineInitializer.java b/source/java/org/alfresco/repo/workflow/activiti/ActivitiEngineInitializer.java index a2fd8434d9..5a321fed47 100644 --- a/source/java/org/alfresco/repo/workflow/activiti/ActivitiEngineInitializer.java +++ b/source/java/org/alfresco/repo/workflow/activiti/ActivitiEngineInitializer.java @@ -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 { 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(); + } + } }