Java 拦截器的Catch返回值
我想检索此拦截器的返回值: 下面是我在代码后面使用CDIBean的方式:Java 拦截器的Catch返回值,java,jakarta-ee,Java,Jakarta Ee,我想检索此拦截器的返回值: 下面是我在代码后面使用CDIBean的方式: @Inject SomeCDI dataLoader; dataLoader.loadDataAsync(); // the loading starts async but I never find out when is the Future class done??? 所以我的问题是如何检索返回值(在我的例子中是来自FutureDelegator)???您不会。EJB上和Tijms建议的模型中的异步调用是“触发
@Inject
SomeCDI dataLoader;
dataLoader.loadDataAsync(); // the loading starts async but I never find out when is the Future class done???
所以我的问题是如何检索返回值(在我的例子中是来自FutureDelegator)???您不会。EJB上和Tijms建议的模型中的异步调用是“触发并忘记”:您调用它们并让它们完成工作。最终,您可以让异步方法在结束时触发一些事件以“返回”结果,观察该事件以给用户一些响应(可能是WebSocket?) 理想情况下,异步方法应该是void,并执行一些回调提升 请注意,CDI 2.0事件模型具有该方法,应该使用该方法而不是您自己的实现,因为它已经具有适当的上下文,并且可以通过事务标记和自定义选项(当使用NotificationOptions方法签名时)来丰富
public class SomeCDI {
@Asynchronous
public void loadDataAsync() {....}
}
@Inject
SomeCDI dataLoader;
dataLoader.loadDataAsync(); // the loading starts async but I never find out when is the Future class done???