Enterprise Java Beans EJB Overview Software Engineering Institute
Enterprise Java. Beans (EJB) Overview Software Engineering Institute Carnegie Mellon University Pittsburgh, PA 15213 -3890 Sponsored by the U. S. Department of Defense © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans - page 1
EJB Overview What is EJB? EJB Roles EJB Architecture Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display. EJB Services Building an EJB Application EJB & CORBA Summary © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans- page 2
EJB in the n-Tier System You Are Here Browser Client Applet Database Client Application Legacy Systems EJB Server Clients © 1999 by Carnegie Mellon University Application SEI/CBS Initiative Data Enterprise Java Beans- page 3 Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display.
What is EJB? Specification for component based distributed computing framework using Java technology. Enterprise Java. Beans Specification describes • roles and responsibilities for component-based software development of server-side applications. • an architecture including EJB Servers, Containers, and Beans. • a set of service interfaces including naming, transactions and security. • interoperability with database servers and CORBA applications. © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans- page 4 Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display.
EJB Specification Evolving Technology • Release 1. 0 - March 98, Final • Release 1. 1 - May 99, Public Draft Goals • Component-Based software development. • Separate business logic from system code. • Address application life cycle. • Compatible with CORBA (non Java apps). Specification owned by Sun and supported by 40+ companies. © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans- page 5 Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display.
EJB Roles Application Development and Deployment Bean Provider - Producer of enterprise beans. Application - Combines enterprise beans into Assembler larger deployable parts. Deployer - Deploys enterprise beans into a specific operational environment. Platform Provider - Container provider and server provider. System Admins - Configuration and administration of infrastructure. © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans- page 6 Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display.
EJB Architecture The container is the platform. The component is your application. Picture provided by Sun Microsystems, Inc. © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans- page 7 Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display.
EJB Platform Provide naming service using JNDI Provide OMG/OTS compliant transaction service Container EJB Server Manage EJ Bean life cycle Make EJ Bean Interfaces Available with JNDI Provide basic security services Persistence Management (DBMS and other) Manage transaction context © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans- page 8 Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display.
EJB Platform Vendors Select EJB complaint platform for purchase (1. 0 or 1. 1). EJB Platform vendors supplement standard EJB with proprietary features. Current Vendors include: • BEA Systems - Web. Logic • Bluestone - Sapphire/Web • IBM - Web. Sphere • Inprise - Application Server • Netscape - Application Server (future) • Oracle - Oracle 8 i • Persistence - Power. Tier • Sun - Net. Dynamics © 1999 by Carnegie Mellon University SEI/CBS Initiative Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display. Enterprise Java Beans- page 9
EJB Application consists of multiple beans Beans are “portable” across containers Beans can be purchased or constructed Enterprise Java. Beans™ Component © 1999 by Carnegie Mellon University SEI/CBS Initiative Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display. Enterprise Java Beans- page 10
Types of Enterprise Java Beans Session Bean • Used for client interface • Not shared between clients • Two kinds of Session Bean: - stateless - common object identity - stateful - unique object identity Entity Bean • Maps to data in database or application • Shared between clients • Persistent state - container managed - access defined at deployment - bean managed - access defined as part of bean • Support optional in 1. 0 and mandatory in 1. 1 © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans- page 11 Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display.
Mixing Beans EJB applications use a combination of entity beans and session beans to implement business logic. Prefix. Bean Client Echo. Service. Bean Session Bean Entity Bean © 1999 by Carnegie Mellon University Database Suffix. Bean Application Server SEI/CBS Initiative Enterprise Java Beans- page 12 Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display.
EJB Client Interfaces Factory Interface Finder Interface EJB Home Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display. EJB Object Remote Interface Contains bean services seen by clients © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans- page 13
EJB Architecture The purchased EJB server is the platform. The application consists of session and entity beans. Application interfaces are made available to clients at time of deployment. Picture provided by Sun Microsystems, Inc. © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans- page 14 Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display.
Deployment Bean + Deployment descriptor Deploy Platform Specific Implementation of Bean Deployment provides a mechanism for adapting a component for a specific runtime environment. Deployment is an intermediate step between coding a bean and executing a bean. This allows some attributes of the bean implementation to be determined by the platform provider, and the deployer. Key EJ bean design decision is determining which bean attributes are coded into the bean and which are decided at deployment time. © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans- page 15 Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display.
EJB Overview What is EJB? EJB Roles EJB Architecture Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display. EJB Services Building an EJB Application EJB & CORBA Summary © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans- page 16
EJB Services Standard EJB service interfaces allow application developers to : • focus on business logic rather than infrastructure • defer responsibility for common services to the EJB platform • create “portable” applications that can be reused • support a component marketplace Standard EJB service interfaces include: • Persistence - JDBC • Naming - JNDI • Transactions - User. Transaction interface of JTA • Security - java. security in JDK © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans- page 17 Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display.
Container-Managed Persistence Deployment Descriptor Deploy database table database pool (location) Generated Bean Code • SQL code • persistence logic Benefits • Developer can defer persistence to container. • Bean need not contain database specific code because decision is made at deployment time. • Choice of bean managed persistence if needed. © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans- page 18 Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display.
Name Service - Deployment Descriptor Deploy bean home name Benefits • EJB server has built-in name server. • Bean need not contain name specific code because decision is made at deployment time. • Some EJB servers support enterprise bean replication. © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans- page 19 Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display.
Name Service - Lookup My. Client Context ct= get. Initial. Context(…) ct. lookup(“Echo. Service”) Runtime Benefits • JNDI allows developer to use one interface for locating CORBA, LDAP, NDS, and file objects. • Allows management of enterprise wide services using naming hierarchy. © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans- page 20 Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display.
Transactions Benefits • Developers defer transaction logic to EJB server and container. • Distributed transactions (future). Picture provided by Sun Microsystems, Inc. © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans- page 21 Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display.
Security Deployment Descriptor Deploy Generated Bean Code • security logic security roles. . . EJB Benefits • Developer can specify permissions for each bean service at deployment time. • Builds on security of JDK. Detailed discussion by Robert Seacord. © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans- page 22 Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display.
Building an EJB Application How do we build an EJB application? Client Database Application Server © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans- page 23 Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display.
Step 1: Create Interfaces EJB Server Specifies the life cycle interfaces public interface Account. Home extends EJBHome{ public create(…) public find. By. Primary. Key(. . ) Home I/F Client Database Specifies the interface provided to bean clients public interface Account extends EJBHome{ public get. Name(…) public set. Name(…) © 1999 by Carnegie Mellon University Remote I/F SEI/CBS Initiative EJB specification Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display. This is generated You write this Enterprise Java Beans- page 24
Step 2: Create Implementation EJB Server Home I/F Client Entity. Bean implements Account Implements bean interfaces public class Account. Bean implements Entity. Bean { Remote I/F public void ejb. Activate(. . . ) {………} public void ejb. Passivate(…) {………. } public get. Name(…) {……. . } public set. Name(…) {……. . } © 1999 by Carnegie Mellon University SEI/CBS Initiative Database EJB specification Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display. This is generated You write this Enterprise Java Beans- page 25
Step 3: Deployment Descriptor EJB Server Home I/F Client Entity. Bean “Tells” the container how to deploy the bean (how to do DBMS access, transactions, security, naming, etc. ) implements Account Database Remote I/F Deployment descriptor EJB specification This is generated You write this © 1999 by Carnegie Mellon University SEI/CBS Initiative Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display. Enterprise Java Beans- page 26
Step 4: Deploy EJB Server Home obj Client implements Entity. Bean Home I/F implements Account Database delegates Remote obj implements Remote I/F Deployment descriptor EJB specification This is generated You write this © 1999 by Carnegie Mellon University SEI/CBS Initiative Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display. Enterprise Java Beans- page 27
Entity Bean Inheritance - 1 Java. rmi. Remote EJBMeta. Data Java. io. Serializable EJBObject EJBHome JDK Enterprise. Bean EJB Spec Entity. Bean Provider (Wombat) Container Provider (Acme) Produced by Acme tools Extends or implements interface Extends implementation, code generation or delegation © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans- page 28 Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display.
Entity Bean Inheritance - 2 Java. rmi. Remote EJBMeta. Data Java. io. Serializable EJBObject EJBHome Account. Home JDK Enterprise. Bean EJB Spec Entity. Bean Account. Bean Provider (Wombat) Container Provider (Acme) Produced by Acme tools Extends or implements interface Extends implementation, code generation or delegation © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans- page 29 Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display.
Entity Bean Inheritance - 3 Java. rmi. Remote EJBMeta. Data Java. io. Serializable Enterprise. Bean EJBObject EJBHome Account. Home Acme. Meta. Data JDK EJB Spec Entity. Bean Account. Bean Provider (Wombat) Account Acme. Home Acme. Remote Acme. Bean Container Provider (Acme) Acme. Account. Home Acme. Remote. Account Acme. Account. Meta. Data Produced by Acme. Account. Bean tools Extends or implements interface Extends implementation, code generation or delegation © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans- page 30 Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display.
EJB & CORBA EJB and CORBA are complimentary standards. EJB uses CORBA for: • Enabling non-Java clients to access EJB applications. • Interoperability for EJB environments that include systems from multiple vendors. EJB-to-CORBA mapping (separate specification) • Mapping of EJB interfaces to RMI-IIOP. • Propagating transaction context. • Propagating security context. • Interoperable naming service. © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans- page 31 Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display.
Summary The EJB architecture simplifies application development by: • providing pre-integrated solution framework • separating the business logic from distributed system services • providing standard service interfaces, including naming, transactions, and security • managing life cycle functions © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans- page 32 Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display.
References [1] Enterprise Java. Beans. TM Specification Version 1. 1 http: //java. sun. com/products/ejb/docs. html [2] Enterprise Java. Beans. TM Specification Version 1. 0 http: //java. sun. com/products/ejb/docs 10. html [3] Enterprise Java. Beans. TM Tools http: //java. sun. com/javaone 98/sessions/T 402/index. htm © 1999 by Carnegie Mellon University SEI/CBS Initiative Enterprise Java Beans- page 33 Delete this red box (from the slide master) after creating all of your slides. Keep everything inside the “safe area” for correct display.
- Slides: 33