use of org.whole.lang.workflows.model.InvokeJavaClassMethod in project whole by wholeplatform.
the class WorkflowsDynamicCompilerVisitor method visit.
@Override
public void visit(InvokeJavaClassMethod entity) {
final Variable resultVariable = entity.getResult();
Expressions arguments = entity.getArguments();
int size = arguments.wSize();
IEntityIterator<?>[] runnableIterators = new IEntityIterator<?>[2 + size];
entity.getClassName().accept(this);
runnableIterators[0] = getResultIterator();
entity.getMethod().accept(this);
runnableIterators[1] = getResultIterator();
for (int i = 0; i < size; i++) {
arguments.get(i).accept(this);
runnableIterators[2 + i] = getResultIterator();
}
setResultIterator(IteratorFactory.multiValuedRunnableIterator(new AbstractWorkflowsRunnable() {
public void run(IEntity selfEntity, IBindingManager bm, IEntity... argsEntities) {
String className = argsEntities[0].wStringValue();
IEntity methodData = argsEntities[1];
Method method;
if (DataTypeUtils.getDataKind(methodData).isString())
method = JavaReflectUtils.getMethod(className, methodData.wStringValue(), ReflectionFactory.getClassLoader(bm));
else
method = (Method) methodData.wGetValue();
Object[] arguments = toArguments(method.getParameterTypes(), method.isVarArgs(), argsEntities);
Object resultValue = JavaReflectUtils.invokeMethod(null, method, arguments);
setResult(bm, resultVariable, resultValue, method.getReturnType());
}
}, runnableIterators).withSourceEntity(entity));
}
use of org.whole.lang.workflows.model.InvokeJavaClassMethod in project whole by wholeplatform.
the class WorkflowsInterpreterVisitor method visit.
@Override
public void visit(InvokeJavaClassMethod entity) {
try {
entity.getClassName().accept(this);
String className = getResultString();
entity.getMethod().accept(this);
IEntity methodData = getResult();
Method method;
if (DataTypeUtils.getDataKind(methodData).isString())
method = JavaReflectUtils.getMethod(className, methodData.wStringValue(), ReflectionFactory.getClassLoader(getBindings()));
else
method = (Method) methodData.wGetValue();
Object[] arguments = toArguments(method.getParameterTypes(), method.isVarArgs(), entity.getArguments());
Object resultValue = JavaReflectUtils.invokeMethod(null, method, arguments);
setResult(entity.getResult(), resultValue, method.getReturnType());
} catch (Exception e) {
throw IWholeRuntimeException.asWholeException(e, entity, getBindings());
}
}
use of org.whole.lang.workflows.model.InvokeJavaClassMethod in project whole by wholeplatform.
the class InvokeJavaClassMethodPart method refreshVisuals.
@Override
protected void refreshVisuals() {
InvokeJavaClassMethod entity = getModelEntity();
Expression e = entity.getMethod();
String name = Matcher.matchImpl(WorkflowsEntityDescriptorEnum.StringLiteral, e) ? e.wStringValue() : "?";
int endIndex = name.indexOf('(');
if (endIndex > 0)
name = name.substring(0, endIndex);
getFigure().setMethodName(name);
super.refreshVisuals();
}
use of org.whole.lang.workflows.model.InvokeJavaClassMethod in project whole by wholeplatform.
the class InvokeJavaClassMethodPart method getModelSpecificChildren.
protected List<IEntity> getModelSpecificChildren() {
InvokeJavaClassMethod entity = getModelEntity();
List<IEntity> children = new ArrayList<IEntity>(6);
children.add(entity.getLabel());
children.add(entity.getClassName());
children.add(entity.getMethod());
// children.add(entity.getTypeArguments());
children.add(entity.getArguments());
children.add(entity.getResult());
return children;
}
Aggregations