Search in sources :

Example 1 with AbstractSimulationActivityBehavior

use of org.activiti.crystalball.simulator.delegate.AbstractSimulationActivityBehavior in project Activiti by Activiti.

the class SimulatorParserUtils method setSimulationBehavior.

static void setSimulationBehavior(ScopeImpl scope, BaseElement baseElement) {
    String behaviorClassName = getBehaviorClassName(baseElement);
    if (behaviorClassName != null) {
        ProcessDefinitionImpl processDefinition = scope.getProcessDefinition();
        ActivityImpl activity = processDefinition.findActivity(baseElement.getId());
        LOG.debug("Scripting task [" + activity.getId() + "] setting behavior to [" + behaviorClassName + "]");
        try {
            @SuppressWarnings("unchecked") Class<AbstractSimulationActivityBehavior> behaviorClass = (Class<AbstractSimulationActivityBehavior>) Class.forName(behaviorClassName);
            Constructor<AbstractSimulationActivityBehavior> constructor = behaviorClass.getDeclaredConstructor(ScopeImpl.class, ActivityImpl.class);
            activity.setActivityBehavior(constructor.newInstance(scope, activity));
        } catch (Throwable t) {
            LOG.error("unable to set simulation behavior class[" + behaviorClassName + "]", t);
            throw new ActivitiException("unable to set simulation behavior class[" + behaviorClassName + "]");
        }
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ProcessDefinitionImpl(org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) AbstractSimulationActivityBehavior(org.activiti.crystalball.simulator.delegate.AbstractSimulationActivityBehavior)

Aggregations

AbstractSimulationActivityBehavior (org.activiti.crystalball.simulator.delegate.AbstractSimulationActivityBehavior)1 ActivitiException (org.activiti.engine.ActivitiException)1 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)1 ProcessDefinitionImpl (org.activiti.engine.impl.pvm.process.ProcessDefinitionImpl)1