@Singleton @Startup完全异步? [英] @Singleton @Startup fully Asynchronous?

查看:303
本文介绍了@Singleton @Startup完全异步?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一起使用@Singleton和@Startup注释来创建一个长时间运行的进程。通过使用这些注释,我可以安全地假设我的进程将是一个完全异步运行的单个线程吗?

I am using the @Singleton and @Startup annotations together to create a long running process. By using these annotation can I safely assume that my process will be a single thread running fully asynchronously?

推荐答案

你可以在课堂级别使用这些注释,所以我不确定你引用了什么'进程' to(@PostConstruct method?)

You can use these annotations just at the class-level, so I'm not sure what 'process' do you refer to (@PostConstruct method?)

我不记得EJB 3.1规范的任何部分讨论了所需的异步单例初始化。

I don't remember any part of the EJB 3.1 specification which talks about the required asynchronous singleton initialization.

4.8.1单例初始化:


(...)bean开发人员可以选择配置Singleton
进行急切初始化。如果启动注释出现在
Singleton bean类(...)上,则容器必须在应用程序启动序列期间初始化Singleton bean实例。在将任何客户端请求交付给
应用程序中的任何企业bean组件之前,容器必须初始化所有这样的
启动时单例

(...)the bean developer can optionally configure the Singleton for eager initialization. If the Startup annotation appears on the Singleton bean class (...) the container must initialize the Singleton bean instance during the application startup sequence. The container must initialize all such startup-time Singletons before any client requests are delivered to any enterprise bean components in the application.

它取决于Application Server供应商他选择的初始化技术。 我不会认为加载会在单独的进程中发生,而只是在服务器启动期间和服务客户​​端之前发生。

It rather depends on the Application Server vendor what technique of initialization he choose. I would not assume that the loading will occur in a separate process but rather just that it will occur during server startup and before serving clients.

从注释中输入:
如何为您的单例初始化程序EJB调用耗时的操作提供单独的异步EJB方法呢?

ENTERED FROM COMMENTS: what about providing a separate asynchronous EJB method for your time-consuming operation which will be invoked from your singleton initializer EJB?

这篇关于@Singleton @Startup完全异步?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆