/** * Shutdown the feature. */ public IFuture<Void> shutdown() { doCleanup(); return IFuture.DONE; }
protected void entryAdded(String key, Object value) { postEvent(key, value); }
initDefaultArguments(); results.put(IComponentIdentifier.RESULTCID, getComponent().getComponentIdentifier()); initDefaultResults();
public void terminated(Exception reason) { if(getComponent().getComponentFeature(IExecutionFeature.class).isComponentThread()) { resfuts.remove(ret); } else { getComponent().getComponentFeature(IExecutionFeature.class).scheduleStep(new IComponentStep<Void>() { public IFuture<Void> execute(IInternalAccess ia) { resfuts.remove(ret); return IFuture.DONE; } }); } } });
/** * Set result values from beliefs. */ public IFuture<Void> shutdown() { IBDIXAgentFeature bdif = getComponent().getComponentFeature(IBDIXAgentFeature.class); BDIXModel model = (BDIXModel)bdif.getModel(); for(MBelief mbel: model.getCapability().getBeliefs()) { if(model.getCapability().getResultMappings().containsKey(mbel.getName()) && mbel.getEvaluationMode()==EvaluationMode.PULL) { Object val; if(mbel.isMulti(null)) { val = bdif.getBeliefbase().getBeliefSet(mbel.getName()).getFacts(); } else { val = bdif.getBeliefbase().getBelief(mbel.getName()).getFact(); } getResults().put(model.getCapability().getResultMappings().get(mbel.getName()), val); } } return super.shutdown(); } }
/** * Perform cleanup in shutdown or kill. */ protected void doCleanup() { if(resfuts!=null) { Exception ex = getComponent().getException(); if(ex!=null) { for(SubscriptionIntermediateFuture<Tuple2<String, Object>> fut: resfuts) { fut.setExceptionIfUndone(ex); } } else { for(SubscriptionIntermediateFuture<Tuple2<String, Object>> fut: resfuts) { fut.setFinishedIfUndone(); } } resfuts = null; } }
protected void entryRemoved(String key, Object value) { postEvent(key, null); }
/** * Kill is only invoked, when shutdown of some (e.g. other) feature does not return due to timeout. * The feature should do any kind of possible cleanup, but no asynchronous operations. */ public void kill() { doCleanup(); }
protected void entryChanged(String key, Object oldvalue, Object newvalue) { postEvent(key, newvalue); } };