1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu Module 8: Solution Design and the Component Object Model ppt

32 582 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Solution Design and the Component Object Model
Trường học University of Information Technology and Communications
Chuyên ngành Solution Design and Application Development
Thể loại Lecture slides
Năm xuất bản 2023
Thành phố Hanoi
Định dạng
Số trang 32
Dung lượng 315,09 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Module Overview Module 3: A Services-based Approach to Solution Design Module 4: Business Solution Conceptual Design Module 5: Business Solution Logical Design Module 6: Beginning Physic

Trang 1

Component Object Model

Trang 2

Module Overview

Module 3: A Services-based Approach to Solution Design Module 4: Business Solution Conceptual Design Module 5: Business Solution Logical Design Module 6: Beginning Physical Design

Module 1: Course Overview Module 2: Solution Design Using the MSF

Module 7: Selecting Solution

Technologies

Module 8: Solution Design and the

Component Object Model

Module 9: Designing Solutions with

Component ObjectModel Basics

Activity 8.2: Identifying the Impact of Distributing COM Components

COM-BasedDesignReview

Activity 8.1: Simulating COM Communication

ApplicationDevelopment and COM

Distributed ComponentObject Model Basics

Module 8: Solution Design and the Component Object

Model

Trang 3

! Overview

In this module

" Component Object Model Basics

" Activity 8.1: Simulating Component Communication

" Application Development and COM

" Distributed Component Object Model Basics

" Activity 8.2: Identifying the Impact of Distributing COM Components

" COM-Based Design

" Review

Microsoft’s Component Object Model (COM), Distributed Component Object Model (DCOM), and COM+ each provide services and structure that aid in implementing large applications It is important to understand these models because they will help you make good decisions about selecting the candidate technologies for developing the business solution These models also provide many benefits that can be used by the application designer and developer This module describes these technologies and presents guidelines for implementing them

After completing this module, you will be able to:

" Describe the Microsoft® COM standard

" Describe COM classes, components, objects, and interfaces

" Explain the relationship between COM and application development

" Describe DCOM and its relationship to COM

" List the benefits of using COM in a solution design

In this module, you will learn

about COM, DCOM, and the

benefits of COM design

Trang 4

! Component Object Model Basics

Slide Objective

To explain the purpose of

the section and what

students will learn in the

section

Trang 5

" COM is specification-based in that it defines objects by using a language in

a location-independent manner In addition, it defines how to locate and identify components, as well as instantiated objects

" COM is also implementation-based in that it provides system services that know how to locate components, load them into memory, execute their methods, and access their properties Additionally, COM can perform interprocess and remote communications

" COM defines the exact binary representation of an interface As a result, any programming language or tool that supports COM must create object interfaces that strictly correspond to this standard binary representation

Slide Objective

To define COM and

introduce the COM

standard

Trang 6

" Binary files used to instantiate COM objects

There are three packaging methods for COM components: a Microsoft Windows® service, an executable file, or a dynamic-linked library (DLL) Windows services are simply applications that are required to always be running Windows executable files are often used if an application must provide

a user interface in addition to furnishing COM objects In most development scenarios, components are packaged as DLLs

Additionally, components are described by their location relative to their calling application, which is referred to as a client or consumer In-process components are implemented as DLLs and execute within the same process as the client Local components are often executable files or a Windows service They are executed on the same computer as the client, but in a separate process Remote components can be packaged as required, as well as located and executed on a separate computer from the calling client

A COM component is a binary unit of compiled application code that can be used to instantiate COM objects into the memory of a computer For a given COM class identifier — also called a unique class identifier (CLSID) — a component will include the COM class, the code to instantiate and execute a class object, and usually the code required to create installation entries into a system’s registry

Slide Objective

To introduce COM

component information

Delivery Tip

Although components are

sometimes called servers,

we avoid confusion with

For the remainder of this

section relating to COM, we

will focus on components

implemented as DLLs

because these components

are most prevalent in n-tier

applications

Trang 7

COM Interface Basics

" Interface contracts

" Interface Description Language

" Available COM interfaces

Interface Description Language (IDL) is a language similar in structure to C++, which describes the exact syntax of an interface Interface definitions begin with an interface keyword; interface attributes are contained in square brackets preceding the interface keyword

To be defined as a COM interface, an interface must satisfy the following requirements:

" A unique identifier must identify the interface

" The interface must ultimately derive from the special interface IUnknown

" Once published, the interface must be immutable In other words, the interface cannot be changed

Instead of using string identifiers alone to identify COM interfaces, COM implements globally unique identifiers (GUIDs) GUIDs are 128-bit, system-generated integers that uniquely identify components The algorithm used to generate GUIDs is statistically guaranteed to generate unique identification numbers

The IUnknown interface defines the fundamental behavior for COM interfaces

Clients can rely on this behavior because all COM interfaces derive from

IUnknown The IUnknown interface helps resolve the technical challenge of

providing a standard means to interact with objects It also provides three important features of interaction: interface navigation, interface versioning, and object lifetime management

Slide Objective

To describe a COM

interface

Lead-in

COM interfaces provide the

means for accessing COM

components

Delivery Tip

According to the COM

specification, GUIDs can be

generated at the rate of

10,000,000 per second per

computer for the next 3,240

years without risk of

duplication

Trang 8

IClassFactory is a standard interface for communicating with class objects As

a result, clients need only one mechanism to create any type of COM object

The most important method of IClassFactory is CreateInstance, which creates

an object and returns a specified interface pointer to the object

IDispatch is the standard COM interface that provides automation and programmatic access to an object By implementing IDispatch, components

can expose any number of functions to clients Clients access all functionality through a single well-known function

Developers using certain development tools, such as Microsoft Visual Basic®, are shielded from the complexity of defining interfaces using IDL Their compilers manage the creation, assignment, and registration of the interfaces

Trang 9

COM Classes

" Name and define a public interface

" Provide

$ A means to instantiate objects

$ Separation of the interface from the implementation

A COM class defines the public interface that may be accessed by a client and defines how to access the interface from a client A COM class is also given a CLSID and a string identifier called a programmatic id (ProgID) Every COM class has an associated class object (also known as a class factory) that provides the ability to create instances of a specific COM class These instances of a COM class differ from most language-based classes in that after an instance has been created, its specific class is no longer relevant to the client All interaction with this instantiated object occurs through interface pointers These pointers do not allow access to the implementation classes used to instantiate the object or

to the internal code that allows the object to perform work

The rigorous separation of interface and implementation is a key feature of COM This “black box” concept greatly simplifies the client coding effort because the client does not need to know how the components work, only that they do work

Slide Objective

To introduce COM classes

Lead-in

A COM class is simply an

instance of a named COM

interface

Trang 10

COM Objects

" Are run-time instances of a COM class

" Simplify access to application logic and information

" Are accessible by multiple clients

" Provide a means for life-cycle management

" Reduce client application code

As with most object-oriented models, COM objects are run-time instances of a particular COM class These objects live in memory and are executed by a computer microprocessor

When COM objects are instantiated, their underlying code and actual class structure are hidden from the client Because the application logic and information structure are hidden, the client is provided with a significantly simplified interface and the ability to perform complex application logic, as well as given access to complex information structures This simplification also reduces the amount of code required by the client application

Many clients can use an instantiated object simultaneously, and a single client can use the same instantiated object multiple times Only a pointer is given to the client or clients to provide access to the instantiated object

As mentioned, a single client may need to use multiple occurrences of the same object at the same time For efficiency, a duplicate copy of the object’s

executable code is typically not created in memory As pointers are given to the client, the object increments and decrements a reference counter through the

IUnknown interface each time a new instance of the same object is required

COM’s life-cycle management of the object allows for more efficient use of computer resources and provides COM with a mechanism for knowing when an object is no longer being used (that is, when its reference count is zero)

Slide Objective

To describe a COM object

Lead-in

A COM object is a run-time

instance of a COM class

Delivery Tip

Technically, the client

receives a pointer to a

pointer to a v-table of

pointers when using

IClassFactory When using

IDispatch, the client must

query the interface each

time to get the information

Trang 11

Activity 8.1: Simulating Component Communication

This activity will demonstrate the specific way in which COM components communicate with one another

In this activity, you will simulate a COM component communicating with other COM components

After completing this lab, you will be able to:

" Demonstrate how COM technologies enable component-based solutions to function

Slide Objective

To introduce the activity

Trang 12

! Application Development and COM

In this section

" COM and Windows DNA

" Calling COM Components

" COM Threading Model

" COM and Marshalling

In this section, you will learn about the application development issues surrounding COM specification You will learn how to use COM components and how a COM component’s internal code can function

Slide Objective

To explain the purpose of

the section and what

students will learn in the

section

Trang 13

COM and Windows DNA

" Foundation for layer independence

" Public interface with standard behaviors

" Client language independence

" Creation language independence

By definition, Windows Distributed interNet Applications (Windows DNA) uses COM as the foundation for interapplication and intraapplication communication Because Windows DNA architecture recommends a cooperating, multiple-layer architecture, COM provides the communication mechanism between the presentation, business, and data layers

COM components publish a public interface that may be accessed by any service layer COM also provides the standard communication mechanism for applications requiring access to additional system services, such as Microsoft Transaction Services, within the Windows DNA business service layer

The nature of COM’s public interface and the fact that COM provides a box” execution standard (meaning that how the component executes is not revealed or accessible from the client) allow the use of any development tool or language to execute a COM component Consequently, the appropriate

“black-development tool can be chosen for each service layer

Finally, COM provides a standard way for the operating system to publish a component’s public interface and process components As a result, as long as a development tool supports the creation of COM components, any tools can be used to code COM components This choice of independent component coding also allows the development team to use different tools to create components for each service layer

Slide Objective

To explain how COM relates

to Windows DNA

Trang 14

Calling COM Components

" Reference the component

" Instantiate an object

" Call the object’s interfaces

" Destroy the object

To use a COM component, the component must first be referenced How reference is accomplished depends on the development environment, but it is generally as simple as a menu choice or a declaration of a variable Typically, the ProgID is used to assign the component a variable name within the application

After the component is referenced, an object may be instantiated, incrementing its reference count This instantiation provides the client with access to the

object’s public interfaces The client knows these interfaces through IDispatch

“memory leaks.”

Slide Objective

To explain the steps

required to call a COM

component

Trang 15

COM Threading Model

COM components can be single-threaded, meaning that all instructions required

to perform its work can only be executed in sequence Each execution “step” of the component must wait for the previous “step” to complete Think of it as a single-file line going through a single door to enter a building

In a multithreaded application, a single process may execute several tasks simultaneously As a result, a specific thread is not required to complete before another task may be started Continuing our example, think of this application

as multiple buildings with multiple doors with multiple people entering the buildings at the same time

Apartment-model threading is a method of multithreading that isolates the threads and provides speed boosts over a single-threaded component In addition, it does not require as much internal plumbing as other forms of multithreaded components to create thread-safe code Using our example, think

of this method as specific, single-file lines entering multiple doors of a single building

Slide Objective

To explain the impact of a

threading model and the

threading models that COM

provides

Trang 16

COM and Marshalling

" Marshalling enables communication

" Marshalling is overhead

" Marshalling occurs often

Marshalling refers to the packaging of information into a specific bundle by using a standard format so that the information can be accessed by using a dissimilar process

When marshalling must occur to allow communication, there is overhead for the calling process Processing overhead is created by the calling process as it bundles information into a standard format Additionally, overhead is created

by the providing process as it unbundles information and places it into its internal format The amount of overhead required depends on the calling and providing processes; however, certain types of marshalling can be costly in processing resources

Marshalling occurs often because dissimilar systems frequently must communicate Marshalling can occur between components executing in different threading models It can also occur when a client must access code running in another process Marshalling also enables DCOM communication and Microsoft Transaction Server (MTS)-based components to communicate across MTS packages

Ngày đăng: 17/01/2014, 09:20

TỪ KHÓA LIÊN QUAN