You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Phani Sekhar <ph...@masconit.com> on 2006/08/01 14:36:30 UTC

Initializing a web service before invoking its methods

Hi all,
 
I want to write a web service that has to be initialized and configured
before doing its actual job.
If we write the initialization code in the same method, it will end up
doing the same stuff for each and every request.
Is there anything that we can do to avoid this and do the initialization
and configuration only for the first request????
Is there anything like init() method of Servlet with which we can
initialize the webservice on the first request ???
Please help.
 
Thanks in Advance
Phani Sekhar
 
 

RE: Initializing a web service before invoking its methods

Posted by Phani Sekhar <ph...@masconit.com>.
Thanks Matthew.....
I've tried it and Its working....

Thanks a lot for ur valuable suggestion......

~sekhar

-----Original Message-----
From: Matthew Carey [mailto:matthew@ssl.co.uk]
Sent: Tuesday, August 01, 2006 6:59 PM
To: axis-user@ws.apache.org
Subject: Re: Initializing a web service before invoking its methods

As a botch you could have a class that contains static data structures to
hold
your initialization data as well as a boolean that would hold whether it had
been initialized.

It might be better if the initialising bit were sychronised.

That way if you wanted to read say a properties file only once you could do
fill
the static properties structure the first time the class was instantiated
and
subsequent times the class was instantiated the properties data would still
be
in memory so no need to read it in again.

However you would want to be careful writing to this structure unless it was
guarded to prevent interference and in locking your resources you had
considered
the possibility of deadlock.

Matthew

Phani Sekhar wrote:
> Hi all,
>
>
>
> I want to write a web service that has to be initialized and configured
> before doing its actual job.
>
> If we write the initialization code in the same method, it will end up
> doing the same stuff for each and every request.
>
> Is there anything that we can do to avoid this and do the initialization
> and configuration only for the first request????
>
> Is there anything like init() method of Servlet with which we can
> initialize the webservice on the first request ???
>
> Please help.
>
>
>
> Thanks in Advance
>
> Phani Sekhar
>
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Initializing a web service before invoking its methods

Posted by Matthew Carey <ma...@ssl.co.uk>.
As a botch you could have a class that contains static data structures to hold 
your initialization data as well as a boolean that would hold whether it had 
been initialized.

It might be better if the initialising bit were sychronised.

That way if you wanted to read say a properties file only once you could do fill 
the static properties structure the first time the class was instantiated and 
subsequent times the class was instantiated the properties data would still be 
in memory so no need to read it in again.

However you would want to be careful writing to this structure unless it was 
guarded to prevent interference and in locking your resources you had considered 
the possibility of deadlock.

Matthew

Phani Sekhar wrote:
> Hi all,
> 
>  
> 
> I want to write a web service that has to be initialized and configured 
> before doing its actual job.
> 
> If we write the initialization code in the same method, it will end up 
> doing the same stuff for each and every request.
> 
> Is there anything that we can do to avoid this and do the initialization 
> and configuration only for the first request????
> 
> Is there anything like init() method of Servlet with which we can 
> initialize the webservice on the first request ???
> 
> Please help.
> 
>  
> 
> Thanks in Advance
> 
> Phani Sekhar
> 
>  
> 
>  
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org