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.

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.
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.
Distributed System Using Java 2 Enterprise Edition (J2EE) B.Ramamurthy.
Sapana Mehta (CS-6V81) Overview Of J2EE & JBoss Sapana Mehta.
Introduction to Enterprise JavaBeans. Integrating Software Development Server-side Component Model Distributed Object Architecture –CORBA –DCOM –Java.
Enterprise Applications & Java/J2EE Technologies Dr. Douglas C. Schmidt Professor of EECS.
Enterprise Java Beans Welcome to the world of “Distributed System” Presented By: Sameer Nanda Date: 12/17/03.
Java 2 Platform, Enterprise Edition (J2EE). Source: Computer, August 2000 J2EE and Other Java 2 Platform Editions.
J2EE Java 2 Enterprise Edition. Relevant Topics in The Java Tutorial Topic Web Page JDBC orial/jdbc
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.
Distributed Multitiered Applications The J2EE platform uses a multitiered distributed application model. Application logic is divided into components 1.
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 l Enterprise Computing -- 3-tier and multi-tier applications l Enterprise JavaBeans n EJB Features n Types of EJBs l Example – A Currency Converter n.
EJB.
Ing. Ignacio Roqueta ARTech GeneXus and J2EE.
Container-Managed Persistence (CMP) Entity Beans Lesson 3A / Slide 1 of 42J2EE Server Components Objectives In this lesson, you will learn to: Identify.
1 Stateful Session Beans Stateless Session Beans Michael Brockway Sajjad Shami Northumbria University School of Computing, Engineering & Information Sciences.
Enterprise Java Beans. Distributed Computing Distributed computing is a field of computer science that studies distributed systems. A distributed system.
Enterprise Java Bean Matt. 2 J2EE 3 J2EE Overview.
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.
Session Beans -) stateless -) stateful. Session Beans A session bean represents a single client inside the J2EE server. To access an application that.
Source: Peter Eeles, Kelli Houston, and Wojtek Kozaczynsky, Building J2EE Applicationa with the Rational Unified Process, Addison Wesley, 2003 Prepared.
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
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
J2EE Chris Hundersmarck Maria Baron Jeff Webb.  Java 2 Platform, Micro Edition (J2ME)  Java 2 Platform, Standard Edition (J2SE)  Java 2 Platform, Enterprise.
Enterprise JavaBeans Session Beans. Session beans are a type of Enterprise JavaBean component designed to implement business logic responsible for managing.
1 Distributed System using J2EE. 2 What is J2EE?  J2EE (Java2 Enterprise Edition) offers a suite of software specification to design, develop, assemble.
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.
©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.
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.
Entity Bean Chuyên đề Lập trình Java & J2EE Chương 15
EJB (Enterprise Java Beans)
Introduction to J2EE Architecture
J2EE Application Development
Distributed System Using Java 2 Enterprise Edition (J2EE)
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.
Objectives In this lesson, you will learn about:
Presentation transcript:

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 invoking the exposed methods, remote clients can access the services provided by the application.

When to use EJB ?  The application must be scalable. To accommodate a growing number of users, you may need to transparently distribute an application's components across multiple machines. Transactions are required to ensure data integrity. Enterprise beans support transactions, the mechanisms that manage the concurrent access of shared objects. The application will have a variety of clients. With just a few lines of code, remote clients can easily locate enterprise beans. These clients can be thin, various, and numerous.

What is J2EE?  The Java TM 2 Platform, Enterprise Edition (J2EE TM ) is an integrated platform which allows to build solutions for multi-tier, enterprise applications. It extends the cross-platform portability of Enterprise JavaBeans TM (EJB TM ) technology by providing a foundation of common services and APIs, including XML, JavaServer Pages TM technology, and Servlets. The Java 2 SDK, Enterprise Edition (J2EE SDK) is the reference implementation for the J2EE TM.

Architectural view

Types of EJB  Enterprise Bean Type Purpose SessionPerforms a task for a client EntityRepresents a business entity object that exists in persistent storage Message-DrivenActs as a listener for the Java Message Service API, processing messages asynchronously

A more detailed architectural view  Image taken from “Mastering EJ2B” DB CMP JDBC

EJB ingredients  Interfaces: The remote and home interfaces are required for remote access. For local access, the local and local home interfaces are required. Enterprise bean class: Implements the methods defined in the interfaces. Helper classes: Other classes needed by the enterprise bean class, such as exception and utility classes.

EJB ingredients  Deployment descriptor: An XML file that specifies information about the bean such as its persistence type and transaction attributes. You package the files in the preceding list into an EJB JAR file, the module that stores the enterprise bean. To assemble a J2EE application, you package one or more modules--such as EJB JAR files-- into an EAR file, the archive file that holds the application.

Architectural view  1 - Write the beans 2 -Write the descriptor 3- Write the client

Entity Beans  An entity bean represents a business object in a persistent storage mechanism. Some examples of business objects are customers, orders, and products. The bean represents a business entity, not a procedure. For example, CreditCardEJB would be an entity bean, but CreditCardVerifierEJB would be a session bean. The bean's state must be persistent. If the bean instance terminates or if the J2EE server is shut down or crashes, the bean's state still exists in persistent storage (a database).

Entity Beans: PERSISTENCE  Persistence means that the entity bean's state exists beyond the lifetime of the application or the J2EE server process. There are two types of persistence for entity beans: bean-managed and container-managed. With bean-managed persistence (BMP), the entity bean code that you write contains the calls that access the database. If your bean has container-managed persistence (CMP), the EJB container automatically generates the necessary database access calls. The code that you write for the entity bean does not include these calls.

Entity Beans: SHARED ACCESS  Entity beans may be shared by multiple clients. Because the clients might want to change the same data, it's important that entity beans work within transactions. Typically, the EJB container provides transaction management. In this case, you specify the transaction attributes in the bean's deployment descriptor. You do not have to code the transaction boundaries in the bean--the container marks the boundaries for you.

Entity Beans: DB-like features  Like in a relational database: Each entity bean has a unique object identifier; An entity bean may be related to other entity beans. The unique identifier, or primary key, enables the client to locate a particular entity bean. You implement relationships differently for entity beans with BMP and those with CMP: BMP: the code that you write implements the relationships. CMP: the EJB container takes care of the relationships for you. (container-managed relationships).

Session Beans  A session bean represents a single client inside the J2EE server. To access an application that is deployed on the server, the client invokes the session bean's methods. The session bean performs work for its client, shielding the client from complexity by executing business tasks inside the server. At any given time, only one client has access to the bean instance. The state (i.e. the values of the instance variables) of the bean is not persistent, existing only for a short period of time. A session bean can be stateful or stateless.

Stateful session Beans  In a stateful session bean, the instance variables represent the state of a unique client-bean session. This state is often called the conversational state. The state is retained for the duration of the client-bean session. If the client removes the bean or terminates, the session ends and the state disappears.

Stateless session Beans  A stateless session bean does not maintain a conversational state for a particular client. When a client invokes the method of a stateless bean, the bean's instance variables may contain a state, but only for the duration of the invocation. When the method is finished, the state is no longer retained.

Stateless vs. stateful session Beans  All instances of a stateless bean are equivalent, allowing the EJB container to assign an instance to any client. => Stateless session beans can support multiple clients, and offer better scalability for applications that require large numbers of clients. Typically, an application requires fewer stateless session beans than stateful session beans to support the same number of clients.

Stateless vs. stateful session Beans  The EJB container can write a stateful session bean to secondary storage. However, stateless session beans are never written to secondary storage. Therefore, stateless beans may offer better performance than stateful beans.

Stateful session Beans – examples of use  The bean needs to hold information about the client across method invocations. The bean mediates between the client and the other components of the application, presenting a simplified view to the client. Behind the scenes, the bean manages the work flow of several enterprise beans.

Stateless session Beans – examples of use  In a single method invocation, the bean performs a generic task for all clients. For example, you might use a stateless session bean to send an that confirms an online order. The bean fetches from a database a set of read-only data that is often used by clients.

Message Driven Beans  A message-driven bean is an enterprise bean that allows J2EE applications to process messages asynchronously. It acts as a JMS message listener, which is similar to an event listener except that it receives messages instead of events. The messages may be sent by any J2EE component--an application client, another enterprise bean, or a Web component--or by a JMS application or system that does not use J2EE technology.

Message Driven Beans  A message-driven bean's instances retain no data or conversational state for a specific client. All instances of a message-driven bean are equivalent, allowing the EJB container to assign a message to any message-driven bean instance. The container can pool these instances to allow streams of messages to be processed concurrently. A single message-driven bean can process messages from multiple clients.

KEY CONCEPTS  Entity beans: synchronous, shared access, concurrency-safe -CMP -BMP Session Beans: synchronous -Statefulsingle access, conversational state -Stateless sharable, no state Message-Drive Beans: asynchronous, sharable, no state