Java Web 服务以及正在进行的后端工作
我正在考虑使用 RESTEasy 开发 Java Web 服务。我将遵循以下示例: http: //technicalmumbojumbo.wordpress.com/2009/10/13/restful-webservices-using-jboss-resteasy-tutorial/
现在,这对于让服务器回复一个简单的响应来说非常好。我如何让一些“后端”事情发生?例如,我想要一个在服务器后台不断运行的排队系统,处理队列中的对象。当有人访问某个 URL(Web 服务)时,我希望 Web 服务将某些内容入队。
此时我脑子里唯一能想到的事情(这可能是完全错误的)就是制作一个单独的 Java(J2SE )应用程序,它运行队列,并通过 RMI 或 Cajo 或其他方式将 Web 服务连接到它。
我想我要问的是,在 Tomcat 上运行的 Java Web 应用程序是否有“main() 方法”的概念“哪个在服务器启动时执行?
任何帮助表示赞赏
谢谢
I'm thinking about developing a Java Web Service using RESTEasy. I am going to follow this example: http://technicalmumbojumbo.wordpress.com/2009/10/13/restful-webservices-using-jboss-resteasy-tutorial/
Now, that's very well and good for getting the server to reply back with a simple response, however how do I get some "backend" things going on? For example, I want a queuing system running in the background constantly on the server, processing objects in the queue. When someone accesses a certain URL (The web service), i want the web service to Enqueue something..
The only thing I can think of in my head at the minute, which is probably totally wrong, is to make a seperate Java (J2SE) application, which runs the Queue, and connect the Web Service to it via RMI or Cajo or something..
I guess what I'm asking is that does a Java Web App running on Tomcat have any concept of a "main() method" which gets executed on server startup?
Any help is appreciated
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 web.xml 文件中适当的 load-on-startup 标记让 servlet 在应用程序加载时启动。
例如:
You can have a servlet get kick started on the load of the application using the appropriate load-on-startup tag in the web.xml file.
So for example: