/** * Create a result listener that is executed as an agent step. * @param listener The listener to be executed as an agent step. */ public <T> IResultListener<T> createResultListener(IResultListener<T> listener) { return interpreter.createResultListener(listener); }
/** * Create a result listener that is executed as an agent step. * @param listener The listener to be executed as an agent step. */ public <T> IIntermediateResultListener<T> createResultListener(IIntermediateResultListener<T> listener) { return interpreter.createResultListener(listener); }
public IFuture<Void> execute(IInternalAccess ia) { init(model.getModelInfo(), MicroAgentInterpreter.this.config, args) .addResultListener(createResultListener(new DelegationResultListener<Void>(inited) { public void customResultAvailable(Void result) { // Call user code init. microagent.agentCreated().addResultListener(new DelegationResultListener<Void>(inited)); } })); return IFuture.DONE; } };
public IFuture<Void> execute(IInternalAccess ia) microagent.executeBody().addResultListener(createResultListener(new IResultListener<Void>()
/** * Called, whenever a message is received. * @param msg The message. * @param mt The message type. */ public void messageArrived(Map msg, MessageType mt) { invokeMethod(AgentMessageArrived.class, new Object[]{msg, mt}).addResultListener( interpreter.createResultListener(new IResultListener<Tuple2<Method, Object>>() { public void resultAvailable(Tuple2<Method, Object> result) { } public void exceptionOccurred(Exception exception) { if(exception instanceof RuntimeException) { throw (RuntimeException)exception; } else { throw new RuntimeException(exception); } } })); }
/** * Called, whenever a message is received. * @param msg The message. * @param mt The message type. */ public void streamArrived(IConnection con) { invokeMethod(AgentStreamArrived.class, new Object[]{con}).addResultListener( interpreter.createResultListener(new IResultListener<Tuple2<Method, Object>>() { public void resultAvailable(Tuple2<Method, Object> result) { } public void exceptionOccurred(Exception exception) { if(exception instanceof RuntimeException) { throw (RuntimeException)exception; } else { throw new RuntimeException(exception); } } })); }
/** * Called, whenever a message is received. * @param msg The message. * @param mt The message type. */ public void messageArrived(Map msg, MessageType mt) { invokeMethod(AgentMessageArrived.class, new Object[]{msg, mt}).addResultListener( interpreter.createResultListener(new IResultListener<Tuple2<Method, Object>>() { public void resultAvailable(Tuple2<Method, Object> result) { } public void exceptionOccurred(Exception exception) { if(exception instanceof RuntimeException) { throw (RuntimeException)exception; } else { throw new RuntimeException(exception); } } })); }
/** * Called, whenever a message is received. * @param msg The message. * @param mt The message type. */ public void streamArrived(IConnection con) { invokeMethod(AgentStreamArrived.class, new Object[]{con}).addResultListener( interpreter.createResultListener(new IResultListener<Tuple2<Method, Object>>() { public void resultAvailable(Tuple2<Method, Object> result) { } public void exceptionOccurred(Exception exception) { if(exception instanceof RuntimeException) { throw (RuntimeException)exception; } else { throw new RuntimeException(exception); } } })); }
public void customResultAvailable(Void result) { injectParent(agent, micromodel).addResultListener(createResultListener(new DelegationResultListener<Void>(ret) { public void customResultAvailable(Void result) { MicroAgentInterpreter.super.initProvidedServices(model, config) .addResultListener(new DelegationResultListener<Void>(ret)); } })); } });
.addResultListener(interpreter.createResultListener( new ExceptionDelegationResultListener<Tuple2<Method, Object>, Void>(ret)
.addResultListener(interpreter.createResultListener( new ExceptionDelegationResultListener<Tuple2<Method, Object>, Void>(ret)
/** * Schedule a step of the component. * May safely be called from external threads. * @param step Code to be executed as a step of the component. * @param delay The delay to wait before step should be done. * @return The result of the step. */ public <T> IFuture<T> scheduleStep(final IComponentStep<T> step, final long delay) { final Future<T> ret = new Future<T>(); SServiceProvider.getService(getServiceContainer(), IClockService.class, RequiredServiceInfo.SCOPE_PLATFORM) .addResultListener(createResultListener(new DelegationResultListener(ret) { public void customResultAvailable(Object result) { IClockService cs = (IClockService)result; cs.createTimer(delay, new ITimedObject() { public void timeEventOccurred(long currenttime) { scheduleStep(step).addResultListener(new DelegationResultListener(ret)); } }); } })); return ret; }
/** * Called from cleanupComponent. */ public IFuture<Void> terminateServiceContainer() { final Future<Void> ret = new Future<Void>(); IResultListener<Void> reslis = new IResultListener<Void>() { public void resultAvailable(Void result) { nosteps = true; exitState(); ret.setResult(result); } public void exceptionOccurred(final Exception exception) { nosteps = true; exitState(); ret.setException(exception); } }; // If platform, do not schedule listener on component as execution service already terminated after terminate service container. if(getComponentIdentifier().getParent()!=null) reslis = createResultListener(reslis); super.terminateServiceContainer().addResultListener(reslis); return ret; }