From joao.barreto at ist.utl.pt Fri Mar 2 14:30:01 2012 From: joao.barreto at ist.utl.pt (Joao Pedro Barreto) Date: Fri, 02 Mar 2012 19:30:01 +0000 Subject: [jbossws-users] Where to put initialization code of a Web Service? In-Reply-To: <4F4DE3D0.2020302@mail.corp.redhat.com> References: <4F4CF75D.60507@ist.utl.pt> <4F4CF80D.1030207@ist.utl.pt> <4F4DE3D0.2020302@mail.corp.redhat.com> Message-ID: <4F511FB9.2020101@ist.utl.pt> Thanks for the help, Richard. However, this still does not help me, and I explain why. The initialization method of my web service depends on a couple of parameters that are defined in the web service's web.xml (using ). So my initialization method needs to have access to the ServletContext. But it seems that at the @PostConstruct moment the ServletContext is not ready yet to be consulted, as I get a error when I try to access it with: servletContext=(ServletContext)context.getMessageContext().get(MessageContext.SERVLET_CONTEXT); How can I have initialization code that is able to receive parameters that are defined in web.xml (or defined by some other means)? Thanks in advance. Joao On 29-02-2012 08:37, Richard Opalka wrote: > Hi Joao, > > best place to put your initialization code is @PostConstruct > annotated method. > See JSR-250 (http://jcp.org/en/jsr/detail?id=250). > > Rio > > On 02/28/2012 04:51 PM, Joao Pedro Barreto wrote: >> Hi, >> >> After exhaustively searching JBossWS documentation I could not find the >> answer to this simple question: >> >> I'm developing a Web Service in JBoss AS 7 that needs to establish a >> connection to a local database before it can serve client requests. >> >> I thought about putting the initialization code in the constructor >> method of the class that implements the Web Service, but I could never >> find any documentation that suggested that. >> >> What is the best place to put this initialization code? >> >> Thanks in advance. >> Joao >> _______________________________________________ >> jbossws-users mailing list >> jbossws-users at lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/jbossws-users > -- http://www.gsd.inesc-id.pt/~jpbarreto From joao.barreto at ist.utl.pt Fri Mar 2 14:32:03 2012 From: joao.barreto at ist.utl.pt (Joao Pedro Barreto) Date: Fri, 02 Mar 2012 19:32:03 +0000 Subject: [jbossws-users] Lifetime of a @WebService class Message-ID: <4F512033.5070801@ist.utl.pt> Hi, What is the lifetime of a @WebService class in Jboss 7? When is it instantiated for the first time (is it the first time that the server receives a client call for some operation?)? When is it destroyed (after some timeout?)? Joao