Middleware Technology (J2EE/EJB) EJB Fundamentals.

Slides:



Advertisements
Similar presentations
11 Copyright © 2005, Oracle. All rights reserved. Creating the Business Tier: Enterprise JavaBeans.
Advertisements

Remote Method Invocation
Approaches to EJB Replication. Overview J2EE architecture –EJB, components, services Replication –Clustering, container, application Conclusions –Advantages.
Universität Bonn, Seminar Softwaretechnologie SS 2003, Duc Luu 1 Topics: Java Remote Method Invocation (RMI) Enterprise JavaBeans (EJB) Overview.
June 1999 EJB1 EJB and CHAIMS Dorothea Beringer Enterprise Java Beans and how to build a CHAIMS infrastructure using the EJB paradigm.
Introduction to Enterprise JavaBeans. Integrating Software Development Server-side Component Model Distributed Object Architecture –CORBA –DCOM –Java.
CORBA Case Study By Jeffrey Oliver March March 17, 2003CORBA Case Study by J. T. Oliver2 History The CORBA (Common Object Request Broker Architecture)
Overview of The Java Platform Solution for E-Business Applications : JSP, Servlet and EJB.
Copyright W. Howden1 Lecture 19: Intro to O/O Components.
J2EE Kenneth M. Anderson CSCI Web Technologies October 3, 2001.
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,
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)
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.
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 JavaBeans Umer Farooq CS6704: Design Patterns & Component FrameworksFebruary 25, 2002.
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.
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.
J2EE Structure & Definitions Catie Welsh CSE 432
Middleware Technology (J2EE/EJB) RMI-IIOP/JNDI. 2 Distributed Objects EJB components are based on distributed objects. A distributed object can be called.
J2EE Overview ver 1.0Page 1 © Wipro Technologies Talent Transformation J2EE Overview.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
Enterprise JavaBeans Understanding EJB Components Version 0.1 Kamal Wickramanayake
RMI remote method invocation. Traditional network programming The client program sends data to the server in some intermediary format and the server has.
Distributed Objects and Middleware. Sockets and Ports Source: G. Coulouris et al., Distributed Systems: Concepts and Design.
© jGuru.com Enterprise JavaBeans Fundamentals.
1 Java EE Programming Enterprise JavaBeans. 2 Topics J2EE Overview Enterprise JavaBeans Overview Enterprise Entity Beans Case Study How to build them.
Introduction to Enterprise JavaBeans Topics In Systems Architecture Barry Herbold
Component Patterns – Architecture and Applications with EJB copyright © 2001, MATHEMA AG Component Patterns Architecture and Applications with EJB Markus.
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.
1 Distributed Systems Distributed Object-Based Systems Chapter 10.
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.
©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.
Tanenbaum & Van Steen, Distributed Systems: Principles and Paradigms, 2e, (c) 2007 Prentice-Hall, Inc. All rights reserved DISTRIBUTED SYSTEMS.
©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 Distributed Computing
EJB Architecture and Design
Java Distributed Computing
Remote Method Invocation
Structure of Enterprise Java Beans
Introduction to Enterprise JavaBean
Objectives In this lesson, you will learn to:
Understanding and Designing with EJB
Enterprise Java Beans.
Knowledge Byte In this section, you will learn about:
Presentation transcript:

Middleware Technology (J2EE/EJB) EJB Fundamentals

2 Enterprise Bean A server-side software component which can be deployed in a distributed multi- tier environment. EJB specification requires that your beans expose a few required methods that allow the EJB container to manage beans uniformly, regardless of which container your beans is running in.

3 Types of Enterprise Bean Session Bean business process, actions such as adding numbers 、 calling other enterprise beans (CMP 、 BMP).  Stateless  StatefulejbActivate ejbPassivate Entity Bean business data , session beans harness entity beans to achieve business goals.  BMP (Bean Management Persistence) ejbLoad ejbStore  CMP (Container Management Persistence) Message-Driven Bean Asynchronous communication, JMS

4 Table 2.1 Session Beans Calling Entity Beans Session BeansEntity Beans Bank tellerBank account Credit card authorizerCredit card DNA sequencerDNA strand Order entry systemOrder, Line item Catalog engineProduct Auction brokerBid, Item Purchase order approval routerPurchase order

5 Figure 2.1 EJB Clients

6 Distributed Objects EJB components are based on distributed objects. A distributed object can be called from an in-process client, an out-of-process client, or a client located elsewhere on the network. Three different technologies  OMG’s CORBA (Common Object Request Broker Architecture)  Microsoft’s DCOM  Sun’s Java RMI-IIOP

7 Figure 2.2 Distributed Object

8 Client Object Reference Stub Servant Skeleton Server network Client and server are collocated in different address space.

9 Client and Server Object Reference Proxy Servant Client and server are collocated in the same address space. Location Transparency No changes to the source code are necessary in either client or server.

10 Distributed Objects and Middleware Explicit Middleware (transaction, security, etc.)  Difficult to write  Difficult to maintain  Difficult to support

11 Explicit Middleware (gained through API)

12 Distributed Objects and Middleware Implicit Middleware (Recommended)JTS Instead of writing any code to middleware APIs, you declare what you need in a simple text file. The request interceptor provide the middleware logic for you transparently

13 Implicit Middleware (gained through declaration)

14 Enterprise Bean Constitution Enterprise Bean Class An enterprise bean class contains implementation details of your component and conforms to a well-defined interface and certain rules which are necessary for your beans to run in any EJB container.  Session Beans: business-process-related logic javax.ejb.SessionBean  Entity Beans: data-related logic javax.ejb.EntityBean  message-oriented logic javax.ejb.MessageDrivenBean public interface javax.ejb.EnterpriseBean extends java.io.Serializable {... }

15 Enterprise Bean Constitution The EJB Object The client never invokes the methods directly on an actual bean instance. Rather, the invocation is intercepted by the EJB container, and then delegated to the bean instance. The EJB container automatically performs the implicit middleware. Services (See also : page 39)

16 Enterprise Bean Constitution EJB objects clone and expose every business method that the bean itself expose, and it acts as a surrogate object between the client and the bean. We could think of EJB objects as physical parts of the container, all EJB objects have container-specific code inside of them. So container vendor generates the class file for your EJB Object automatically.  The Remote Interface This interface duplicate all the business methods that the corresponding bean class expose.

17 Enterprise Bean Constitution  Java RMI-IIOP and EJB Objects Every javax.ejb.EJBObject extends java.rmi.Remote which is part of Java Remote Method Invocation over Internet Inter- ORB Protocol (RMI-IIOP). (1) Any object that implements javax.rmi.Remote interface is a remote object and is callable from a different JVM. (2) Any method that is part of a remote object must throw a special remote exception. The parameters you pass in method must be valid types for RMI-IIOP, such as primitives, serializable objects and RMI-IIOP remote objects

18 Figure 2.5 EJB Objects

19 public interface javax.ejb.EJBObject extends java.rmi.Remote { public javax.ejb.EJBHome getEJBHome() throws java.rmi.RemoteException; public java.lang.Object getPrimaryKey() throws java.rmi.RemoteException; public void remove() throws java.rmi.RemoteException, javax.ejb.RemoveException; public javax.ejb.Handle getHandle() throws java.rmi.RemoteException; public boolean isIdentical(javax.ejb.EJBObject) throws java.rmi.RemoteException; } EJBObject interface source

20 Enterprise Bean Constitution The Home Object EJB promotes location transparency, so clients should never be aware of exactly where an EJB object resides. To acquire a reference to an EJB object, your client code asks for an EJB object from an EJB object factory which is called a home object. Chief responsibilities of home objects:  create EJB objects  find existing EJB objects  remove EJB objects Home objects are physically part of the container and are automatically generated by the container vendor’s tool.

21  The Home Interface The container’s home object implements your home interface. Home interface simply defines methods for creating, destroying, and finding EJB objects. Your home interface must extend javax.ejb.EJBHome interface. Enterprise Bean Constitution

22 Figure 2.6 Home Object

23 public interface javax.ejb.EJBHome extends java.rmi.Remote { public EJBMetaData getEJBMetaData() throws java.rmi.RemoteException; public javax.ejb.HomeHandle getHomeHandle() throws java.rmi.RemoteException; public void remove(javax.ejb.Handle handle) throws java.rmi.RemoteException, javax.ejb.RemoveException; public void remove(Object primaryKey) throws java.rmi.RemoteException, javax.ejb.RemoveException; } EJBHome interface source

24 7 steps in remote invocation (1) The client calls a local stub. (2) The stub marshals parameters into a form suitable for the network. (3) The stub goes over a network connection to the skeleton. (4) The skeleton demarshals parameters into a form suitable for Java. (5) The skeleton calls the EJB object. (6) The EJB object performs needed middleware, such as connection pooling, transactions, security, and lifecycle services. (7 )Once the EJB object calls the enterprise bean instance, and the bean does its work, each of the preceding steps must be repeated for the return trip home.

25 Enterprise Bean Constitution The Local Interfaces EJB 2.0 specification provides a local interface rather than a remote interface, and local home interface rather than home interface to avoid the steps of the stub, skeleton, network and marshaling/unmarshaling of parameters. You can use the local interface when you call beans in the same process.

26 local object ---- local interface ---- javax.ejb.EJBLocalObject local home object ---- local home interface ---- javax.ejb.EJBLocalHome pass-by-reference EJB object ---- remote interface ---- javax.ejb.EJBObject Home object ---- home interface ---- javax.ejb.EJBHome pass-by-value Enterprise Bean Constitution

27 Deployment Descriptors Deployment descriptors declare how your beans should use middleware, rather than you writing code to use middleware (implicit middleware). In EJB 2.0, a deployment descriptor is an XML file.  Bean management and lifecycle requirements  Persistence requirements (Entity beans only)  Transaction requirements  Security requirements Enterprise Bean Constitution

28 Three key components of an EJB bean EJBHome (extends javax.ejb.EJBHome) using the factory design pattern, defining the create, find and remove methods. EJBObject (extends javax.ejb.EJBObject) using the proxy design pattern, defining the business logic implemented in bean. Bean Implementation Class (implements javax.ejb.EntityBean/SessionBean/MessageDrivenBean) implementing the business logic