Search in sources :

Example 6 with PvmException

use of org.activiti.engine.impl.pvm.PvmException in project Activiti by Activiti.

the class ExecutionImpl method findInactiveConcurrentExecutions.

public List<ActivityExecution> findInactiveConcurrentExecutions(PvmActivity activity) {
    List<ActivityExecution> inactiveConcurrentExecutionsInActivity = new ArrayList<ActivityExecution>();
    List<ActivityExecution> otherConcurrentExecutions = new ArrayList<ActivityExecution>();
    if (isConcurrent()) {
        List<? extends ActivityExecution> concurrentExecutions = getParent().getExecutions();
        for (ActivityExecution concurrentExecution : concurrentExecutions) {
            if (concurrentExecution.getActivity() != null && concurrentExecution.getActivity().getId().equals(activity.getId())) {
                if (concurrentExecution.isActive()) {
                    throw new PvmException("didn't expect active execution in " + activity + ". bug?");
                }
                inactiveConcurrentExecutionsInActivity.add(concurrentExecution);
            } else {
                otherConcurrentExecutions.add(concurrentExecution);
            }
        }
    } else {
        if (!isActive()) {
            inactiveConcurrentExecutionsInActivity.add(this);
        } else {
            otherConcurrentExecutions.add(this);
        }
    }
    if (log.isDebugEnabled()) {
        log.debug("inactive concurrent executions in '{}': {}", activity, inactiveConcurrentExecutionsInActivity);
        log.debug("other concurrent executions: {}", otherConcurrentExecutions);
    }
    return inactiveConcurrentExecutionsInActivity;
}
Also used : ArrayList(java.util.ArrayList) ActivityExecution(org.activiti.engine.impl.pvm.delegate.ActivityExecution) PvmException(org.activiti.engine.impl.pvm.PvmException)

Example 7 with PvmException

use of org.activiti.engine.impl.pvm.PvmException in project Activiti by Activiti.

the class ExecutionImpl method signal.

// methods that translate to operations /////////////////////////////////////
public void signal(String signalName, Object signalData) {
    ensureActivityInitialized();
    SignallableActivityBehavior activityBehavior = (SignallableActivityBehavior) activity.getActivityBehavior();
    try {
        activityBehavior.signal(this, signalName, signalData);
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        throw new PvmException("couldn't process signal '" + signalName + "' on activity '" + activity.getId() + "': " + e.getMessage(), e);
    }
}
Also used : SignallableActivityBehavior(org.activiti.engine.impl.pvm.delegate.SignallableActivityBehavior) PvmException(org.activiti.engine.impl.pvm.PvmException) PvmException(org.activiti.engine.impl.pvm.PvmException)

Example 8 with PvmException

use of org.activiti.engine.impl.pvm.PvmException in project Activiti by Activiti.

the class AtomicOperationActivityExecute method execute.

public void execute(InterpretableExecution execution) {
    ActivityImpl activity = (ActivityImpl) execution.getActivity();
    ActivityBehavior activityBehavior = activity.getActivityBehavior();
    if (activityBehavior == null) {
        throw new PvmException("no behavior specified in " + activity);
    }
    log.debug("{} executes {}: {}", execution, activity, activityBehavior.getClass().getName());
    try {
        if (Context.getProcessEngineConfiguration() != null && Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
            Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createActivityEvent(ActivitiEventType.ACTIVITY_STARTED, execution.getActivity().getId(), (String) execution.getActivity().getProperty("name"), execution.getId(), execution.getProcessInstanceId(), execution.getProcessDefinitionId(), (String) activity.getProperties().get("type"), activity.getActivityBehavior().getClass().getCanonicalName()));
        }
        activityBehavior.execute(execution);
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        LogMDC.putMDCExecution(execution);
        throw new PvmException("couldn't execute activity <" + activity.getProperty("type") + " id=\"" + activity.getId() + "\" ...>: " + e.getMessage(), e);
    }
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) ActivityBehavior(org.activiti.engine.impl.pvm.delegate.ActivityBehavior) PvmException(org.activiti.engine.impl.pvm.PvmException) PvmException(org.activiti.engine.impl.pvm.PvmException)

Example 9 with PvmException

use of org.activiti.engine.impl.pvm.PvmException in project Activiti by Activiti.

the class AtomicOperationTransitionNotifyListenerTake method execute.

public void execute(InterpretableExecution execution) {
    TransitionImpl transition = execution.getTransition();
    List<ExecutionListener> executionListeners = transition.getExecutionListeners();
    int executionListenerIndex = execution.getExecutionListenerIndex();
    if (executionListeners.size() > executionListenerIndex) {
        execution.setEventName(org.activiti.engine.impl.pvm.PvmEvent.EVENTNAME_TAKE);
        execution.setEventSource(transition);
        ExecutionListener listener = executionListeners.get(executionListenerIndex);
        try {
            listener.notify(execution);
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new PvmException("couldn't execute event listener : " + e.getMessage(), e);
        }
        execution.setExecutionListenerIndex(executionListenerIndex + 1);
        execution.performOperation(this);
    } else {
        if (log.isDebugEnabled()) {
            log.debug("{} takes transition {}", execution, transition);
        }
        execution.setExecutionListenerIndex(0);
        execution.setEventName(null);
        execution.setEventSource(null);
        ActivityImpl activity = (ActivityImpl) execution.getActivity();
        ActivityImpl nextScope = findNextScope(activity.getParent(), transition.getDestination());
        execution.setActivity(nextScope);
        // Firing event that transition is being taken     	
        if (Context.getProcessEngineConfiguration() != null && Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
            Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createSequenceFlowTakenEvent(ActivitiEventType.SEQUENCEFLOW_TAKEN, transition.getId(), activity.getId(), (String) activity.getProperties().get("name"), (String) activity.getProperties().get("type"), activity.getActivityBehavior().getClass().getCanonicalName(), nextScope.getId(), (String) nextScope.getProperties().get("name"), (String) nextScope.getProperties().get("type"), nextScope.getActivityBehavior().getClass().getCanonicalName()));
        }
        execution.performOperation(TRANSITION_CREATE_SCOPE);
    }
}
Also used : TransitionImpl(org.activiti.engine.impl.pvm.process.TransitionImpl) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) PvmException(org.activiti.engine.impl.pvm.PvmException) PvmException(org.activiti.engine.impl.pvm.PvmException) ExecutionListener(org.activiti.engine.delegate.ExecutionListener)

Aggregations

PvmException (org.activiti.engine.impl.pvm.PvmException)9 ArrayList (java.util.ArrayList)3 ActivityExecution (org.activiti.engine.impl.pvm.delegate.ActivityExecution)3 List (java.util.List)2 ExecutionListener (org.activiti.engine.delegate.ExecutionListener)2 PvmTransition (org.activiti.engine.impl.pvm.PvmTransition)2 SignallableActivityBehavior (org.activiti.engine.impl.pvm.delegate.SignallableActivityBehavior)2 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)2 MapExceptionEntry (org.activiti.bpmn.model.MapExceptionEntry)1 ActivitiException (org.activiti.engine.ActivitiException)1 MultiInstanceActivityBehavior (org.activiti.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior)1 UserTaskActivityBehavior (org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior)1 ActivityBehavior (org.activiti.engine.impl.pvm.delegate.ActivityBehavior)1 ScopeImpl (org.activiti.engine.impl.pvm.process.ScopeImpl)1 TransitionImpl (org.activiti.engine.impl.pvm.process.TransitionImpl)1 OutgoingExecution (org.activiti.engine.impl.pvm.runtime.OutgoingExecution)1