©1996-2000 jGuru.com Enterprise JavaBeans Fundamentals.

Slides:



Advertisements
Similar presentations
12 Copyright © 2005, Oracle. All rights reserved. Implementing Business Tasks with Session EJBs.
Advertisements

11 Copyright © 2005, Oracle. All rights reserved. Creating the Business Tier: Enterprise JavaBeans.
Enterprise JavaBeans Ruslana Svidzinska CSE690. What is EJB? l An EJB is a specialized, non-visual JavaBean that runs on a server. l EJB technology supports.
6/1/20151 Luca Simone Software Engineering 2 a.a. 2001/2002.
1 Softsmith Open Learning - EJB 21-Nov Enterprise Java Beans Introduction –Application ServerApplication Server –Java 2 Enterprise EditionJava.
Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 1 Topics: Java Remote Method Invocation (RMI) Enterprise JavaBeans (EJB) Overview.
Sapana Mehta (CS-6V81) Overview Of J2EE & JBoss Sapana Mehta.
Introduction to Enterprise JavaBeans. Integrating Software Development Server-side Component Model Distributed Object Architecture –CORBA –DCOM –Java.
Overview of The Java Platform Solution for E-Business Applications : JSP, Servlet and EJB.
Copyright W. Howden1 Lecture 19: Intro to O/O Components.
J2EE Kenneth M. Anderson CSCI Web Technologies October 3, 2001.
Emmanuel Cecchet et al.  Performance Scalability of J2EE application servers.  Test effect of: ◦ Application Implementation Methods ◦ Container Design.
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
EJB. Component Characteristics An enterprise Bean typically contains business logic that operates on the enterprise’s data. An enterprise Bean’s instances.
Brad Rippe Fullerton College. What you need to get started? JDK 1.3 standard for compilation J2EE - SDK1.2.1 App Server - An EJB Container/Web Container.
Enterprise Java Beans CS-422. Application Servers In the late 1980s and though the mid 1990s a number of corporations (Broadvision, Netscape…) marketed.
1 Session Bean Chuyên đề Lập trình Java & J2EE Chương 14 Biên soạn: Th.S Nguyễn văn Lành.
J2EE Part 2: Enterprise JavaBeans CSCI 4300 Images and code samples from jGuru EJB tutorial,
Enterprise Java Beans - (EJB)
EJB Enterprise Java Bean.
Writing Enterprise Applications with J2EE (Second lesson) Alessio Bechini June 2002 (based on material by Monica Pawlan)
Entity Beans BMP Celsina Bignoli
Middleware Technology (J2EE/EJB) Entity Bean. 2 Introduction to Entity Beans Persistence Concepts Entity beans are persistent objects that can be stored.
Lecture 8 Advanced Topics in Enterprise JavaBeans.
Advanced Java Session 7 New York University School of Continuing and Professional Studies.
© jGuru.com Enterprise JavaBeans Fundamentals.
Enterprise Java Beans Part I Kyungmin Cho 2001/04/10.
Container-Managed Persistence (CMP) Entity Beans Lesson 3A / Slide 1 of 42J2EE Server Components Objectives In this lesson, you will learn to: Identify.
Distributed Systems 1 Master of Information System Management Distributed Systems Persistence.
Enterprise Java Bean Matt. 2 J2EE 3 J2EE Overview.
The Triad of Beans I Oleh: Dini Addiati ( ) Fahrurrozi Rahman ( Y) Irfan Hilmy ( ) Salman Azis A ( ) Aziiz Surahman.
Presented By Pradeep K Sahu. What will be the Contents of the Seminar ? What is EJB ? EJB Architecture Types of EJB Session Entity Why EJB ? Writing a.
Enterprise JavaBeans. Lesson 1: Introduction to Server-Side Component Software.
Enterprise JavaBeans. What is EJB? l An EJB is a specialized, non-visual JavaBean that runs on a server. l EJB technology supports application development.
Introduction to J2EE Architecture Portions by Kunal Mehta.
EJB Framework.  As we know, EJB is the center of the J2EE architecture that provides a sturdy framework for building enterprise applications. The major.
Enterprise Java Bean Computer Networks Natawut Nupairoj, Ph.D. Department of Computer Engineering Chulalongkorn University.
第十四章 J2EE 入门 Introduction What is J2EE ?
Enterprise JavaBeans Understanding EJB Components Version 0.1 Kamal Wickramanayake
© jGuru.com Enterprise JavaBeans Fundamentals.
Creating competitive advantage Copyright © 2003 Enterprise Java Beans Presenter: Wickramanayake HMKSK Version:0.1 Last Updated:
20 September 2007Kaiser: COMS W4156 Fall COMS W4156: Advanced Software Engineering Prof. Gail Kaiser
Introduction to Enterprise JavaBeans Topics In Systems Architecture Barry Herbold
EJB Overview: Constraint Types and Enforcement in JBoss Elissa Newman Fluid Meeting 6/3/04.
Entity Beans & Persistence Chris Alexander CS 486 Spring 2001.
Enterprise Java Bean Technology Briefing Markus Hebach.
Introduction to EJB. What is an EJB ?  An enterprise java bean is a server-side component that encapsulates the business logic of an application. By.
Java Programming: Advanced Topics 1 Enterprise JavaBeans Chapter 14.
Enterprise Java Beans N.V.RAJASEKHAR REDDY. Definition of EJB EJBs are the components that are the set of classes and interfaces deployed within a container.
Copyright © 2002 ProsoftTraining. All rights reserved. Enterprise JavaBeans.
Enterprise Java Beans Ye Zhou CS6704 Presentation Virginia Tech.
13 Copyright © 2004, Oracle. All rights reserved. Managing Persistent Data in the Business Tier Entity EJBs.
©NIIT Introducing Enterprise JavaBeans (EJB) Lesson 1A / Slide 1 of 43J2EE Server Components Objectives In this lesson, you will learn about: The features.
Enterprise JavaBeans: Fundamentals. EJB Fundamentals(c)CDAC(Formerly NCST)2 Contents Introduction Technology Overview EJB Architecture EJB Specification.
Enterprise JavaBeans. Lesson 1: Introduction to Server-Side Component Software.
Middleware Technology (J2EE/EJB) EJB Fundamentals.
Advanced Java Session 7 New York University School of Continuing and Professional Studies.
EJB. Introduction Enterprise Java Beans is a specification for creating server- side scalable, transactional, multi-user secure enterprise-level applications.
14 Copyright © 2004, Oracle. All rights reserved. Achieving State Management in the Business Tier.
©NIIT Session Beans Lesson 1B/ Slide 1 of 37J2EE Server Components Objectives In this lesson, you will learn to: Describe the characteristics of session.
Entity Bean Chuyên đề Lập trình Java & J2EE Chương 15
Ruslana Svidzinska CSE690
Structure of Enterprise Java Beans
Luca Simone Software Engineering 2 a.a. 2001/2002
Objectives In this lesson, you will learn to:
Understanding and Designing with EJB
Enterprise Java Beans Bina Ramamurthy 1/13/2019 B.Ramamurthy.
Understanding and Designing with EJB
Enterprise Java Beans Bina Ramamurthy 4/5/2019 B.Ramamurthy.
Knowledge Byte In this section, you will learn about:
Presentation transcript:

© jGuru.com Enterprise JavaBeans Fundamentals

2 Agenda Enterprise JavaBeans defined EJB and Distributed Computing EJB Architecture Entity beans Session bean Deployment EJB Clients

© jGuru.com Enterprise JavaBeans: Defined

4 What is Enterprise JavaBeans The Enterprise JavaBeans architecture is a component architecture for the development and deployment of object-oriented distributed enterprise-level applications. Applications written using the Enterprise JavaBeans architecture is scalable, transactional and multi-user secure. These applications may be written once, and deployed on any server platform that supports the Enterprise JavaBeans specification Sun Microsystems Enterprise JavaBeans™ Specification, v1.1, Copyright 1999 by Sun Microsystems, Inc.

5 In English Please! Enterprise JavaBeans is a specification –(a piece of paper) not a product –As is XML, CORBA, TCP/IP Enterprise JavaBeans is Java based –Defined by Sun Microsystems –Applications are written in Java Enterprise JavaBeans is distributed objects –Similar to CORBA | Java RMI (JRMP) | Microsoft MTS Enterprise JavaBeans is components –Similar to regular JavaBeans (similar but not the same) –Similar to COM/DCOM/COM+ Enterprise JavaBeans products are Transactional Monitors –Similar to CICS | TUXEDO –A complete environment for a distributed object

© jGuru.com Distributed Computing

7 Two-Tier Computing

8 Client: Presentation and Application logic –Text, Graphs, Widgets –Business logic –Data Access Backend: Database –Data –Security, Transactions –Resource Management

9 Multitier Computing

10 3-Tier Computing Client: Presentation Logic –Text, Graphs, Widgets Middle-Tier: Application Logic –Business Logic –Security, Transactions –Resource Management –Data Access Backend: Database –Data

11 Motivations for using 3-tier over 2-tier Quality of Service –Scalability –Availability –Performance Versatility –Flexibility –Extensibility

12 COM+ Simple Programming Model –Attribute based programming –Focus on Business Logic –Simple API –Well defined Lifecycle Limited Portability –Only on Windows Platform –One vendor: Microsoft

13 CORBA Complex Programming Model –Different API for each Service –Explicit use of service APIs –Lifecycle depends on services used Fairly Portable –Many Languages, many platforms (pro and con) –Non-Uniform support of Services

14 Enterprise JavaBeans Simple Programming Model –Attribute based programming –Focus on Business Logic –Simple API –Well defined Lifecycle Portable –Specification ensures basic services –Component Packaging (JARs and XML DD) –Java

© jGuru.com EJB Architecture

16 Foundation of EJB The EJB Container Enterprise bean components

17 The EJB Container Containers host enterprise beans Containers isolate beans from clients Containers manage enterprise beans Bean-Container interface –callback methods –EJBContext –JNDI ENC

18

19 Enterprise Bean Components Implements the EJB API Defined by an XML Deployment Descriptor Adheres to the EJB specification. Packaged in a JAR file

20 Component API: Interfaces and Classes Home Interface –Extends javax.ejb.EJBHome –Provides remote access to create, find, remove beans Remote Interface –Extends javax.ejb.EJBObject –Provides remote access to business methods Bean Class –Extends a javax.ejb.EnterpriseBean type –Implements business logic and other functionality

21

22 Remote Interface import javax.ejb.EJBObject; import java.rmi.RemoteException; public interface Customer extends EJBObject { public Name getName() throws RemoteException; public void setName(Name name) throws RemoteException; public Address getAddress() throws RemoteException; public void setAddress(Address address) throws RemoteException; }

23 Home Interface import javax.ejb.EJBHome; import javax.ejb.CreateException; import javax.ejb.FinderException; import java.rmi.RemoteException; public interface CustomerHome extends EJBHome { public Customer create(Integer customerNumber) throws RemoteException, CreateException; public Customer findByPrimaryKey(Integer customerNumber) throws RemoteException, FinderException; public Enumeration findByZipCode(int zipCode) throws RemoteException, FinderException; }

24

25 Bean Class import javax.ejb.EntityBean; public class CustomerBean implements EntityBean { Address myAddress; Name myName; CreditCard myCreditCard; public Name getName() { return myName; } public void setName(Name name) { myName = name; } public Address getAddress() { return myAddress; } public void setAddress(Address address) { myAddress = address; }... }

26

27 Types of Beans Entity Beans –Represent data in the database –Include behavior (business methods) Session Beans –Represent tasks or processes –Do not represent data, but can access data –Manage the interactions of other beans

© jGuru.com Entity Beans

29 Characteristics of Entity beans Model entities in a system –represent their data and associated behavior one or many relational database tables an object in an object database an entity in a legacy system –Nouns: People, Places or Things Customer, Employee, Student City, Building, Hotel Room Order, Organization, Health Benefit –Two Kinds of Persistence Container-Managed Persistence Bean-Managed Persistence

30 Container-Managed Persistence (CMP) Persistence is automatic –inserts, updates, and deletes are automatic –transactions managed automatically Focus on business logic, not persistence Components more portable –not backend specific –shrink wrapped components Requires sophisticated data mapping tools

31 public interface javax.ejb.EntityBean { public void setEntityContext(); public void unsetEntityContext(); public void ejbLoad(); public void ejbStore(); public void ejbActivate(); public void ejbPassivate(); public void ejbRemove(); } import javax.ejb.EntityBean; public class CustomerBean implements EntityBean { Address myAddress; Name myName; CreditCard myCreditCard;... public void setEntityContext(){} public void unsetEntityContext(){} public void ejbLoad(){} public void ejbStore(){} public void ejbActivate(){} public void ejbPassivate(){} public void ejbRemove(){} }

32 Callback Methods in CMP setEntityContext() / unserEntityContext() –EntityContext is an interface to container client identity, transactions, self ejbLoad() / ejbStore( ) –database synchronization notifications ejbLoad() just after bean fields refreshed from database ejbStore() just prior to database write

33 Callback Methods in CMP (cont..) ejbCreate()/ ejbRemove() –In response to client invocations –ejbCreate() just before inserting a new record(s) –ejbRemove() just before deleting record(s) ejbActivate( ) / ejbPassivate( ) –Resource Conservation Passivated instances are evicted or pooled Most container pool entity beans –Notify bean when passivation is occurring ejbPassivate() just before passivation ejbActivate() just after bean is restored

34 Bean-Managed Persistence Persistence is not automatic –Database access coded directly into bean Callback methods dictate when to insert, update, delete Database connections managed automatically Transactions and connections managed automatically Focus on business logic and persistence More control over persistence Don’t need Sophisticated data mapping tools

35 Callback Methods in BMP ejbLoad() / ejbStore( ) –Database synchronization notifications ejbLoad() tells bean to write state to database ejbStore() tells bean to read state from database ejbCreate()/ ejbRemove() –In response to client invocations –ejbCreate() tells bean to insert a new record(s) –ejbRemove() tells bean to delete record(s)

36 Callback method in BMP (cont.…) setEntityContext() / unserEntityContext() –Same as CMP ejbActivate( ) / ejbPassivate( ) –Same as CMP

37 Characteristics of Session beans Not persistent, but can access database Model tasks, process or agents –Charge a credit card –Process a stock purchase –Perform hotel reservations Manage interactions of other beans Two Kinds of Session beans –Stateless –Stateful

38 Stateless Session Beans Perform transitive tasks Independent business methods –Act on method arguments, not bean state –Similar to procedures in traditional TPM systems Most performant bean type Not dedicated to one client

39 Callback methods in stateless beans setSessionContext() –SessionContext is an interface to container Client identity, transactions, self ejbCreate()/ ejbRemove() –Not in response to client invocations –ejbCreate() beginning of bean instance life –ejbRemove() end of bean instance life (before eviction) ejbPassivate()/ejbActivate() –Not used in stateless beans

40 Stateful Session Beans Act on behalf of one client –Extension of the client –Agent that performs work for the client Interdependent business methods –Bean has conversational state –Method depend on conversational state Dedicated to exactly one client

41 Callback methods in stateful beans setSessionContext() –SessionContext is an interface to container Client identity, transactions, self ejbCreate()/ ejbRemove() –In response to client invocations –ejbCreate() initialize conversational state –ejbRemove() just before bean is destroyed

42 Callback methods in stateful beans (cont.…) ejbPassivate()/ejbActivate() –Passivation to secondary storage –ejbPassivate() just before passivation –ejbActivate() just after passivation

© jGuru.com EJB Deployment

44 Function of a Deployment Descriptor Describe bean(s) to the container –interfaces and class –type of bean (entity or session) –identify primary key & container-managed fields Declare runtime behavior –transaction attributes of methods –authorization access to method –persistence type (BMP vs. CMP) Written in XML

45 XML Deployment Descriptors XML Document –uses a DTD to verify structure –text document can view with any text editor –mark-up language start and end tags similar to HTML DTD (Document Type Definition) –defines all valid tags –defines nesting of tags

© jGuru.com EJB Clients

47 Types of Clients Enterprise beans J2EE Application Components Java Applications Java Applets Servlets JSP

48 Example: J2EE Application Component CustomerHome home; Object ref; // Obtain a reference to the CustomerHome ref = jndiContext.lookup("java:comp/env/ejb/Customer"); // Cast object returned by the JNDI lookup to the // appropriate datatype home = PortableRemoteObject.narrow(ref, CustomerHome.class); // Use the home interface to create a // new instance of the Customer bean. Customer customer = home.create(customerID); // Use a business method on the Customer. customer.setName(someName);

49 Java RMI-IIOP EJB 1.1 clients use the Java RMI-IIOP API Underlying protocol doesn’t have to be IIOP EJB 2.0 will require IIOP as the protocol Requirement smoothes transition to EJB 2.0 PortableRemoteObject.narrow( ) because CORBA doesn’t support native casting.

50 Topic Review Defined Enterprise JavaBeans EJB and Distributed Computing EJB Architecture Entity beans Session bean Deployment EJB Clients

51 Online Resources jGuru EJB FAQ – Sun EJB Page – EJBNow –