use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class DelegateExpressionTaskListener method notify.
public void notify(DelegateTask delegateTask) {
// Note: we can't cache the result of the expression, because the
// execution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}'
Object delegate = expression.getValue(delegateTask.getExecution());
ClassDelegate.applyFieldDeclaration(fieldDeclarations, delegate);
if (delegate instanceof TaskListener) {
try {
Context.getProcessEngineConfiguration().getDelegateInterceptor().handleInvocation(new TaskListenerInvocation((TaskListener) delegate, delegateTask));
} catch (Exception e) {
throw new ActivitiException("Exception while invoking TaskListener: " + e.getMessage(), e);
}
} else {
throw new ActivitiIllegalArgumentException("Delegate expression " + expression + " did not resolve to an implementation of " + TaskListener.class);
}
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class BpmnParse method getImporter.
protected XMLImporter getImporter(Import theImport) {
if (this.importers.containsKey(theImport.getImportType())) {
return this.importers.get(theImport.getImportType());
} else {
if (theImport.getImportType().equals("http://schemas.xmlsoap.org/wsdl/")) {
Class<?> wsdlImporterClass;
try {
wsdlImporterClass = Class.forName("org.activiti.engine.impl.webservice.CxfWSDLImporter", true, Thread.currentThread().getContextClassLoader());
XMLImporter newInstance = (XMLImporter) wsdlImporterClass.newInstance();
this.importers.put(theImport.getImportType(), newInstance);
return newInstance;
} catch (Exception e) {
throw new ActivitiException("Could not find importer for type " + theImport.getImportType());
}
}
return null;
}
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class BpmnParse method createItemDefinitions.
protected void createItemDefinitions() {
for (org.activiti.bpmn.model.ItemDefinition itemDefinitionElement : bpmnModel.getItemDefinitions().values()) {
StructureDefinition structure = null;
try {
// it is a class
Class<?> classStructure = ReflectUtil.loadClass(itemDefinitionElement.getStructureRef());
structure = new ClassStructureDefinition(classStructure);
} catch (ActivitiException e) {
// it is a reference to a different structure
structure = this.structures.get(itemDefinitionElement.getStructureRef());
}
ItemDefinition itemDefinition = new ItemDefinition(itemDefinitionElement.getId(), structure);
if (StringUtils.isNotEmpty(itemDefinitionElement.getItemKind())) {
itemDefinition.setItemKind(ItemKind.valueOf(itemDefinitionElement.getItemKind()));
}
itemDefinitions.put(itemDefinition.getId(), itemDefinition);
}
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class CdiActivitiTestCase method waitForJobExecutorToProcessAllJobs.
//////////////////////// copied from AbstractActivitiTestcase
public void waitForJobExecutorToProcessAllJobs(long maxMillisToWait, long intervalMillis) {
JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();
jobExecutor.start();
try {
Timer timer = new Timer();
InteruptTask task = new InteruptTask(Thread.currentThread());
timer.schedule(task, maxMillisToWait);
boolean areJobsAvailable = true;
try {
while (areJobsAvailable && !task.isTimeLimitExceeded()) {
Thread.sleep(intervalMillis);
areJobsAvailable = areJobsAvailable();
}
} catch (InterruptedException e) {
} finally {
timer.cancel();
}
if (areJobsAvailable) {
throw new ActivitiException("time limit of " + maxMillisToWait + " was exceeded");
}
} finally {
jobExecutor.shutdown();
}
}
use of org.activiti.engine.ActivitiException in project Activiti by Activiti.
the class CdiActivitiTestCase method waitForJobExecutorOnCondition.
public void waitForJobExecutorOnCondition(long maxMillisToWait, long intervalMillis, Callable<Boolean> condition) {
JobExecutor jobExecutor = processEngineConfiguration.getJobExecutor();
jobExecutor.start();
try {
Timer timer = new Timer();
InteruptTask task = new InteruptTask(Thread.currentThread());
timer.schedule(task, maxMillisToWait);
boolean conditionIsViolated = true;
try {
while (conditionIsViolated) {
Thread.sleep(intervalMillis);
conditionIsViolated = !condition.call();
}
} catch (InterruptedException e) {
} catch (Exception e) {
throw new ActivitiException("Exception while waiting on condition: " + e.getMessage(), e);
} finally {
timer.cancel();
}
if (conditionIsViolated) {
throw new ActivitiException("time limit of " + maxMillisToWait + " was exceeded");
}
} finally {
jobExecutor.shutdown();
}
}
Aggregations