users@jersey.java.net

Re: not build a ressource at each request

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 19 Dec 2007 12:46:04 +0100

Hi Guilhem,

You can annotate a resource class with @Singleton [1]. Only one instance
of such a resource class will be instantiated per web application. It
also means the HTTP methods are reentrant.

Paul.

[1] com.sun.ws.rest.spi.resource.Singleton

guilhem legal wrote:
> hi!
>
> I am develloping a jersey web-service, and i have a little issue :
>
> I have a ressource with a relative hight cost of build, and the
> constructor is call at every request.
> can we build a ressource only one time?
>
> my resource is coded like this :
>
> @UriTemplate("wms")
> public class WMService {
> @HttpContext
> private UriInfo context;
>
> /**
> * Build a new instance of the webService and initialise the JAXB
> marshaller.
> */
> public WMService() throws JAXBException, IOException,
> WebServiceException {
> logger.severe("construteur");
> }
>
> @HttpMethod("GET")
> public Response treatGETrequest() throws JAXBException {
> .....
> }
>
> and so i have a print of "constructeur" each request i made.
>
> please reply if you have a solution
>
> regards,
> Guilhem Legal
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109