Java Programming: Advanced Topics 1 Enterprise JavaBeans Chapter 14.

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.
An architecture for webb applications, J2EE
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.
Enterprise JavaBeans 2.0 Wu Lu (Cont’d). EJB2.0 Query Language EJB QL is a declarative language similar in many respects to SQL Is intended to be portable.
Introduction to Enterprise JavaBeans. Integrating Software Development Server-side Component Model Distributed Object Architecture –CORBA –DCOM –Java.
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 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.
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.
EJB Fundamentals Celsina Bignoli
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.
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,
Ing. Ignacio Roqueta ARTech GeneXus and J2EE.
Entity Beans BMP Celsina Bignoli
Chemical Toxicity and Safety Information System Shuanghui Luo Ying Li Jin Xu.
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. Distributed Computing Distributed computing is a field of computer science that studies distributed systems. A distributed system.
Replication & EJB Graham Morgan. EJB goals Ease development of applications –Hide low-level details such as transactions. Provide framework defining the.
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.
TDDD05 EJB Lab (Part of slides reused from Mikhail’s) Lu Li
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
Source: Peter Eeles, Kelli Houston, and Wojtek Kozaczynsky, Building J2EE Applicationa with the Rational Unified Process, Addison Wesley, 2003 Prepared.
Ch 2 – Application Assembly and Deployment COSC 617 Jeff Schmitt September 14, 2006.
Lecture # 3 & 4 Chapter # 2 Database System Concepts and Architecture Muhammad Emran Database Systems 1.
Enterprise Java Beans. Model 1 J2EE – Web View Model/View/Controller Model View Control Data base Web Server Model One Architecture HTTP Request HTTP.
Introduction to Enterprise JavaBeans Topics In Systems Architecture Barry Herbold
Consultant Effective Patterns and Practices in J2EE George de la Torre.
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.
Preface IIntroduction Objectives I-2 Course Overview I-3 1Oracle Application Development Framework Objectives 1-2 J2EE Platform 1-3 Benefits of the J2EE.
Preface 1Introduction Course Objectives 1-2 Course Environment 1-4 Course Overview 1-5 About the Course Applications 1-8 Order Entry Schema 1-9 Human Resources.
Enterprise JavaBeans 3.0. What is EJB 3.0 -Reusable server-side component framework-technology -Designed to support building demanding enterprise – level.
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.
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 Topics1 Introduction to Advanced Java Programming Chapter 1.
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. Lesson 1: Introduction to Server-Side Component Software.
Middleware Technology (J2EE/EJB) EJB Fundamentals.
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.
J2EE Lecture 10: EJB 3.0 Overview
Entity Bean Chuyên đề Lập trình Java & J2EE Chương 15
EJB (Enterprise Java Beans)
Introduction to J2EE Architecture
Enterprise Java Bean. Overview of EJB View of EJB Conversation Roles in EJB, Types of Enterprise Beans Lifecycle of Beans Developing Applications using.
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:

Java Programming: Advanced Topics 1 Enterprise JavaBeans Chapter 14

Java Programming: Advanced Topics 2 Objectives Explore an enterprise application’s needs for secure distributed access, scalability with high performance, robustness, data persistence with transactional integrity, and management of distributed and often disparate resources Discover how the EJB framework provides the quality of services enterprise applications require Learn how stateful and stateless session EJBs provide components that perform business logic

Java Programming: Advanced Topics 3 Objectives (Cont.) Learn how to program an EJB client Discuss exception handling in EJBs and EJB clients Learn how entity beans represent persistent data in Java objects

Java Programming: Advanced Topics 4 Objectives (Cont.) Discuss mapping fields of entity beans to elements in databases using CMP and BMP Learn how to use container-managed relationships and EJB query language with container-managed persistence Learn what Java Message Service is and learn how message-driven beans consume asynchronous messages

Java Programming: Advanced Topics 5 Objectives (Cont.) Discuss transactional properties of EJBs Discuss elements of application security that relate to EJBs Consider some best practices for designing applications that use EJBs

Java Programming: Advanced Topics 6 Enterprise Programming EJB specification: a description of this environment and the framework for building distributed objects that implement a standard interface Distributed systems: software systems that reside on several physical hosts –the components must interoperate over a network that may be a local area network (LAN) or the Internet

Java Programming: Advanced Topics 7 Enterprise Programming (Cont.) Scalability: the ability of a system to continue to give high performance as the number of users increases Persistence: any data that outlives any software component Resource management is required whenever the system makes high demands on databases and other resources

Java Programming: Advanced Topics 8 Enterprise Programming (Cont.) Connection pooling: keeping a set of connections open so that different software components can be given an open connection for short-term exclusive use Security: usually of critical importance in enterprise applications Transactional integrity: often the quality that most concerns developers of enterprise applications

Java Programming: Advanced Topics 9 What are EJBs Enterprise JavaBeans (EJBs): server-side software components that conform to the J2EE architecture for development and deployment of distributed systems J2EE-compliant application servers must provide a run-time environment for the EJBs: an EJB container

Java Programming: Advanced Topics 10 What are EJBs (Cont.) EJBs come in three basic kinds: –Session beans: can perform any kind of processing –Entity beans: represent persistent data –Message-driven beans (MDB): have a specialized purpose and are used with messaging software

Java Programming: Advanced Topics 11 What are EJBs (Cont.) The major components of an EJB: –Bean class –Home interface –Local or Remote interface

Java Programming: Advanced Topics 12 MVC Architecture

Java Programming: Advanced Topics 13 EJB Containers and Services The role of the EJB container is to provide the following: –The distribution infrastructure and a naming service to help client code locate and access EJBs. –The ability to place EJBs in a scalable architecture –Support for concurrent access –Resource management, including connection pooling –Security services in addition to the secure environment that can be configured for applications loaded into the application server –Transaction managers that interact with JDBC drivers and resource adapters

Java Programming: Advanced Topics 14 J2EE Enterprise Application Packaging and Deployment EJBs are always packaged in J2EE enterprise applications Files that compose EJBs are packaged in jar files An EJB jar must contain a deployment descriptor file

Java Programming: Advanced Topics 15 J2EE Packaging into Archive Files

Java Programming: Advanced Topics 16 Session EJBs Session EJBs can do general purpose processing They are associated with the client that calls them There are two types of session EJBs: –stateful –stateless

Java Programming: Advanced Topics 17 Stateless Session EJBs Stateless session beans can be shared among clients Methods defined in the javax.ejb.SessionBean interface are call-back methods that control the lifecycle of the bean, that called by the container

Java Programming: Advanced Topics 18 Stateless Session EJBs (Cont.) Steps to create a stateless session EJB: –1. Define a class that extends the SessionBean interface –2. Create a home interface –3. Add business methods to the session bean class and write implementations of those methods –4. Add a remote interface and include all the business methods that can be called by remote clients –5. Write the deployment descriptor

Java Programming: Advanced Topics 19 Stateful Session EJBs Stateful session EJBs retain conversational state between method calls and are used by only one client Conversational state: information that must be retained as long as the client is actively interacting with the application Transactional state: data that must be permanently recorded when the client activity ends

Java Programming: Advanced Topics 20 EJB Clients The EJB 2.0 specification adds interfaces to all entity and session beans specifically for use by co-located clients There are four interfaces that you can define for a session or entity bean

Java Programming: Advanced Topics 21 The Client Interfaces

Java Programming: Advanced Topics 22 The Client Interfaces (Cont.)

Java Programming: Advanced Topics 23 The Client Interfaces (Cont.)

Java Programming: Advanced Topics 24 The Client Interfaces (Cont.)

Java Programming: Advanced Topics 25 Writing EJB Clients The client starts by accessing the JNDI namespace, by instantiating an object of type javax.naming.InitialContext When the client has the EJB home, it uses a create method to get a handle to the remote interface

Java Programming: Advanced Topics 26 Handling Exceptions in EJB Clients Define and use application-level exception classes to encapsulate anticipated problem conditions Application-level exceptions: exceptions that business logic can anticipate and possibly recover from.

Java Programming: Advanced Topics 27 Entity EJBs Entity beans represent persistent data Use entity beans as the interface between Java components and relational or object-oriented databases The container uses the primary key to locate the data when a client requests an entity bean and creates only one bean to represent that data in a Java object

Java Programming: Advanced Topics 28 EJB to Database Schema Mapping There are three approaches to database schema mapping: –Top-down mapping: possible when a new database is required and Java developers are allowed to create databases –Bottom-up mapping: occurs when you have a database and can design your EJBs to match the tables and columns defined in the database schema –Meet-in-the-middle mapping: most common solution in practice

Java Programming: Advanced Topics 29 EJB to Database Schema Mapping (Cont.) The EJB specification allows two approaches: –Container Managed Persistence (CMP): involves declaring the mapping between the deployment descriptor and delegating all code generation to the container –Bean Managed Persistence (BMP): is a do-it-yourself solution

Java Programming: Advanced Topics 30 Sample CMP Entity Bean

Java Programming: Advanced Topics 31 EJB Query Language Enterprise JavaBean Query Language (EJB QL) was introduced in the EJB 2.0 specification to support the abstract persistence model EJB QL: language for expressing the equivalent of SQL SELECT statements for CMP beans

Java Programming: Advanced Topics 32 Comparing EJB QL and SQL Statements

Java Programming: Advanced Topics 33 Using EJB QL

Java Programming: Advanced Topics 34 Message-Driven Beans An message-driven bean (MDB) initiates processing in response to an external event To create an MDB, build the bean class The MDB class must implement javax.ejb.MessageDrivenBean and javax.jms.MessageListener

Java Programming: Advanced Topics 35 A Deployment Descriptor with MDB

Java Programming: Advanced Topics 36 A Possible Scenario that Uses MDBs

Java Programming: Advanced Topics 37 EJB Transactional Characteristics The EJB specification gives you options for defining transactions: –Container managed transactions (CMT) –Bean managed transactions (BMT) –Client demarked transaction

Java Programming: Advanced Topics 38 EJB Transactional Levels

Java Programming: Advanced Topics 39 EJB Transactional Levels (Cont.)

Java Programming: Advanced Topics 40 EJB Transactional Levels (Cont.)

Java Programming: Advanced Topics 41 EJB Security The concept of passing security roles down the call stack as EJB methods call other EJB methods is called delegation Role-based security can be applied to entire EJBs or to individual methods EJB developers are not responsible for user authentication or authorization (mapping the user to a role)

Java Programming: Advanced Topics 42 Summary EJBs are distributable server-side components that run in EJB containers provided by J2EE- compliant application servers EJBs come in three basic kinds: session beans, entity beans, and message-driven beans (MDB) EJB clients locate bean instances by looking up the name in a JNDI server Stateless session beans can be shared among clients, while stateful session EJBs are used by only one client

Java Programming: Advanced Topics 43 Summary (Cont.) Entity beans represent persistent data and can be designed for container-managed persistence (CMP) or bean-managed persistence (BMP) EJB QL is a SQL-like language for writing database queries in terms of CMP bean classes and fields The concept of passing security roles down the call stack as EJB methods call other EJB methods is called delegation