Singleton, Singlecall & ClientActivated Object :
SingleCall objects don't maintain any state between calls and every call to the object would be serviced by a new instance of the object. So essentially, they are stateless and are perfect candidates for load balancing and would scale-out well if deployed in a server farm.
Singleton objects follow the classic Singleton pattern where the same instance of the object is used to service requests from consumers. This pattern is useful when you need to maintain shared data or resources between all clients. For example, say you wanted to maintain a hit counter that tracked the number of hits on a server resource.
Client Activated Objects (CAO) use the activation & lifetime pattern that we see in object models like COM. When the client calls new or Activator.CreateInstance to create a CAO object, a remote request is sent in the form of an activation message that is intercepted by the Remoting Activator and the remote object is invoked. An object reference( ObjRef ) is passed back to the client. Every call that the client makes using the ObjRef that was handed over, is serviced by the same object on the server, thus allowing you to maintain state between method calls. This is quite different from the SingleCall and Singleton models because in both those models, the remote object is activated only when the first method call is made on the proxy and not during the actual instance creation.
|