提交 7fb6c020 编写于 作者: T Tijs Rademakers

Merge with master

......@@ -31,7 +31,7 @@ import org.activiti.engine.ActivitiException;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import org.activiti.engine.impl.util.cache.ProcessDefinitionCacheUtil;
import org.activiti.engine.impl.util.ProcessDefinitionUtil;
import org.activiti.engine.repository.ProcessDefinition;
/**
......@@ -76,7 +76,7 @@ public class CdiTaskListener implements TaskListener, Serializable {
}
protected BusinessProcessEvent createEvent(DelegateTask task) {
ProcessDefinition processDefinition = ProcessDefinitionCacheUtil.getCachedProcessDefinitionEntity(task.getExecution().getProcessDefinitionId());
ProcessDefinition processDefinition = ProcessDefinitionUtil.getProcessDefinitionEntity(task.getExecution().getProcessDefinitionId());
return new CdiBusinessProcessEvent(activityId, transitionName, processDefinition, task, type, task.getExecution().getProcessInstanceId(), task.getExecutionId(), new Date());
}
......
......@@ -20,7 +20,7 @@ import org.activiti.engine.delegate.event.ActivitiEventType;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.activiti.engine.impl.util.cache.ProcessDefinitionCacheUtil;
import org.activiti.engine.impl.util.ProcessDefinitionUtil;
import org.activiti.engine.repository.ProcessDefinition;
/**
......@@ -104,20 +104,22 @@ public class ActivitiEventDispatcherImpl implements ActivitiEventDispatcher {
*/
protected ProcessDefinitionEntity extractProcessDefinitionEntityFromEvent(ActivitiEvent event) {
ProcessDefinitionEntity result = null;
if (event.getProcessDefinitionId() != null) {
result = ProcessDefinitionCacheUtil.getCachedProcessDefinitionEntity(event.getProcessDefinitionId());
if (result != null) {
result = Context.getProcessEngineConfiguration().getDeploymentManager().resolveProcessDefinition(result);
}
}
if (result == null && event instanceof ActivitiEntityEvent) {
if (event instanceof ActivitiEntityEvent) {
Object entity = ((ActivitiEntityEvent) event).getEntity();
if (entity instanceof ProcessDefinition) {
result = (ProcessDefinitionEntity) entity;
}
}
if (result == null && event.getProcessDefinitionId() != null) {
result = ProcessDefinitionUtil.getProcessDefinitionEntity(event.getProcessDefinitionId());
if (result != null) {
result = Context.getProcessEngineConfiguration().getDeploymentManager().resolveProcessDefinition(result).getProcessDefinitionEntity();
}
}
return result;
}
......
......@@ -30,7 +30,7 @@ import org.activiti.engine.impl.persistence.entity.TaskEntityManager;
import org.activiti.engine.impl.persistence.entity.VariableInstanceEntity;
import org.activiti.engine.impl.persistence.entity.VariableInstanceEntityManager;
import org.activiti.engine.impl.pvm.delegate.ActivityExecution;
import org.activiti.engine.impl.util.cache.ProcessDefinitionCacheUtil;
import org.activiti.engine.impl.util.ProcessDefinitionUtil;
/**
* @author Joram Barrez
......@@ -57,7 +57,7 @@ public abstract class AbstractOperation implements Runnable {
*/
protected FlowElement findCurrentFlowElement(final ActivityExecution execution) {
String processDefinitionId = execution.getProcessDefinitionId();
org.activiti.bpmn.model.Process process = ProcessDefinitionCacheUtil.getCachedProcess(processDefinitionId);
org.activiti.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(processDefinitionId);
String activityId = execution.getCurrentActivityId();
FlowElement currentFlowElement = process.getFlowElement(activityId, true);
execution.setCurrentFlowElement(currentFlowElement);
......
......@@ -23,7 +23,7 @@ import org.activiti.engine.impl.persistence.entity.ExecutionEntityManager;
import org.activiti.engine.impl.persistence.entity.MessageEntity;
import org.activiti.engine.impl.pvm.delegate.ActivityBehavior;
import org.activiti.engine.impl.pvm.delegate.ActivityExecution;
import org.activiti.engine.impl.util.cache.ProcessDefinitionCacheUtil;
import org.activiti.engine.impl.util.ProcessDefinitionUtil;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -197,7 +197,7 @@ public class ContinueProcessOperation extends AbstractOperation {
protected org.activiti.bpmn.model.Process getProcessDefinition(String processDefinitionId) {
// TODO: must be extracted / cache should be accessed in another way
return ProcessDefinitionCacheUtil.getCachedProcess(processDefinitionId);
return ProcessDefinitionUtil.getProcess(processDefinitionId);
}
}
......@@ -9,7 +9,7 @@ import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.impl.pvm.delegate.InactiveActivityBehavior;
import org.activiti.engine.impl.util.cache.ProcessDefinitionCacheUtil;
import org.activiti.engine.impl.util.ProcessDefinitionUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -39,7 +39,7 @@ public class ExecuteInactiveBehaviorsOperation extends AbstractOperation {
for (ExecutionEntity executionEntity : involvedExecutions) {
Process process = ProcessDefinitionCacheUtil.getCachedProcess(executionEntity.getProcessDefinitionId());
Process process = ProcessDefinitionUtil.getProcess(executionEntity.getProcessDefinitionId());
Collection<String> flowNodeIdsWithInactivatedBehavior = new ArrayList<String>();
for (FlowNode flowNode : process.findFlowElementsOfType(FlowNode.class)) {
if (flowNode.getBehavior() instanceof InactiveActivityBehavior) {
......
......@@ -3,14 +3,17 @@ package org.activiti.engine.impl.agenda;
import java.util.ArrayList;
import java.util.List;
import org.activiti.bpmn.model.Activity;
import org.activiti.bpmn.model.FlowElement;
import org.activiti.bpmn.model.FlowNode;
import org.activiti.bpmn.model.Gateway;
import org.activiti.bpmn.model.SequenceFlow;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.impl.persistence.entity.ExecutionEntityManager;
import org.activiti.engine.impl.pvm.delegate.ActivityExecution;
import org.activiti.engine.impl.util.condition.ConditionUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -42,7 +45,6 @@ public class TakeOutgoingSequenceFlowsOperation extends AbstractOperation {
// must first be destroyed before we can continue
if (execution.getParentId() != null && execution.isScope()) {
agenda.planDestroyScopeOperation(execution);
// return;
}
// No scope, can continue
......@@ -58,23 +60,47 @@ public class TakeOutgoingSequenceFlowsOperation extends AbstractOperation {
logger.debug("Leaving flow node {} with id '{}' by following it's {} outgoing sequenceflow", flowNode.getClass(), flowNode.getId(), flowNode.getOutgoingFlows().size());
// Get default sequence flow (if set)
String defaultSequenceFlowId = null;
if (flowNode instanceof Activity) {
defaultSequenceFlowId = ((Activity) flowNode).getDefaultFlow();
} else if (flowNode instanceof Gateway) {
defaultSequenceFlowId = ((Gateway) flowNode).getDefaultFlow();
}
// Determine which sequence flows can be used for leaving
List<SequenceFlow> outgoingSequenceFlow = new ArrayList<SequenceFlow>();
for (SequenceFlow sequenceFlow : flowNode.getOutgoingFlows()) {
if (!evaluateConditions || (evaluateConditions && ConditionUtil.hasTrueCondition(sequenceFlow, execution))) {
if (!evaluateConditions
|| (evaluateConditions
&& ConditionUtil.hasTrueCondition(sequenceFlow, execution)
&& (defaultSequenceFlowId == null || !defaultSequenceFlowId.equals(sequenceFlow.getId()))
)
) {
outgoingSequenceFlow.add(sequenceFlow);
}
}
// Check if there is a default sequence flow
if (outgoingSequenceFlow.size() == 0 && evaluateConditions) { // The elements that set this to false also have no support for default sequence flow
if (defaultSequenceFlowId != null) {
for (SequenceFlow sequenceFlow : flowNode.getOutgoingFlows()) {
if (defaultSequenceFlowId.equals(sequenceFlow.getId())) {
outgoingSequenceFlow.add(sequenceFlow);
break;
}
}
}
}
// Check if we actually can continue. If not, end the current execution
// No outgoing found. Ending the execution
if (outgoingSequenceFlow.size() == 0) {
logger.warn("No outgoing sequence flow found for flow node '{}'.", flowNode.getId());
agenda.planEndExecutionOperation(execution);
return;
}
// Leave, and reuse the incoming sequence flow, make executions for all
// the others (if applicable)
// Leave, and reuse the incoming sequence flow, make executions for all the others (if applicable)
ExecutionEntityManager executionEntityManager = commandContext.getExecutionEntityManager();
List<ExecutionEntity> outgoingExecutions = new ArrayList<ExecutionEntity>(flowNode.getOutgoingFlows().size());
......@@ -105,8 +131,7 @@ public class TakeOutgoingSequenceFlowsOperation extends AbstractOperation {
}
}
// Leave (only done when all executions have been made, since some
// queries depend on this)
// Leave (only done when all executions have been made, since some queries depend on this)
for (ExecutionEntity outgoingExecution : outgoingExecutions) {
agenda.planContinueProcessOperation(outgoingExecution);
}
......
......@@ -87,11 +87,11 @@ public class AbstractBpmnActivityBehavior extends FlowNodeActivityBehavior {
}
@Override
public void trigger(ActivityExecution execution, String signalName, Object signalData) {
if ("compensationDone".equals(signalName)) {
signalCompensationDone(execution, signalData);
public void trigger(ActivityExecution execution, String triggerName, Object triggerData) {
if ("compensationDone".equals(triggerName)) {
signalCompensationDone(execution, triggerData);
} else {
super.trigger(execution, signalName, signalData);
super.trigger(execution, triggerName, triggerData);
}
}
......
......@@ -88,9 +88,7 @@ public class BoundaryEventActivityBehavior extends FlowNodeActivityBehavior {
throw new ActivitiException("Programmatic error: no parent scope execution found for boundary event");
}
commandContext.getAgenda().planDestroyScopeOperation(executionEntity); // The destroy scope operation will figure
// out the correct scope execution, don't pass
// in the parentScopeExecution here
commandContext.getAgenda().planDestroyScopeOperation(executionEntity); // The destroy scope operation will figure out the correct scope execution, don't pass in the parentScopeExecution here
commandContext.getAgenda().planTakeOutgoingSequenceFlowsOperation(parentScopeExecution, true);
}
......
......@@ -19,10 +19,12 @@ import java.util.Iterator;
import java.util.Set;
import org.activiti.engine.delegate.Expression;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.activiti.engine.impl.pvm.PvmProcessDefinition;
import org.activiti.engine.impl.pvm.delegate.ActivityExecution;
import org.activiti.engine.impl.rules.RulesAgendaFilter;
import org.activiti.engine.impl.rules.RulesHelper;
import org.activiti.engine.impl.util.ProcessDefinitionUtil;
import org.drools.KnowledgeBase;
import org.drools.runtime.StatefulKnowledgeSession;
......@@ -30,6 +32,7 @@ import org.drools.runtime.StatefulKnowledgeSession;
* activity implementation of the BPMN 2.0 business rule task.
*
* @author Tijs Rademakers
* @author Joram Barrez
*/
public class BusinessRuleTaskActivityBehavior extends TaskActivityBehavior {
......@@ -42,8 +45,9 @@ public class BusinessRuleTaskActivityBehavior extends TaskActivityBehavior {
}
public void execute(ActivityExecution execution) {
PvmProcessDefinition processDefinition = execution.getActivity().getProcessDefinition();
String deploymentId = processDefinition.getDeploymentId();
ProcessDefinitionEntity processDefinitionEntity =
ProcessDefinitionUtil.getProcessDefinitionEntity(execution.getProcessDefinitionId());
String deploymentId = processDefinitionEntity.getDeploymentId();
KnowledgeBase knowledgeBase = RulesHelper.findKnowledgeBaseByDeploymentId(deploymentId);
StatefulKnowledgeSession ksession = knowledgeBase.newStatefulKnowledgeSession();
......
......@@ -44,8 +44,7 @@ public class InclusiveGatewayActivityBehavior extends GatewayActivityBehavior im
// The join in the inclusive gateway works as follows:
// When an execution enters it, it is inactivated.
// All the inactivated executions stay in the inclusive gateway
// until ALL executions that CAN reach the inclusive gateway have
// reached it.
// until ALL executions that CAN reach the inclusive gateway have reached it.
//
// This check is repeated on execution changes until the inactivated
// executions leave the gateway.
......@@ -75,8 +74,7 @@ public class InclusiveGatewayActivityBehavior extends GatewayActivityBehavior im
}
}
// If no execution can reach the gateway, the gateway activates and
// executes fork behavior
// If no execution can reach the gateway, the gateway activates and executes fork behavior
if (!oneExecutionCanReachGateway) {
logger.debug("Inclusive gateway cannot be reached by any execution and is activated");
......@@ -90,9 +88,6 @@ public class InclusiveGatewayActivityBehavior extends GatewayActivityBehavior im
}
// Leave
// TODO: default sequence flow
commandContext.getAgenda().planTakeOutgoingSequenceFlowsOperation(execution, true);
}
}
......
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.bpmn.behavior;
import org.activiti.bpmn.model.TimerEventDefinition;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.jobexecutor.TriggerTimerEventJobHandler;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.impl.persistence.entity.TimerEntity;
import org.activiti.engine.impl.pvm.delegate.ActivityExecution;
import org.activiti.engine.impl.util.TimerUtil;
public class IntermediateTimerCatchEventActivityBehavior extends AbstractBpmnActivityBehavior {
protected TimerEventDefinition timerEventDefinition;
public IntermediateTimerCatchEventActivityBehavior(TimerEventDefinition timerEventDefinition) {
this.timerEventDefinition = timerEventDefinition;
}
public void execute(ActivityExecution execution) {
TimerEntity timer = TimerUtil.createTimerEntityForTimerEventDefinition(timerEventDefinition,
false, (ExecutionEntity) execution, TriggerTimerEventJobHandler.TYPE, execution.getCurrentActivityId());
Context.getCommandContext().getJobEntityManager().schedule(timer);
}
@Override
public void trigger(ActivityExecution execution, String triggerName, Object triggerData) {
leave(execution);
}
}
......@@ -16,7 +16,6 @@ import org.activiti.engine.ActivitiException;
import org.activiti.engine.delegate.BpmnError;
import org.activiti.engine.impl.bpmn.helper.ErrorPropagation;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.impl.pvm.delegate.ActivityExecution;
import org.activiti.engine.impl.scripting.ScriptingEngines;
import org.apache.commons.lang3.exception.ExceptionUtils;
......@@ -39,8 +38,7 @@ public class ScriptTaskActivityBehavior extends TaskActivityBehavior {
protected String script;
protected String language;
protected String resultVariable;
protected boolean storeScriptVariables = false; // see
// http://jira.codehaus.org/browse/ACT-1626
protected boolean storeScriptVariables = false; // see http://jira.codehaus.org/browse/ACT-1626
public ScriptTaskActivityBehavior(String script, String language, String resultVariable) {
this.script = script;
......@@ -67,7 +65,7 @@ public class ScriptTaskActivityBehavior extends TaskActivityBehavior {
} catch (ActivitiException e) {
LOGGER.warn("Exception while executing " + ((ExecutionEntity) execution).getActivityId() + " : " + e.getMessage());
LOGGER.warn("Exception while executing " + execution.getCurrentFlowElement().getId() + " : " + e.getMessage());
noErrors = false;
Throwable rootCause = ExceptionUtils.getRootCause(e);
......
......@@ -20,6 +20,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.bpmn.model.EventDefinition;
import org.activiti.bpmn.model.FlowElement;
import org.activiti.bpmn.model.StartEvent;
......@@ -83,6 +84,7 @@ public class BpmnDeployer implements Deployer {
List<ProcessDefinitionEntity> processDefinitions = new ArrayList<ProcessDefinitionEntity>();
Map<String, org.activiti.bpmn.model.Process> processModels = new HashMap<String, org.activiti.bpmn.model.Process>();
Map<String, BpmnModel> bpmnModels = new HashMap<String, BpmnModel>();
Map<String, ResourceEntity> resources = deployment.getResources();
final ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
......@@ -126,23 +128,14 @@ public class BpmnDeployer implements Deployer {
}
if (deployment.getTenantId() != null) {
processDefinition.setTenantId(deployment.getTenantId()); // process
// definition
// inherits
// the
// tenant
// id
processDefinition.setTenantId(deployment.getTenantId()); // process definition inherits the tenant id
}
String diagramResourceName = getDiagramResourceForProcess(resourceName, processDefinition.getKey(), resources);
// Only generate the resource when deployment is new to
// prevent modification of deployment resources
// after the process-definition is actually deployed. Also
// to prevent resource-generation failure every
// time the process definition is added to the
// deployment-cache when diagram-generation has failed the
// first time.
// Only generate the resource when deployment is new to prevent modification of deployment resources
// after the process-definition is actually deployed. Also to prevent resource-generation failure every
// time the process definition is added to the deployment-cache when diagram-generation has failed the first time.
if (deployment.isNew()) {
if (processEngineConfiguration.isCreateDiagramOnDeploy() && diagramResourceName == null && processDefinition.isGraphicalNotationDefined()) {
try {
......@@ -151,10 +144,7 @@ public class BpmnDeployer implements Deployer {
processEngineConfiguration.getLabelFontName(), processEngineConfiguration.getClassLoader()), null);
diagramResourceName = getProcessImageResourceName(resourceName, processDefinition.getKey(), "png");
createResource(diagramResourceName, diagramBytes, deployment);
} catch (Throwable t) { // if anything goes wrong,
// we don't store the image
// (the process will still
// be executable).
} catch (Throwable t) { // if anything goes wrong, we don't store the image (the process will still be executable).
log.warn("Error while generating process diagram, image will not be stored in repository", t);
}
}
......@@ -162,7 +152,9 @@ public class BpmnDeployer implements Deployer {
processDefinition.setDiagramResourceName(diagramResourceName);
processDefinitions.add(processDefinition);
processModels.put(processDefinition.getKey(), bpmnParse.getBpmnModel().getProcessById(processDefinition.getKey()));
bpmnModels.put(processDefinition.getKey(), bpmnParse.getBpmnModel());
}
}
}
......@@ -226,9 +218,9 @@ public class BpmnDeployer implements Deployer {
dbSqlSession.insert(processDefinition);
addAuthorizations(processDefinition);
if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_INITIALIZED, processDefinition));
}
// if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
// commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_INITIALIZED, processDefinition));
// }
scheduleTimers(timers);
......@@ -251,7 +243,8 @@ public class BpmnDeployer implements Deployer {
}
// Add to cache
ProcessDefinitionCacheEntry cacheEntry = new ProcessDefinitionCacheEntry(processDefinition, processModels.get(processDefinition.getKey()));
ProcessDefinitionCacheEntry cacheEntry = new ProcessDefinitionCacheEntry(processDefinition,
bpmnModels.get(processDefinition.getKey()), processModels.get(processDefinition.getKey()));
processEngineConfiguration.getDeploymentManager().getProcessDefinitionCache().add(processDefinition.getId(), cacheEntry);
// Add to deployment for further usage
......
......@@ -54,6 +54,7 @@ import org.activiti.engine.impl.bpmn.behavior.IntermediateCatchEventActivityBeha
import org.activiti.engine.impl.bpmn.behavior.IntermediateThrowCompensationEventActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.IntermediateThrowNoneEventActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.IntermediateThrowSignalEventActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.IntermediateTimerCatchEventActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.MailActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.ManualTaskActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior;
......@@ -176,6 +177,8 @@ public interface ActivityBehaviorFactory {
public abstract IntermediateCatchEventActivityBehavior createIntermediateCatchEventActivityBehavior(IntermediateCatchEvent intermediateCatchEvent);
public abstract IntermediateTimerCatchEventActivityBehavior createIntermediateTimerCatchEventActivityBehavior(IntermediateCatchEvent intermediateCatchEvent, TimerEventDefinition timerEventDefinition);
public abstract IntermediateThrowNoneEventActivityBehavior createIntermediateThrowNoneEventActivityBehavior(ThrowEvent throwEvent);
public abstract IntermediateThrowSignalEventActivityBehavior createIntermediateThrowSignalEventActivityBehavior(ThrowEvent throwEvent, Signal signal,
......@@ -183,6 +186,7 @@ public interface ActivityBehaviorFactory {
public abstract IntermediateThrowCompensationEventActivityBehavior createIntermediateThrowCompensationEventActivityBehavior(ThrowEvent throwEvent,
CompensateEventDefinition compensateEventDefinition);
public abstract NoneEndEventActivityBehavior createNoneEndEventActivityBehavior(EndEvent endEvent);
......
......@@ -61,6 +61,7 @@ import org.activiti.engine.impl.bpmn.behavior.IntermediateCatchEventActivityBeha
import org.activiti.engine.impl.bpmn.behavior.IntermediateThrowCompensationEventActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.IntermediateThrowNoneEventActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.IntermediateThrowSignalEventActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.IntermediateTimerCatchEventActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.MailActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.ManualTaskActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior;
......@@ -379,6 +380,11 @@ public class DefaultActivityBehaviorFactory extends AbstractBehaviorFactory impl
public IntermediateCatchEventActivityBehavior createIntermediateCatchEventActivityBehavior(IntermediateCatchEvent intermediateCatchEvent) {
return new IntermediateCatchEventActivityBehavior();
}
@Override
public IntermediateTimerCatchEventActivityBehavior createIntermediateTimerCatchEventActivityBehavior(IntermediateCatchEvent intermediateCatchEvent, TimerEventDefinition timerEventDefinition) {
return new IntermediateTimerCatchEventActivityBehavior(timerEventDefinition);
}
public IntermediateThrowNoneEventActivityBehavior createIntermediateThrowNoneEventActivityBehavior(ThrowEvent throwEvent) {
return new IntermediateThrowNoneEventActivityBehavior();
......
......@@ -29,11 +29,7 @@ public class BusinessRuleParseHandler extends AbstractActivityBpmnParseHandler<B
@Override
protected void executeParse(BpmnParse bpmnParse, BusinessRuleTask businessRuleTask) {
ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, businessRuleTask, BpmnXMLConstants.ELEMENT_TASK_BUSINESSRULE);
activity.setAsync(businessRuleTask.isAsynchronous());
activity.setExclusive(!businessRuleTask.isNotExclusive());
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createBusinessRuleTaskActivityBehavior(businessRuleTask));
businessRuleTask.setBehavior(bpmnParse.getActivityBehaviorFactory().createBusinessRuleTaskActivityBehavior(businessRuleTask));
}
}
......@@ -12,30 +12,17 @@
*/
package org.activiti.engine.impl.bpmn.parser.handler;
import java.util.ArrayList;
import java.util.List;
import org.activiti.bpmn.model.BaseElement;
import org.activiti.bpmn.model.BoundaryEvent;
import org.activiti.bpmn.model.IntermediateCatchEvent;
import org.activiti.bpmn.model.TimerEventDefinition;
import org.activiti.engine.delegate.Expression;
import org.activiti.engine.impl.bpmn.parser.BpmnParse;
import org.activiti.engine.impl.el.ExpressionManager;
import org.activiti.engine.impl.jobexecutor.TimerDeclarationImpl;
import org.activiti.engine.impl.jobexecutor.TimerDeclarationType;
import org.activiti.engine.impl.pvm.process.ScopeImpl;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Joram Barrez
*/
public class TimerEventDefinitionParseHandler extends AbstractBpmnParseHandler<TimerEventDefinition> {
private static final Logger logger = LoggerFactory.getLogger(TimerEventDefinitionParseHandler.class);
public Class<? extends BaseElement> getHandledType() {
return TimerEventDefinition.class;
}
......@@ -44,21 +31,9 @@ public class TimerEventDefinitionParseHandler extends AbstractBpmnParseHandler<T
if (bpmnParse.getCurrentFlowElement() instanceof IntermediateCatchEvent) {
throw new RuntimeException("Need to implement");
// timerActivity.setProperty("type", "intermediateTimer");
// TimerDeclarationImpl timerDeclaration = createTimer(bpmnParse,
// timerEventDefinition, timerActivity,
// TimerCatchIntermediateEventJobHandler.TYPE);
// if (getPrecedingEventBasedGateway(bpmnParse,
// (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement()) !=
// null) {
// addTimerDeclaration(timerActivity.getParent(), timerDeclaration);
// } else {
// addTimerDeclaration(timerActivity, timerDeclaration);
// timerActivity.setScope(true);
// }
IntermediateCatchEvent intermediateCatchEvent = (IntermediateCatchEvent) bpmnParse.getCurrentFlowElement();
intermediateCatchEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateTimerCatchEventActivityBehavior(intermediateCatchEvent, timerEventDefinition));
} else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent) {
BoundaryEvent boundaryEvent = (BoundaryEvent) bpmnParse.getCurrentFlowElement();
......@@ -67,44 +42,4 @@ public class TimerEventDefinitionParseHandler extends AbstractBpmnParseHandler<T
}
}
protected TimerDeclarationImpl createTimer(BpmnParse bpmnParse, TimerEventDefinition timerEventDefinition, ScopeImpl timerActivity, String jobHandlerType) {
TimerDeclarationType type = null;
Expression expression = null;
ExpressionManager expressionManager = bpmnParse.getExpressionManager();
if (StringUtils.isNotEmpty(timerEventDefinition.getTimeDate())) {
// TimeDate
type = TimerDeclarationType.DATE;
expression = expressionManager.createExpression(timerEventDefinition.getTimeDate());
} else if (StringUtils.isNotEmpty(timerEventDefinition.getTimeCycle())) {
// TimeCycle
type = TimerDeclarationType.CYCLE;
expression = expressionManager.createExpression(timerEventDefinition.getTimeCycle());
} else if (StringUtils.isNotEmpty(timerEventDefinition.getTimeDuration())) {
// TimeDuration
type = TimerDeclarationType.DURATION;
expression = expressionManager.createExpression(timerEventDefinition.getTimeDuration());
}
// neither date, cycle or duration configured!
if (expression == null) {
logger.warn("Timer needs configuration (either timeDate, timeCycle or timeDuration is needed) (" + timerActivity.getId() + ")");
}
// Parse the timer declaration
// TODO move the timer declaration into the bpmn activity or next to the TimerSession
TimerDeclarationImpl timerDeclaration = new TimerDeclarationImpl(expression, type, jobHandlerType);
timerDeclaration.setJobHandlerConfiguration(timerActivity.getId());
timerDeclaration.setExclusive(true);
return timerDeclaration;
}
@SuppressWarnings("unchecked")
protected void addTimerDeclaration(ScopeImpl scope, TimerDeclarationImpl timerDeclaration) {
List<TimerDeclarationImpl> timerDeclarations = (List<TimerDeclarationImpl>) scope.getProperty(PROPERTYNAME_TIMER_DECLARATION);
if (timerDeclarations == null) {
timerDeclarations = new ArrayList<TimerDeclarationImpl>();
scope.setProperty(PROPERTYNAME_TIMER_DECLARATION, timerDeclarations);
}
timerDeclarations.add(timerDeclaration);
}
}
......@@ -34,7 +34,6 @@ import java.util.Set;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.FormService;
import org.activiti.engine.HistoryService;
......@@ -183,7 +182,6 @@ import org.activiti.engine.impl.persistence.entity.IdentityInfoEntityManager;
import org.activiti.engine.impl.persistence.entity.IdentityLinkEntityManager;
import org.activiti.engine.impl.persistence.entity.JobEntityManager;
import org.activiti.engine.impl.persistence.entity.ModelEntityManager;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntityManager;
import org.activiti.engine.impl.persistence.entity.PropertyEntityManager;
import org.activiti.engine.impl.persistence.entity.ResourceEntityManager;
......@@ -310,8 +308,6 @@ public abstract class ProcessEngineConfigurationImpl extends ProcessEngineConfig
protected int processDefinitionCacheLimit = -1; // By default, no limit
protected DeploymentCache<ProcessDefinitionCacheEntry> processDefinitionCache;
protected int bpmnModelCacheLimit = -1; // By default, no limit
protected DeploymentCache<BpmnModel> bpmnModelCache;
protected int knowledgeBaseCacheLimit = -1;
protected DeploymentCache<Object> knowledgeBaseCache;
......@@ -981,15 +977,6 @@ public abstract class ProcessEngineConfigurationImpl extends ProcessEngineConfig
}
}
// BpmnModel cache
if (bpmnModelCache == null) {
if (bpmnModelCacheLimit <= 0) {
bpmnModelCache = new DefaultDeploymentCache<BpmnModel>();
} else {
bpmnModelCache = new DefaultDeploymentCache<BpmnModel>(bpmnModelCacheLimit);
}
}
// Knowledge base cache (used for Drools business task)
if (knowledgeBaseCache == null) {
if (knowledgeBaseCacheLimit <= 0) {
......@@ -1000,7 +987,6 @@ public abstract class ProcessEngineConfigurationImpl extends ProcessEngineConfig
}
deploymentManager.setProcessDefinitionCache(processDefinitionCache);
deploymentManager.setBpmnModelCache(bpmnModelCache);
deploymentManager.setKnowledgeBaseCache(knowledgeBaseCache);
}
}
......
......@@ -60,8 +60,7 @@ public class ChangeDeploymentTenantIdCmd implements Command<Void>, Serializable
commandContext.getJobEntityManager().updateJobTenantIdForDeployment(deploymentId, newTenantId);
commandContext.getEventSubscriptionEntityManager().updateEventSubscriptionTenantId(oldTenantId, newTenantId);
// Doing process definitions in memory, cause we need to clear the
// process definition cache
// Doing process definitions in memory, cause we need to clear the process definition cache
List<ProcessDefinition> processDefinitions = commandContext.getDbSqlSession().createProcessDefinitionQuery().deploymentId(deploymentId).list();
for (ProcessDefinition processDefinition : processDefinitions) {
commandContext.getProcessEngineConfiguration().getProcessDefinitionCache().remove(processDefinition.getId());
......
......@@ -18,6 +18,7 @@ import org.activiti.bpmn.model.BpmnModel;
import org.activiti.engine.ActivitiIllegalArgumentException;
import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.util.ProcessDefinitionUtil;
/**
* @author Joram Barrez
......@@ -37,6 +38,6 @@ public class GetBpmnModelCmd implements Command<BpmnModel>, Serializable {
throw new ActivitiIllegalArgumentException("processDefinitionId is null");
}
return commandContext.getProcessEngineConfiguration().getDeploymentManager().getBpmnModelById(processDefinitionId);
return ProcessDefinitionUtil.getBpmnModel(processDefinitionId);
}
}
\ No newline at end of file
......@@ -26,7 +26,7 @@ import org.activiti.engine.impl.persistence.deploy.DeploymentManager;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.impl.persistence.entity.MessageEventSubscriptionEntity;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.activiti.engine.impl.util.cache.ProcessDefinitionCacheUtil;
import org.activiti.engine.impl.util.ProcessDefinitionUtil;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
......@@ -88,7 +88,7 @@ public class StartProcessInstanceByMessageCmd implements Command<ProcessInstance
throw new ActivitiObjectNotFoundException("No process definition found for id '" + processDefinitionId + "'", ProcessDefinition.class);
}
Process process = ProcessDefinitionCacheUtil.getCachedProcess(processDefinition.getId());
Process process = ProcessDefinitionUtil.getProcess(processDefinition.getId());
if (process == null) {
throw new ActivitiException("Cannot start process instance. Process model " + processDefinition.getName() + " (id = " + processDefinition.getId() + ") could not be found");
}
......
......@@ -37,7 +37,7 @@ import org.activiti.engine.impl.persistence.deploy.DeploymentManager;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.activiti.engine.impl.runtime.ProcessInstanceBuilderImpl;
import org.activiti.engine.impl.util.cache.ProcessDefinitionCacheUtil;
import org.activiti.engine.impl.util.ProcessDefinitionUtil;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.IdentityLinkType;
......@@ -133,7 +133,7 @@ public class StartProcessInstanceCmd<T> implements Command<ProcessInstance>, Ser
}
// Get model from cache
Process process = ProcessDefinitionCacheUtil.getCachedProcess(processDefinition.getId());
Process process = ProcessDefinitionUtil.getProcess(processDefinition.getId());
if (process == null) {
throw new ActivitiException("Cannot start process instance. Process model " + processDefinition.getName() + " (id = " + processDefinition.getId() + ") could not be found");
}
......@@ -177,8 +177,9 @@ public class StartProcessInstanceCmd<T> implements Command<ProcessInstance>, Ser
return processInstance;
}
protected ExecutionEntity createProcessInstance(CommandContext commandContext, ProcessDefinitionEntity processDefinitionEntity, String businessKey, String initiatorVariableName,
FlowElement initialFlowElement) {
protected ExecutionEntity createProcessInstance(CommandContext commandContext,
ProcessDefinitionEntity processDefinitionEntity, String businessKey,
String initiatorVariableName, FlowElement initialFlowElement) {
ExecutionEntity processInstance = new ExecutionEntity();
processInstance.setProcessDefinitionId(processDefinitionEntity.getId());
......
......@@ -25,7 +25,7 @@ import org.activiti.engine.impl.persistence.deploy.DeploymentManager;
import org.activiti.engine.impl.persistence.entity.EventSubscriptionEntity;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.activiti.engine.impl.util.cache.ProcessDefinitionCacheUtil;
import org.activiti.engine.impl.util.ProcessDefinitionUtil;
import org.activiti.engine.repository.ProcessDefinition;
/**
......@@ -54,7 +54,7 @@ public class SignalEventHandler extends AbstractEventHandler {
throw new ActivitiObjectNotFoundException("No process definition found for id '" + processDefinitionId + "'", ProcessDefinition.class);
}
Process process = ProcessDefinitionCacheUtil.getCachedProcess(processDefinition.getId());
Process process = ProcessDefinitionUtil.getProcess(processDefinition.getId());
if (process == null) {
throw new ActivitiException("Cannot start process instance. Process model " + processDefinition.getName() + " (id = " + processDefinition.getId() + ") could not be found");
}
......
......@@ -12,7 +12,7 @@ import org.activiti.engine.impl.persistence.deploy.DeploymentCache;
import org.activiti.engine.impl.persistence.deploy.ProcessDefinitionCacheEntry;
import org.activiti.engine.impl.persistence.entity.EventLogEntryEntity;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.activiti.engine.impl.util.cache.ProcessDefinitionCacheUtil;
import org.activiti.engine.impl.util.ProcessDefinitionUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -60,13 +60,10 @@ public abstract class AbstractDatabaseEventLoggerEventHandler implements EventLo
// Current tenant
if (!data.containsKey(Fields.TENANT_ID) && processDefinitionId != null) {
DeploymentCache<ProcessDefinitionCacheEntry> processDefinitionCache = Context.getProcessEngineConfiguration().getProcessDefinitionCache();
if (processDefinitionCache != null) {
ProcessDefinitionEntity processDefinitionEntity = ProcessDefinitionCacheUtil.getCachedProcessDefinitionEntity(processDefinitionId);
if (processDefinitionEntity != null && !ProcessEngineConfigurationImpl.NO_TENANT_ID.equals(processDefinitionEntity.getTenantId())) {
putInMapIfNotNull(data, Fields.TENANT_ID, processDefinitionEntity.getTenantId());
}
}
ProcessDefinitionEntity processDefinitionEntity = ProcessDefinitionUtil.getProcessDefinitionEntity(processDefinitionId);
if (processDefinitionEntity != null && !ProcessEngineConfigurationImpl.NO_TENANT_ID.equals(processDefinitionEntity.getTenantId())) {
putInMapIfNotNull(data, Fields.TENANT_ID, processDefinitionEntity.getTenantId());
}
}
try {
......
......@@ -41,27 +41,14 @@ public class DefaultDeploymentCache<T> implements DeploymentCache<T> {
* limit.
*/
public DefaultDeploymentCache(final int limit) {
this.cache = Collections.synchronizedMap(new LinkedHashMap<String, T>(limit + 1, 0.75f, true) { // +1
// is
// needed,
// because
// the
// entry
// is
// inserted
// first,
// before
// it
// is
// removed
this.cache = Collections.synchronizedMap(new LinkedHashMap<String, T>(limit + 1, 0.75f, true) { // +1 is needed, because the entry is inserted first, before it is removed
// 0.75 is the default (see javadocs)
// true will keep the 'access-order', which is needed to
// have a real LRU cache
// true will keep the 'access-order', which is needed to have a real LRU cache
private static final long serialVersionUID = 1L;
protected boolean removeEldestEntry(Map.Entry<String, T> eldest) {
boolean removeEldest = size() > limit;
if (removeEldest) {
if (removeEldest && logger.isTraceEnabled()) {
logger.trace("Cache limit is reached, {} will be evicted", eldest.getKey());
}
return removeEldest;
......
......@@ -13,11 +13,9 @@
package org.activiti.engine.impl.persistence.deploy;
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import org.activiti.bpmn.converter.BpmnXMLConverter;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.ActivitiIllegalArgumentException;
......@@ -30,9 +28,6 @@ import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.persistence.entity.DeploymentEntity;
import org.activiti.engine.impl.persistence.entity.DeploymentEntityManager;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
import org.activiti.engine.impl.persistence.entity.ResourceEntity;
import org.activiti.engine.impl.util.io.BytesStreamSource;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.ProcessDefinition;
/**
......@@ -43,11 +38,7 @@ import org.activiti.engine.repository.ProcessDefinition;
public class DeploymentManager {
protected DeploymentCache<ProcessDefinitionCacheEntry> processDefinitionCache;
protected DeploymentCache<BpmnModel> bpmnModelCache;
protected DeploymentCache<Object> knowledgeBaseCache; // Needs to be object
// to avoid an import
// to Drools in this
// core class
protected DeploymentCache<Object> knowledgeBaseCache; // Needs to be object to avoid an import to Drools in this core class
protected List<Deployer> deployers;
public void deploy(DeploymentEntity deployment) {
......@@ -74,51 +65,18 @@ public class DeploymentManager {
if (processDefinition == null) {
throw new ActivitiObjectNotFoundException("no deployed process definition found with id '" + processDefinitionId + "'", ProcessDefinition.class);
}
processDefinition = resolveProcessDefinition(processDefinition);
processDefinition = resolveProcessDefinition(processDefinition).getProcessDefinitionEntity();
}
return processDefinition;
}
public BpmnModel getBpmnModelById(String processDefinitionId) {
if (processDefinitionId == null) {
throw new ActivitiIllegalArgumentException("Invalid process definition id : null");
}
// first try the cache
BpmnModel bpmnModel = bpmnModelCache.get(processDefinitionId);
if (bpmnModel == null) {
ProcessDefinitionEntity processDefinition = findDeployedProcessDefinitionById(processDefinitionId);
if (processDefinition == null) {
throw new ActivitiObjectNotFoundException("no deployed process definition found with id '" + processDefinitionId + "'", ProcessDefinition.class);
}
// Fetch the resource
String resourceName = processDefinition.getResourceName();
ResourceEntity resource = Context.getCommandContext().getResourceEntityManager().findResourceByDeploymentIdAndResourceName(processDefinition.getDeploymentId(), resourceName);
if (resource == null) {
if (Context.getCommandContext().getDeploymentEntityManager().findDeploymentById(processDefinition.getDeploymentId()) == null) {
throw new ActivitiObjectNotFoundException("deployment for process definition does not exist: " + processDefinition.getDeploymentId(), Deployment.class);
} else {
throw new ActivitiObjectNotFoundException("no resource found with name '" + resourceName + "' in deployment '" + processDefinition.getDeploymentId() + "'", InputStream.class);
}
}
// Convert the bpmn 2.0 xml to a bpmn model
BpmnXMLConverter bpmnXMLConverter = new BpmnXMLConverter();
bpmnModel = bpmnXMLConverter.convertToBpmnModel(new BytesStreamSource(resource.getBytes()), false, false);
bpmnModelCache.add(processDefinition.getId(), bpmnModel);
}
return bpmnModel;
}
public ProcessDefinitionEntity findDeployedLatestProcessDefinitionByKey(String processDefinitionKey) {
ProcessDefinitionEntity processDefinition = Context.getCommandContext().getProcessDefinitionEntityManager().findLatestProcessDefinitionByKey(processDefinitionKey);
if (processDefinition == null) {
throw new ActivitiObjectNotFoundException("no processes deployed with key '" + processDefinitionKey + "'", ProcessDefinition.class);
}
processDefinition = resolveProcessDefinition(processDefinition);
processDefinition = resolveProcessDefinition(processDefinition).getProcessDefinitionEntity();
return processDefinition;
}
......@@ -127,7 +85,7 @@ public class DeploymentManager {
if (processDefinition == null) {
throw new ActivitiObjectNotFoundException("no processes deployed with key '" + processDefinitionKey + "' for tenant identifier '" + tenantId + "'", ProcessDefinition.class);
}
processDefinition = resolveProcessDefinition(processDefinition);
processDefinition = resolveProcessDefinition(processDefinition).getProcessDefinitionEntity();
return processDefinition;
}
......@@ -137,28 +95,30 @@ public class DeploymentManager {
if (processDefinition == null) {
throw new ActivitiObjectNotFoundException("no processes deployed with key = '" + processDefinitionKey + "' and version = '" + processDefinitionVersion + "'", ProcessDefinition.class);
}
processDefinition = resolveProcessDefinition(processDefinition);
processDefinition = resolveProcessDefinition(processDefinition).getProcessDefinitionEntity();
return processDefinition;
}
public ProcessDefinitionEntity resolveProcessDefinition(ProcessDefinitionEntity processDefinition) {
/**
* Resolving the process definition will fetch the BPMN 2.0, parse it and store the {@link BpmnModel} in memory.
*/
public ProcessDefinitionCacheEntry resolveProcessDefinition(ProcessDefinitionEntity processDefinition) {
String processDefinitionId = processDefinition.getId();
String deploymentId = processDefinition.getDeploymentId();
ProcessDefinitionCacheEntry cacheEntry = processDefinitionCache.get(processDefinitionId);
processDefinition = cacheEntry != null ? cacheEntry.getProcessDefinitionEntity() : null;
ProcessDefinitionCacheEntry cachedProcessDefinition = processDefinitionCache.get(processDefinitionId);
if (processDefinition == null) {
if (cachedProcessDefinition == null) {
DeploymentEntity deployment = Context.getCommandContext().getDeploymentEntityManager().findDeploymentById(deploymentId);
deployment.setNew(false);
deploy(deployment, null);
processDefinition = processDefinitionCache.get(processDefinitionId).getProcessDefinitionEntity();
cachedProcessDefinition = processDefinitionCache.get(processDefinitionId);
if (processDefinition == null) {
if (cachedProcessDefinition == null) {
throw new ActivitiException("deployment '" + deploymentId + "' didn't put process definition '" + processDefinitionId + "' in the cache");
}
}
return processDefinition;
return cachedProcessDefinition;
}
public void removeDeployment(String deploymentId, boolean cascade) {
......@@ -215,14 +175,6 @@ public class DeploymentManager {
this.processDefinitionCache = processDefinitionCache;
}
public DeploymentCache<BpmnModel> getBpmnModelCache() {
return bpmnModelCache;
}
public void setBpmnModelCache(DeploymentCache<BpmnModel> bpmnModelCache) {
this.bpmnModelCache = bpmnModelCache;
}
public DeploymentCache<Object> getKnowledgeBaseCache() {
return knowledgeBaseCache;
}
......
......@@ -13,8 +13,8 @@
package org.activiti.engine.impl.persistence.deploy;
import java.io.Serializable;
import java.util.Date;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.bpmn.model.Process;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
......@@ -26,12 +26,12 @@ public class ProcessDefinitionCacheEntry implements Serializable {
private static final long serialVersionUID = 6833801933658529070L;
protected ProcessDefinitionEntity processDefinitionEntity;
protected BpmnModel bpmnModel;
protected Process process;
protected Date createTimestamp;
protected Date lastUsedTimestamp;
public ProcessDefinitionCacheEntry(ProcessDefinitionEntity processDefinitionEntity, Process process) {
public ProcessDefinitionCacheEntry(ProcessDefinitionEntity processDefinitionEntity, BpmnModel bpmnModel, Process process) {
this.processDefinitionEntity = processDefinitionEntity;
this.bpmnModel = bpmnModel;
this.process = process;
}
......@@ -42,8 +42,16 @@ public class ProcessDefinitionCacheEntry implements Serializable {
public void setProcessDefinitionEntity(ProcessDefinitionEntity processDefinitionEntity) {
this.processDefinitionEntity = processDefinitionEntity;
}
public BpmnModel getBpmnModel() {
return bpmnModel;
}
public Process getProcess() {
public void setBpmnModel(BpmnModel bpmnModel) {
this.bpmnModel = bpmnModel;
}
public Process getProcess() {
return process;
}
......@@ -51,20 +59,4 @@ public class ProcessDefinitionCacheEntry implements Serializable {
this.process = process;
}
public Date getCreateTimestamp() {
return createTimestamp;
}
public void setCreateTimestamp(Date createTimestamp) {
this.createTimestamp = createTimestamp;
}
public Date getLastUsedTimestamp() {
return lastUsedTimestamp;
}
public void setLastUsedTimestamp(Date lastUsedTimestamp) {
this.lastUsedTimestamp = lastUsedTimestamp;
}
}
......@@ -57,7 +57,7 @@ import org.activiti.engine.impl.pvm.runtime.AtomicOperation;
import org.activiti.engine.impl.pvm.runtime.InterpretableExecution;
import org.activiti.engine.impl.pvm.runtime.OutgoingExecution;
import org.activiti.engine.impl.util.BitMaskUtil;
import org.activiti.engine.impl.util.cache.ProcessDefinitionCacheUtil;
import org.activiti.engine.impl.util.ProcessDefinitionUtil;
import org.activiti.engine.runtime.Execution;
import org.activiti.engine.runtime.Job;
import org.activiti.engine.runtime.ProcessInstance;
......@@ -347,7 +347,7 @@ public class ExecutionEntity extends VariableScopeImpl implements ActivityExecut
if (currentFlowElement == null) {
String processDefinitionId = getProcessDefinitionId();
if (processDefinitionId != null) {
org.activiti.bpmn.model.Process process = ProcessDefinitionCacheUtil.getCachedProcess(processDefinitionId);
org.activiti.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(processDefinitionId);
currentFlowElement = process.getFlowElement(getCurrentActivityId(), true);
}
}
......
......@@ -26,7 +26,6 @@ import org.activiti.bpmn.model.SequenceFlow;
import org.activiti.bpmn.model.SubProcess;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.impl.util.cache.ProcessDefinitionCacheUtil;
public class ExecutionGraphUtil {
......@@ -73,7 +72,7 @@ public class ExecutionGraphUtil {
public static boolean isReachable(String processDefinitionId, String sourceElementId, String targetElementId) {
// Fetch source and target elements
Process process = ProcessDefinitionCacheUtil.getCachedProcess(processDefinitionId);
Process process = ProcessDefinitionUtil.getProcess(processDefinitionId);
FlowNode sourceElement = (FlowNode) process.getFlowElement(sourceElementId, true);
FlowNode targetElement = (FlowNode) process.getFlowElement(targetElementId, true);
......
......@@ -10,37 +10,39 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.util.cache;
package org.activiti.engine.impl.util;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.bpmn.model.Process;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.persistence.deploy.DeploymentManager;
import org.activiti.engine.impl.persistence.deploy.ProcessDefinitionCacheEntry;
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
/**
* A utility class that hides the complexity of {@link ProcessDefinitionEntity} and {@link Process} lookup.
* Use this class rather than accessing the process definition cache or {@link DeploymentManager} directly.
*
* @author Joram Barrez
*/
public class ProcessDefinitionCacheUtil {
public class ProcessDefinitionUtil {
public static ProcessDefinitionEntity getCachedProcessDefinitionEntity(String processDefinitionId) {
ProcessDefinitionCacheEntry cacheEntry = getCacheEntry(processDefinitionId);
if (cacheEntry != null) {
return cacheEntry.getProcessDefinitionEntity();
}
return null;
public static ProcessDefinitionEntity getProcessDefinitionEntity(String processDefinitionId) {
return Context.getProcessEngineConfiguration().getDeploymentManager().findDeployedProcessDefinitionById(processDefinitionId);
}
public static Process getCachedProcess(String processDefinitionId) {
ProcessDefinitionCacheEntry cacheEntry = getCacheEntry(processDefinitionId);
if (cacheEntry != null) {
return cacheEntry.getProcess();
}
return null;
public static Process getProcess(String processDefinitionId) {
return getCacheEntry(processDefinitionId).getProcess();
}
public static BpmnModel getBpmnModel(String processDefinitionId) {
return getCacheEntry(processDefinitionId).getBpmnModel();
}
public static ProcessDefinitionCacheEntry getCacheEntry(String processDefinitionId) {
ProcessDefinitionCacheEntry cacheEntry = Context.getProcessEngineConfiguration().getProcessDefinitionCache().get(processDefinitionId);
return cacheEntry;
DeploymentManager deploymentManager = Context.getProcessEngineConfiguration().getDeploymentManager();
ProcessDefinitionEntity processDefinitionEntity = deploymentManager.findDeployedProcessDefinitionById(processDefinitionId);
return deploymentManager.resolveProcessDefinition(processDefinitionEntity);
}
}
......@@ -33,8 +33,8 @@ public class TimerUtil {
* Takes in an optional execution, if missing the
* {@link NoExecutionVariableScope} will be used (eg Timer start event)
*/
public static TimerEntity createTimerEntityForTimerEventDefinition(TimerEventDefinition timerEventDefinition, boolean isInterruptingTimer, ExecutionEntity executionEntity, String jobHandlerType,
String jobHandlerConfig) {
public static TimerEntity createTimerEntityForTimerEventDefinition(TimerEventDefinition timerEventDefinition,
boolean isInterruptingTimer, ExecutionEntity executionEntity, String jobHandlerType, String jobHandlerConfig) {
String businessCalendarRef = null;
Expression expression = null;
......
......@@ -62,6 +62,7 @@ import org.activiti.engine.impl.bpmn.behavior.IntermediateCatchEventActivityBeha
import org.activiti.engine.impl.bpmn.behavior.IntermediateThrowCompensationEventActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.IntermediateThrowNoneEventActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.IntermediateThrowSignalEventActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.IntermediateTimerCatchEventActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.MailActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.ManualTaskActivityBehavior;
import org.activiti.engine.impl.bpmn.behavior.NoneEndEventActivityBehavior;
......@@ -290,6 +291,11 @@ public class TestActivityBehaviorFactory extends AbstractBehaviorFactory impleme
public IntermediateCatchEventActivityBehavior createIntermediateCatchEventActivityBehavior(IntermediateCatchEvent intermediateCatchEvent) {
return wrappedActivityBehaviorFactory.createIntermediateCatchEventActivityBehavior(intermediateCatchEvent);
}
@Override
public IntermediateTimerCatchEventActivityBehavior createIntermediateTimerCatchEventActivityBehavior(IntermediateCatchEvent intermediateCatchEvent, TimerEventDefinition timerEventDefinition) {
return wrappedActivityBehaviorFactory.createIntermediateTimerCatchEventActivityBehavior(intermediateCatchEvent, timerEventDefinition);
}
@Override
public IntermediateThrowNoneEventActivityBehavior createIntermediateThrowNoneEventActivityBehavior(ThrowEvent throwEvent) {
......
......@@ -352,7 +352,7 @@
inner join ${prefix}ACT_RU_VARIABLE A${index} on RES.ID_ = A${index}.EXECUTION_ID_
</when>
<otherwise>
inner join ${prefix}ACT_RU_VARIABLE A${index} on RES.PROC_INST_ID_ = A${index}.PROC_INST_ID_
inner join ${prefix}ACT_RU_VARIABLE A${index} on RES.ID_ = A${index}.PROC_INST_ID_
</otherwise>
</choose>
</foreach>
......
......@@ -30,6 +30,7 @@ import org.activiti.engine.runtime.Job;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.activiti.engine.test.Deployment;
import org.junit.Ignore;
/**
* Test case for all {@link ActivitiEvent}s related to activities.
......@@ -87,8 +88,7 @@ public class ActivityEventsTest extends PluggableActivitiTestCase {
*/
@Deployment
public void testActivityEvents() throws Exception {
// We're interested in the raw events, alter the listener to keep those
// as well
// We're interested in the raw events, alter the listener to keep those as well
listener.setIgnoreRawActivityEvents(false);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("activityProcess");
......
......@@ -61,6 +61,9 @@ public class CustomDeploymentCache implements DeploymentCache<ProcessDefinitionC
// For testing purposes only
public ProcessDefinitionEntity getCachedProcessDefinition() {
if (entry == null) {
return null;
}
return entry.getProcessDefinitionEntity();
}
......
......@@ -52,8 +52,7 @@ public class ActivitiRuleJunit4Test {
assertEquals(0, runtimeService.createProcessInstanceQuery().count());
}
// this is to show how JobTestHelper could be used to wait for jobs to be
// all processed
// this is to show how JobTestHelper could be used to wait for jobs to be all processed
@Test
@Deployment(resources = { "org/activiti/engine/test/bpmn/async/AsyncTaskTest.testAsyncTask.bpmn20.xml" })
public void testWaitForJobs() {
......
......@@ -20,7 +20,7 @@
<list>
<bean class="org.activiti.engine.test.impl.logger.ProcessExecutionLoggerConfigurator" />
</list>
</property> -->
</property> -->
<!-- job executor configurations -->
<property name="jobExecutorActivate" value="false" />
......
......@@ -29,7 +29,7 @@
</scriptTask>
<scriptTask id="theScriptTaskWithNewProcessVariableName" scriptFormat="juel" activiti:resultVariable="newProcessVariableName">
<script>#{execution.id}</script>
<script>#{execution.parent.id}</script>
</scriptTask>
<scriptTask id="theScriptTaskWithNoResultVariable" scriptFormat="juel">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册