May 13, 2009

COM & COM+

Nhân có ku em nói về COM & COM+, nên tìm hiểu chút.
Hồi trước làm trên VB6 và sau này là .NET vẫn lơ mơ về khái niệm COM & COM+. Hiểu nôm na là thành phần (Components được MS sử dụng trong công nghệ phát triển của mình - cũng có cài đặt vài COM nhỏ test thử trên VB6)

COM: Component Object Model Technologies

COM và COM+ là 2 chủ đề rất rộng, không thể dùng 1 vài dòng để nói được. Tuy nhiên ở đây tôi đưa ra vài mô tả về 2 công nghệ này

- COM là công nghệ về component(thực ra nó là một đặc tả, chứ không phải là một ngôn ngữ lập trình) của MS giúp cho lập trình viên có thể tạo ra các component có tính reuse cao và sử dụng được với nhiều component hay ứng dụng viết bằng các ngôn ngữ khác nhau. Với COM ta có thể viết 1 component bằng VC++ sau đó dùng trong 1 chương trình viết bằng VB. COM component phải được đăng ký với windows trong registry.

- Còn COM+ (trước đây được gọi là MTS) thực ra là một service có sẵn trong windows 2000 hay XP trở lên cung cấp các dịch vụ về component cho một ứng dụng (chủ yếu là các ứng dụng lớn, phân tán-DCOM). Các dịch vụ này là những yêu cầu thường gặp đối với các ứng dụng lơn, phân tán như vấn đề security, transaction, queue, synchronization. Một COM component có thể được host trong COM+ (và như vậy được gọi là COM+ component) và giúp cho 1 ứng dụng VB front-end có thể gọi các methods của component đó từ một máy khác đồng thời tận dụng được các dịch vụ mà COM+ cung cấp như đề cập ở trên.

Một vài dòng không thể nói hết về 2 công nghệ khá phức tạp này. Hy vọng đây có thể là điểm khởi đầu để bạn đọc thêm về COM và COM+
COM có mô hình 3 lớp, còn COM+ là n-lớp, n-lớp là do COM+ sử dụng được các Service của MS support.
Tham khảo về COM và COM+
http://www.microsoft.com/com/default.mspx

COM: Component Object Model Technologies!

Microsoft COM (Component Object Model) technology in the Microsoft Windows-family of Operating Systems enables software components to communicate. COM is used by developers to create re-usable software components, link components together to build applications, and take advantage of Windows services. The family of COM technologies includes COM+, Distributed COM (DCOM) and ActiveX® Controls.

COM is used in applications such as the Microsoft Office Family of products. For example COM OLE technology allows Word documents to dynamically link to data in Excel spreadsheets and COM Automation allows users to build scripts in their applications to perform repetitive tasks or control one application from another.

Microsoft provides COM interfaces for many Windows application services such as Microsoft Message Queuing (MSMQ) Microsoft Active Directory (AD) and Windows Management and Instrumentation (WMI).

Microsoft recommends that developers use the .NET Framework rather than COM for new development.

What is COM+?

COM+ is the name of the COM-based services and technologies first released in Windows 2000. COM+ brought together the technology of COM components and the application host of Microsoft Transaction Server (MTS). COM+ automatically handles difficult programming tasks such as resource pooling, disconnected applications, event publication and subscription and distributed transactions.
COM+ infrastructure also provides services to .NET developers and applications through the System.EnterpriseServices namespace of the .NET Framework. More information on Using COM+ Services in .NET is available on the MSDN web site.

What is DCOM (Distributed Component Object Model) is a proprietary Microsoft technology for communication among software components distributed across networked computers. DCOM, which originally was called "Network OLE", extends Microsoft's COM, and provides the communication substrate under Microsoft's COM+ application server infrastructure. It has been deprecated in favor of Microsoft .NET.

The addition of the "D" to COM was due to extensive use of DCE/RPC (Distributed Computing Environment/Remote Procedure Calls) – more specifically Microsoft's enhanced version, known as MSRPC.

In terms of the extensions it added to COM, DCOM had to solve the problems of

  • Marshalling – serializing and deserializing the arguments and return values of method calls "over the wire".
  • Distributed garbage collection – ensuring that references held by clients of interfaces are released when, for example, the client process crashed, or the network connection was lost.

One of the key factors in solving these problems is the use of DCE/RPC as the underlying RPC mechanism behind DCOM. DCE/RPC has strictly defined rules regarding marshalling and who is responsible for freeing memory.

DCOM was a major competitor to CORBA. Proponents of both of these technologies saw them as one day becoming the model for code and service-reuse over the Internet. However, the difficulties involved in getting either of these technologies to work over Internet firewalls, and on unknown and insecure machines, meant that normal HTTP requests in combination with web browsers won out over both of them. Microsoft, at one point, attempted and failed to head this off by adding an extra http transport to DCE/RPC called ncacn_http (Network Computing Architecture, Connection-based, over HTTP). This was later resurrected to support an Exchange 2003 connection over HTTP.

To access DCOM settings on a computer running Windows 2000, Windows XP and earlier, click Start > Run, and type "dcomcnfg". (Click NO for any warning screens that appear.) To access DCOM settings on a computer running Windows Vista, click Start, type "dcomcnfg", right-click "dcomcnfg.exe" in the list, and click "Run as administrator".

This opens the Distributed COM Configuration Properties dialog.

No comments: