Danh mục

Bài giảng Công nghệ lập trình tiên tiến: Chương 5 - ĐH Công nghệ Đồng Nai

Số trang: 74      Loại file: pptx      Dung lượng: 4.77 MB      Lượt xem: 9      Lượt tải: 0    
10.10.2023

Phí tải xuống: 4,000 VND Tải xuống file đầy đủ (74 trang) 0
Xem trước 8 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

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.
Nội dung trích xuất từ tài liệu:
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 . ...

Tài liệu được xem nhiều:

Gợi ý tài liệu liên quan: