-----------------------------------------------------------

New Message on MumbaiUserGroup

-----------------------------------------------------------
From: Nasha
Message 2 in Discussion




  
    
    New Message on MumbaiUserGroup
  
  





      Article :.NET Remoting ( Part - 3 Formatters,ObjectActivation,Proxy & Msg 
Sinks)

    
  
    
      Reply

          
            
                
               
                  Reply to Sender
                    Recommend
                  
                  Message 1 in Discussion
                                                
            
          
        
                    
        
            
              From: 
              Nasha
            
            
              

               
Hi Frndz,

Continuing our yesterdays discussion letz start with formatters.

Formatters :- .NET framework provides us with two formatters classes namely 
SoapFormatter and BinaryFormatter. You can find  them under namespace 
System..Runtime.Serialization.Formatters.Binary and 
System.Runtime.Serialization.Formatters.Soap .  Formatters are used to transfer 
data to and fro from a channel. They are associated with a channel through 
formatter sink objects and  providers.Both these formatters implement a common 
interface know as IRemotingFormatter. IRemoting is available under  
System.Runtime.Remoting.Messaging Namespace. This interface has two methods 
Serialize and Deserialize which help to serialize  data to be transfered across.

Both these formatters are primarily used for serialization and deseralization 
of method calls and reponses.When a method call is  made , the method call 
information has to be serialized inorder to be sent to the remote object. To 
execute the request it has to be  deserialized. After the request is executed 
on the remote object the response has to be serialized and sent. The response 
is further  deserialised by the client.

You can also create your custom formatter and associate it to a channel.

Object Activation :-  Remote objects can be either client activiated or server 
activated. You can get reference to the remote objects  using the Activator 
class. Activator.GetObject method returns you a reference to the proxy of a 
server activated object.  Activator.CreateInstance returns you a refernce to a 
proxy of client Activated object.

Server or WellKnown Objects :- Activator.GetObject and RemotingServices.Connect 
both return a reference to a proxy of a server or wellknown object. There are 
two types of the wellknown service type. SingleCall and Singleton.

SingleCall :- SingleCall objects dont hold any state that means for every call 
you make to the remote object a new object is created.  So there is no object 
to persist data in between calls. This can be efficient as the server does not 
need to hold any resources for the  client.

Singleton :- As the word singleton says the same object is used across client. 
This object can be used to share data across clients.  As with any other 
singleton object one has to be careful of locking of resources and concurrency.

When we create a server activated remote object we can register the 
wellknownservicetype as either of them.

Client-Activated Objects :-Activator.CreateInstance creates a client activated 
object. Life-time of the client activated object is in the  hands of the client 
unlike the server activated objects i.e. the object lives till the time the 
cleint wants it to live. On creating a client  activated object yuo can 
specifiy the lease time of the object. Since the the client has reference to 
the object, object state can be  maintained easily.

Proxy :-  We just saw above that both the static methods Activator.GetObject 
and Activator.CreateInstance return us reference to a  proxy object. In 
Remoting there are two types of proxies Transparent and Real Proxy. Transparent 
proxy is an object that looks like  the remote object but all the method calls 
are further redirected to real proxy. Transparent proxy calls the Invoke method 
of the real  proxy object.

To check whether the proxy received by you is a real proxy or a transparent 
proxy .NET provides us with a method called  IsTransparentProxy exposed by 
RemotingServices class. This method takes the refrence to the proxy object as a 
parameter and  returns a boolean value.

MessageSinks :-  Message sinks are interceptors that can change the messages 
and perform some additional actions. Whenever we  create an object we get a 
reterence to its proxy. This proxy uses a chain of envoy sinks to pass messages 
to the channel. All  message sinks implement IMessageSink Interface which has 
one property NextSink and two methods SyncProcessMessage and  
AsyncProcessMessage.

NextSink returns a refernce to the next sink in the hierarchy to pass the 
message. SycnProcessMessage method processes a  message request in a 
synchronous manner and returns a response message [ a an IMessage object ]. 
AsyncProcessMessage  method process the message request asynchronously and 
returns a reference to the passed async message [ an IMessageCtrl  object].

There are mainly three types of message sinks i.e. Envoy,Server Context and 
Object.

Envoy Sink :- They are created from the server context so the server can pass 
messages to the client. Envoy sinks are generally  used to collect client info 
and pass it to the server.

Server Context Sink :- When a message is received on the server side it is 
passed to the server context sink.

Object Sink :- An object sink is created for a particular object if its class 
defines context sinks and attributes.      
-- Please post your queries and comments for my articles in the user group for 
the benefit of all. I hope this step from my end is helpful to all of us. You 
can find all articles written by me at my personal blog 
http://spaces.msn.com/members/nasha. 

Regards,

Namratha (Nasha)
          
        
      
          
  

    View other groups in this category.
  

  

      




-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/mumbaiusergroup/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to