Presentation is loading. Please wait.

Presentation is loading. Please wait.

Windows Server 2003 中的代码重用 孙巍微软资深讲师

Similar presentations


Presentation on theme: "Windows Server 2003 中的代码重用 孙巍微软资深讲师"— Presentation transcript:

1 Windows Server 2003 中的代码重用 孙巍微软资深讲师 sunwei@bjmcse.com.cn

2 What we will cover COM+ 的概念及优点 COM+ 的概念及优点 Microsoft.NET / COM+ 连接 Microsoft.NET / COM+ 连接 更强的服务及架构 更强的服务及架构

3 Session Prerequisites Level 200 Visual Basic ®.NET or C# 的使用经验 Visual Basic ®.NET or C# 的使用经验 熟悉数据库事务 熟悉数据库事务 不需要任何有关 COM 的经验 不需要任何有关 COM 的经验

4 Key Messages Microsoft.NET 在企业服务上依靠于 COM+ Microsoft.NET 在企业服务上依靠于 COM+ 执行简单好处多 执行简单好处多 比重新开发一遍代码更划算 比重新开发一遍代码更划算

5 Demonstrations COM+ 服务管理代码 COM+ 服务管理代码 隔离级别 和无组件的 COM+ 服务 隔离级别 和无组件的 COM+ 服务 队列组件 队列组件

6 Agenda COM+ 服务 COM+ 服务 管理代码 管理代码 COM+ 1.5 增强 COM+ 1.5 增强 更强的 COM+ 服务 更强的 COM+ 服务

7 COM+ Services Overview 企业服务架构及运行时 企业服务架构及运行时 过去的技术 过去的技术  COM  Microsoft Transaction Server (MTS)  COM+ 1.0 更强的管理界面 更强的管理界面  组件服务  管理 API

8 COM+ Services Benefits 可靠性 —— 事务的应用 可靠性 —— 事务的应用 规模性 —— 对象池以及即时活动的应用 规模性 —— 对象池以及即时活动的应用 灵活性 —— 松散耦合事件 灵活性 —— 松散耦合事件 批处理和组件队列保证消息传递 批处理和组件队列保证消息传递 简单执行 —— 通过服务而不是组件 简单执行 —— 通过服务而不是组件

9 COM+ Services Transactions 对组件提供事务性上下文 对组件提供事务性上下文 组件说明自己的事务性需求 组件说明自己的事务性需求 在一个事务中可以包含多个组件 在一个事务中可以包含多个组件 自动的提交或回滚 自动的提交或回滚

10 COM+ Services Transactions B DB DB A MSMQ C

11 COM+ Services Just-In-Time Activation 客户端请求前服务器资源始终是可用的 客户端请求前服务器资源始终是可用的  增加规模性 返回调用之后变为不活动的状态 返回调用之后变为不活动的状态  资源回收  客户端认为所有对象都是活动的 仅在方法调用时变为活动的 仅在方法调用时变为活动的 使用无状态对象 使用无状态对象

12 COM+ Services Object Pooling 内存中的对象实例池 内存中的对象实例池 客户端请求 客户端请求  在可用的情况下从池中返回实例  客户端请求一直被阻止直到实例可用或超时时 对 “ 昂贵的 ” 对象使用对象池 对 “ 昂贵的 ” 对象使用对象池  创建  获取

13 COM+ Services Object Pooling 最大 / 最小设置 最大 / 最小设置 减少相应时间 减少相应时间  更高的最小值 减少最大请求数量 减少最大请求数量  降低最大值

14 Agenda COM+ 服务 COM+ 服务 管理代码 管理代码 COM+ 1.5 增强 COM+ 1.5 增强 更强的 COM+ 服务 更强的 COM+ 服务

15 Managed Code System.EnterpriseServices MTS 和 COM+ 的后续支持 MTS 和 COM+ 的后续支持 提供以下支持 提供以下支持  分布式事务  Just-In-Time activation  对象池  安全性  队列组件  松散耦合事件  服务应用程序处理模式

16 Managed Code Programming Model public class AccountClient private void btnTransactions_Click() { Account acc = New Account(); acc.Credit() }

17 Managed Code Programming Model using System; using System.EnterpriseServices; [assembly : ApplicationName("TxDemo")] [TransactionAttribute()] public class Account : ServicedComponent { [AutoCompleteAttribute()] public void Credit() { // do some work }

18 Managed Code Assembly Attributes ApplicationNameAttribute ApplicationNameAttribute ApplicationIDAttribute ApplicationIDAttribute ApplicationActivationAttribute ApplicationActivationAttribute ApplicationAccessControlAttribute ApplicationAccessControlAttribute ApplicationQueuingAttribute ApplicationQueuingAttribute

19 Managed Code Class Attributes TransactionAttribute TransactionAttribute JustInTimeActivationAttribute JustInTimeActivationAttribute ObjectPoolingAttribute ObjectPoolingAttribute PrivateComponentAttribute PrivateComponentAttribute ComponentAccessControlAttribute ComponentAccessControlAttribute SecurityRoleAttribute SecurityRoleAttribute EventClassAttribute EventClassAttribute InterfaceQueuingAttribute InterfaceQueuingAttribute

20 Managed Code Registration 必须注册在 COM+ 目录中 必须注册在 COM+ 目录中  创建 COM+ 应用  安装组件  配置组件 自动注册 自动注册 RegSvcs.exe RegSvcs.exe RegistrationHelper 类 RegistrationHelper 类

21 Managed Code Registration CLR / Dynamic registrationRegistrationHelper RegSvcs.exe Your admin code COM+ catalog Assembly

22 Demonstration 1 COM+ Services In Managed Code Transactions Registration

23 Agenda COM+ 服务 COM+ 服务 管理代码 管理代码 COM+ 1.5 增强 COM+ 1.5 增强 更强的 COM+ 服务 更强的 COM+ 服务

24 COM+ 1.5 Enhancements Isolation Level 管理并发的数据访问 管理并发的数据访问 使用 SQL 语句 使用 SQL 语句 可配置 可配置  组件服务  TransactionAttribute [Transaction(Isolation= TransactionIsolationLevel.ReadUncommitted)]

25 COM+ 1.5 Enhancements Isolation Level Insert… John Doe 123 Main St. Redmond, WA Select … Where State = WA

26 COM+ 1.5 Enhancements Isolation Level 默认为串行 默认为串行  安全但是受限制  会降低性能 降低隔离级别 降低隔离级别  潜在的可以增加并发、性能以及规模  会导致读脏数据

27 COM+ 1.5 Enhancements Services Without Components Transactions without ServicedComponent Transactions without ServicedComponent  More implementation options ServiceConfig ServiceConfig  Set context options like IsolationLevel and TransactionTimeout ServiceDomain ServiceDomain  Enter and leave transaction  Query transaction result ContextUtil ContextUtil  Vote with SetComplete and SetAbort

28 COM+ 1.5 Enhancements Services Without Components ServiceConfig config = new ServiceConfig(); config.Transaction = TransactionOption.RequiresNew; config.TransactionTimeout = 30; config.IsolationLevel = TransactionIsolationLevel.ReadUncommitted; ServiceDomain.Enter(config);

29 COM+ 1.5 Enhancements Services Without Components … ServiceDomain.Enter(config); try { sqlCom1.ExecuteNonQuery(); sqlCom2.ExecuteNonQuery(); ContextUtil.SetComplete(); } catch { ContextUtil.SetAbort(); } TransactionStatus s = ServiceDomain.Leave();

30 COM+ 1.5 Enhancements Private Components COM+ 1.0 COM+ 1.0  所有组件都是公共的 COM+ 1.5 COM+ 1.5  可配置组件的作用域  Public— 其他应用程序可用  Private— 仅同一个应用程序可用

31 Demonstration 2 COM+ 1.5 Enhancements Isolation Level Services Without Components

32 Agenda COM+ 服务 COM+ 服务 管理代码 管理代码 COM+ 1.5 增强 COM+ 1.5 增强 高级 COM+ 服务 高级 COM+ 服务

33 Advanced COM+ Services Process Initialization 获取 COM+ 应用程序启动和关闭事件 获取 COM+ 应用程序启动和关闭事件 IProcessInitializer 接口 IProcessInitializer 接口  启动  所有工作必须在 90 秒内完成  关闭 不保证序列 不保证序列 实例运行在应用程序中 实例运行在应用程序中

34 Advanced COM+ Services Queued Components 异步组件调用的架构 异步组件调用的架构 MSMQ 提供传输的可靠性 MSMQ 提供传输的可靠性 增加客户端性能 增加客户端性能  不依靠于应用程序的可靠性  立刻返回调用 增加服务器性能 增加服务器性能  更短的组件生存周期  有计划的批处理

35 Client Advanced COM+ Services Queued Components Server Queue Component Listener / Player App Recorder Method Call Call Return Method Call

36 Advanced COM+ Services Queued Components InterfaceQueuingAttribute InterfaceQueuingAttribute  Class level  Identifies what interfaces to expose for queuing ApplicationQueuingAttribute ApplicationQueuingAttribute  Assembly level  Notifies COM+ to create and activate a listener

37 Advanced COM+ Services Queued Components Client uses Marshal.BindToMoniker with COM moniker to get object reference Client uses Marshal.BindToMoniker with COM moniker to get object reference IFoo iQc = null; string m = "queue:/new:MyApp.Bar" iQc=(IFoo)Marshal.BindToMoniker(m);

38 Advanced COM+ Services Loosely Coupled Events 后期消息绑定模型的事件发布 后期消息绑定模型的事件发布 多对多的发布 多对多的发布 发布者和订阅者通过事件类绑定,而不是相 互绑定 发布者和订阅者通过事件类绑定,而不是相 互绑定 COM+ 管理订阅 COM+ 管理订阅  Component Services  COM+ API

39 COM+ Event Classes Subscriptions Register Event Add Subscription Advanced COM+ Services Loosely Coupled Events Subscriber CustomSink CustomEvent CustomEvent  CustomSink Publisher CustomEvent ec = new CustomEvent(); ec.SomeEvent();

40 Advanced COM+ Services Loosely Coupled Events 持续 / 短暂订阅 持续 / 短暂订阅 事件队列 事件队列 并行执行 并行执行 事件过滤 事件过滤

41 Demonstration 3 Queued Components Creating a Queued Component Calling a Queued Component

42 Session Summary 使用 COM+ 服务 使用 COM+ 服务  Increase reliability  Increase scalability  Increase flexibility EnterpriseServices EnterpriseServices  通过属性实现更加简单

43 For More Information… MSDN Web site at MSDN Web site at  msdn.microsoft.com Writing Serviced Components Writing Serviced Components  http://msdn.microsoft.com/library/en- us/cpguide/html/cpconwritingservicedcom ponents.asp http://msdn.microsoft.com/library/en- us/cpguide/html/cpconwritingservicedcom ponents.asp http://msdn.microsoft.com/library/en- us/cpguide/html/cpconwritingservicedcom ponents.asp COM+ Services Without Components COM+ Services Without Components  http://msdn.microsoft.com/library/default.a sp?url=/library/en- us/cossdk/htm/pgservices_serviceswithou tcomponents_7u5v.asp

44 Training & Events MSDN Webcasts, MSDN Online Seminars, Tech-Ed, PDC, Developer Days MSDN Essential Resources for Developers Subscription Services Online Information Membership Programs Print Publications Library, OS, Professional, Enterprise, Universal Delivered via CD-ROM, DVD, Web MSDN Online, MSDN Flash, How-To Resources, Download Center MSDN User Groups MSDN Magazine MSDN News

45 How-To Resources Simple, Step-By-Step Procedures Embedded Development How-To Resources Embedded Development How-To Resources General How-To Resources General How-To Resources Integration How-To Resources Integration How-To Resources JScript ®.NET How-To Resources JScript ®.NET How-To Resources.NET Development How-To Resources.NET Development How-To Resources Office Development Resources Office Development Resources Security How-To Resources Security How-To Resources Visual Basic ®.NET How-To Resources Visual Basic ®.NET How-To Resources Visual C# ™.NET How-To Resources Visual C# ™.NET How-To Resources Visual Studio ®.NET How-To Resources Visual Studio ®.NET How-To Resources Web Development How-To Resources (ASP, IIS, XML) Web Development How-To Resources (ASP, IIS, XML) Web Services How-To Resources Web Services How-To Resources Windows Development How-To Resources Windows Development How-To Resourceshttp://msdn.microsoft.com/howto

46 MSDN Webcasts Interactive, Live Online Event Interactive, synchronous, live online event Interactive, synchronous, live online event Discuss the hottest topics from Microsoft Discuss the hottest topics from Microsoft Open and free for the general public Open and free for the general public Held each week Held each weekhttp://www.microsoft.com/usa/webcasts

47 MSDN Subscriptions THE way to get Visual Studio.NET Visual Studio.NET MSDN Subscriptions NEW Professional Tools to build applications and XML Web services for Windows and the WebTools to build applications and XML Web services for Windows and the Web MSDN Professional $1199 new $899 renewal/upgrade MSDN Enterprise $2199 new $1599 renewal/upgrade MSDN Universal $2799 new $2299 renewal/upgrade Enterprise Developer Enterprise lifecycle toolsEnterprise lifecycle tools Team development supportTeam development support Core Windows Server System ™ family membersCore Windows Server System ™ family members Enterprise Architect Software and data modelingSoftware and data modeling Enterprise templatesEnterprise templates Architectural guidanceArchitectural guidance

48 Where Can I Get MSDN? Visit MSDN Online at msdn.microsoft.com Visit MSDN Online at msdn.microsoft.com Register for the MSDN Flash e-mail newsletter at Register for the MSDN Flash e-mail newsletter atmsdn.microsoft.com/flash Become an MSDN CD subscriber at msdn.microsoft.com/subscriptions Become an MSDN CD subscriber at msdn.microsoft.com/subscriptions MSDN Online Seminars MSDN Online Seminarsmsdn.microsoft.com/training/seminars Attend more MSDN events Attend more MSDN events

49 Microsoft Press Essential Resources for Developers Microsoft ® Visual Studio ®.NET is here! This is your chance to start building the next big thing. Develop your.NET skills, increase your productivity with.NET books from Microsoft ® Press www.microsoft.com/mspress

50 Become A Microsoft Certified Solution Developer What Is MCSD? What Is MCSD?  Premium certification for professionals who design and develop custom business solutions. How Do I attain MCSD Certification? How Do I attain MCSD Certification?  It requires passing four exams to prove competency with Microsoft solution architecture, desktop applications, distributed application development, and development tools. Where Do I Get More Information? Where Do I Get More Information?  For more information about certification requirements, exams, and training options, visit www.microsoft.com/mcp.

51 Training Training Resources for Developers Course Title: Course Title:  Course Number:  Availability:  Detailed Syllabus: www.microsoft.com/traincert Course Title: Course Title:  Course Number:  Availability:  Detailed Syllabus: www.microsoft.com/traincert To locate a training provider for this course, please access www.microsoft.com/traincert Microsoft Certified Technical Education Centers are Microsoft premier partners for training services

52 © 2003 Microsoft Corporation. All rights reserved. Microsoft, MSDN, Windows, Windows Server, Windows Server System, Visual Basic, Visual Studio, Microsoft Press, and SQL Server are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. The names of actual companies and products mentioned herein may be the trademarks of their respective owners. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

53 Session Credits Author: Author: Producer/Editor: Field Content Team Producer/Editor: Field Content Team Reviewers Reviewers  Field Content Council


Download ppt "Windows Server 2003 中的代码重用 孙巍微软资深讲师"

Similar presentations


Ads by Google