[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

SingleCall calling SingleTon object

Lord2702

9/13/2004 8:31:00 PM

Mon. Sep. 13, 2004 1:20 PM PT

Suppose, I have a server, which hosts two MBRO's, one is SingleCall
(MBRO_One) and another is SingleTon (MBRO_Two). Both hosts on one server,
Now, client will call a function from MBRO_One, which further calls a
function in MBRO_Two. Is it possible to place this call. If possible, then
how do I activate the MBRO_Two object, on MBRO_One object side. Because Both
these objects are on one AppDomain, whereas Client is on separate domain.

Thanks.


2 Answers

Ken Kolda

9/13/2004 10:13:00 PM

0

Assuming it's your single-call object accessing your singleton, you can do
this two ways:

1) Marshal your singleton manually instead of using the
RemotingConfiguration.RegisterWellKnownServerObject(). This will allow you
to create a static instance of your remoted class which is accessible both
by remote objects and objects in the same AppDomain. For example:

class MySingletonObject : MarshalByRefObject
{
public static MySingletonObject RemotedObject = new MySingletonObject();
}

class MyServer
{
public static void Main()
{
// Marshal object manually
RemotingServices.Marshal(MySingletoneObject.RemotedObject,
"Singleton.rem");
}
}

class MySingleCallObject : MarshalbyRefObject
{
public void SomMethod()
{
MySingletonObject.RemotedObject.SomeOtherMethod();
}
}


2) You can actually make your server a client of itself. In your SingleCall
object's methods, you would use Activator.GetObject() to fetch a reference
to the Singleton. This will be slower because you're actually going out thru
remoting and back in with each method call, but it requires less work. Plus,
if the object you're calling is SingleCall instead of Singleton, this is the
only way to do it (beside various techniques of wrapping the single-call
object).

Hope that helps -
Ken


"Lord2702" <Lord2702@MSN.com> wrote in message
news:%234a0hCdmEHA.3352@TK2MSFTNGP10.phx.gbl...
> Mon. Sep. 13, 2004 1:20 PM PT
>
> Suppose, I have a server, which hosts two MBRO's, one is SingleCall
> (MBRO_One) and another is SingleTon (MBRO_Two). Both hosts on one server,
> Now, client will call a function from MBRO_One, which further calls a
> function in MBRO_Two. Is it possible to place this call. If possible, then
> how do I activate the MBRO_Two object, on MBRO_One object side. Because
Both
> these objects are on one AppDomain, whereas Client is on separate domain.
>
> Thanks.
>
>


Lord2702

9/14/2004

0

Yes that helps a lot, I actually thought of making SingleTon MBRO as
Singleton, but then stop, at the point that hey, as already this object is A
Singleton, but then in your design, it makes me simple to access the static
instance of SingleTon object. Thanks.

"Ken Kolda" <ken.kolda@elliemae-nospamplease.com> wrote in message
news:%23%23G3d7dmEHA.2772@tk2msftngp13.phx.gbl...
> Assuming it's your single-call object accessing your singleton, you can do
> this two ways:
>
> 1) Marshal your singleton manually instead of using the
> RemotingConfiguration.RegisterWellKnownServerObject(). This will allow you
> to create a static instance of your remoted class which is accessible both
> by remote objects and objects in the same AppDomain. For example:
>
> class MySingletonObject : MarshalByRefObject
> {
> public static MySingletonObject RemotedObject = new
MySingletonObject();
> }
>
> class MyServer
> {
> public static void Main()
> {
> // Marshal object manually
> RemotingServices.Marshal(MySingletoneObject.RemotedObject,
> "Singleton.rem");
> }
> }
>
> class MySingleCallObject : MarshalbyRefObject
> {
> public void SomMethod()
> {
> MySingletonObject.RemotedObject.SomeOtherMethod();
> }
> }
>
>
> 2) You can actually make your server a client of itself. In your
SingleCall
> object's methods, you would use Activator.GetObject() to fetch a reference
> to the Singleton. This will be slower because you're actually going out
thru
> remoting and back in with each method call, but it requires less work.
Plus,
> if the object you're calling is SingleCall instead of Singleton, this is
the
> only way to do it (beside various techniques of wrapping the single-call
> object).
>
> Hope that helps -
> Ken
>
>
> "Lord2702" <Lord2702@MSN.com> wrote in message
> news:%234a0hCdmEHA.3352@TK2MSFTNGP10.phx.gbl...
> > Mon. Sep. 13, 2004 1:20 PM PT
> >
> > Suppose, I have a server, which hosts two MBRO's, one is SingleCall
> > (MBRO_One) and another is SingleTon (MBRO_Two). Both hosts on one
server,
> > Now, client will call a function from MBRO_One, which further calls a
> > function in MBRO_Two. Is it possible to place this call. If possible,
then
> > how do I activate the MBRO_Two object, on MBRO_One object side. Because
> Both
> > these objects are on one AppDomain, whereas Client is on separate
domain.
> >
> > Thanks.
> >
> >
>
>