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

Slides:



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

J0 1 Marco Ronchetti - Basi di Dati Web e Distribuite – Laurea Specialistica in Informatica – Università di Trento.
Distributed Systems Architectures
Author: Julia Richards and R. Scott Hawley
1 Copyright © 2013 Elsevier Inc. All rights reserved. Appendix 01.
Communicating in J2EE.
19 Copyright © 2005, Oracle. All rights reserved. Distributing Modular Applications: Developing Web Services.
21 Copyright © 2005, Oracle. All rights reserved. Oracle Application Server 10g Transaction Support.
12 Copyright © 2005, Oracle. All rights reserved. Implementing Business Tasks with Session EJBs.
1 Copyright © 2005, Oracle. All rights reserved. Introduction.
7 Copyright © 2005, Oracle. All rights reserved. Maintaining State in J2EE Applications.
18 Copyright © 2005, Oracle. All rights reserved. Distributing Modular Applications: Introduction to Web Services.
5 Copyright © 2005, Oracle. All rights reserved. Accessing the Database with Servlets.
4 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: Servlets.
16 Copyright © 2005, Oracle. All rights reserved. Developing Message-Driven Beans.
3 Copyright © 2005, Oracle. All rights reserved. Designing J2EE Applications.
3 Copyright © 2005, Oracle. All rights reserved. Basic Java Syntax and Coding Conventions.
15 Copyright © 2005, Oracle. All rights reserved. Container-Managed Relationships (CMRs)
1 Copyright © 2005, Oracle. All rights reserved. Introducing the Java and Oracle Platforms.
9 Copyright © 2005, Oracle. All rights reserved. Modularizing JavaServer Pages Development with Tags.
8 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: JavaServer Pages.
J2EE Overview.
10 Copyright © 2005, Oracle. All rights reserved. Reusing Code with Inheritance and Polymorphism.
6 Copyright © 2005, Oracle. All rights reserved. Building Applications with Oracle JDeveloper 10g.
17 Copyright © 2005, Oracle. All rights reserved. Deploying Applications by Using Java Web Start.
Enterprise Java and Data Services Designing for Broadly Available Grid Data Access Services.
31242/32549 Advanced Internet Programming Advanced Java Programming
Understanding Generalist Practice, 5e, Kirst-Ashman/Hull
Executional Architecture
©Brooks/Cole, 2001 Chapter 12 Derived Types-- Enumerated, Structure and Union.
PSSA Preparation.
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.
EJB Design. Server-side components Perform –complex algorithms –high volume transactions Run in –highly available environment (365 days/year) –fault tolerant.
Enterprise Java Beans Welcome to the world of “Distributed System” Presented By: Sameer Nanda Date: 12/17/03.
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.
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.
Ing. Ignacio Roqueta ARTech GeneXus and J2EE.
Enterprise Java Bean Matt. 2 J2EE 3 J2EE Overview.
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.
1 Java EE Programming Enterprise JavaBeans. 2 Topics J2EE Overview Enterprise JavaBeans Overview Enterprise Entity Beans Case Study How to build them.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Session Beans Based on: Patel, Brose, Silverman, Mastering Enterprise JavaBeans 3.0.
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. 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.
14 Copyright © 2004, Oracle. All rights reserved. Achieving State Management in the Business Tier.
©NIIT Session Beans Lesson 1B/ Slide 1 of 37J2EE Server Components Objectives In this lesson, you will learn to: Describe the characteristics of session.
EJB (Enterprise Java Beans)
Introduction to J2EE Architecture
Objectives In this lesson, you will learn to:
Component-based Applications
Component Technology Bina Ramamurthy 2/25/2019 B.Ramamurthy.
Understanding and Designing with EJB
Knowledge Byte In this section, you will learn about:
Presentation transcript:

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

11-2 Copyright © 2005, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: Define an Enterprise JavaBean Describe the Enterprise JavaBeans (EJB) architecture Describe the types of EJBs and when they are used Explain EJB interfaces Define the steps to deploy an EJB to Oracle Application Server 10g

11-3 Copyright © 2005, Oracle. All rights reserved. Enterprise JavaBeans (EJB) Enterprise JavaBeans are portable components, which: Enable faster application development Allow reuse of business components Encapsulate business logic that can be invoked by clients Execute in a container that provides services such as support for transactions, persistence, and access control for the beans

11-4 Copyright © 2005, Oracle. All rights reserved. When to Use EJBs When developing a J2EE application, decide whether to use EJBs based on the following requirements: The applications are complex and would benefit from the system-level services that are provided by an EJB container. The applications must be portable and scalable. The applications must be accessed by different types of clients.

11-5 Copyright © 2005, Oracle. All rights reserved. Types of EJBs EJB TypePurpose Session BeansPerforms a task for a client Entity Beans Represents a business object that exists in a database Message-Driven Beans Receives asynchronous Java Message Service (JMS) messages

11-6 Copyright © 2005, Oracle. All rights reserved.

11-7 Copyright © 2005, Oracle. All rights reserved. Session Beans Session beans invoke methods for a single client. There are two types of session beans: Stateless Session Beans (SLSBs) –Conversation that spans a single method call –Single request business processes that do not maintain client-specific state Stateful Session Beans (SFSBs) –Conversation with one client that may invoke many methods –Business processes that span multiple method requests, thus maintaining state EJB container Client 1 Client 2 Pool of SLSBs EJB container Client 1 Client 2 SFSBs

11-8 Copyright © 2005, Oracle. All rights reserved.

11-9 Copyright © 2005, Oracle. All rights reserved. Entity Beans Entity beans represent a business object in the database. They are: Sharable across multiple clients Uniquely identifiable through a primary key Persistentthe state survives an EJB server crash There are two types of persistence in entity EJBs: Container-managed persistence (CMP) beans: –The state of the bean is maintained by the container. –The bean developer specifies the persistent fields. Bean-managed persistence (BMP) beans: –The state of the bean is maintained by the bean itself. –The bean developer writes the logic to manage persistence by using Java Database Connectivity (JDBC).

11-10 Copyright © 2005, Oracle. All rights reserved. Message-Driven Beans Provide a facility for asynchronous communication Exist within a pool, and receive and process incoming messages from a JMS queue or topic Are invoked by the container to handle each incoming message from the queue or topic Are similar to stateless session beans Clients EJB container Pool of MDBs JMS queue

11-11 Copyright © 2005, Oracle. All rights reserved. EJB Architecture EJB client EJB server Enterprise Services Naming, Transaction, Security, Messaging Deployment descriptor Database EJB container Remote/ local object Home/ local home object Remote/ local interface Home/local home interface EJB Class

11-12 Copyright © 2005, Oracle. All rights reserved. EJB Server Manages the EJB container Provides a deployment and execution platform for EJB components Provides system services to containers that in turn provide services to beans: –Transaction services –JNDI naming services Can provide vendor-specific features such as connection pooling

11-13 Copyright © 2005, Oracle. All rights reserved. EJB Container Manages the life cycle of the enterprise beans Isolates the enterprise beans from direct access by client applications Makes required services available to the EJB classes through well-defined interfaces Client EJB container EJB class home/local home object Home/local home interface Container generated remote/l ocal object Remote/ local interface

11-14 Copyright © 2005, Oracle. All rights reserved. Services Provided by the EJB Container Life-cycle management Bean instance pooling Client state management Database connection pooling Declarative transaction management Security Persistence

11-15 Copyright © 2005, Oracle. All rights reserved.

11-16 Copyright © 2005, Oracle. All rights reserved. EJB Client An EJB client is a stand-alone application, servlet, JSP, or another EJB that accesses the bean. It can be a: Local client: –Resides within the same Java virtual machine (JVM) as the bean –Passes arguments by reference to the bean –Interacts with the EJB through methods defined in the local interface Remote client: –Is location independent –Passes arguments by value to the bean –Interacts with the EJB through methods defined in the remote interface

11-17 Copyright © 2005, Oracle. All rights reserved. EJB Interfaces and Classes Interfaces: –Remote interface/Local interface –Home interface/Local home interface Classes: –Bean class –Primary key class (entity beans)

11-18 Copyright © 2005, Oracle. All rights reserved. Remote Interface and Remote Object Remote interface: –Extends the javax.ejb.EJBObject interface that extends the java.rmi.Remote interface –Describes the client view of an EJB –Declares the business methods that are accessible to remote clients EJB object: –Is a container-generated implementation of a remote interface –Is a reference object that a client receives –Delegates the method calls to a bean class after doing some infrastructure work The remote interface and remote object are used by session and entity beans.

11-19 Copyright © 2005, Oracle. All rights reserved. Home Interface and Home Object Home interface: –Extends the javax.ejb.EJBHome interface that extends the java.rmi.Remote interface –Contains the life-cycle methods for creating, removing, and locating the instances of a bean class –Contains home methods –Are accessed by remote clients Home object: –Is a container-generated implementation of the home interface –Uses callback methods on a bean class to perform its functions

11-20 Copyright © 2005, Oracle. All rights reserved. Local Interface and Local Home Interface Local interface: –Extends the javax.ejb.EJBLocalObject interface –Declares the business methods of the bean that are accessible by a local client –Improves performance because the bean resides in the same JVM, and parameters are passed by reference Local home interface: –Extends the javax.ejb.EJBLocalHome interface –Defines the life-cycle methods that are accessible by local clients These interfaces are used by session and entity beans. They enable relationships between entity beans.

11-21 Copyright © 2005, Oracle. All rights reserved. EJB Bean Class A bean class extends javax.ejb.EnterpriseBean. A session/entity bean class: –Implements javax.ejb.SessionBean / javax.ejb.EntityBean –Implements business/life-cycle methods –Contains methods to support container callbacks –Contains methods to set and unset the context of the bean A message-driven bean class: –Implements javax.ejb.MessageDrivenBean –Must implement the MessageListener interface –Contains business logic in the onMessage() method

11-22 Copyright © 2005, Oracle. All rights reserved. The EJB Deployment Process Jar command/ tool EJB JAR JNDI Component deployers responsibility Developers responsibility Home interface Remote interface Bean class Other classes Deployment descriptor Deployment tools/ commands Deployed EJB in the Server

11-23 Copyright © 2005, Oracle. All rights reserved. | | Say Hello HelloWorld lesson11.HelloWorldHome lesson11.HelloWorld lesson11.impl.HelloWorldBean | | ejb-jar.xml File

11-24 Copyright © 2005, Oracle. All rights reserved. orion-ejb-jar.xml File Oracle Application Server 10g uses the orion-ejb-jar.xml file for deployment. This file: Specifies run-time attributes of the bean for deployment to the container Enables customization of the run-time behavior of enterprise beans

11-25 Copyright © 2005, Oracle. All rights reserved. Creating an EJB in JDeveloper

11-26 Copyright © 2005, Oracle. All rights reserved. Using the EJB Wizard

11-27 Copyright © 2005, Oracle. All rights reserved. Using the EJB Wizard

11-28 Copyright © 2005, Oracle. All rights reserved. Adding Methods to the Bean To add methods to the bean, right-click and select Go To Bean Class:

11-29 Copyright © 2005, Oracle. All rights reserved. Deploying to Oracle Application Server 10g from JDeveloper

11-30 Copyright © 2005, Oracle. All rights reserved. Summary In this lesson, you should have learned how to: Define an EJB Describe the EJB architecture Describe the types of EJBs and when they are used Explain EJB interfaces Define the steps to deploy an EJB to Oracle Application Server 10g

11-31 Copyright © 2005, Oracle. All rights reserved. Practice 11-1: Overview This practice covers the following topics: Creating an EJB in JDeveloper Testing an EJB

11-32 Copyright © 2005, Oracle. All rights reserved.

11-33 Copyright © 2005, Oracle. All rights reserved.

11-34 Copyright © 2005, Oracle. All rights reserved.