use of org.whole.lang.bindings.ITransactionScope in project whole by wholeplatform.
the class PerformHandler method canExecute.
@CanExecute
public boolean canExecute(@Named(BEHAVIOR_XWL_PARAMETER_ID) String behaviorXwl, @Named(PREDICATE_XWL_PARAMETER_ID) String predicateXwl, @Optional @Named(IServiceConstants.ACTIVE_SELECTION) IBindingManager bm) throws Exception {
ITransactionScope ts = BindingManagerFactory.instance.createTransactionScope();
try {
bm.wEnterScope(ts);
defineBindings(behaviorXwl, predicateXwl, bm);
return HandlersBehavior.canPerform(bm);
} catch (Exception e) {
return false;
} finally {
ts.rollback();
bm.wExitScope();
}
}
use of org.whole.lang.bindings.ITransactionScope in project whole by wholeplatform.
the class TestsInterpreterVisitor method visit.
@Override
public void visit(Test entity) {
ITransactionScope ts = BindingManagerFactory.instance.createTransactionScope();
getBindings().wEnterScope(ts);
String name = entity.getName().getValue();
Outcome outcome = TestsEntityFactory.instance.createOutcome(OutcomeEnum.SUCCESS);
StringLiteral location = CommonsEntityAdapterFactory.createResolver(StringLiteral);
StringLiteral cause = CommonsEntityAdapterFactory.createResolver(StringLiteral);
Result result = TestsEntityFactory.instance.createResult(outcome, location, cause);
try {
for (BeforeTest beforeTest : BehaviorUtils.<BeforeTest>compileAndLazyEvaluate(createAspectPath("BeforeTest"), entity)) {
beforeTest.accept(this);
getResult();
}
entity.getBody().accept(this);
getResult();
for (AfterTest afterTest : BehaviorUtils.<AfterTest>compileAndLazyEvaluate(createAspectPath("AfterTest"), entity)) {
afterTest.accept(this);
getResult();
}
printWriter().printf(" %32s(...) OK\n", name);
} catch (OperationCanceledException e) {
throw e;
} catch (TestsException e) {
outcome.wSetValue(OutcomeEnum.FAILURE);
location.setValue(EntityUtils.getLocation(e.getSubjectStatement()));
cause.setValue(e.getMessage());
reportFailure(name, e);
} catch (RuntimeException e) {
outcome.wSetValue(OutcomeEnum.ERROR);
IEntity sourceEntity = null;
if (e instanceof IWholeRuntimeException) {
sourceEntity = ((IWholeRuntimeException) e).getSourceEntity();
if (EntityUtils.getCompoundRoot(sourceEntity) != EntityUtils.getCompoundRoot(entity))
// FIXME replace with outer aspect or statement
sourceEntity = null;
}
if (sourceEntity == null)
sourceEntity = entity;
location.setValue(EntityUtils.getLocation(sourceEntity));
cause.setValue(e.getMessage());
reportError(name, e);
} finally {
ts.rollback();
getBindings().wExitScope();
}
if (EntityUtils.isResolver(entity.getExpectedResult()))
entity.setExpectedResult(EntityUtils.clone(result));
if (!Matcher.match(result, entity.getActualResult()))
entity.setActualResult(result);
setResult(result);
}
Aggregations