Enterprise JavaBeans Understanding EJB Components Version 0.1 Kamal Wickramanayake

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.
Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 1 Topics: Java Remote Method Invocation (RMI) Enterprise JavaBeans (EJB) Overview.
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.
Writing Enterprise Applications with J2EE (Third lesson) Alessio Bechini June 2002 (based on material by Monica Pawlan)
SEI/CBS Initiative Software Engineering Institute Carnegie Mellon University Pittsburgh, PA Sponsored by the U.S. Department of Defense © 1999.
J2EE Kenneth M. Anderson CSCI Web Technologies October 3, 2001.
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
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)
Advanced Java Session 7 New York University School of Continuing and Professional Studies.
Using JavaBeans and Custom Tags in JSP Lesson 3B / Slide 1 of 37 J2EE Web Components Pre-assessment Questions 1.The _____________ attribute of a JSP page.
© 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.
Enterprise Java Beans Part II Kyungmin Cho 2001/04/13.
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.
J2EE Structure & Definitions Catie Welsh CSE 432
A TUTORIAL TO USING EJBs by SHREERAM IYER 09/17/2001.
Source: Peter Eeles, Kelli Houston, and Wojtek Kozaczynsky, Building J2EE Applicationa with the Rational Unified Process, Addison Wesley, 2003 Prepared.
© jGuru.com Enterprise JavaBeans Fundamentals.
© jGuru.com Enterprise JavaBeans Fundamentals.
Enterprise Java v041102EJB QL1 EJB Query Language Source: “Enterprise JavaBeans, 3rd Edition”, Richard Monson-Haefel.
Copyright © 2002 ProsoftTraining. All rights reserved. JavaServer Pages.
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.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
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.
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.
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.
17 Copyright © 2004, Oracle. All rights reserved. Integrating J2EE Components.
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.
Java Servlets By: Tejashri Udavant..
Introduction to J2EE Architecture
Ruslana Svidzinska CSE690
Structure of Enterprise Java Beans
J2EE Application Development
Introduction to Enterprise JavaBean
Objectives In this lesson, you will learn to:
Enterprise Java Beans Bina Ramamurthy 1/13/2019 B.Ramamurthy.
Enterprise Java Beans Bina Ramamurthy 4/5/2019 B.Ramamurthy.
Enterprise Java Beans.
Objectives In this lesson, you will learn about:
Presentation transcript:

Enterprise JavaBeans Understanding EJB Components Version 0.1 Kamal Wickramanayake

creating competitive advantage JavaBeans vs Enterprise JavaBeans l Enterprise JavaBeans is a framework for building and deploying server-side Java components l JavaBeans is a framework for client-side Java components l Conceptually related because both are components l The specifications are different l The specifications do not build on each other or rely on each other

creating competitive advantage What’s in the EJB Specification ~200 Pages of technical material for EJB vendors l Goals for the Release l Roles and Scenarios l Fundamentals (Scope of EJB) l Session and Entity Beans l Transactions, Exceptions, Distribution l EJB Bean and Container Responsibilities l API Reference EJB Vendors Have to do all the WORK

creating competitive advantage Enterprise EJB Scenario ClientsWeb Server EJB Application Server Existing Enterprise Middleware CICS Programs SAP Modules Browser Application Servlet Shopping Cart Credit Card Inventory EJB Server EJB Container Databases

creating competitive advantage l Bean Class is written by the developer l EJBHome and EJBObject interfaces and classes control access to the Bean class l Deployment Descriptor and MANIFEST describe security and transactional characteristics of the Bean Written by Developer Generated at Deployment Generated at Development EJB Server EJB Container EJBHome Interface EJBHome Interface Deployment Descriptor EJBObject Interface EJBObject Interface EJBHome Class EJBHome Class EJBObject Class EJBObject Class EJB Class Manifest An inside look at the various components of EJB

creating competitive advantage EJB Server EJB Container EJBHome Interface EJBHome Interface EJBHome Class EJBHome Class EJBHome Interface and Class l Used to get a reference to a bean’s remote interface l Provides bean creation services –myFoo = fooHome.create() instead of myFoo = new foo() –Supports multiple signatures to create EJB instances l May be generated by tools that come with an EJB server l Also manages EJB: –querying (Entity Bean) –deleting (Entity Bean)

creating competitive advantage Interface javax.ejb.EJBHome l Home objects must implement this interface l Returns a reference to a bean by creating or finding it l Every bean has a EJBHome interface that provides methods for getting references to one or more beans –create methods are used to create new beans –there can be many create methods, similar to a class having many constructors l Provides a bean removal interface also l The EJBHome Class implementation is provided by the EJB Server Provider

creating competitive advantage Sample EJBHome Interface public interface CustomerHome extends EJBHome { public abstract Customer create(String id, String name) throws RemoteException, CreateException; public abstract Enumeration findByName(String val) throws RemoteException, FinderException; public abstract RemoteEnumeration findStateByName(String val) throws RemoteException, FinderException; public abstract Customer findByPrimaryKey(CustomerKey pkey) throws RemoteException, FinderException; public abstract Customer findByPrimaryKey(CustomerKey pkey, int findSource) throws RemoteException, FinderException; public abstract CustomerState findStateByPrimaryKey(CustomerKey pkey, int findSource) throws RemoteException, FinderException; }

creating competitive advantage Clients EJB Server EJB Container EJBHome Class create() Client makes invocation to EJBHome Class via the EJBHome Interface l Client calls one of the create() methods on the EJBHome Class. The EJBHome class can have multiple create() signatures.

creating competitive advantage Clients EJB Server EJB Container EJBHome Class EJB Class EJB Class EJBHome Class instantiates the Bean Class l When the create() method is called in the EJBHome Class, it is responsible for instantiating the Bean class.

creating competitive advantage EJB Server EJB Container EJBObject Interface EJBObject Interface EJBObje ct Class EJBObje ct Class EJBObject Interface and Class l Intercepts calls to the EJB Class to add support for: –transactions –security –threading l EJBObject class has the same methods as the bean and delegates to the bean as the bean and delegates to the bean for actual behavior l EJBObject class checks security and sets up transaction before delegating method call to the bean l Clients can never get a reference to a bean’s EJB Class, only the EJBObject interface

creating competitive advantage Interface javax.ejb.EJBObject public interface javax.ejb.EJBObject extends java.rmi.Remote { EJBHome getEJBHome() throws RemoteException; Handle getHandle() throws RemoteException; Object getPrimaryKey() throws RemoteException; boolean isIdentical(EJBObject obj) throws RemoteException; void remove() throws RemoteException, RemoveException; } l Represents a specific bean instance l Remote objects must implement this interface l Primary key is an object that represents the primary key for a specific instance of a bean l The EJBObject Class implementation is provided by the EJB Server Provider

creating competitive advantage Sample EJBObject Interface public interface Customer extends EJBObject { public abstract String getId() throws RemoteException; public abstract String getName() throws RemoteException; public abstract void setName(String val) throws RemoteException; public abstract boolean getNameNull() throws RemoteException; public abstract boolean getIdNull() throws RemoteException; public abstract Enumeration getAccounts() throws RemoteException; public abstract void addToAccounts(Account relInst) throws RemoteException; public abstract void removeFromAccounts(Account relInst) throws RemoteException; }

creating competitive advantage Clients EJB Server EJB Container Passes ref of Bean Client now has reference to the EJBObject Class. NOT A REFERENCE TO THE BEAN ITSELF!!!! EJBHome Class EJB Class EJB Class EJBHome Class After the EJBHome Class instantiates the Bean... l The EJBHome Class will instantiate the EJBObject Class, initializing it with the remote object reference to the Bean Class. l The Client will now communicate to the EJBObject Class. The EJBObject Class will delegate the call to the Bean.

creating competitive advantage Clients EJB Server EJB Container EJBHome Class EJB Class EJB Class EJBHome Class Client communicates to the Bean class via the EJBObject Class l Client never has a direct reference to the Bean. l The EJBObject Interface is the interface for the Bean, so the EJBObject Class “delegates” the calls to the Bean. l The EJBObject Class implementation will be generated using vendor tools.

creating competitive advantage EJB Class l A bean has a single Java class at its core –This class is written by a developer if it’s a session bean –This class is sometimes generated by a tool if it’s an entity bean l Implements application-specific business logic l Implements one of the following contracts: –javax.ejb.EntityBean –javax.ejb.SessionBean l These contracts provide for consistent behavior when activating beans, passivating beans, reading data, writing data l Every container can expect these methods in every bean

creating competitive advantage Deployment Descriptor EJB Container EJB Server Deployment Descriptor l Allows you to declare transaction and security attributes, NO PROGRAMMING REQUIRED!!! l An EJB Deployment Descriptor describes the classes, interfaces and declarative behavior of an EJB l Deployment Descriptor format is serialized objects: –javax.ejb.deployment.ControlDescriptor –javax.ejb.deployment.DeploymentDescriptor –javax.ejb.deployment.EntityDescriptor –javax.ejb.deployment.SessionDescriptor l The deployment descriptor is generated by server tools l The deployment descriptor classes are defined in the EJB specification

creating competitive advantage Let’s look at the value of the Deployment Descriptor l Step #1 - Write your Bean implementation. l Step #2 - Compile this Java source into Java bytecode l Step #3 - Developer is responsible for creating a serialized deployment descriptor for the bean. Most likely using a tool from the vendor. EJB tools will use Reflection API on the compiled EJB Bean to determine: –name of Bean class –methods –parameters –return values l Step #4 - The EJB Tool will use the above information to generate a Deployment Descriptor file and an editor with which to set transaction and security attributes.

creating competitive advantage Manifest EJB Container EJB Server Enterprise JavaBean Packaging l Enterprise JavaBeans are comprised of many Java files l These files are put in a JAR file –A JAR file is a ZIP file with a MANIFEST that describes the contents of the file –A MANIFEST is a simple text file Name: bank/AccountDeployment.ser Enterprise-Bean: True Name: bank/AccountDeployment.ser Enterprise-Bean: True l A JAR file can contain more than one Enterprise JavaBean

creating competitive advantage Written by Developer Generated at Development Generated at Deployment EJB Server EJB Container EJBHome Interface EJBHome Interface Deployment Descriptor EJBObject Interface EJBObject Interface EJBHome Class EJBHome Class EJBObject Class EJBObject Class EJB Class Manifest Summary: Bean Development Process l Implement the EJB Class l Specify the remote interface l Specify the home interface l Specify security and transactional characteristics using vendor tools (DeploymentDescriptor) l Use vendor tools to generate supporting code and package components in EJB-jar l Iterate...