我需要为这些特性编写一个Java系统。
- 当系统启动时,需要创建一些需要在系统运行时永久生存的对象。 同样在对象的构造函数中,将创建新线程,并且在系统运行时这些线程也需要存活。
- 系统需要公开一个将使用启动时创建的对象的Web服务。
为了给出我需要做什么的背景,我需要编写一个应用程序,当它启动时,它会创建一些负责执行轮询任务的对象。 另外我需要一个使用这些对象来处理请求的Web服务。
我如何在Java中实现这些? 我正在考虑使用Java EE来实现Web服务,也是因为我打算实现一个使用Web服务的Web界面。 但是我所拥有的大问题是,如何在Java EE中实现自应用程序启动后永远存在的线程?
I need to code a Java system with these characteristics.
-When the system starts up, it needs to create some objects that need to live forever while the system is running. Also on the constructor of the objects, new threads will be created and these threads will also need to live while the system is running.
-The system needs to expose a web service that will use the object that were created on startup.
To give a context of what do I need to do, I need to code an app that when it starts up it creates some objects that are in charge of doing a polling task. Also I need a web service that uses these objects to process their requests.
How do I implement these in Java? I was thinking of using Java EE to implement the web services and also because I'm planning to implement a web interface that consumes the web services. But the BIG QUESTION that I have is, how do I implement in Java EE the threads that live forever since the application starts?
最满意答案
如果您采用Java EE方式,则应考虑EJB定时服务 。
If you are going the Java EE way, you should consider the EJB Timer Service.
更多推荐
发布评论