Enterprise Java Beans - (EJB)

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.
Transactions Celsina Bignoli Motivations Atomic operations –Group of operation that must all succeed or all fail Network or machine.
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.
June 1999 EJB1 EJB and CHAIMS Dorothea Beringer Enterprise Java Beans and how to build a CHAIMS infrastructure using the EJB paradigm.
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.
Copyright W. Howden1 Lecture 19: Intro to O/O Components.
SEI/CBS Initiative Software Engineering Institute Carnegie Mellon University Pittsburgh, PA Sponsored by the U.S. Department of Defense © 1999.
Version # Software Engineering Institute Carnegie Mellon University Pittsburgh, PA Sponsored by the U.S. Department of Defense © 1999 by Carnegie.
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
EJB Overview Celsina Bignoli Distributed Business Applications Server DB Client DB Server DB.
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.
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,
Seminar: Enterprise JavaBeans. Agenda Agenda Java™ 2 Platform Java™ 2 Platform Java™ 2 Platform,Enterprise Edition(J2EE) Java™ 2 Platform,Enterprise Edition(J2EE)
© jGuru.com EJB Transactions. Transactions Simple Transaction –Transaction = more than one statement which must all succeed (or all fail) together.
Entity Beans BMP Celsina Bignoli
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.
Enterprise JavaBeans Umer Farooq CS6704: Design Patterns & Component FrameworksFebruary 25, 2002.
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.
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.
Java Transaction API Sean C. Sullivan
Enterprise Java Beans Java for the Enterprise Server-based platform for Enterprise Applications Designed for “medium-to-large scale business, enterprise-wide.
Session Beans -) stateless -) stateful. Session Beans A session bean represents a single client inside the J2EE server. To access an application that.
J2EE Overview ver 1.0Page 1 © Wipro Technologies Talent Transformation J2EE Overview.
© jGuru.com Enterprise JavaBeans Fundamentals.
1 Transactions Michael Brockway Sajjad Shami CG0165: Advanced Applications Development in Java Northumbria University School of Computing, Engineering.
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
Assignment of JAVA id : BSSE-F10-M-10-JAVA1 Overview of J2EE/Session 2/Slide 1 of 38.
EJB Overview: Constraint Types and Enforcement in JBoss Elissa Newman Fluid Meeting 6/3/04.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Enterprise Java Bean Technology Briefing Markus Hebach.
Enterprise JavaBeans Session Beans. Session beans are a type of Enterprise JavaBean component designed to implement business logic responsible for managing.
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.
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.
©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.
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
Luca Simone Software Engineering 2 a.a. 2001/2002
Objectives In this lesson, you will learn to:
Enterprise Java Beans Bina Ramamurthy 1/13/2019 B.Ramamurthy.
Component-based Applications
Component Technology Bina Ramamurthy 2/25/2019 B.Ramamurthy.
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 - (EJB) By Bharath Reddy Allam By Bharath Reddy Allam

EJB Overview Enterprise Java Beans Technology is part of larger Framework - The J2EE (Java 2 Enterprise Edition) Component Architecture for Distributed Systems Framework for creating middleware

Why EJB? EJB Architecture simplifies the development of distributed enterprise applications. EJB Specification is a solution that is operating-system independent. Middleware Independence EJB defines a solution that eases the development and deployment of distributed applications

Why EJB? EJB enables the development of reusable and portable components. EJB has Broad Industry Support: Server Vendors and End Users.

EJB Vs JavaBeans EJB component model logically extends the JavaBeans component model to support server components. EJB components cannot be manipulated by a visual Java IDE in the same way that JavaBeans can, They are prepackaged pieces of application functionality that are designed to run in an application server. JavaBeans component model defines a standard mechanism to develop portable, Java components, such as widgets or controls. JavaBeans technology can be used in any visual Java technology integrated development environment (IDE)

EJB Architecture EJB Server EJB Container EJB Client Enterprise Java Beans Auxiliary Systems - JNDI, JTA, JavaMail

Roles in EJB Development EJB Developer - Person who provides implementations of EJB classes EJB Deployer - Responsible for Deploying EJB’s in EJB Server EJB Container Vendor - Provides software to install an EJB into an EJB Server EJB Server Vendor - Provides an Application Framework in which to run EJB Containers Application Developer - Who writes client applications that uses EJB.

EJB Server Is a High Level Process or Application that Manages and makes EJB Containers Visible Provides Access to System Services Provides Naming and Transaction Services

EJB Container Interface between Enterprise Java Bean and outside world Accessing of EJB is done through Container generated methods, which in turn call the EJB methods

EJB Clients Is an Application, Servlet, JSP or Applet that Find EJB Containers via JNDI Uses EJBHome to Create or Remove EJB from Container Uses EJBObject to Invoke Business Methods of EJB

Enterprise Java Beans Entity Session Bean 1. Bean Managed 1. Stateless 2. Container Managed Session Bean 1. Stateless 2. Stateful

Session Vs Entity Beans 1. Performs a task for a Client 2. Associated with a particular client 3. Non Persistent and do not survive System Shutdown Entity 1. Represents a business entity Object that exists in a persistent Storage 2. Shared by multiple clients 3. Persistent across multiple Invocations and survives System Shutdown

Passivation and Activation Passivation - Saving the state of a Bean to a persistent Storage Device and swapping it out Activation - Restoring the state of Bean from a persistent Storage Device and swapping it in Depends upon Container Provider Applies to both Session and Entity Beans

Stateless Vs Stateful Session Beans 1. Posses State during Client-Bean Session 2. Is passivated 3. One Per Client Stateless 1. No State during Client-Bean Session 2. Is not passivated 3. Can be shared by multiple clients

SessionBean Interface public abstract interface SessionBean extends EnterpriseBean{ public void setSessionContext(SessionContext ctx) throws EJBException, java.rmi.RemoteException public void ejbRemove() throws EJBException, java.rmi.RemoteException public void ejbActivate() throws EJBException, java.rmi.RemoteException public void ejbPassivate() throws EJBException, java.rmi.RemoteException }

Writing a Session Bean-Step 1 Create a Remote Interface - Should extend EJBObject - Provide the Business methods - Arguments and Return types must be valid RMI types - The throws Clause of the Business methods must include java.rmi.RemoteException

Writing a Session Bean-Step 2 Create Home Interface - Should extend EJBHome - The argument and return types of create method(s) must be valid RMI types - create method(s) should return the Remote Interface - Throws clause of create method(s) must include java.rmi.RemoteException and javax.ejb.CreateException

Writing a Session Bean-Step 3 Writing the Bean Class (SessionBean) - should implement SessionBean interface - Should be a public class, and cannot be abstract or final - contains public constructor with no Arguments - should implement ejbCreate methods whose arguments should correspond to create methods of Home Interface - Return type of ejbCreate methods should be void - throws clause of ejbCreate methods should implement javax.ejb.CreateException - implements Business Methods of Remote Interface

Writing an EJB Client Locate the Home Interface Create an Enterprise Bean Instance Invoke a Business Method upon the Enterprise Bean Remove the Bean

Life Cycle of Stateful SessionBean

Life Cycle of Stateless SessionBean

Container Vs Bean Managed EntityBean 1. Bean is responsible for saving its own state 2. Entity Bean consists Code for DB calls 3. Some times the code Contains DB specific calls which makes non portable Container-Managed EntityBean 1. Container is responsible for Saving the state of Bean 2. In DD, Specify the Container managed fields 3. Is Independent of Data Store, Such as a Relational Database

EntityBean Interface public abstract interface EntityBean extends EnterpriseBean{ public void setEntityContext(EntityContext ctx) throws EJBException, java.rmi.RemoteException public void unsetEntityContext() throws EJBException, public void ejbRemove() throws RemoveException, EJBException, public void ejbActivate() throws EJBException, java.rmi.RemoteException public void ejbPassivate() throws EJBException, java.rmi.RemoteException public void ejbLoad() throws EJBException, java.rmi.RemoteException public void ejbStore() throws EJBException, java.rmi.RemoteException }

Writing a Entity Bean - Step 1 Create a Remote Interface - Should extend EJBObject - Provide the Business methods - Arguments and Return types must be valid RMI types - The throws Clause of the Business methods must include java.rmi.RemoteException

Writing a Entity Bean - Step 2 Create Home Interface - Should extend EJBHome - The argument and return types of create method(s) must be valid RMI types - create method(s) should return the Remote Interface - Throws clause of create method(s) must include java.rmi.RemoteException and javax.ejb.CreateException

Writing a Entity Bean - Step 3 Writing the Bean Class (EntityBean) - should implement EntityBean interface - Should be a public class, and cannot be abstract or final - contains public constructor with no Arguments - should implement ejbCreate and ejbPostCreate method(s) whose arguments should correspond to create method(s) of Home Interface - Return type of ejbCreate method(s) is Primarykey - Return type of ejbPostCreate method(s) is void - throws clause of ejbCreate methods should implement javax.ejb.CreateException - implements Business Methods of Remote Interface

Life Cycle of Entity Bean

Deployment of EJB’s in J2EE Server

Transactions Transactions are units of work that can maintain a reliable data source that is accessed by several clients.

Transactions Transactions have ACID Properties Atomicity: A transaction either commits or aborts Consistency: A transaction correctly manages the changing state of a system Isolation: A transaction’s effects are isolated from other transactions’ effects Durability: The result of a transaction persists

Java Transaction Service (JTS) JTS is an implementation of an underlying transaction service javax.transaction.TransactionService allows the application server to manage transaction boundaries.

EJB Transactions EJB Architecture: Supports flat transactions Supports the two-phase commit protocol Prepare-ready Commit Supports access to transaction service using the JTS interface.

UserTransaction Interface javax.transaction.UserTransaction begin commit rollback setRollbackOnly setTransactionTimeOut getStatus

Container-Managed Isolation Enterprise Bean can still participate via the EJBContext The setRollbackOnly method is used by a Bean to force a rollback (usually due to an application exception). The getRollbackOnly method is used by a Bean to test if the transaction is marked for a rollback.

Bean-Managed Isolation Session Bean Can: Gain Access to the transaction service Define transaction type as Bean in the deployment descriptor Ensure methods do not declare attributes that conflict with Bean-Managed demarcation. Use the javax.transaction.UserTransaction interface. Start a new transaction only after others complete

Bean-Managed Isolation import javax.transaction.UserTransaction; public class CartBean implements SessionBean{ EJBContext ic = null; // initialize some where else void someMethod(){ UserTransaction ex = ic.getUserTransaction(); tx.begin(); // do work tx.commit(); }

Bean-Managed Isolation Use the following methods: UserTransaction.getStatus method obtains status of a global transaction UserTransaction.rollback method rolls back a global transaction Do not use the following methods: setRollbackOnly() getRollbackOnly()

Bean-Managed Demarcation Stateful Session Beans Methods can return in the middle of a transaction without closing the transaction. Subsequent calls can go to any Bean method Stateless and Entity Beans Methods must complete a transaction before returning.

Vendors Supporting EJB SUN IBM WebLogic Oracle Inprise BEA Novell Netscape IONA Gemstone Informix Allaire