Bài giảng Công nghệ lập trình tiên tiến: Chương 5 - ĐH Công nghệ Đồng Nai
lượt xem 7
download
Bài giảng Công nghệ lập trình tiên tiến: Chương 5 trình bày các kiến thức về lập trình trong .Net Remoting như đặc điểm, công dụng, câu lệnh, cú pháp,... Đây là tài liệu dành cho sinh viên ngành Công nghệ thông tin.
Bình luận(0) Đăng nhập để gửi bình luận!
Nội dung Text: Bài giảng Công nghệ lập trình tiên tiến: Chương 5 - ĐH Công nghệ Đồng Nai
- DONG NAI UNIVERSITY OF TECHNOLOGY HO CHI MINH UNIVERSITY OF INDUSTRY .NET Remoting 1
- DONG NAI UNIVERSITY OF TECHNOLOGY HO CHI MINH UNIVERSITY OF INDUSTRY Net Remoting Definition: • Application which is located in another application domain or process can communicate with another by using .Net Remoting. • Net Remoting allows processes to share the objects. It can call the method and can access the properties of an objects that are: 2
- DONG NAI UNIVERSITY OF TECHNOLOGY HO CHI MINH UNIVERSITY OF INDUSTRY Ø Hosted in different application domain with in the same process or Ø Different process executing on same computer or Ø Different computers connected by LAN or Ø Different computer distributed over world wide 3
- DONG NAI UNIVERSITY OF TECHNOLOGY HO CHI MINH UNIVERSITY OF INDUSTRY Modern applications are no longer stand-alone applications. - Provides a solution for communication between application domains .NET Remoting: 4
- DONG NAI UNIVERSITY OF TECHNOLOGY HO CHI MINH UNIVERSITY OF INDUSTRY You known Application Domain ?: Application domain is the collection of classes, which isolate these from other applications. The application in one application domain could not access the application in other application domain (without using Remoting) 5
- 2 Object type DONG NAI UNIVERSITY OF TECHNOLOGY HO CHI MINH UNIVERSITY OF INDUSTRY Remotable • It can be accessed outside its Object application domain. Ø CLR objects cannot, by default, be used outside their AppDomain - No way to copy them Non - No way to reference them Remotable Ø Exception occurs when you try to Object pass an object reference to a different domain Ø SO: It can not be accessed outside its own application domain. 6
- Remotable Object: DONG NAI UNIVERSITY OF TECHNOLOGY HO CHI MINH UNIVERSITY OF INDUSTRY Ø Can request that instances of a class be accessible outside original AppDomain – Client get a copy of the object – Client get a reference (proxy) to the original object Ø When an object is Remotable? The object should inherit the class System.MarshalByRefObject Ø Two Types of Remotable Objects are there – Marshal by Value – Marshal by Reference *More detail later 7
- DONG NAI UNIVERSITY OF TECHNOLOGY HO CHI MINH UNIVERSITY OF INDUSTRY Object Serialization: Conversion of an object (instance) into a data stream of bytes, Serialization is a method of persisting objects for storage in a database, to various media, or during marshaling—the process of moving an object to a new application domain, context, process, or system. Serialization is performed by the Common Language Runtime (CLR). 8
- DONG NAI UNIVERSITY OF TECHNOLOGY HO CHI MINH UNIVERSITY OF INDUSTRY MarshalByRef objects: Ø When the object's class derives, directly or indirectly, from MarshalByRefObject, the runtime creates a proxy to the object [Serializable] class Foo : System.MarshalByRefObject { . . . } Ø Clients in foreign AppDomains receive proxy Ø How does a client specify what proxy? 9
- DONG NAI UNIVERSITY OF TECHNOLOGY HO CHI MINH UNIVERSITY OF INDUSTRY Serializable objects: Ø When runtime can make a copy of the object, an object can marshal-by-value to other AppDomains – Add SerializableAttribute – Or implement the ISerializable interface [Serializable] Class Far { . . . } 10
- DONG NAI UNIVERSITY OF TECHNOLOGY HO CHI MINH UNIVERSITY OF INDUSTRY Remoting in general : q Clients must connect to servers Ø Server needs to publish an object • I listen on this TCP channel and that HTTP channel • I have a service called "MathService" • When client connects to MathService using a supported channel, give the client [ a | this ] Calculator instance Ø Clients need to specify the desired object • Connect to the "MathService" on server "LightningFast" using protocol HTTP on port 80 11
- DONG NAI UNIVERSITY OF TECHNOLOGY HO CHI MINH UNIVERSITY OF INDUSTRY ASP.NET Web services (WS) vs .NET Remoting (NR) See next slide… 12
- DONG NAI UNIVERSITY OF TECHNOLOGY HO CHI MINH UNIVERSITY OF INDUSTRY 1. WS: only be accessed over HTTP; NR various protocols like TCP, HTTP etc. 2. WS stateless environment, NR state management 3. WS more reliable than .NET Remoting. 4. WS are easy to create and use, NR are complex to be created. 5. WS across platforms, NR requires client to be built using .NET 6. WS support datatypes defined in the XSD type system while .NET remoting provides support for rich type system using binary communication. 13
- DONG NAI UNIVERSITY OF TECHNOLOGY HO CHI MINH UNIVERSITY OF INDUSTRY .Net Remoting components Ø A remotable object. Ø A host application. – listen to requests for the hosted remotable object. Ø A client application. – requests for the remotable object. 14
- DONG NAI UNIVERSITY OF TECHNOLOGY HO CHI MINH UNIVERSITY OF INDUSTRY How Does .NET Remoting Works? Ø In the client – create a new remotable object =>creates a proxy object – When client call method => call method on proxy=> server=> return to proxy => client 15
- DONG NAI UNIVERSITY OF TECHNOLOGY HO CHI MINH UNIVERSITY OF INDUSTRY Proxy Ø To avoid conjunction in networking. It contains reference to all methods and properties of object. There are two type of proxy. – Transparent proxy (There is no physical existence, Created by IISserver) – Real Proxy (Physical Existence) 16
- DONG NAI UNIVERSITY OF TECHNOLOGY HO CHI MINH UNIVERSITY OF INDUSTRY Ø Remoting makes an object in server available to code in client => marshalling Ø 2 ways to marshal an object – Marshal by value • the server creates a copy of the object passes the copy to the client – Marshal by reference • the client creates a proxy for the object and then uses the proxy to access the object 17
- Marshal by reference DONG NAI UNIVERSITY OF TECHNOLOGY HO CHI MINH UNIVERSITY OF INDUSTRY Ø 2 types – Server-Activated Objetcs (SAO) – Client-Activated Objects (CAO) Ø Client-Activated Object: – Server side object creation is handled by client application. – An instance of object is created, when the client calls the new operator. Ø Server-Activated Object: – The object is created, when the client actually invoke a method on proxy. – Single Call (stateless) • This object handles one and only one request coming from client. – Singleton • This can be used to retain the state across multiple method calls. 18
- DONG NAI UNIVERSITY OF TECHNOLOGY HO CHI MINH UNIVERSITY OF INDUSTRY SAO - CAO Ø Server-Activated • lifetime is controlled by server • Use when there are clients sharing the same server object • It’s a one-to-many relationship between the server object and clients – Singleton – SingleCall Is called: WellKnow object Ø Client-Activated Objects • lifetime is controlled by the client • Use when multiple server instances of the same kind need to be run on the server at the same time • one-to-one relationship between each server object and its corresponding client 19
- DONG NAI UNIVERSITY OF TECHNOLOGY HO CHI MINH UNIVERSITY OF INDUSTRY Client-activated objects Client-activated objects. Each client gets an independent object for its use. Like the classic client-server model, clients can still share objects. 20
CÓ THỂ BẠN MUỐN DOWNLOAD
-
Bài giảng Công nghệ lập trình tiên tiến: Chương 0 - ĐH Công nghệ Đồng Nai
8 p | 157 | 11
-
Bài giảng Công nghệ lập trình tiên tiến: Chương 1 - ĐH Công nghệ Đồng Nai
59 p | 105 | 9
-
Bài giảng Công nghệ lập trình tiên tiến: Chương 2 - ĐH Công nghệ Đồng Nai
93 p | 83 | 9
-
Bài giảng Công nghệ lập trình tiên tiến: Chương 4 - ĐH Công nghệ Đồng Nai
164 p | 90 | 9
-
Bài giảng Công nghệ lập trình tiên tiến: Chương 3 - ĐH Công nghệ Đồng Nai
86 p | 91 | 7
-
Bài giảng Công nghệ lập trình tích hợp: Chương 4.2 - TS. Nguyễn Quang Uy
19 p | 11 | 4
-
Bài giảng Công nghệ lập trình tích hợp: Chương 4.1 - TS. Nguyễn Quang Uy
25 p | 10 | 4
-
Bài giảng Công nghệ lập trình tích hợp: Chương 4.0 - TS. Nguyễn Quang Uy
40 p | 12 | 4
-
Bài giảng Công nghệ lập trình tích hợp: Chương 2.1 - TS. Nguyễn Quang Uy
28 p | 11 | 4
-
Bài giảng Công nghệ lập trình tích hợp: Chương 2.0 - TS. Nguyễn Quang Uy
59 p | 12 | 4
-
Bài giảng Công nghệ lập trình tích hợp: Chương 1 - TS. Nguyễn Quang Uy
31 p | 14 | 4
-
Bài giảng Công nghệ lập trình tích hợp: Chương 3 - TS. Nguyễn Quang Uy
38 p | 8 | 3
-
Bài giảng Công nghệ lập trình tích hợp: Chương 0 - TS. Nguyễn Quang Uy
9 p | 20 | 3
-
Bài giảng Công nghệ lập trình tích hợp: Chương 5 - TS. Nguyễn Quang Uy
48 p | 8 | 3
-
Bài giảng Công nghệ lập trình tích hợp: Chương 6 - TS. Nguyễn Quang Uy
45 p | 12 | 3
-
Bài giảng Công nghệ lập trình tích hợp: Chương 7 - TS. Nguyễn Quang Uy
39 p | 10 | 3
-
Bài giảng Công nghệ lập trình tích hợp: Chương 8 - TS. Nguyễn Quang Uy
42 p | 14 | 3
Chịu trách nhiệm nội dung:
Nguyễn Công Hà - Giám đốc Công ty TNHH TÀI LIỆU TRỰC TUYẾN VI NA
LIÊN HỆ
Địa chỉ: P402, 54A Nơ Trang Long, Phường 14, Q.Bình Thạnh, TP.HCM
Hotline: 093 303 0098
Email: support@tailieu.vn