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

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

Đ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

Module 8: Solution Design and the Component Object Model 246 Module 8: Solution Design and the Component Object Model Module Overview Module 12: Introduction to Functional Specifications Module 11: Designing the Presentation Layer Module 1: Course Overview Module 10: Completing the Physical Design Designing Business Solutions Module 9: Designing Solutions with Microsoft Technologies Module 8: Solution Design and the Component Object Model Module 2: Solution Design Using the MSF Module 3: A Services-based Approach to Solution Design Module 4: Business Solution Conceptual Design Module 7: Selecting Solution Technologies Module 5: Business Solution Logical Design Component Object Model Basics Module 6: Beginning Physical Design Activity 8.1: Simulating COM Communication Review Module 8: Solution Design and the Component Object Model Application Development and COM Distributed Component Object Model Basics COM-Based Design Activity 8.2: Identifying the Impact of Distributing COM Components Module 8: Solution Design and the Component Object Model 247 ! Overview Slide Objective To provide an overview of the module topics and objectives " Component Object Model Basics Lead-in " 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 In this module, you will learn about COM, DCOM, and the benefits of COM design In this module In this module 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 248 Module 8: Solution Design and the Component Object Model ! Component Object Model Basics Slide Objective To explain the purpose of the section and what students will learn in the section " COM Standard " COM Components " COM Interface Basics " COM Classes " COM Objects In this section In this section COM is a foundation for successful application designs based on Microsoft technologies In this section, you will learn about COM and how it enables applications to easily communicate and interoperate At the end of the section, you will practice what you have learned in an activity that simulates COM and application interaction Module 8: Solution Design and the Component Object Model 249 COM Standard Slide Objective To define COM and introduce the COM standard " Binary standard for object interaction " Part specification " Part implementation COM, as a binary standard for object interaction and addresses many component challenges It is a binary standard because it is in part specificationoriented and in part implementation-oriented " 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 250 Module 8: Solution Design and the Component Object Model COM Components Slide Objective To introduce COM component information " Three basic packaging methods: $ $ Executable $ " Windows NT services Dynamic-link library Multiple physical locations: $ $ Delivery Tip Although components are sometimes called servers, we avoid confusion with server computers by maintaining the original term, “component,” throughout this module Delivery Tip 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 Local components $ " In-process Remote components 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 Module 8: Solution Design and the Component Object Model 251 COM Interface Basics Slide Objective To describe a COM interface " Interface Description Language " COM interfaces provide the means for accessing COM components Interface contracts " Lead-in Available COM interfaces $ IUnknown $ IClassFactory $ IDispatch A COM interface is a contract between a provider of services, the COM class, and the consumer of those services (the client) The interface is the only means of communication between the provider and consumer It defines how messages and information will be accepted by the component, as well as how information will be returned to the client 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: " " 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 The interface must ultimately derive from the special interface IUnknown " Delivery Tip A unique identifier must identify the interface 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, systemgenerated 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 252 Module 8: Solution Design and the Component Object Model 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 Module 8: Solution Design and the Component Object Model 253 COM Classes Slide Objective To introduce COM classes Lead-in A COM class is simply an instance of a named COM interface " 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 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 work 254 Module 8: Solution Design and the Component Object Model COM Objects Slide Objective To describe a COM object Lead-in " 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 " A COM object is a run-time instance of a COM class 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 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 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) 262 Module 8: Solution Design and the Component Object Model DCOM Standard Slide Objective To explain the DCOM standard Lead-in DCOM is a specification that enables COM components to reside on different computers on a network and be called remotely " DCOM components are computer-independent COM components " Remote computers must be located " Component use appears seamless Technically, DCOM is simply the protocol (that is, the language and structure) that components use to communicate over a network Most references to DCOM use the concept of separating a COM component onto different computers Consequently, we will refer to DCOM as the interface specification and communication protocol that allows COM components to reside on different computers and execute remotely Because part of a DCOM component is on a remote computer, the remote computer must be properly located and a communication session must be established Successfully locating and communicating with the remote computer is dependent on network availability DCOM also allows components to appear to the client as executing on the local client computer This DCOM characteristic means that a developer trying to locate and execute COM and DCOM components does not have to implement application code differently for each Module 8: Solution Design and the Component Object Model 263 DCOM Component Location Slide Objective To explain the issues involved in locating DCOM components across a network Lead-in Separating components across different computers on a network introduces a new set of issues to be addressed " Accessing named computers " DCOM over networks " DCOM over HTTP DCOM components are referred to on the local computer by the remote computer’s name To establish a DCOM session, this name must be resolved to a lower-level network name such as an Internet Protocol (IP) address DCOM components can reside and execute anywhere on a network Because execution and control occur across a network, the interfacing of DCOM components is susceptible to all of the common problems of a network, including overloaded bandwidth, unresolved computer names, network protocols, firewalls, and proxies The speed of communication can become a bottleneck for low-bandwidth connections The speed of large quantities of data traveling between the client and object can also be affected by network performance Security is especially important in a distributed solution because validating an accessing client may be necessary before access to an object can be granted Because many remote clients will need to gain access to components through the Internet, DCOM enables the use of COM components over HTTP Using DCOM over HTTP can assist developers who are using distributed components by enabling communication through network security devices, such as firewalls that block certain types of network traffic 264 Module 8: Solution Design and the Component Object Model DCOM Component Use Slide Objective To explain the issues involved in executing DCOM components Lead-in When using DCOM components, local clients are shielded from the distributed nature of DCOM " DCOM components appears as local COM components " DCOM remote network access is transparent The DCOM component is physically separated on different computers The local client computer accesses the DCOM component through a local COM stub/proxy As a result, the local computer thinks that the component is executing as an in-process COM component Technically, the local, in-process component communicates with the remote component and does not actually the work For a developer, calling a DCOM component and a COM component requires using identical instantiation syntax Remember that a local stub/proxy component must be installed on the local computer for the local computer to be able to access the remote portion of the DCOM component Network access by the DCOM object is transparent to the calling client This network access is handled by the low-level plumbing of the COM and DCOM engines Networking issues may arise as objects await results For example, multithreaded applications may need to be enhanced to handle the potential delay of accessing components across a network Module 8: Solution Design and the Component Object Model 265 Activity 8.2: Identifying the Impact of Distributing COM Components Slide Objective To introduce the activity In this activity, you will identify potential problems in a distributed component topology After completing this lab, you will be able to: " Identify issues in a distributed component topology 266 Module 8: Solution Design and the Component Object Model ! COM-Based Design Slide Objective To explain the purpose of the section and what students will learn in the section Lead-in In this section, you will learn about some of the benefits of COM and DCOM designs, the future of COM, and some guidelines related to implementing COM applications " Benefits of COM Design " Benefits of DCOM Design " Future of COM: COM+ " Windows 2000 COM+ Support and Services In this section, you will learn about how implementing n-tier applications by using COM and DCOM simplifies and enhances application development Additionally, new versions of the COM specification, collectively known as COM+, provide new features and new challenges to implementing COM-based applications Module 8: Solution Design and the Component Object Model 267 Benefits of COM Design Slide Objective To explain some of the benefits of COM design " Technology to enable developers to assemble applications from prebuilt parts " Technical challenges that COM addresses $ Component location and execution $ Standards for component and application interaction $ Maintaining language independence A fundamental goal of COM is to enable developers to create applications assembled from prebuilt parts or components For example, an order-entry application could use a data-entry grid component to simplify entering ordered items into the application To make this goal a reality, several technical challenges must be met: " The first challenge is to locate the component on a computer or network, and once located, to execute the component Applications must also be available to identify and execute vendor-created components " The next challenge is to provide standards for the interaction between the application and the components If no standards exist, the overhead cost of learning how to use such objects creates a barrier to reusing code Ideally, a standard mechanism for object interaction would not distinguish the location of any given object, whether the object exists within its own application’s process, within another process on the application’s host computer, or within a different process on another computer altogether " The final challenge is to take advantage of true language independence This challenge is complex for any object model Every element involved in a particular object — memory allocation, method names, parameter types, calling conventions, and so on — must be defined in such a way that an object can be created in one programming language and used by another Application developers should not need to spend valuable time or energy worrying what programming languages or tools are used to create a desired component Without wide support from development languages and tools, many different models will fragment the component market This fragmentation raises the costs of identifying, purchasing, and developing components that are operable only in certain environments 268 Module 8: Solution Design and the Component Object Model Benefits of DCOM Design Slide Objective To explain some of the benefits of a DCOM design Lead-in There are many benefits to designing a DCOM-based application " Improves scaleable architectures " Does not require a change to the code base " Controls remote surrogate processes DCOM components allow for scalability beyond the basic “buy a bigger machine” scaling option available with standard COM components Components can be executed on computers specifically tuned to provide these remote component services, and clients not incur the memory and processing overhead associated with the actual component execution Because DCOM is implemented at the lowest operating system levels, it is transparent to component developers and requires no additional functionality or application code to be built into the objects DCOM also provides an advantage to developers who need to remotely control the execution of application logic DCOM inherently provides all of the control, communication, monitoring, error handling, and execution of remote components Developers are no longer responsible for building all of the application code for their application’s remote execution of components Module 8: Solution Design and the Component Object Model 269 Future of COM: COM+ Slide Objective To explain the future of COM, COM+ Lead-in COM+ is the next generation of the COM specification " Easier implementation " Integrated support for: $ $ Inheritance $ Dynamic load balancing $ " Transactions Integrated security Tighter integration with system services COM+ will further ease implementation for component developers while also allowing a number of new features to be used natively, without the need for consuming customized code COM+ contains support for many new features These features include automatic synchronous and asynchronous transaction support, inheritance, load balancing across computers, and integrated security (including integration with Active Directory™) In addition to integrating MTS, additional system services have also been integrated with COM, such as Microsoft Message Queue (MSMQ) Services The name given to this unified set of component services is COM+ Services This integration of COM and system services allows applications written to use COM+ to automatically take advantage of these services The different client calling mechanisms of COM, MTS, and MSMQ have been combined into a single COM+ mechanism 270 Module 8: Solution Design and the Component Object Model Windows 2000 COM+ Support and Services Slide Objective To introduce initial information about COM and MTS integration Lead-in In Windows 2000, COM+ Services are provided natively by the operating systems " Native COM+ support " Native integration of COM+ services " Integration of new COM+ services Microsoft Windows 2000 will bring the many enhancements of COM+ to the application environment First and foremost, it will provide native support for COM+ and COM+ services COM+ is built on a general-purpose activation and interception architecture that lets COM+ associate an object context with every object as it is created This architecture also allows COM+ to intercept calls to the objects created During activation, COM+ uses attributes stored with the component or in application configuration information to determine which services, if any, the object uses COM+ keeps track of which services are in use and determines whether a call to the object requires work on the part of any of the services If so, the services are automatically invoked at the appropriate point in the call Instead of using a separate context wrapper to intercept calls, as MTS does, COM+ merges interception into the normal proxy/stub architecture already used to detect calls across apartment, process, or computer boundaries Windows 2000 and COM+ also introduce new services not previously available with COM The services add load balancing for COM+ components, additional location independence with monikers, and Active Directory Module 8: Solution Design and the Component Object Model ! Review Slide Objective To reinforce module objectives by reviewing key points Lead-in In this section, you will learn some practical guidelines for practicing the concepts of this module, and you will test yourself on your understanding of those concepts " Guidelines " Review Questions " Looking Forward In this section In this section 271 272 Module 8: Solution Design and the Component Object Model Guidelines Slide Objective To present some general guidelines related to the information in this module " Use multiple service-layer designs to best use COM components " Create COM components, regardless of the packaging and distribution strategy " Create apartment model-based components by default " Create DCOM components for the business service layer of applications with significant concurrent use requirements " Design new applications for COM+ Lead-in The following are some general guidelines to consider The multiple-layer approach advocated by Windows DNA is the best way to get the most COM functionality in an application Creating COM components does not mean applications must be packaged and deployed as distributed applications COM components provide the same benefits for developing applications when packaged for a single application running on a single computer Microsoft Word 2000 is an excellent example of an application heavily reliant on COM components, yet deployable as a standalone application When trying to determine the threading models with which to develop for COM components, start by creating apartment-model components These components can be used within MTS if required; they also provide the best performance for the level of development skill required to implement them Concurrent use requirements for an application can be the most important factor in determining how to implement the business layer DCOM components provide the best scalability metrics and the type architecture for components that will be used with MTS MTS provides performance scaling to meet the demands of large quantities of concurrent users New applications should be designed in the context of COM+ and its new services Because many applications are just beginning their design stages, COM+ additions can provide an easier development path and additional capabilities for an application’s design Module 8: Solution Design and the Component Object Model 273 Review Questions Slide Objective To reinforce module objectives by reviewing key points Lead-in The review questions cover some of the key concepts taught in this module " 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 What does COM provide for the system developer? A unified and systematic approach to developing and interfacing with objects, and to using Microsoft development tools and system services What is the relationship between a COM class, COM object, and COM component? A COM class defines what the public interface will be and how applications can communicate with the component's interfaces Classes are definitions A COM object is an instance of a COM class that is loaded into the memory of a computer Objects are created and used when an application runs A COM component is the binary application code that implements a COM class and is run to instantiate a COM object What are DCOM components? DCOM components are COM components whose client interface and component execution are distributed on different computers The client only calls a stub/proxy in-process COM object, which in turn communicates with a remote component and performs its work within the memory and microprocessor of a computer that is different from the client computer 274 Module 8: Solution Design and the Component Object Model How the COM, DCOM, and Windows DNA designs intersect? Windows DNA specifies a multiple-layer, COM-based approach to application development COM and DCOM components can be created to provide application logic for any Windows DNA service layer Because COM and DCOM are independent of any particular programming language, most Windows DNA development tools and services can be used with COM and DCOM components Module 8: Solution Design and the Component Object Model 275 Looking Forward Slide Objective Provide a context in which students can frame what they have just learned, and foreshadow what they will be learning Module 12: Introduction to Functional Specifications Module 11: Designing the Presentation Layer Module 10: Completing the Physical Design Module 9: Designing Solutions with Microsoft Technologies Module 1: Course Overview Designing Business Solutions Module 8: Solution Design and the Component Object Model Module 7: Selecting Solution Technologies Module 2: Solution Design Using the MSF 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 In this module, you learned about COM, DCOM, and COM+, the foundation for developing scaleable and distributed applications In the next module, you will add to this knowledge by learning about other types of technologies, such as operating systems and data storage This leads to selecting candidate technologies for the business solution and the final steps of physical design 276 Module 8: Solution Design and the Component Object Model THIS PAGE INTENTIONALLY LEFT BLANK ... Overview Module 10: Completing the Physical Design Designing Business Solutions Module 9: Designing Solutions with Microsoft Technologies Module 8: Solution Design and the Component Object Model Module. .. using COM in a solution design 248 Module 8: Solution Design and the Component Object Model ! Component Object Model Basics Slide Objective To explain the purpose of the section and what students... Solutions Module 8: Solution Design and the Component Object Model Module 7: Selecting Solution Technologies Module 2: Solution Design Using the MSF Module 3: A Services-Based Approach to Solution Design

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

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan