EJB Entity Beans. Entity Beans Data versus logic Used to represent an instance rather than a collection of data (depending on underlying storage) Represents.

Slides:



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

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.
Container Managed Persistence. General Guidelines Home and Remote interfaces are implemented the same as for bean managed persistence Entity Bean class.
June 1999 EJB1 EJB and CHAIMS Dorothea Beringer Enterprise Java Beans and how to build a CHAIMS infrastructure using the EJB paradigm.
Enterprise Java Beans Welcome to the world of “Distributed System” Presented By: Sameer Nanda Date: 12/17/03.
Copyright W. Howden1 Lecture 19: Intro to O/O Components.
“DOK 322 DBMS” Y.T. Database Design Hacettepe University Department of Information Management DOK 322: Database Management Systems.
J2EE Kenneth M. Anderson CSCI Web Technologies October 3, 2001.
Lecture The Client/Server Database Environment
Data Persistence and Object-Relational Mapping Slides by James Brucker, used with his permission 1.
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
Database System Concepts and Architecture Lecture # 3 22 June 2012 National University of Computer and Emerging Sciences.
Introduction –All information systems create, read, update and delete data. This data is stored in files and databases. Files are collections of similar.
EJB. Component Characteristics An enterprise Bean typically contains business logic that operates on the enterprise’s data. An enterprise Bean’s instances.
1 J2EE Components. 2 Application Servers relieve the programming burden for business distributed components. They provide support for system level services.
Enterprise Java Beans - (EJB)
1 Advanced Computer Programming Databases. Overview What is a database? Database Basics Database Components Data Models Normalization Database Design.
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.
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 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.
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.
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.
1 Part 2: EJB Persistency Jianguo Lu. 2 Object Persistency A persistent object is one that can automatically store and retrieve itself in permanent storage.
Chapter 14 - Designing Data Access Classes1 Chapter 14 Designing Data Access Classes.
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:
Database Management Systems (DBMS)
EJB Overview: Constraint Types and Enforcement in JBoss Elissa Newman Fluid Meeting 6/3/04.
Entity Beans & Persistence Chris Alexander CS 486 Spring 2001.
© jGuru.com EJB State Diagrams. Simple Lifecycle of Session Bean ClientEJBHomeEJBObjectContainerContextInstanceData Store setSessionContext(ctxt)
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 25 I’m Suffering from Information Overload.
Chapter 24 I’m Suffering from Information Overload (Access Databases) Clearly Visual Basic: Programming with Visual Basic nd Edition.
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.
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.
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.
1 Information Retrieval and Use De-normalisation and Distributed database systems Geoff Leese September 2008, revised October 2009.
INFORMATION TECHNOLOGY DATABASE MANAGEMENT. A database is a collection of information organized to provide efficient retrieval. The collected information.
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
Structure of Enterprise Java Beans
Database Fundamentals
Understanding and Designing with EJB
Luca Simone Software Engineering 2 a.a. 2001/2002
Objectives In this lesson, you will learn to:
EJB Types Alessio Bechini June 2002.
Understanding and Designing with EJB
Entity Beans B.Ramamurthy 2/17/2019 BR.
Knowledge Byte In this section, you will learn about:
Database Design Hacettepe University
Understanding and Designing with EJB
Enterprise Java Beans.
Knowledge Byte In this section, you will learn about:
Presentation transcript:

EJB Entity Beans

Entity Beans Data versus logic Used to represent an instance rather than a collection of data (depending on underlying storage) Represents –a row in a table –an object instance in a OO database

Example Examples –Student in the class –Customer –Ingredients in a recipe Other criteria –must have a unique primary key

Figure 5.1

Figure 5.2

Managing Entity Beans When client needs access, loaded into the application container At appropriate time, the bean in written back to permanent storage Two strategies –container managed –bean-managed

Call backs –EJBStore() called by container when data needs to be persisted –EJBLoad() called by container when data needs to be retrieved How often to refresh/recall is a little complicated –related to transactional state Managing Entity Beans (ctd)

Called by container not client

How many instances? If only one instance, all clients end up being lock-stepped. If more than one instance of a bean (row), one per client, you run the risk of corruption due to race conditions. Give the management to the container Let container use call-backs to keep the bean consistent across all instances(clients)

Other things to save Data is saved/restored via ejbLoad() and ejbStore() Other items such as socket connections define the state of the bean and need to be stored. These non-data items like socket/file connections are managed via ejbPassivate() and ejbActivate() One doesn’t necessarily dictate the other

Other things to save (ctd) Assume a socket connection is part of the bean. Another client updates a property. Container may need to update bean but socket may not need to be opened or closed. Similarly closing a socket doesn’t imply the need to store bean data.

Steps in creating an Entity Bean Access home interface Client calls create() which is like the constructor function. Container calls ejbCreate(). Each client has a separate bean synchronized by container. Bean returns primary key Container creates EJBobject and returns to creator the remote interface to use

Removal Use either home OR remote interface

Bean vs Container Managed Persistence Who writes the code to store the date to permanent storage. Container can manage it. My guess is that eventually the container managed persistence will dominate because it is less work Bean managed allows you to write to whatever store you want-> more flexibility -> more work

getPrimaryKey() Gives a bean a means to figure out which key IT is. Why wouldn’t it know? Could have been activated with a new key For ejbStore it would know “who” it is For ejbLoad it wouldn’t. ejbRemove() should check first in the event that it has been activated with a new key

Code

All Entity Beans must create these. Others for create and findmay apply also.

Implementation Guidelines Entity Beans

Finder Methods

Bean Managed Persistence Bank Account Example

THE Bean Bean-managed State Fields Business Logic Methods EJB required methods

Home<> (static-like) procedure Note: home interface is GetTotalBankValue()

EJB Entity Bean Implementation (things to note) ejbRemove() calls getPrimaryKey() ejbHomeGetTotalBankValue() illustrates how to use JDBC calls and a result set even though this result set has a single member (because of use of sum()) ejbCreate() and use of PreparedStatement ejbFindByOwnerName(..) returns Collection

EJB Entity Bean Implementation (ctd) Note the AccountBean() constructor –no parameters –used when Bean created by container, no key at this point Keys defined on ejbCreate() or ejbLoad(); ejbCreate() has parameters

Client Code (note) Home.getTotalBankValue(); findByOwnerName() returns Collection which can apparently be used to initialize an iterator. Calls home.create(id,owner) to get ejbCreate()

Entity Bean Life Cycle