1 Softsmith Open Learning - EJB 21-Nov-2008. 2 Enterprise Java Beans Introduction –Application ServerApplication Server –Java 2 Enterprise EditionJava.

Slides:



Advertisements
Similar presentations
J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento.
Advertisements

11 Copyright © 2005, Oracle. All rights reserved. Creating the Business Tier: Enterprise JavaBeans.
Approaches to EJB Replication. Overview J2EE architecture –EJB, components, services Replication –Clustering, container, application Conclusions –Advantages.
An architecture for webb applications, J2EE
6/1/20151 Luca Simone Software Engineering 2 a.a. 2001/2002.
Distributed System Using Java 2 Enterprise Edition (J2EE) B.Ramamurthy.
Sapana Mehta (CS-6V81) Overview Of J2EE & JBoss Sapana Mehta.
Overview of The Java Platform Solution for E-Business Applications : JSP, Servlet and EJB.
6/19/ Enterprise Java Beans Introduction –Application ServerApplication Server –Java 2 Enterprise EditionJava 2 Enterprise Edition What is an.
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.
Distributed System Using Java 2 Enterprise Edition (J2EE)
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.
1 J2EE Components. 2 Application Servers relieve the programming burden for business distributed components. They provide support for system level services.
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.
Enterprise Java Beans - (EJB)
EJB.
Ing. Ignacio Roqueta ARTech GeneXus and 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 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.
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.
第十四章 J2EE 入门 Introduction What is J2EE ?
J2EE Structure & Definitions Catie Welsh CSE 432
Enterprise Java Beans Java for the Enterprise Server-based platform for Enterprise Applications Designed for “medium-to-large scale business, enterprise-wide.
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.
Collaborate Lesson 4C / Slide 1 of 22 Collaborate Knowledge Byte In this section, you will learn about: The EJB timer service Message linking in EJB 2.1.
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
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.
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.
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.
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 Enterprise Java Beans JAVA Enterprise Edition
EJB. Introduction Enterprise Java Beans is a specification for creating server- side scalable, transactional, multi-user secure enterprise-level applications.
©NIIT Session Beans Lesson 1B/ Slide 1 of 37J2EE Server Components Objectives In this lesson, you will learn to: Describe the characteristics of session.
Enterprise Java Beans. Contents  Understanding EJBs  Practice Section.
Introduction to Enterprise JavaBean
Understanding and Designing with EJB
Luca Simone Software Engineering 2 a.a. 2001/2002
Objectives In this lesson, you will learn to:
Understanding and Designing with EJB
Component-based Applications
Component Technology Bina Ramamurthy 2/25/2019 B.Ramamurthy.
Understanding and Designing with EJB
Enterprise Java Beans.
Knowledge Byte In this section, you will learn about:
Presentation transcript:

1 Softsmith Open Learning - EJB 21-Nov-2008

2 Enterprise Java Beans Introduction –Application ServerApplication Server –Java 2 Enterprise EditionJava 2 Enterprise Edition What is an Enterprise Bean ? –EJB PropertiesEJB Properties –EJB OverviewEJB Overview –Deployment PhaseDeployment Phase –Type of beansType of beans Client access with interfaces –Remote accessRemote access –Local AccessLocal Access

3 Enterprise Java Beans Contents of an Enterprise Bean EJB Example EJB vs MTS A few EJB implementationsA few EJB implementations What’s new in EJB 2.0 Bibliography

4 Introduction Enterprise Java Beans ( EJB ) is –a middleware component model for Java and CORBA –a specification for creating server-side, scalable, transactional, multi-user and secure enterprise-level applications – one of several Java APIs in the Java Presented by Sun in the 1999, they are easier than other technologies as RMI or Corba

5 Introduction This is the three level structure for Application Server

6 Applicaton Server Presentation –HTML Application –Java Application Business Logic Data Access

7 Presentation HTML –Generated server-side HTML –Runs on any Web browser –Less client-side power Java –Required Java virtual Machine –More client side power –Runned on a page –Security (Applet) –Launched from a browser or a standalone application

8 Business Logic Implements the logic of the application defining all the function that may be used from a client –Change Business Rules Easily –Re-use components –Make complex applications manageable –Secure Data hiding

9 Data Access Utility to access external datas such as Database or other Web component Access other SOA

10 J2EE Application Server Java 2 Enterprise Edition standardizes interfaces for Application Server components

11 What is an Enterprise Bean ? Is a server side component written in Java Language Industry standard distribuited component model Incorporates the business logic of an application ( the code that implements the purpose of the application) Replicates the table model as objects

12 EJB Properties Bean writers need not write –Remote access Protocols –Transactional Behaviour –Threads –Security –State Management –Object life cycle –Resource pooling –Persistence –Native queries execution

13 EJB Overview

14 Deployment Phase

15 Deployment Phase

16 When to use Enterprise bean The application must be scalable.It will run on different machine and their location will remain transparent to the client Transaction requirement The application will have lot of different type of clients Multilevel security layer

17 Type of beans Session Bean Entity Bean Message Driven Bean

18 Session Bean Represents a single client inside the server The client calls the session bean to invoke methods of an application on the server Perform works for its client, hiding the complexity of interaction with other objects in the server Is not shared Is not persistent When the client stops the session,the bean can be assigned to another client from the server Unique to each client

19 Session Bean Stateful session bean Stateless session bean

20 Stateful Session Bean Contains the state of a single client session: –Information on the client –On method called –Return values This state is called conversational state and is not retained when the session ends, also if the client not removes the bean - Remembers previous request, and response of session

21 Stateless Session Bean Not maintain a conversational state for a particular client Contains values only for the duration of the single invocation Except during method invocation, all instances of stateless session bean are equivalent Pooled

22 Entity Bean Represents a business object in a persistent storage mechanism such as a relational database Usually is a table in the database and each instance of that entity bean is a row in that table Properties: PersistentPersistent Allow shared accessAllow shared access Have primary keyHave primary key Have relationship with other entity beans.Have relationship with other entity beans. Auto commit.Auto commit.

23 Entity Bean persistent Bean managed persistence Container managed persistence

24 Bean managed persistence Who write the bean’s code must access the database and save his own data you will have more control over how the entity bean accesses a database

25 Container managed persistence The container save the data There is no code in the bean for access the database The container handles all database access required for the bean Links between beans are created using a structure called abstract schemaabstract schema the EJB container transparently and implicitly manages the persistent state

26 Entity bean’s shared access Entity beans can be used by different clients It’s important that they work whithin transactions The EJB container provides transaction management The transaction’s attribute are specified in the bean’s deployment description Concurrency management

27 Entity bean’s primary key Each entity bean has a unique object identifier like a key in a database table Each instance represents as Row in table

28 Entity bean’s relationship Container managed persistent –The container performs all the operation to create relationship Bean managed persistent –The code to perform relations must be written in the bean

29 Message Driven bean Allows applications to process messages asynchronously The messages may be sent by : –An application client –Another enterprise bean –A Web component –A JMS Client

30 Message Driven bean Retain no data or conversational state for a specific client All instances are equivalent, allowing the EJB container to assign a message to any message- driven bean instance. The container can pool these instances. The instance variables of the message- driven bean e can contain some state across the handling of client messages-- for example, a JMS API connection, an open database connection, or an object reference to an ejb.

31 Message Driven bean A client can’t access directly to a message driven bean When a message arrive, the container gives it to a message driven bean The bean process the message The onMessage method may call helper methods, or it may invoke a session or entity bean to process the information in the message or to store it in a database

32 Client access with interfaces A client may access a session or an entity bean only through the methods defined in the bean's interfaces They define the client's view of a bean Public business methods declared in Bean interface’s can be visible to client, to invoke Types of access: –Remote access –Local access

33 Remote access A remote client of an enterprise bean has the following traits: –It may run on a different machine and a different Java virtual machine than the enterprise bean it accesses (It is not required to run on a different JVM ) –It can be a Web component –It can be another enterprise bean –It can be RMI object

34 Remote access To create an enterprise bean with remote access, you must : –Code a remote interface Business methods –Code a home interface Finder methods Home methods Utility methods (to get home)

35 Remote access example

36 Local access A local client has these characteristics –It must run in the same JVM as the enterprise bean it accesses –It may be a Web component or another enterprise bean –To the local client, the location of the enterprise bean it accesses is not transparent –It is often an entity bean that has a container- managed relationship with another entity bean

37 Local access To create an enterprise bean with local access, you must : –Code the local interface Bean's business methods –Code the local home interface Life cycle Finder methods Utility methods

38 Local interfaces If an entity bean is the target of a container managed relationship it MUST have local interfaces An EJB can use local client view only if it is really guaranteed that other enterprise beans or clients will only address the bean within a single JVM

39 Contents of an Enterprise Bean Deployment descriptor –Persistence type –Transaction attribute Enterprise bean class Interfaces Helper classes –Exception –Utility classes

40 EJB Example The OnLine Bank We will take a not completed system to give an idea to how choose if a component is an entity, session or message driven bean.

41 EJB Example Virtual Bank Client SecurityAccounts Services

42 EJB Example The example has three component: –Services: what the client can do in the system such as see the foreign currency, listed shares or make operations on his hown account. –Accounts: a database containing the accounts of all the clients of the bank with information about credit,debit,access etc.. –Security: is a subsystem that receives all the alarm caused from wrong access and performs action about the situation ( calls police and stops operation of that client keeping information about him )

43 EJB Example In this example is easy to create an EJB structure. –Client will have a web page at client side to insert values and connect the system.This will be done using JSP ( Java Servlet Pages ) –Services will be a Statefull Session Bean and it will be different for each client connecting the system mantaining data about the client connected. –Accounts will be formed by an Entity Bean for each account in the system with a code-account as primary key. –Security will be a Message driven bean and will be called only from container if some operation are abnormal for result or the autentification for the same client fails too much times.

44 A few EJB implementations WebLogic Bluestone Novera Persistence Oracle AS Oracle8i

45 What’s new in EJB 2.0 Released On April 26, 2001 Integration with Java TM Message Service (JMS) -- Asynchronous Capabilities Streamline Systems –Send asynchronous messages via the JMS API Container-Managed Persistence (CMP) -- Simplifying and Expediting Application Development –Used to isolate the application developer from the physical database schema –Introduces for the first time a portable query language, based on the abstract schema –No need to worry about data access code

46 What’s new in EJB 2.0 Local Interfaces -- Streamlining Calls Between Local Beans –The local interface may be defined for a bean during development, to allow streamlined calls to the bean if a caller is in the same container –Uses when Client and bean reside in same JVM Inter-Server Interoperability -- Enabling Heterogeneous Environments –Takes the benefit of cross-server application portability –Able to deploy the EJB technology-based application across a heterogeneous environment mixing application servers from different vendors

47 The EJB architecture Consists of: –An EJB server –EJB containers that run within the server –Home objects –Remote EJBObjects –Enterprise Beans –EJB clients –Auxiliary systems like Java Naming and Directory Interface (JNDI) Java Transaction Service (JTS) Security services Threading Pooling

48 The EJB architecture

49 Stateful session bean’s life cycle The client invoke the create method The EJB container : –Instantiates the bean –Invokes the setSessionContext –Invokes ejbCreate The bean is ready Business methods ready to be called

50 Stateful session bean’s life cycle While in the ready state –EJB container may passivate the bean moving it from memory to secondary storage –A client may invoke a business method –EJB container may activate a bean,moving it back to the ready stage, and then calls the bean's ejbActivate method –A client may invoke the remove method and the container calls the bean's ejbRemove method –Client cannot invoke passivate

51 Stateful session bean’s life cycle

52 Stateless session bean’s life cycle The client invoke the create method The EJB container : –Instantiates the bean –Invokes the setSessionContext –Invokes ejbCreate The bean is ready

53 Stateless session bean’s life cycle While in the ready state –A client may invoke a business method –A client may invoke the remove method and the container calls the bean's ejbRemove method –It’s never passivate –It’s can be pooled

54 Stateless session bean’s life cycle

55 Entity bean’s life cycle The EJB container : –Creates the instance –Calls the setEntityContext The entity bean moves to a pool of available instances

56 Entity bean’s life cycle While in the pool : –Instance is not associated with any particular object identity –All instances in the pool are identical –EJB container may assign an identity to an instance when moving it to the ready stage invoking the ejbActivate method –A client may invoke the create method EJB container calls ejbCreate and ejbPostCreate –EJB container may remove the instance invoking unsetEntityContext –Same bean instance (row) shared by all client

57 Entity bean’s life cycle While in the ready state : –A client may invoke entity bean's business methods –A client may invoke the remove method EJB container calls the ejbRemove method –EJB container may invoke the ejbPassivate method

58 Entity bean’s life cycle

59 Message driven bean’s life cycle EJB container creates a pool of message- driven bean instances For each instance, the EJB container instantiates the bean : –It calls the setMessageDrivenContext –It calls the instance's ejbCreate Like a stateless session bean,it’s never passivated, It has only two states: –Nonexistent –Ready to receive messages. –is only a bean class – no interfaces

60 Message driven bean’s life cycle While in the ready state : –EJB container may call onMessage –EJB container may call the ejbRemove

61 Message driven bean’s life cycle