Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Request specific singleton in webservice ?

Reply
Thread Tools

Request specific singleton in webservice ?

 
 
Poul Lund J?rgensen
Guest
Posts: n/a
 
      05-28-2004
Hi,

I would like to use the singleton pattern in a webservice in order to
ensure one and only one instance of certains objects within the
context of the webservice request.

When I try to build the usual singleton pattern with the static
instance variable I notice that the static member is shared between
different webservice call which is NOT what I want.

I am considering using the HttpContext.Current.Items dictonary as a
kind of webservice local singleton storage in order to avoid the
singletons being shared between webservice call, but it would require
a lot refactoring in the current application.

Does anyone know a better way to obtain webservice locale singletons ?

best regards
Poul Lund Jørgensen
 
Reply With Quote
 
 
 
 
Charlie Nilsson [MSFT]
Guest
Posts: n/a
 
      05-28-2004
You'll have to use static variables or maintain an index / collection
that's shared in your web service call. Start by thinking what objects
are created and then destroyed by the SOAP / web service calls, independent
of other calls.

Maybe you would want to store this variable in the WebService.Context
object (of type System.Web.HttpContext) which is created for the request.
Check out the "Items" collection member variable.

--
CharlieN
DevDiv

This posting is provided "AS IS" with no warranties, and confers no rights.

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.

--------------------
> From: http://www.velocityreviews.com/forums/(E-Mail Removed) (Poul Lund J?rgensen)
> Newsgroups: microsoft.public.dotnet.framework.aspnet.webservic es
> Subject: Request specific singleton in webservice ?
> Date: 28 May 2004 04:58:21 -0700
> Organization: http://groups.google.com
> Lines: 19
> Message-ID: <(E-Mail Removed) >
> NNTP-Posting-Host: 217.157.117.32
> Content-Type: text/plain; charset=ISO-8859-1
> Content-Transfer-Encoding: 8bit
> X-Trace: posting.google.com 1085745501 1877 127.0.0.1 (28 May 2004

11:58:21 GMT)
> X-Complaints-To: (E-Mail Removed)
> NNTP-Posting-Date: Fri, 28 May 2004 11:58:21 +0000 (UTC)
> Path:

cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFT NGP08.phx.gbl!news-out.cwi
x.com!newsfeed.cwix.com!prodigy.com!prodigy.com!ne ws.glorb.com!postnews1.goo
gle.com!not-for-mail
> Xref: cpmsftngxa10.phx.gbl

microsoft.public.dotnet.framework.aspnet.webservic es:24047
> X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservic es
>
> Hi,
>
> I would like to use the singleton pattern in a webservice in order to
> ensure one and only one instance of certains objects within the
> context of the webservice request.
>
> When I try to build the usual singleton pattern with the static
> instance variable I notice that the static member is shared between
> different webservice call which is NOT what I want.
>
> I am considering using the HttpContext.Current.Items dictonary as a
> kind of webservice local singleton storage in order to avoid the
> singletons being shared between webservice call, but it would require
> a lot refactoring in the current application.
>
> Does anyone know a better way to obtain webservice locale singletons ?
>
> best regards
> Poul Lund Jørgensen
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Singleton methods without the singleton class Charles Oliver Nutter Ruby 4 03-22-2010 10:46 PM
Singleton object vs. enhancing singleton class Paul McMahon Ruby 3 06-09-2008 06:05 AM
Singleton Modules rather than Singleton Classes Trans Ruby 12 09-14-2007 06:45 AM
Singleton - Whether Cloneable overrides Singleton Proton Projects - Moin Java 4 03-27-2007 02:59 AM
Singleton classes and Singleton pattern Wilhelm Ruby 1 10-11-2006 01:08 PM



Advertisments