[英]“Standardized” way of handling the lifecycle of a Java EE application
When developing an Java EE Application, I often came across the 'problem' to do stuff when the application is started, stopped etc. Now for Weblogic for example, there is a mechanism for that (the application life-cycle listener).在开发 Java EE 应用程序时,我经常遇到在应用程序启动、停止等时执行操作的“问题”。例如,对于 Weblogic,有一种机制(应用程序生命周期侦听器)。 But if you want to keep your application free from stuff that is app.但是,如果您想让您的应用程序不受应用程序的影响。 server specific, you have to find a different solution.特定于服务器,您必须找到不同的解决方案。 Some recommend using a servlet that is loaded on start-up, and "abuse" the init()
/ destroy()
.有些人建议使用在启动时加载的 servlet,并“滥用” init()
/ destroy()
。
Others say use a ServletContextListener
.其他人说使用ServletContextListener
。 To me, the last one sounds best (according to the java doc for ServletContextListener
. Unfortunately, today I tried JBoss 7, where it seems that jax-ws webservices are initialized before any other Servlet
, thus before the ServletContextListener
gets a notification.对我来说,最后一个听起来最好(根据ServletContextListener
的 java 文档。不幸的是,今天我尝试了ServletContextListener
7,似乎 jax-ws webservices 在任何其他Servlet
通知之前被初始化,因此在
Long story short - am I just facing some app server specific issues here - or is there any "more appropriate", standardized Java EE way to register things, do stuff, before any webservice, servlet, whatsoever is initialized?长话短说 - 我只是在这里面临一些应用程序服务器特定的问题 - 还是有任何“更合适”的标准化 Java EE 方式来注册东西,做一些事情,在任何 web 服务、servlet 之前初始化?
If your webservices are annotated like this如果您的网络服务是这样注释的
@javax.jws.WebService(...)
public interface YourServiceEndpoint
they are no real servlets yet, but JBoss (Jax-WS) will turn them into a startup.他们还不是真正的servlets,但是 JBoss (Jax-WS) 会将他们变成一家初创公司。
I am using jboss-4.2.3 and I am also getting these messages before my ServletContextListner
is called.我正在使用 jboss-4.2.3,并且在调用ServletContextListner
之前我也会收到这些消息。
[org.jboss.wsf.framework.management.DefaultEndpointRegistry] register: jboss.ws:context=crm,endpoint=YourService
But I wonder, if this webservice is available before the complete application has started because nearly at the end of deployment I get following messages但我想知道,如果在完整的应用程序启动之前这个 web 服务可用,因为几乎在部署结束时我收到以下消息
[org.jboss.wsf.stack.jbws.WSDLFilePublisher] WSDL published to: ... YourServlet(..).wsdl
So I would guess, that this is a jboss related issue.所以我猜,这是一个 jboss 相关问题。 Maybe we should test on another app server to proof so.也许我们应该在另一个应用服务器上进行测试来证明这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.