.NET Remoting - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

.NET Remoting

Description:

A Distributed Application Cookbook Agenda Brief overview of Remoting Technicalities for creating a distributed application based on Remoting Examples has been ... – PowerPoint PPT presentation

Number of Views:78
Avg rating:3.0/5.0
Slides: 11
Provided by: acil150
Category:
Tags: net | cookbook | java | remoting

less

Transcript and Presenter's Notes

Title: .NET Remoting


1
.NET Remoting
  • A Distributed Application Cookbook

2
Agenda
  • Brief overview of Remoting
  • Technicalities for creating a distributed
    application based on Remoting
  • Examples has been uploaded to the course site

3
Remoting
  • RMI Remote Method Invocation (JAVA)
  • RPC Remote Procedure Call (.NET)

Costumizable!
Client
Server
Remote invocation
f
y
f(x)
Object
h
On runtime transparent to client
Standard development syntax
4
Step 1
  • Create three modules
  • A client module
  • Holds client code
  • Will ultimately run the client process (console
    application)
  • A server module
  • Holds server code
  • Will ultimately run the server process (console
    application)
  • A common library
  • This module contains all the declarations\definit
    ions that are common to the client and the server
    (DLL)

5
Step 2 Creating the remote object
  • In the common library module Declare an interface
    exposing your remote objects methods
  • In the server module, declare the objects class
    extending MarshalByRefObject and implementing the
    interface

6
Step 3 Hosting the object
  • The object is hosted in the server process
  • Programmatically
  • Using a configuration file

BinaryServerFormatterSinkProvider
serverSinkProvider new BinaryServerFormatterSink
Provider() serverSinkProvider.TypeFilterLevel
System.Runtime.Serialization.Formatters.TypeFilter
Level.Full IDictionary prop new
Hashtable() prop"port" 9999 // listen on
a specific port ChannelServices.RegisterChannel(n
ew TcpChannel(prop, null, serverSinkProvider),
false) RemotingConfiguration.RegisterWellKnownSe
rviceType( Type.GetType("Serve
r.Program"), "Service",
WellKnownObjectMode.Singleton)
7
Step 4 Instantiation at the client
  • The object is instantiated and accessed in the
    client process
  • Programmatically
  • Using a configuration file

BinaryClientFormatterSinkProvider
clientSinkProvider new BinaryClientFormatterSink
Provider() clientSinkProvider.TypeFilterLevel
System.Runtime.Serialization.Formatters.TypeFilter
Level.Full IDictionary prop new
Hashtable() prop"port" 0 // open an
arbitrary port ChannelServices.RegisterChannel(ne
w TcpChannel(prop, clientSinkProvider, null),
false) Common.IService service
(Common.IService)Activator.GetObject(typeof(Common
.IService),
"tcp//localhost9999/Service")
8
Custom Sinks
BinaryFormatter
9
Custom Sinks
  • A class implementing the sink
  • Extend BaseChannelSinkWithProperties
  • Implement IClientChannelSink or
    IserverChannelSink
  • Implement IMessageSink if placed before the
    formatter sink
  • A sink provider class
  • Implementing IClientChannelSinkProvider or
    IServerChannelSinkProvider
  • Actually passed to the channel

10
Custom Sinks Usage
  • public IMessage SyncProcessMessage(IMessage
    reqMsg)
  • destURI DataServersManager.GetAvailab
    leDataServer()
  • reqMsg.Properties"__Uri"
    destURI
  • // create new next sink with new
    URI
  • nextSink nextSinkProvider.CreateSi
    nk(channel, destURI.ToString(), null)
  • Console.WriteLine("Going to send request to "
    (string)reqMsg.Properties"__Uri")
  • IMethodReturnMessage returnMessage
    NextSink.SyncProcessMessage(reqMsg)
  • return returnMessage
Write a Comment
User Comments (0)
About PowerShow.com