基于构件的软件开发.ppt
Component-based software development,基于构件的软件开发 一直未曾完全实现的老想法 重用 “工业化” 影响因素不仅限于技术层面,What is a software “Component”?,Clemens Szyperski: A software component is a unit of composition with contractually specified interfaces and explicit context dependencies only. A software component can be deployed independently and is subject to composition by third parties. Szyperski 的书中还比较评论了许多其他人的说法。,CCM Component,Component,Components are for composition Connection-oriented composition Contextual composition Data-driven composition Federation and peer-to-peer,Connection-oriented composition,Wiring outgoing and incoming interfaces 对于一个接口来说 非对称 Caller --- callee 当对于component来说 可以同时充当caller和callee (静态)类型检查 ADL JavaBeans BML,Contextual composition,设想诸如Transaction、Security等非功能特性如何在分布构件组装中得以实现? 几乎每个实际分布构件系统都用到 由开发者在功能代码中实现? 太复杂 另加? separation of concerns! Howto? 自动化?,Contextual composition: Domains and contexts,c1,c3,c2,Load-balancing domain,Transaction domain,Contextual composition,使用“Containers” EJB containers CCM containersCLR contexts and channels The list of context properties is extensible,Enterprise JavaBeans,J2EE EJB 在 J2EE 中的位置,EJB,EJB,Session Beans Entity Beans Message-driven beans,package com.jeffhanson.ejb; import javax.ejb.EJBObject; import java.rmi.RemoteException; public interface SimpleMessenger extends EJBObject { public String retrieveMessage() throws RemoteException; },Remote Interface,Home Interface,package com.jeffhanson.ejb; import java.rmi.RemoteException; import javax.ejb.CreateException; import javax.ejb.EJBHome; public interface SimpleMessengerHome extends EJBHome { SimpleMessenger create() throws RemoteException, CreateException; },package com.jeffhanson.ejb; import java.rmi.RemoteException; import javax.ejb.SessionBean; import javax.ejb.SessionContext; public class SimpleMessengerBean implements SessionBean { private SessionContext sessionCtx = null; public String retrieveMessage() { return “Hello from SimpleMessengerBean “; } public void ejbCreate() {} public void ejbRemove() {} public void ejbActivate() { } public void ejbPassivate() { } public void setSessionContext(SessionContext sessionCtx) { this.sessionCtx = sessionCtx; } }, A simple session bean Simple Message EJB SimpleMessenger com.jeffhanson.ejb.SimpleMessengerHome com.jeffhanson.ejb.SimpleMessenger com.jeffhanson.ejb.SimpleMessengerBean Stateless Bean , Sample Deployment XML Sample XMLSampleBeansimpleBusinessMethodMandatory, Example User UserHome User UserBean Stateful Container ,Contextual composition,实现原理(我的理解) 为每个context维护一个逻辑上共享的信息空间 Transaction ID; 用户认证信息,等等 实现上 在Domain中的各个构件间进行交互时携带这些信息; 在调用前后插入Interceptors处理这些信息 麻烦的问题是这些aspects并不都是“正交”的 (意味着Interceptor之间的顺序有关系!),Date-driven composition,EJB message-driven beans Java Message Service (JMS) Microsoftw message queue (MSMQ)异步,松耦合 适合工作流系统,较不适合交互系统;,Federation and peer-to-peer,Jini 即插即用 设备之间无需驱动程序,就可以互相辨认并交换信息资源 基于Java分布计算技术的解决方案,,Federation and peer-to-peer,Peer-to-Peer Generally, a peer-to-peer (or P2P) computer network is any network that does not rely on dedicated servers for communication but instead mostly uses direct connections between clients (peers). A pure peer-to-peer network does not have the notion of clients or servers, but only equal peer nodes that simultaneously function as both “clients“ and “servers“ to the other nodes on the network.,Peer-to-Peer,第一代 集中的文件列表服务器,Napster 第二代 分散的文件列表服务器,Gnutella, FastTrack 第三代 提供更高的效率、可靠性和匿名性 匿名网:Freenet, I2P, GNUnet, Entropy,JXTA,JXTA,核心层(JXTA Core): 这一层封装了最根本的东西,包括Peer、对等组、Peer发现、Peer通信、Peer监视和相关的安全原语。 服务层(JXTA Services): 这一层包括对于P2P网络不是必需的、但很通用的功能,如查找、共享、索引、代码缓存和内容缓存的机制。 应用层(JXTA Application): 这一层包括了应用JXTA服务开发出来的完整的P2P应用程序,例如myJXTA,JXTA-CAD等应用程序。,Service-Oriented Architecture,应用需求 基础技术 面向服务的架构,SOA: 应用需求,信息系统从独立分散到互通互联 企业计算 个人计算 开放网络计算 信息应用的深化、普遍化软件作为服务 开发、运营、维护、扩展 麻烦! 进一步的社会分工,开放环境下的“服务”,SOA技术基础,显然,软件服务应该基于Internet。 WWW是Internet最成功的应用。 全球化的信息网络 技术基础:URL, HTTP, HTML软件服务的形式:Web Service XML-based standards for DOC,技术基础,SOAP Simple Object Access Protocol WSDL Web Service Description Language UDDI Universal Description Discovery and Integration,Service 集成,复杂应用BPEL4WS WS-Coordination WS-Transaction 短transaction 和 长transaction ,