/** * Dispatch a new top-level goal. * @param goal The new goal. */ public <T> IFuture<T> dispatchTopLevelGoal(final IGoal goal) { final Future<T> ret = new Future<T>(); goal.addListener(new ExceptionDelegationResultListener<Void, T>(ret) { public void customResultAvailable(Void result) { Object res = RGoal.getGoalResult((RGoal)goal, agent.getClassLoader()); ret.setResult((T)res); } }); // System.out.println("adopt goal"); RGoal.adoptGoal((RGoal)goal, getAgent()); return ret; }
/** * Create a goal from a template goal. * To be processed, the goal has to be dispatched as subgoal * or adopted as top-level goal. * @param type The template goal name as specified in the ADF. * @return The created goal. */ public IGoal createGoal(String type) { MGoal mgoal = getCapability().getMCapability().getResolvedGoal(scope, type); return new RGoal(getAgent(), mgoal, null, null, null, null, null); }