Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 46 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
46
Dung lượng
248 KB
Nội dung
Lecture 7 Enterprise JavaBeans: ArchitectureandGoals What are EnterpriseJavaBeans • EJB is a semi-automated server-side component management architecture that facilitates the deployment of enterprise-class distributed object applications in Java. – server-side • highly-available enterprise (24x7) – components • encapsulated (self-contained) • portability • object model (inheritance, polymorphism, interface/implementation disjunction) • reusability – automated management • Persistence (distributed 2-Phase Commit Transactions) • Security • Load balanced/fault tolerant – deployment – enterprise distributed object applications – Java language Foundations • EBJ Technology is built on other key J2EE and OMG foundations: – RMI objects • JNDI naming and location – Does for Novell’s NDS and LDAP access what JDBC did for Sybase and Oracle DBMS acccess • Remote method exposure – JDBC – JTS/JTA – CORBA IIOP What’s J2EE all about? • J2EE is a specification – Vendor independent – Platform independent (portable) – API consistency – Test suite – Reference implementation J2EE Technologies (EJB as a canton in a larger confederacy) • RMI and RMI-IIOP • Java Naming and Directory Interface (JNDI) • JDBC • Java Transaction API (JTA) and Java Transaction Service (JTS) • Java Messaging Service (JMS) • Java Servlet API (JSDK) • Java Server Pages (JSP) • Java IDL (CORBA) • JavaMail API • Extensible Markup Language (XML) • Enterprise Java Beans (EJB) Stated Goals of EJB • “The EJB architecture will be the standard component architecture for building distributed object-oriented business applications in the Java Programming Language.” Sun EJB Specification 1.1 • “Application developers will not have to understand low- level transaction and state management details, multi- threading, connection pooling and other complex low-level APIs.” ibid. • “EJBs will follow the Write Once, Run Anywhere philosophy of the Java Programming Language. An EJB can be developed once, and then deployed on multiple platforms without recompilation or source code modification.” ibid. Stated Goals of EJB • “The EJB architecture will address the development, deployment, and runtime aspects of an enterprise application’s life cycle.” ibid. • “The EJB architecture will provide interoperability between enterprise Beans and non-Java programming language applications.” ibid. • “The EJB architecture will be compatible with the CORBA protocols.” ibid. What benefits does the EJB Architecture Provide? • Component Transaction Monitor – Distributed Transaction/2 Phase monitoring • Generic Naming and Implicit component location – clients do not have to know the specific location of a component to use it • Security – Automated User Authentication via Access Control Lists What benefits does the EJB Architecture Provide? • Persistence – Implicit persisting, activation and deactivation – Implicit component life cycle management • Implicit distributed transaction management – Distributed 2-Phase commit (Begin,End,Commit,Rollback) • Load Balancing/Transparent Failover – Resource Pooling – Multi-client support • Metadata Management – Declarative Specification Server Architecture [...]... • Object-Relational database mapping is done declaratively in the deployment descriptor • Programmer generally writes little if any direct JDBC connection code (but is free to if he wishes) Container-Managed Persistence • finder functions are described in the deployment descriptor (ejb-jar.xml): – – – findAccount – – double... java.security.Principal and SessionContext) – isCallerInRole(securityRole) - checks to see that the current user (per the EntityContext) is a member of a role – getCallerPrincipal() - returns the secure name of the client user Session Bean Persistence • Stateful Session Bean Passivation and Activation – Since Stateful SessionBeans cannot be shared but are client-specific, their resources are limited and can, under...Client-Server Interaction Component Characteristics • An enterprise bean contains business logic that operates on the enterprise s data • An enterprise bean’s instances are created and managed at runtime by a Container • An enterprise bean can be customized by the customer at deployment time by editing the bean’s metadata... – – findAccount – – double – – – – – – Entity Bean Persistence • Bean-Managed Persistence – Bean developer, not the container, provides all data access logic – Developer implements... is equivalent, but some may have higher priority due to access algorithms (LRU, Round-Robin) • New instances can be created and added to the pool, and other instances can be checked in and out for usage by clients • Pool management is handled intelligently by the container • Database ConnectionPools are supported and userdefined Resource Management/Load Balancing Mechanisms • EJB Servers/Containers... be swapped for client access because they maintain no client-specific state, they are truly equivalent, and one will work as well as another – Entity beans can also be swapped through the interaction of the container and the setEntityContext() and unsetEntityContext() methods • EJB Servers/Containers provide management through activation and passivation Failover Management • Stateless Session Beans:... handled either declaratively or programmatically – Programmatically handled requires programmer to issue Begin, End, Commit, Rollback – Declaratively handled requires the EJBObject (container) to issue transaction boundaries on behalf of the implementation Distributed Transaction Support • EJB Transaction Attribute Values (set in Deployment Descriptor): – TX_BEAN_MANAGED: bean is programmatically handling... manager that validates a user and returns a token • pooled resource • Stateless Session Bean EJB Topology • An EJB may implement: – an object that represents a conversational session with a particular client (contradistinguished from HTTP protocol) • Extension of client business functionality on the server side – avoids Fat clients and 2-tier scenarios • Typically will handle database operations on... to client access on the persisted bean The state is restored and ejbActivate() is called to notify the bean that it should re-establish connections, handles, etc – Passivation is performed according to a Least Recently Used (LRU) strategy The bean whose last client access was farthest back in time is the first to be passivated Container-Managed Persistence • The container implicitly performs all database... scenarios • Typically will handle database operations on behalf of the client • automated instance passivation and activation • pooled resource • Stateful Session Bean EJB Topology • An EJB may implement: – a high-level abstraction that represents a business entity that encapsulates business state and is accessible by multiple clients • a “Customer” object • a “Contract” object in futures trading • a “Policy” . 7 Enterprise JavaBeans: Architecture and Goals What are Enterprise JavaBeans • EJB is a semi-automated server-side component management architecture that facilitates the deployment of enterprise- class. Markup Language (XML) • Enterprise Java Beans (EJB) Stated Goals of EJB • “The EJB architecture will be the standard component architecture for building distributed object-oriented business applications. 1.1 • “Application developers will not have to understand low- level transaction and state management details, multi- threading, connection pooling and other complex low-level APIs.” ibid. • “EJBs will follow