PDA

View Full Version : Multiple SaoFactoryObjects


oz_ko
11-23-2006, 07:28 AM
Hi,

I have a multithreaded application that calls many _different_ remote servers and multiple threads may access the SaoFactoryObject; Since SaoFactoryObjects are an IFactory there can be only one instance defined in the config.

What I've had to do is instantiate a SaoFactoryObject per thread and set the ServiceUrl and ServiceInterface manually and then generate the remote proxy using SaoFactoryObject.GetObject().

So the question is does the SaoFactoryObject have any static state information that would cause it to fail with multiple threads or is all OK? Also - is there a better way to implement this?

Thanks,
Oz

Bruno Baia
11-25-2006, 06:03 PM
Hi Oz,

The remote proxy is created on the server side, the SaoFActoryObject just gets it :

public object GetObject()
{
return Activator.GetObject(serviceInterface, serviceUrl);
}



Why not just calling ctx.GetObject("myObject") in each thread ?


Bruno

oz_ko
11-28-2006, 12:37 AM
Bruno,
Thanks for all the input! The issue is that the ServiceInterface and ServiceUrl are determined at runtime so essentially I need a factory for the SoaFactoryObject.

Multiple threads setting the serviceInterface and serviceUrl properties on a singleton SaoFactoryObject would end up in concurrency issues.

Maybe I should just be using System.Activator.GetObject(..) instead?

Thanks,
Oz