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

o'reilly - com and .net component services

385 430 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

Định dạng
Số trang 385
Dung lượng 3,65 MB

Nội dung

2 COM and .NET Com ponent Services Dedication Foreword Preface Scope of This Book Som e Assum pt ions About t he Reader Definit ions and Text Convent ions Ot her COM+ Books and References How to Contact Us Acknowledgm ent s 1. COM+ Com ponent Services 1.1 COM+ Com ponent Ser vices 1.2 The Com ponent Services Explorer 1.3 Hello COM+ 1.4 COM+ Configured Com ponent s 1.5 Applicat ions, DLLs, and Com ponent s 1.6 Configur ing COM+ Applications 1.7 Debugging COM+ Applicat ions 1.8 Deploying COM+ Applications 1.9 Sum m ary 2. COM+ Cont ext 2.1 Encapsulat ion via Marshaling in COM 2.2 Encapsulat ion via I nt ercept ion in COM+ 2.3 The Cont ext Object 2.4 The Call Obj ect 2.5 Cross- Cont ext Manual Marshaling 2.6 Sum m ary 3. COM+ I nst ance Managem ent 3.1 Client Types 3.2 I nstance Managem ent and Scaling 3.3 Obj ect Pooling 3.4 Just - in-Tim e Act ivation 3.5 Com bining JITA wit h Obj ect Pooling 3.6 Obj ect Const ruct or String 3.7 COM+ I nst ance Managem ent Pitfalls 4. COM+ Transactions 4.1 Transact ion Basics 4.2 Transact ion Properties 4.3 Transact ion Scenarios 4.4 COM+ Transact ions Archit ecture 4.5 Configur ing Transact ions 4.6 Vot ing on a Transaction 4.7 Transact ional Obj ect Life Cycle 4.8 Designing Transact ional Com ponent s 4.9 Nont ransactional Clients 4.10 Transact ions and Obj ect Pooling 4.11 Com pensating Transactions 4.12 Transact ion Execut ion Tim e 3 4.13 Tracing Transact ions 4.14 I n-Doubt Transactions 4.15 Transact ion St atist ics 4.16 COM+ Transactions Pitfalls 5. COM+ Concurr ency Model 5.1 Obj ect - Oriented Program m ing and Multiple Threads 5.2 Apart m ent s: The Classic COM Solution 5.3 Act ivities: The COM+ I nnovat ion 5.4 COM+ Configuration Set t ings 5.5 Act ivities and JITA 5.6 Act ivities and Transact ions 5.7 Tracing Act ivit ies 5.8 The Neutral Threaded Apart m ent 5.9 Sum m ary 6. Program m ing t he COM+ Catalog 6.1 Why Program the Cat alog? 6.2 The Cat alog Progr am ming Model 6.3 Catalog St ruct ur e 6.4 I nt eract ing w it h t he Catalog 6.5 Features of COMAdm inCat alog 6.6 The COM+ Catalog and Transact ions 6.7 Sum m ary 7. COM+ Securit y 7.1 The Need for Securit y 7.2 Basic Securit y Term s 7.3 Role- Based Securit y 7.4 Securing a Server Applicat ion 7.5 Securing a Library Applicat ion 7.6 Program matic Role- Based Security 7.7 Security Boundaries 7.8 Advanced COM+ Securit y 7.9 COM+ Securit y Pit falls 7.10 Sum m ary 8. COM+ Queued Com ponent s 8.1 Major Benefits of Queued Com ponent s 8.2 Queued Com ponent s Archit ect ure 8.3 Com ponent Services Explorer Configurat ion 8.4 I nvoking Queued Com ponents on the Client Side 8.5 Designing Queued Com ponent I nt erfaces 8.6 Receiving Out put from a Queued Com ponent 8.7 Queued Com ponent Error Handling 8.8 Queued Com ponent s and Transact ions 8.9 Synchronous Versus Asynchronous Com ponent s 8.10 Queued Com ponents Security 8.11 Queued Com ponents Pit falls 8.12 Sum m ary 9. COM+ Event Service 9.1 Classic COM Event s 9.2 COM+ Event Model 9.3 The Event Class 9.4 Subscript ion Types 9.5 Delivering Event s 4 9.6 Event Filtering 9.7 Distribut ed COM+ Event s 9.8 Asynchronous Event s 9.9 COM+ Event s and Transact ions 9.10 COM+ Events and Securit y 9.11 COM+ Events Lim it ation 9.12 Sum m ary 10. .NET Serviced Com ponent s 10.1 Developing Serviced Com ponent s 10.2 .NET Assem blies and COM+ Applications 10.3 Regist ering Assem blies 10.4 Configur ing Serviced Com ponents 10.5 Applicat ion Activat ion Type 10.6 The Descript ion At t ribute 10.7 Accessing t he COM+ Cont ext 10.8 COM+ Cont ext At t ributes 10.9 COM+ Object Pooling 10.10 COM+ Just - in-Tim e Act ivat ion 10.11 COM+ Const ruct or St r ing 10.12 COM+ Transact ions 10.13 COM+ Synchronization 10.14 Program m ing t he COM+ Cat alog 10.15 COM+ Security 10.16 COM+ Queued Com ponents 10.17 COM+ Loosely Coupled Events 10.18 Sum mary A. The COM+ Logbook A.1 Logbook Requirem ent s A.2 Log File Exam ple A.3 Using the Logbook A.4 Configuring t he Logbook A.5 How Does t he Logbook Work? A.6 Sum mary B. COM+ 1.5 B.1 I m proved User I nterface Usabilit y B.2 Legacy Applications and Com ponent s B.3 Disabling Applications and Com ponent s B.4 Pausing Applicat ions B.5 Service Activat ion Type B.6 I m proved Queuing Support B.7 Application Pooling and Recycling B.8 Application Dum p B.9 Application Partitioning B.10 Aliasing Com ponent s B.11 Configurable Transact ion I solat ion Level B.12 I m proved Cont ext Act ivat ion Set t ing B.13 Private Com ponent s B.14 Web Serv ices in COM+ 1.5 B.15 Sum m ary C. I nt roduction to .NET C.1 .NET Program m ing Languages C.2 Packaging .NET Com ponent s: Assem blies C.3 Developing .NET Com ponent s 5 C.4 Writing .NET Client - Side Code C.5 .NET as a Com ponent Technology C.6 Com posing Assem blies Colophon 6 Dedicat ion To m y wife, Dana 7 Forew ord I first ran into COM+ back in 1996. I n those days, I was working as a Com m on Obj ect Request Broker Architect ure ( CORBA) consultant and was fresh out of I BM, where I had been heav ily involved in I BM’s original CORBA im plem entat ion. CORBA was the first of the archit ect ures that we m ight describe today as Dist ribut ed Com ponent archit ect ures, which set the stage for both COM/ DCOM in the Microsoft space and RMI / I I OP in t he Java space. Back t hen, I was int erest ed in a particularly knot ty problem related to distributed com ponent archit ect ures. System s built wit h such architectures had a characteristic perform ance pattern. They could handle large num bers of t ransact ions, as long as t hose transact ions originated from a sm all num ber of client s. So, for exam ple, 5,000 transact ions per m inute divided between 5 clients worked fine. But when those sam e 5,000 transactions per m inut e were split am ong 1,000 client s, each processing 5 t ransact ions per m inut e, t he system s choked. This was odd, I t hought. Why should 5 clients, each processing 1,000 transactions per m inut e, be fundam ent ally different than 1,000 client s, each processing 5 t ransact ions per m inut e? What is the difference bet ween the first 5,000 tr ansactions per m inut e and the second? Dist ributed com ponent archit ect ures, as they existed in 1996, dict at ed a one- to- one relationship bet ween client s and com ponent inst ances. The business logic of such architect ures is in the com ponent instances. And it is the business logic that makes transact ional request s of transactional resources, such as t he dat abase. In order t o m ake transact ional requests, the com ponent inst ances require expensive resources, such as database connections. We run out of steam ( i.e., t ransact ional throughput ) when one of two t hings happen: we overload the syst em wit h transact ional request s or we run out of resources ( e.g., database connections) . Clearly, going from 5 client s, each m ak ing 1,000 transactional request s per m inute, t o 1,000 clients, each making 5 transact ional request s per m inute, has no overall im pact on t he t ransact ional throughput. Therefore, the reason why our distribut ed com ponent system s m ust be dying is t hat we ar e running out of resources. So the answer to getting lot s of client s on a distributed com ponent architecture is not going to com e from increased capability of the back- end transact ional resources ( e.g., databases) . I t will have to com e from som et hing else- som et hing that allows resource sharing. This, t hen, is the problem I worked on back in 1996. How do you 8 get several clients t o share resources in a distributed com ponent architecture? The solut ion to this problem cam e from an unex pect ed source. I was asked to write a book on COM and DCOM. I knew very litt le about COM and DCOM back t hen. As I looked over t he COM/ DCOM white papers on t he Microsoft web site, I quickly recognized it as a typical dist ribut ed com ponent archit ect ure and predicted the sam e throughput problem s I had seen in other distributed com ponent system s. As I browsed through the whit e papers, I not iced an obscure bet a product called Microsoft Transact ion Server ( MTS) . At first, I dism issed MTS as an API used to manage dist ribut ed t ransactions. But as I read m ore about MTS, I realized that it had litt le to do with transact ions. I nst ead, it at tacked a m uch m ore interesting problem : how to share resources am ong clients. I n a nut shell, MTS addressed the very problem that had so vexed the existing dist ribut ed com ponent system s-how to support a large num ber of low- transact ion generat ing clients! I did eventually w rit e that book, as well as m any articles on the im portance of the ideas int roduced by MTS. Many of t hese articles appear ed in m y ObjectWat ch newslet ter (available at www.obj ectwatch.com ), a newslet ter t hat has, over t im e, becom e influential in its space. Back in 1996, I predicted t hat MTS would be a hist orically im portant product- one t hat w ould redefine approaches to scalabilit y in dist ribut ed com ponent system s. I n fact , t hat prediction has com e true. Today, every infrast ructure designed to support high scalability in distributed com ponent system s is based directly on the ideas, algorithm s, and principals first introduced by MTS in 1996. Enterprise JavaBeans, for exam ple, the Jav a scalabilit y infrastruct ure, is alm ost a direct copy of MTS. But what does this have t o do with COM+ , you may ask. I t t urns out that COM+ and MTS are one and the sam e. Microsoft, never known for its m arketing savvy, decided to wait unt il cust om ers finally got used to t he nam e MTS ( itself a m isleading nam e), and then it pulled a fast one- it switched the nam e! And not just any nam e, but one t hat would be as confusing as possible! So they renam ed MTS as COM+ . Naturally, cust om ers assum ed that COM+ was the next release of COM. I n fact , COM+ was t he next release of MTS. Now Microsoft has announced .NET. Once again, the brilliant Microsoft m ark et ing organization has left m any custom ers confused. I s COM+ now dead? Far from it —.NET is a series of int er esting new features, none of which replace COM+ . COM+ is st ill the scalable infrastruct ure that supports resource sharing and deals with the m yriad of issues (such as security and transaction boundary 9 m anagem ent) that are so closely relat ed t o resource sharing and so crucial t o dist ributed applicat ions. So whether you are rushing into Microsoft ’s new .NET t echnology platform or taking a wait and see att it ude, if you need to put a lot of clients around your system , you need to understand COM+ . Therefore, this book is very tim ely. COM+ is going to be with us for a long time. I ts nam e m ay change again, j ust to confuse the innocent; but the ideas, algorit hm s, and principals will not . COM+ , under whatever nam e, is here to stay! Roger Sessions, CEO, Object Watch, I nc. Publisher, Obj ect Watch newslet ter ( www.objectwatch.com ) Author, COM+ and the Bat tle for t he Middle Tier Austin, Texas 10 Preface This book discusses COM+ com ponent services. Each service is covered in it s own chapter, and each chapter discusses a sim ilar range of issues: the problem the serv ice addresses, possible solutions t o t hat problem , an in- depth description of the COM+ solution, tradeoffs, design, and im plem entation guidelines, tips, and known pitfalls. I have tried t o provide useful design inform ation and lessons I learned while applying COM+ . I also descr ibe COM+ helper classes and ut ilities I developed that will enhance your productivit y significantly . ( The COM+ Events helper object s and t he COM+ Logbook are prim e ex am ples.) This book focuses on the "how to"— that is, it provides practical inform at ion. You should read the chapt ers in order, since m ost chapt ers rely on inform ation discussed in t he preceding chapters. The book also aim s to explain COM+ step by step. A soft ware engineer already fam iliar with COM who wants to know what COM+ is and how to use it can read this book and st art developing COM+ applications im m ediately. Scope of Th is Book Here is a brief sum mary of the chapters and appendixes in this book: • Chapter 1 introduces t he Com ponent Services Explorer and basic COM+ term inology. This chapter deliberately holds your hand as you develop your first " Hello World" COM+ com ponent. Subsequent chapters do m uch less handholding and assum e y ou are fam iliar with the COM+ environment . I f you already have experience wit h basic COM+ developm ent, feel free to skip t his chapt er. • Chapter 2 dem ystifies the COM+ context by presenting it as the key mechanism for providing com ponent services using call int erception. Generally , you need not be concerned with cont ext s at all. However, t he COM+ context underlies the way COM+ services are im plem ented. • Chapter 3 describes t wo scalability- enabling m echanism s t hat COM+ provides for a m odern ent erprise application: obj ect pooling and Just- in- Tim e Act iv at ion ( JITA) . The discussion of inst ance m anagem ent, and especially JI TA, is independent of transact ions. Early COM+ docum entat ion and books t ended t o couple inst ance m anagem ent and transactions. However, I found that not only can you use instance m anagem ent independent ly of t ransact ions, but it is easier to explain it that [...]... an in- proc com ponent is im port ed t o COM+ , it is called a configured com ponent t o em phasize t he fact t hat m uch com ponent funct ionalit y and behav ior is act ually configured and adm inist er ed out side t he com ponent A classic COM com ponent ( be it in- pr oc or local) t hat has not been im port ed int o COM+ is called a nonconfigur ed com ponent Configured and nonconfigur ed com ponent... refer t o t he COM+ com ponent services When we speak of COM+ com ponent s, we refer t o COM com ponent s configured t o run under t hose services Howev er, as y ou will see, a COM+ applicat ion m ay consist of eit her COM or NET com ponent s ( see COM+ : The Migrat ion Pat h t o NET) Her e is a quick sum m ar y of t he m ost im port ant serv ices prov ided by COM+ : Adm inist r at ion Tools and serv ices... window: Com put ers My Com put er COM+ Applicat ions Ev ery icon in t he COM+ Applicat ions folder represent s a COM+ applicat ion Each COM+ applicat ion cont ains COM+ com ponent s Com ponent s m ust be explicit ly im port ed int o t he Com ponent Ser vices Explor er t o t ak e advant age of COM+ serv ices The Com ponent Serv ices Explorer offers a hier archical approach t o m anaging COM+ serv ices and. .. erpr ise applicat ions You will also creat e, debug, and deploy a sim ple COM+ " Hello Wor ld" applicat ion, using a t r adit ional COM com ponent and learning about COM+ applicat ion t y pes and configured com ponent s as y ou do so 17 1 1 COM+ Com pon e n t Ser vice s Com ponent s need runt im e services t o work The original COM runt im e support ed com ponent s locat ed on t he sam e m achine, t y... program m ers and adm inist rat ors t o configure and m anage com ponent s and com ponent - based applicat ions The m ost im por t ant t ool is t he Microsoft Managem ent Console Com ponent Serv ices Ex plorer COM+ also prov ides a st andard locat ion, t he COM+ Cat alog, for st oring configur at ion infor m at ion The Com ponent Services Explorer is explained in t he following sect ion The COM+ Cat alog... oft en COM- based, code base and t he developer sk ills needed t o m aint ain it Unless com panies hav e a com pelling reason t o m ove t o NET or a r easonable m igr at ion pat h, t hey post pone or avoid m ak ing t he change However, because COM and NET com ponent s can coexist in t he sam e COM+ applicat ion, com panies can cont inue t o build COM com ponent s t oday , adding NET ser viced com ponent... fort hcom ing changes 1 2 Th e Com pone n t Ser vice s Ex plor e r COM+ com ponent s and applicat ions ar e m anaged t hrough t he Com ponent Services Explorer ( form erly known as t he COM+ Explorer) The Com ponent Serv ices Explorer is a Microsoft Managem ent Console snap- in and is available on ev ery Windows 2000 m achine To fir e up t he Com ponent Ser vices Explor er, go t o t he St art m enu and. .. Obj ect Model ( COM) has been t he st andard for com ponent s t hat r un on Windows m achines, including Windows 9x and Me client s and Windows NT and 2000 server s The COM m odel is well docum ent ed by t he Microsoft Com ponent Obj ect Model Specificat ion Tools such as Visual C+ + and Visual Basic m ake it easy t o cr eat e COM com ponent s, and scor es of book s, t raining classes, and art icles... classic COM com ponent All COM+ com ponent s st ar t t heir life as classic COM com ponent s, developed wit h such t ools as ATL, MFC, or Visual Basic 6.0 2 Cr eat e a new COM+ applicat ion t o host t he com ponent 3 Add t he com ponent t o t he applicat ion 4 Writ e a client and t est t he com ponent The r est of t his chapt er uses t his " Hello COM+ " exam ple t o dem onst r at e v arious COM+ feat... ill regist er it for you As y ou will see lat er, COM+ m aint ains it s own com ponent s regist r at ion and configurat ion reposit ory 1 3 2 Cr e a t in g a COM + Applica t ion Open t he Com ponent Ser vices Explorer and expand My Com put er COM+ Applicat ions folder Right - click t he COM+ Applicat ions folder and select New Applicat ion from t he pop- up cont ext m enu This st ep br ings up t he Applicat . Internet. Collectively, the services that support COM and .NET com ponent- based applications are known as the COM+ com ponent services, or sim ply as COM+ . The Evolut ion of COM + Services COM. 1. COM+ Com ponent Services 1.1 COM+ Com ponent Ser vices 1.2 The Com ponent Services Explorer 1.3 Hello COM+ 1.4 COM+ Configured Com ponent s 1.5 Applicat ions, DLLs, and Com ponent. of MTS and DCOM by fusing t hem into a new com prehensive component services suit e. Microsoft added yet m ore services, including obj ect pooling, queued com ponents, and events, and m ade

Ngày đăng: 25/03/2014, 10:40

TỪ KHÓA LIÊN QUAN