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

@@ -2,10 +2,10 @@
<beans xmlns="http://www.springframework.org/schema/beans" <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util" xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
@@ -45,11 +45,11 @@
<property name="databaseSchemaUpdate" value="none" /> <property name="databaseSchemaUpdate" value="none" />
<property name="history" value="full" /> <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" /> <property name="jobExecutorActivate" value="false" />
<!-- Limit the visible beans in expressions --> <!-- Limit the visible beans in expressions -->
<property name="beans" ref="activitiBeanRegistry" /> <property name="beans" ref="activitiBeanRegistry" />
<property name="customTypes"> <property name="customTypes">
<list> <list>
@@ -190,7 +190,8 @@
<!-- Starting job-executor, after SchemaAvailableEvent has been broadcasted --> <!-- Starting job-executor, after SchemaAvailableEvent has been broadcasted -->
<bean id="activitiEngineInitializer" class="org.alfresco.repo.workflow.activiti.ActivitiEngineInitializer"> <bean id="activitiEngineInitializer" class="org.alfresco.repo.workflow.activiti.ActivitiEngineInitializer">
<property name="processEngine" ref="activitiProcessEngine" /> <property name="processEngine" ref="activitiProcessEngine" />
<property name="workflowAdminService" ref="workflowAdminService" />
</bean> </bean>
</beans> </beans>

View File

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

View File

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