本文整理了Java中jadex.commons.future.Future.addResultListener()
方法的一些代码示例,展示了Future.addResultListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Future.addResultListener()
方法的具体详情如下:
包路径:jadex.commons.future.Future
类名称:Future
方法名:addResultListener
[英]Add an functional result listener, which is only called on success. Exceptions will be handled by DefaultResultListener.
[中]添加一个函数结果侦听器,该侦听器仅在成功时调用。异常将由DefaultResultListener处理。
代码示例来源:origin: org.activecomponents.jadex/jadex-commons
/**
* Add an functional result listener, which is only called on success.
* Exceptions will be handled by DefaultResultListener.
*
* @param sucListener The listener.
*/
public void addResultListener(IFunctionalResultListener<E> sucListener)
{
addResultListener(sucListener, null);
}
代码示例来源:origin: org.activecomponents.jadex/jadex-runtimetools-swing
/**
* Create a new listener.
*/
public KillListener(IModelInfo model, String fullname, Future fut, Component parent)
{
super(parent);
this.model = model;
this.fullname = fullname;
fut.addResultListener(new IResultListener()
{
public void resultAvailable(Object result)
{
cid = (IComponentIdentifier)result;
}
public void exceptionOccurred(Exception exception)
{
// handled in createComponent(...)
// KillListener.this.exceptionOccurred(exception);
}
});
}
代码示例来源:origin: net.sourceforge.jadex/jadex-runtimetools-swing
/**
* Create a new listener.
*/
public KillListener(IModelInfo model, String fullname, Future fut, Component parent)
{
super(parent);
this.model = model;
this.fullname = fullname;
fut.addResultListener(new IResultListener()
{
public void resultAvailable(Object result)
{
cid = (IComponentIdentifier)result;
}
public void exceptionOccurred(Exception exception)
{
// handled in createComponent(...)
// KillListener.this.exceptionOccurred(exception);
}
});
}
代码示例来源:origin: org.activecomponents.jadex/jadex-commons
/**
* Add a result listener by combining an OnSuccessListener and an
* OnExceptionListener.
*
* @param sucListener The listener that is called on success.
* @param exListener The listener that is called on exceptions. Passing
* <code>null</code> enables default exception logging.
*/
public void addResultListener(IFunctionalResultListener<E> sucListener, IFunctionalExceptionListener exListener)
{
addResultListener(SResultListener.createResultListener(sucListener, exListener));
}
代码示例来源:origin: org.activecomponents.jadex/jadex-commons
public <T> IFuture<T> thenCompose(final Function<? super E, IFuture<T>> function, Class<?> futuretype)
{
final Future<T> ret = getFuture(futuretype);
this.addResultListener(new ExceptionDelegationResultListener<E, T>(ret)
{
public void customResultAvailable(E result)
{
IFuture<T> res = function.apply(result);
res.addResultListener(SResultListener.delegate(ret));
}
});
return ret;
}
代码示例来源:origin: org.activecomponents.jadex/jadex-commons
public IFuture<Void> thenAccept(final Consumer<? super E> consumer, Class<?> futuretype)
{
final Future<Void> ret = getFuture(futuretype);
this.addResultListener(new ExceptionDelegationResultListener<E, Void>(ret)
{
public void customResultAvailable(E result)
{
consumer.accept(result);
ret.setResult(null);
}
});
return ret;
}
代码示例来源:origin: org.activecomponents.jadex/jadex-commons
public <T> IFuture<T> thenApply(final Function<? super E, ? extends T> function, Class<?> futuretype)
{
final Future<T> ret = getFuture(futuretype);
this.addResultListener(new ExceptionDelegationResultListener<E, T>(ret)
{
public void customResultAvailable(E result)
{
T res = function.apply(result);
ret.setResult(res);
}
});
return ret;
}
代码示例来源:origin: org.activecomponents.jadex/jadex-commons
public <U,V> IFuture<V> thenCombine(final IFuture<U> other, final BiFunction<? super E,? super U, ? extends V> function, Class<?> futuretype)
{
final Future<V> ret = getFuture(futuretype);
this.addResultListener(new ExceptionDelegationResultListener<E, V>(ret)
{
public void customResultAvailable(final E e)
{
other.addResultListener(new ExceptionDelegationResultListener<U, V>(ret) {
public void customResultAvailable(U u)
{
ret.setResult(function.apply(e, u));
}
});
}
});
return ret;
}
代码示例来源:origin: org.activecomponents.jadex/jadex-kernel-bdiv3
/**
* Add a listener
* @param listener The listener.
*/
public void addResultListener(IResultListener<E> listener)
{
super.addResultListener(new BDIComponentResultListener<E>(listener, getAgent()));
}
}
代码示例来源:origin: net.sourceforge.jadex/jadex-kernel-bdiv3
/**
*
* @param listener
*/
public void addResultListener(IResultListener<E> listener)
{
super.addResultListener(new BDIComponentResultListener<E>(listener, (BDIAgentInterpreter)((BDIAgent)ia).getInterpreter()));
}
}
代码示例来源:origin: org.activecomponents.jadex/jadex-platform
public void proceed()
{
// Only wait 2 secs for sending status before terminating the agent.
done.addResultListener(new TimeoutResultListener<Void>(2000, agent.getExternalAccess(),
new DelegationResultListener<Void>(ret)
{
public void exceptionOccurred(Exception exception)
{
super.resultAvailable(null);
}
}));
}
});
代码示例来源:origin: net.sourceforge.jadex/jadex-platform
public void proceed()
{
// Only wait 2 secs for sending status before terminating the agent.
done.addResultListener(new TimeoutResultListener<Void>(2000, agent.getExternalAccess(),
new DelegationResultListener<Void>(ret)
{
public void exceptionOccurred(Exception exception)
{
super.resultAvailable(null);
}
}));
}
});
代码示例来源:origin: net.sourceforge.jadex/jadex-applib-bdi
/**
* Compensate in case the task is canceled.
* @return To be notified, when the compensation has completed.
*/
public IFuture cancel(final IInternalAccess instance)
{
final Future ret = new Future();
creationFuture.addResultListener(instance.createResultListener(new IResultListener()
{
public void resultAvailable(Object result)
{
space.removeObjectTask(taskid, objectid);
ret.setResult(null);
}
public void exceptionOccurred(Exception exception)
{
ret.setResult(null);
}
}));
return ret;
}
代码示例来源:origin: org.activecomponents.jadex/jadex-applications-bdiv3
@AgentCreated
public void init()
{
Future<String> fut = new Future<String>();
fut.addResultListener(new IResultListener<String>()
{
public void resultAvailable(String message)
{
ack = message;
// setAck(message);
}
public void exceptionOccurred(Exception exception)
{
exception.printStackTrace();
}
});
fut.setResult("hello");
}
代码示例来源:origin: net.sourceforge.jadex/jadex-kernel-base
public void customResultAvailable(IComponentManagementService cms)
{
final List<IComponentIdentifier> cids = new ArrayList<IComponentIdentifier>();
Future<Void> fut = new Future<Void>();
fut.addResultListener(new ExceptionDelegationResultListener<Void, IComponentIdentifier>(ret)
{
public void customResultAvailable(Void result)
{
if(cids.size()>0)
{
ret.setResult(cids.get(0));
}
else
{
ret.setException(new RuntimeException("Component not created: "+component));
}
}
});
createComponent(new ComponentInstanceInfo[]{component}, cms, getModel(), 0, fut, cids);
}
}));
代码示例来源:origin: org.activecomponents.jadex/jadex-platform
public IFuture<Void> execute(IInternalAccess ia)
{
final Future<Void> ret = new Future<Void>();
try
{
AbstractSendTask task = createTask(StreamSendTask.ALIVE, null, null, null);
sendTask(task);
task.getFuture().addResultListener(new DelegationResultListener<Void>(ret));
}
catch(Exception e)
{
ret.setException(e);
}
return ret;
}
});
代码示例来源:origin: net.sourceforge.jadex/jadex-platform
public IFuture<Void> execute(IInternalAccess ia)
{
final Future<Void> ret = new Future<Void>();
try
{
AbstractSendTask task = createTask(StreamSendTask.ALIVE, null, null, null);
sendTask(task);
task.getFuture().addResultListener(new DelegationResultListener<Void>(ret));
}
catch(Exception e)
{
ret.setException(e);
}
return ret;
}
});
代码示例来源:origin: net.sourceforge.jadex/jadex-platform-base
public IFuture<Void> execute(IInternalAccess ia)
{
final Future<Void> ret = new Future<Void>();
try
{
AbstractSendTask task = createTask(StreamSendTask.ALIVE, null, null, null);
sendTask(task);
task.getFuture().addResultListener(new DelegationResultListener<Void>(ret));
}
catch(Exception e)
{
ret.setException(e);
}
return ret;
}
});
代码示例来源:origin: net.sourceforge.jadex/jadex-platform-base
/**
* Send addRef to the origin process of the remote reference.
* @param rr The remote reference.
*/
public Future<Void> sendAddRemoteReference(final RemoteReference rr)
{
checkThread();
// DGC: notify rr origin that a new proxy of target object exists
// todo: handle failures!
final Future<Void> ret = new Future<Void>();
// System.out.println("send add: "+rr);
final String callid = SUtil.createUniqueId(rsms.getRMSComponentIdentifier().getLocalName());
RemoteDGCAddReferenceCommand com = new RemoteDGCAddReferenceCommand(rr, rsms.getRMSComponentIdentifier(), callid);
Future<Object> fut = new Future<Object>();
fut.addResultListener(new ExceptionDelegationResultListener<Object, Void>(ret)
{
public void customResultAvailable(Object result)
{
ret.setResult(null);
}
});
rsms.sendMessage(rr.getRemoteManagementServiceIdentifier(), null, com, callid, BasicService.DEFAULT_REMOTE, fut, null);
return ret;
}
代码示例来源:origin: net.sourceforge.jadex/jadex-platform
/**
* Send addRef to the origin process of the remote reference.
* @param rr The remote reference.
*/
public Future<Void> sendAddRemoteReference(final RemoteReference rr)
{
checkThread();
// DGC: notify rr origin that a new proxy of target object exists
// todo: handle failures!
final Future<Void> ret = new Future<Void>();
// System.out.println("send add: "+rr);
final String callid = SUtil.createUniqueId(rsms.getRMSComponentIdentifier().getLocalName());
RemoteDGCAddReferenceCommand com = new RemoteDGCAddReferenceCommand(rr, rsms.getRMSComponentIdentifier(), callid);
Future<Object> fut = new Future<Object>();
fut.addResultListener(new ExceptionDelegationResultListener<Object, Void>(ret)
{
public void customResultAvailable(Object result)
{
ret.setResult(null);
}
});
rsms.sendMessage(rr.getRemoteManagementServiceIdentifier(), null, com, callid, BasicService.getRemoteDefaultTimeout(), fut, null, null);
return ret;
}
内容来源于网络,如有侵权,请联系作者删除!