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). 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()
.
Others say use a 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.
Long story short - am I just facing some app server specific issues here - or is ther开发者_如何转开发e any "more appropriate", standardized Java EE way to register things, do stuff, before any webservice, servlet, whatsoever is initialized?
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.
I am using jboss-4.2.3 and I am also getting these messages before my ServletContextListner
is called.
[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
[org.jboss.wsf.stack.jbws.WSDLFilePublisher] WSDL published to: ... YourServlet(..).wsdl
So I would guess, that this is a jboss related issue. Maybe we should test on another app server to proof so.
精彩评论