Copyright © 2003, developerLabs Extending.NET Distributed Applications Stephen Fulcher...
-
Upload
corey-johns -
Category
Documents
-
view
212 -
download
0
Transcript of Copyright © 2003, developerLabs Extending.NET Distributed Applications Stephen Fulcher...
Copyright © 2003, developerLabs
Extending .NET Distributed Applications
Stephen FulcherdeveloperLabs
Copyright © 2003, developerLabs
Topics
General Extensibility Remoting Extensibility
Copyright © 2003, developerLabs
General Extensibility
Custom configuration The .NET configuration hierarchy can be extended arbitrarily New configuration sections can be defined and we can supply handlers for those
sections Programmatic type activation
Configuration metadata can be used to describe types to the satisfaction of the loader
Assembly loading might be required Types activated in this manner must already be compiled into assembly form
Programmatic type generation The CodeDOM namespace includes support for programmatically generating
and compiling types The reflection namespace also includes a technique for creating a type
programmatically
Copyright © 2003, developerLabs
Remoting Extensibility - Overview
Crossing a context, application domain, process or machine boundary requires marshaling
Objects can be marshaled by value of by reference MBROs can be activated by the server or the client
Server activated objects include single-call and singleton Object life-cycle varies by activation type
Singletons use a lease-based lifecycle Client activated objects use a lease-based lifecycle Single-call objects live through a single call
Copyright © 2003, developerLabs
Infrastructure
Object activation requests return an ObjRef instance
The ObjRef is unpacked/unmarshaled into a transparent proxyThe transparent proxy leverages unmanaged
memory to model the server side objectA transparent proxy holds a reference to a
real proxy
Copyright © 2003, developerLabs
Infrastructure
The RealProxy type is abstract, and has a RemotingProxy implementation
The RealProxy type instances take the unmanaged memory block managed by the transparent proxy and turn it into a Message
Messages implement the IMessage interface and basically encapsulate a collection of key-value pairs, an IDictionary reference
Copyright © 2003, developerLabs
Infrastructure
The message is passed from the real proxy to the envoy sink chain
A sink object can operate on the message as part of a chain
Each sink object implements the IMessageSink interface: NextSink AsyncProcessMessage SyncProcessMessage
An envoy sink operates in the context of the client holding the reference to the transparent proxy
The envoy sink chain has a terminator sink at the end that passes off to the client context sink chain
Copyright © 2003, developerLabs
Infrastructure
The message is passed from the real proxy to the context sink chain
Each context sink in the chain gets to operates on a message
The last sink in the context chain is the terminator context sink If the call is simply a cross-context call, the terminator sink passes
the message to the cross-context channel, a lightweight channel If the call target is in a different application domain, process or
machine, the terminator sink passes the message out of the client object context to the channel sink chain
The channel sink chain prepares the message for transport to the remote process/machine
Copyright © 2003, developerLabs
Infrastructure
The first sink in the channel sink chain is the formatter, which implements IFormatter
This sink serializes the message to the initial wire format The platform includes two formatters, SoapFormatter
and BinaryFormatter The message is passed fro the formatter sink to a set of
channel sinks These channel sinks can operate on the serialized
message format before transport The terminator channel sink is the transport sink, which
passes the message off to transport
Copyright © 2003, developerLabs
Infrastructure
On the server side, a reasonably symmetric set of sink chains exist going from the transport wire to the remote object
The transport sink passes to the channel sink chain, which passes to the server context sink chain, which passes to the server object sink chain
The last sink is the Stackbuilder sink, which preps the stack for the call to the remote object
After the call, the server object sinks take the result from the call, pack it into a message, and send it back through the infrastructure to the client
Copyright © 2003, developerLabs
Extensibility Points
Custom ObjRef types Custom proxies
These are classes that derive from RealProxy and replace RemotingProxy
These work for client-side only logic in contrast with something that has part on the client and a part on the server, like encryption/decryption
Copyright © 2003, developerLabs
Extensibility Points
Custom message types: IMessage In particular, message headers
Custom message sinks: IMessageSinkEnvoy sinksContext sinks
Copyright © 2003, developerLabs
Extensibility Points
Custom channel sinksFormatter sink: IFormatterChannel sink:
BaseChannelSinkWithProperties, IXXXChannelSink
Copyright © 2003, developerLabs
Resources
BooksAdvanced .NET Remoting, APressMicrosoft .NET Remoting, MSPress
Free stuffSDK docshttp://www.ingorammer.comhttp://www.gotdotnet.comhttp://msdn.microsoft.com