Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How many instances of web service class are created?

 
Dean Fredericks
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a java bean web service.

I place to class into axis and rename it to a .jws, and there is my web service.

When I look at my log files - it seems the contructor of my class is running for every request that is comming in!

That cant be right !? thats not how servlets works! I want only one instance of my class to be made, otherwise I think it will mess up my connection pooling. My DataSource is looked up in the constructor - I want one dataSource - many connections. Not each request getting its own istance of the class and therefore its own datasource!
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using Axis ? If yes it is possible to create a single instance of WS class. I have posted a link before in this forum so searching the forum will help.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thats not how servlets works!

Why would you expect it to work like a servlet? Like you said, it's a bean that gets exposed as web service. The Axis documentation does not mention anywhere what the lifecycle semantics are, but it does mention the various drawbacks the .jws approach has, which make it unsuitable for serious use.
[ September 30, 2005: Message edited by: Ulf Dittmer ]
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As DataSource is thread safe and as only one is needed, declare it static.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:

Why would you expect it to work like a servlet? Like you said, it's a bean that gets exposed as web service. The Axis documentation does not mention anywhere what the lifecycle semantics are, but it does mention the various drawbacks the .jws approach has, which make it unsuitable for serious use.

[ September 30, 2005: Message edited by: Ulf Dittmer ]


I think he wanted only one instance of the service class same as the servlet.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic