The Triad of Beans I Oleh: Dini Addiati (1203000366) Fahrurrozi Rahman (120300042Y) Irfan Hilmy (1203000552) Salman Azis A (1203001001) Aziiz Surahman.

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.
EJB Entity Beans. Entity Beans Data versus logic Used to represent an instance rather than a collection of data (depending on underlying storage) Represents.
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.
Overview of The Java Platform Solution for E-Business Applications : JSP, Servlet and EJB.
Enterprise Java Beans Welcome to the world of “Distributed System” Presented By: Sameer Nanda Date: 12/17/03.
Application Server Lecture Paulo Barroso Kris Carver Todd Kitterman Eric Silva.
Copyright W. Howden1 Lecture 19: Intro to O/O Components.
J2EE Kenneth M. Anderson CSCI Web Technologies October 3, 2001.
CS 483 Enterprise and Web Application Programming
Emmanuel Cecchet et al.  Performance Scalability of J2EE application servers.  Test effect of: ◦ Application Implementation Methods ◦ Container Design.
EJB Fundamentals Celsina Bignoli
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.
15 - RMI/EJBCSC4071 Distributed Objects Java Remote Method Invocation Enterprise Java Beans.
1 J2EE Components. 2 Application Servers relieve the programming burden for business distributed components. They provide support for system level services.
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)
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)
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.
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.
Middleware Technology (J2EE/EJB) Stateful Session Bean.
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.
Session Beans -) stateless -) stateful. Session Beans A session bean represents a single client inside the J2EE server. To access an application that.
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:
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.
© jGuru.com EJB State Diagrams. Simple Lifecycle of Session Bean ClientEJBHomeEJBObjectContainerContextInstanceData Store setSessionContext(ctxt)
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
Structure of Enterprise Java Beans
Introduction to Enterprise JavaBean
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
Enterprise Java Beans Bina Ramamurthy 1/13/2019 B.Ramamurthy.
Entity Beans B.Ramamurthy 2/17/2019 BR.
Knowledge Byte In this section, you will learn about:
Understanding and Designing with EJB
Enterprise Java Beans Bina Ramamurthy 4/5/2019 B.Ramamurthy.
Presentation transcript:

The Triad of Beans I Oleh: Dini Addiati ( ) Fahrurrozi Rahman ( Y) Irfan Hilmy ( ) Salman Azis A ( ) Aziiz Surahman ( ) Titin Farida(

Session Beans What is Session Beans?  A session beans represent work being performed for client code that is calling it Session Bean life time  Equivalent of a session of the client code that is calling the session bean  Non-persistent  Could be as long as a browser window is open, as long as your java applet is running, as long as your java application is open,as long as another bean is using your bean.

SESSION BEANS SUB TYPES Stateful Session Bean Stateless Session Bean stateful stateless MonSessionBean Atribut method ejbCreate(Arg arg) MonSessionBean method ejbCreate()

Stateful Session Bean  a bean that is designed to service business processes that span multiple method requests or transactions  Retaining state on behalf of an individual client  If state is changed during a method invocation, that same state will be available to that same client upon the following invocation Stateless Session Bean  a bean that holds conservations that span a single method call  Do not hold multhimethod conservations with their clients.  Can be pooled, reused, and swapped from one client to another client on each method call  Example: credit card verification

Characteristic of Stateful Session Beans Passivation  Container use object serialization (or equivalent protocol ) to convert the bean’s conversational state to bit blob and write out state to disk  The bean instance can be reassigned to a different client, and can hold a brand- new conversation with that new client Activation  A serialized blob that had been written is read back into memory and converted to in-memory bean data What makes the whole process work??  javax.ejb.EnterpriseBean interface extends java.io.Serializable  every enterprise bean class indirectly implements this interface  reapplied recursively on those objects

Entity Beans Entity Beans are persistent objects that can be stored in permanent storage.

Features of Entity Beans Entity Beans Survive Failures. They survive critical failures such as server crashing or even database crashing. Entity Beans Instance Are a View into a Database. The object and the database itself are one and the same. This means update to the object will update the database too. Several Entity Beans Instances May Represent the Same Underlying Data. EJB dictates only single thread can run within a bean instance. We could allow containers to instantiate multiple instance of the same entity bean class. This would allow many clients to concurrently interact with separate instance, each represent the same entity data.

Features of Entity Beans Entity Bean Instances Can Be Pooled.  Entity bean instances are recyclable objects and may be pooled depending on container’s policy.  The container may pool and reuse entity bean instances to represent different instances of the same type of data. There Are Two Ways to Persist Entity Beans.  A bean-managed persistent entity bean is entity bean that must be persisted by hand. The component developer must write the code to translate the object in the database.  Another way is container-managed persistence. In this case, the container perform the persistence.

Features of Entity Beans Creation and Removal of Entity Beans.  Because entity beans instance and the underlying database are one and the same, the initialization of an entity bean instance should entail initialization of database data. Entity Beans Can Be Found.  Because entity bean data is uniquely identified in an underlying storage, entity beans can also be found rather than created.  We can define many ways to find an entity bean. Just list all methods in the entity bean home interface. These are called finder methods.

Features of Entity Beans We Can Modify Entity Bean Data without Using EJB.  We can directly modifying the underlying database where the bean data is stored. For example we can simply delete/create the entity bean data by directly delete/add the row in the database.

Writing Bean-Managed Persistent Entity Beans: A Bank Account Implements javax.ejb.EntityBean Finding existing entity beans: ejbFind() (finder methods). Create java files Create deployment descriptor (XML file) Create container-specific deployment descriptor Setting up the database Running the client program

javax.ejb.EntityBean interface public interface javax.ejb.EntityBean extends javax.ejb.EnterpriseBean { public void setEntityContext(javax.ejb.EntityContext); public void unsetEntityContext(); public void ejbRemove(); public void ejbActivate(); public void ejbPassivate(); public void ejbLoad(); public void ejbStore(); } javax.ejb.EnterpriseBean interface public interface javax.ejb.EnterpriseBean implements java.io.Serializable{ }

ejbFind() Finder methods : Find existing bean in storage, load old entity bean data, not create new database. Example other finder methods: /** Finds the unique bank account indexed by primary key */ public AccountPK ejbFindByPrimaryKey(AccountPK key) throws FinderException {...} /** Find the all product entity beans. Return a collection of primary keys */ public Collection ejbFindAllProducts() throws FinderException {...}

Finder Methods Rules All finder methods must begin with ejbFind You must have at least one finder method, called ejbFindByPrimaryKey. You can have many different finder methods, each with different names and different parameters. A finder method must return either primary key for the entity bean it finds or a collection of primary keys if it finds more than one. As with ejbCreate(), client do not invoke your finder methods on the bean instance itself.

Account examples.AccountHome examples.Account. The Account Bean’s ejb-jar.xml deployment descriptor

Bean-Managed Persistent Example: A Bank Account > java.rmi.Remote > javax.ejb.EJBLocalObject > javax.ejb.EJBObject > javax.ejb.EJBHome > javax.ejb.EJBLocalHome > Bank Account Local Interface > Bank Account Remote Interface > Bank Account Home Interface > Bank Account Local Home Interface Bank Account EJB Local Object Bank Account EJB Object Bank Account Home Object Bank Account Local Home Object > javax.ejb.EnterpriseBean > javax.ejb.EntityBean Bank Account Bean Implementation Class Bank Account Primary Key Class > java.io.Serializable Comes with Java 2 Platform Comes with EJB Distribution Supplied by Bean Provider (We Will Write) Generated for Us by Container Vendor’s Tools Figure 1. The bank account object model

The files that we must create for our entity bean component Account.java : is our entity bean’s remote interface-what remote clients use to call our bean’s methods. AccountLocal.java : is our entity bean’ local interface-what local clients use to call our bean’s methods. AccountHome.java : our home interface AccountLocalHome.java : our local home interface, the higher performing home interface used by local clients. AccountPK.java : our entity bean’s primary key class.

AccountBean.java : our bean implementation code divided into several sections. Bean-managed state fields : persistable fields of our entity bean class. Our bean instance will load and store database data into these fields. Business logic methods : this method perform services for clients, such as withdrawing or depositing into an account. EJB-required methods : these are EJB-required methods that the container calls to manage our bean. AccountException.java Client.java

ejbRemove() 1: ejbCreate() 2: ejbPostCreate() Does Not Exist Pooled 1: unsetEntityContext() 2: JVM Will Garbage Collect and Call finalize() 1:newInstance() 2:setEntityContext() Passive Your Bean: 1: ejbStore() 2: ejbPassivate() Activate Your Bean: 1: ejbActivate() 2: ejbLoad() Ready Business Method ejbStore()ejbLoad() ejbFind() ejbHome() The lifecycle of a bean-managed persistent entity bean Figure 2. The lifecycle of a bean-managed persistent entity bean