Enterprise Java Beans Ye Zhou CS6704 Presentation Virginia Tech.

Slides:



Advertisements
Similar presentations
Session #, Speaker Name1 Enterprise JavaBeans Architecture Vlada Matena Sun Microsystems Inc.
Advertisements

12 Copyright © 2005, Oracle. All rights reserved. Implementing Business Tasks with Session EJBs.
11 Copyright © 2005, Oracle. All rights reserved. Creating the Business Tier: Enterprise JavaBeans.
Technische universität dortmund Service Computing Service Computing Prof. Dr. Ramin Yahyapour IT & Medien Centrum 12. November 2009.
EJB Entity Beans. Entity Beans Data versus logic Used to represent an instance rather than a collection of data (depending on underlying storage) Represents.
Development and Deployment Roles Venugopal Pakanati.
Distributed System Using Java 2 Enterprise Edition (J2EE) B.Ramamurthy.
Enterprise JavaBeans 2.0 Wu Lu (Cont’d). EJB2.0 Query Language EJB QL is a declarative language similar in many respects to SQL Is intended to be portable.
Enterprise JavaBeans Components. Objectives of This Chapter Introduce J2EE framework and EJB architecture Introduce the concepts of EJB component and.
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.
J2EE Part 2: Enterprise JavaBeans CSCI 4300 Images and code samples from jGuru EJB tutorial,
Enterprise Java Beans - (EJB)
EJB Enterprise Java Bean.
Seminar: Enterprise JavaBeans. Agenda Agenda Java™ 2 Platform Java™ 2 Platform Java™ 2 Platform,Enterprise Edition(J2EE) Java™ 2 Platform,Enterprise Edition(J2EE)
Writing Enterprise Applications with J2EE (Second lesson) Alessio Bechini June 2002 (based on material by Monica Pawlan)
Module 6 Message-Driven Beans. History Introduced in EJB 2.0 –Supports processing of asynchronous messages from a JMS provider Definition expanded in.
Distributed Object-Oriented Programming (3) – Enterprise JavaBeans SNU iDB Lab. Taewhi Lee May 14th, 2007.
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.
Advanced Java Session 7 New York University School of Continuing and Professional Studies.
Container-Managed Persistence (CMP) Entity Beans Lesson 3A / Slide 1 of 42J2EE Server Components Objectives In this lesson, you will learn to: Identify.
Enterprise JavaBeans Umer Farooq CS6704: Design Patterns & Component FrameworksFebruary 25, 2002.
Distributed Systems 1 Master of Information System Management Distributed Systems Persistence.
Enterprise Java Beans Part II Kyungmin Cho 2001/04/13.
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.
EJB Framework.  As we know, EJB is the center of the J2EE architecture that provides a sturdy framework for building enterprise applications. The major.
Message-Driven Beans and EJB Security Lesson 4B / Slide 1 of 37 J2EE Server Components Objectives In this lesson, you will learn about: Identify features.
Enterprise Java Bean Computer Networks Natawut Nupairoj, Ph.D. Department of Computer Engineering Chulalongkorn University.
Session Beans Objectives Introduction to Session Beans Local and Remote Session Beans Stateless and Stateful Session Beans Session Bean Lifecycle Accessing.
Session Beans -) stateless -) stateful. Session Beans A session bean represents a single client inside the J2EE server. To access an application that.
A TUTORIAL TO USING EJBs by SHREERAM IYER 09/17/2001.
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:
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.
Session Beans Based on: Patel, Brose, Silverman, Mastering Enterprise JavaBeans 3.0.
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.
13 Copyright © 2004, Oracle. All rights reserved. Managing Persistent Data in the Business Tier Entity EJBs.
Enterprise JavaBeans: Fundamentals. EJB Fundamentals(c)CDAC(Formerly NCST)2 Contents Introduction Technology Overview EJB Architecture EJB Specification.
D Copyright © 2004, Oracle. All rights reserved. BMP Entity EJBs J2EE Connector Architecture.
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.
Enterprise JavaBeans™ Trademark of Sun Microsystems, Inc.
Session Beans & Business Logic CS 486 Sagar Deshpande.
14 Copyright © 2004, Oracle. All rights reserved. Achieving State Management in the Business Tier.
JAVA & J2EE UNIT – 8 ENTERPRISE JAVA BEAN - EJB 28-Jun-16 Prepared by: SANTHIYA.M & GANGA V. C. Department: Computer Science & Engineering Course code:
1 EJB 3.0: There’s Something Different About You Martin Jäkle, TSBU Middleware.
©NIIT Session Beans Lesson 1B/ Slide 1 of 37J2EE Server Components Objectives In this lesson, you will learn to: Describe the characteristics of session.
Enterprise Java Beans Overview
Entity Bean Chuyên đề Lập trình Java & J2EE Chương 15
Structure of Enterprise Java Beans
Architectural Overview
Objectives In this lesson, you will learn to:
EJB Types Alessio Bechini June 2002.
Understanding and Designing with EJB
Enterprise Java Beans Bina Ramamurthy 1/13/2019 B.Ramamurthy.
Knowledge Byte In this section, you will learn about:
Understanding and Designing with EJB
Enterprise Java Beans Bina Ramamurthy 4/5/2019 B.Ramamurthy.
Objectives In this lesson, you will learn about:
Presentation transcript:

Enterprise Java Beans Ye Zhou CS6704 Presentation Virginia Tech

Entity Beans An in-memory Java representation of persistent data -- a view into a database Long-lived – as long as data lives Shared access from multiple users Transactional Can survive from the server crash

Entity Bean Model Entity Bean class ejbLoad() – load state from underlying DB ejbStore() – synchronize the state regularly ejbRemove() – remove object when client calls ejbActivate() – bean instance out of pool ejbPassivate() – bean instance disassociated setEntityContext() – called by container on creation unsetEntityContext() – called by container before being removed Primary Key class Unique Identifier

Entity Bean usage

BMP & CMP BMP – Bean Managed Persistence an entity bean that synchronizes its state with the database manually CMP – Container Managed Persistence EJB container will do it instead

BMP & CMP

Entity bean example

import javax.ejb.*; import java.rmi.remoteException; public interface AccountHome extends EJBHome{ Account create(String accountID, String ownerName) throws CreateException, AccountException; public Account findByPrimaryKey(AccountPK key) throws FinderException, RemoteException; public Collection findByOwnerName(String name) throws FinderException, RemoteException; public double getTotalBankValue() throws RemoteException, AccountException; }

Entity bean example import java.io.Serializable; public class AccountPK implements java.io.Serializable{ public String accountID; public AccountPK(String id){ this.accountID = id; } public String toString() { return accountID: } public boolean equals(Object account){ return ((AccountPK)account).accountID.equals(accountID); }

Entity bean example public class AccountBean implements EntityBean{ protected EntityBeanContext ctx; private String accountID; //primary key private String ownerName; private double balance; //getter & setter on fields public setXXX(String value) public String getXXX() …

Entity bean example //Business Logic methods public void Deposit(double amt) throws AccountException { balance+=amt; } public void WithDraw(double amt) throws AccountException { if(amt > balance) { throw new AccountException(accountID+“Limit reached”); } else balance-=amt; }

Entity bean example //EJB required methods public void ejbLoad() { AccountPK account = (AccountPK) ctx.getPrimaryKey(); String id = account.toString(); PreparedStatement ps =null; Connection con=null; try{ con=getConnection(); ps = con.preparedStatement(“select owner, balance from accounts where id = ?”); ps.setString(1,id); ResultSet rs = ps.executeQuery(); rs.next(); ownerName = rs.getString(1); balance = rs.getDouble(2); }catch(Exception e){throw new EJBException(“Fail to load from DB”);} }

Message-Driven Bean Motivation Performance: RMI-IIOP is a blocking protocol Reliability: RMI-IIOP can’t survive from the server failure Multiple senders and receivers: RMI-IIOP is connection-oriented, which is not possible for clients to broadcast the events to servers.

Message-Driven Bean Definition A special EJB component that can receive JMS messages.

Message-Driven Bean Life cycle

Message-Driven Bean Characteristics No home interface, local home interface and remote interface It has a single, weakly-couple typed business method “OnMessage” No return values Stateless Do not send Exception back to clients Subscription can be durable or non-durable

Message-Driven Bean example import javax.ejb.*; import javax.jms.*; public sampleBean implements MessageDrivenBean, MessageListener { protected MessageDrivenContext ctx; public void setMessageDrivenContext(MessageDrivenContext ctx) {this.ctx=ctx;} public void ejbCreate() {System.err.println(“bean initialized”);}

Message-Driven Bean example public void onMessage(Message msg) { if(msg instanceOf TextMessage) { TextMessage tm=(TextMessage)msg; try{ String text = tm.getText(); System.err.println(“Text is”+text); }catch(JMSException e) { e.printStackTrace(); } } public void ejbRemove() { System.err.println(“bean removed”);} }

Transaction Features ACID Types Programmatic Declarative Client-initiated Package Javax.transaction.*

Reference Ed Roman, “Mastering Enterprise Javabeans ”, John Wiley & Sons Inc., 2002 Linda DeMichiel, “Enterprise Javabeans Spec V2.0”, Sun Microsystem, 2001 Gopalan Raj,