Do SingleCall server activation objects retain state across calls?

  • Thread starter Thread starter Sathyaish
  • Start date Start date
S

Sathyaish

Do SingleCall server activation mode objects retain their state across
different calls?

For e.g.

Server code:
------------
//RemoteServerObject's activation mode is server activation. The
WellKnownObjectMode enum value assigned is SingleCall, done in config
file.

public class RemoteServerObject: MarshalByRef
{
private int _value = 0;

public void SetValue(int value)
{
this._value = value;
}


public int GetValue()
{
return this._value;
}
}


Client code:
-------------

RemoteServerObject r = new RemoteServerObject(); //Nothing happens
here

r.SetValue(3); //New instance of RemoteServerObject created on server.
It's _value set to 3.

/* Suppose that the lifetime lease of r expires here */

Console.WriteLine( r.GetValue().ToString() ); //Another instance
created by server. Question: Will this instance retain the value 3?


My common sense says that the remoting infrastructure would persist
state of the object across its various lifetimes. but I don't know for
sure.
 
I'm not 100% sure, but I don't think any state is retained
automatically. If you need this, you'd have to do it yourself, but
it's not trivial.
 
It doesn't matter. The object is released after the call. This is what
makes it SingleCall. You get a new instance every time you make a new call.
 
Back
Top