public void run() { Object rgoal = ((ElementFlyweight)goal).getHandle(); // Directly add rgoal to waitqueue if already finished. if(goal.isFinished()) { getState().addAttributeValue(rplan, OAVBDIRuntimeModel.plan_has_waitqueueelements, rgoal); } else { SFlyweightFunctionality.addGoal(getOrCreateWaitAbstraction(), (ElementFlyweight)goal, getState(), getScope()); } } };
/** * Wait for a goal. * @param goal The goal. * @param timeout The timeout. */ public void waitForGoal(final IGoal goal, long timeout) { if(goal.isFinished()) { // Todo: check thread access. if(OAVBDIRuntimeModel.GOALPROCESSINGSTATE_FAILED.equals( getState().getAttributeValue(((ElementFlyweight)goal).getHandle(), OAVBDIRuntimeModel.goal_has_processingstate))) { throw new GoalFailureException("Goal failed: "+goal); } } else { // Todo: check thread access. Object wa = getState().createObject(OAVBDIRuntimeModel.waitabstraction_type); SFlyweightFunctionality.addGoal(wa, (ElementFlyweight)goal, getState(), getRCapability()); PlanRules.waitForWaitAbstraction(wa, timeout, getState(), getRCapability(), getRPlan()); } }