Lecture 7 Enterprise JavaBeans: Architecture and Goals.

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.
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.
June 1999 EJB1 EJB and CHAIMS Dorothea Beringer Enterprise Java Beans and how to build a CHAIMS infrastructure using the EJB paradigm.
Sapana Mehta (CS-6V81) Overview Of J2EE & JBoss Sapana Mehta.
Copyright W. Howden1 Lecture 19: Intro to O/O Components.
July 23 th, 2005 Software Architecture in Practice RiSE’s Seminars Bass’s et al. Book :: Chapter 16 Fred Durão.
SEI/CBS Initiative Software Engineering Institute Carnegie Mellon University Pittsburgh, PA Sponsored by the U.S. Department of Defense © 1999.
Version # Software Engineering Institute Carnegie Mellon University Pittsburgh, PA Sponsored by the U.S. Department of Defense © 1999 by Carnegie.
J2EE Kenneth M. Anderson CSCI Web Technologies October 3, 2001.
CS 483 Enterprise and Web Application Programming
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)
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.
Lecture 8 Advanced Topics in Enterprise JavaBeans.
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.
J2EE Overview ver 1.0Page 1 © Wipro Technologies Talent Transformation J2EE Overview.
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.
Enterprise Java Bean Technology Briefing Markus Hebach.
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.
Alan L. Batongbacal CS 4244 / 01 Nov 2000
Enterprise JavaBeans. Lesson 1: Introduction to Server-Side Component Software.
Middleware Technology (J2EE/EJB) EJB Fundamentals.
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.
J2EE Platform Overview (Application Architecture)
Introduction to J2EE Architecture
Luca Simone Software Engineering 2 a.a. 2001/2002
Objectives In this lesson, you will learn to:
Enterprise Java Beans Bina Ramamurthy 1/13/2019 B.Ramamurthy.
Component-based Applications
Component Technology Bina Ramamurthy 2/25/2019 B.Ramamurthy.
Understanding and Designing with EJB
Enterprise Java Beans Bina Ramamurthy 4/5/2019 B.Ramamurthy.
Knowledge Byte In this section, you will learn about:
Presentation transcript:

Lecture 7 Enterprise JavaBeans: Architecture and Goals

What are Enterprise JavaBeans EJB is a semi-automated server-side component management architecture that facilitates the deployment of enterprise-class distributed object applications in Java. –server-side highly-available enterprise (24x7) –components encapsulated (self-contained) portability object model (inheritance, polymorphism, interface/implementation disjunction) reusability –automated management Persistence (distributed 2-Phase Commit Transactions) Security Load balanced/fault tolerant –deployment –enterprise distributed object applications –Java language

Foundations EBJ Technology is built on other key J2EE and OMG foundations: –RMI objects JNDI naming and location –Does for Novell’s NDS and LDAP access what JDBC did for Sybase and Oracle DBMS acccess Remote method exposure –JDBC –JTS/JTA –CORBA IIOP

What’s J2EE all about? J2EE is a specification –Vendor independent –Platform independent (portable) –API consistency –Test suite –Reference implementation

J2EE Technologies (EJB as a canton in a larger confederacy) RMI and RMI-IIOP Java Naming and Directory Interface (JNDI) JDBC Java Transaction API (JTA) and Java Transaction Service (JTS) Java Messaging Service (JMS) Java Servlet API (JSDK) Java Server Pages (JSP) Java IDL (CORBA) JavaMail API Extensible Markup Language (XML) Enterprise Java Beans (EJB)

Stated Goals of EJB “The EJB architecture will be the standard component architecture for building distributed object-oriented business applications in the Java Programming Language.” Sun EJB Specification 1.1 “Application developers will not have to understand low- level transaction and state management details, multi- threading, connection pooling and other complex low-level APIs.” ibid. “EJBs will follow the Write Once, Run Anywhere philosophy of the Java Programming Language. An EJB can be developed once, and then deployed on multiple platforms without recompilation or source code modification.” ibid.

Stated Goals of EJB “The EJB architecture will address the development, deployment, and runtime aspects of an enterprise application’s life cycle.” ibid. “The EJB architecture will provide interoperability between enterprise Beans and non-Java programming language applications.” ibid. “The EJB architecture will be compatible with the CORBA protocols.” ibid.

What benefits does the EJB Architecture Provide? Component Transaction Monitor –Distributed Transaction/2 Phase monitoring Generic Naming and Implicit component location –clients do not have to know the specific location of a component to use it Security –Automated User Authentication via Access Control Lists

What benefits does the EJB Architecture Provide? Persistence –Implicit persisting, activation and deactivation –Implicit component life cycle management Implicit distributed transaction management –Distributed 2-Phase commit (Begin,End,Commit,Rollback) Load Balancing/Transparent Failover –Resource Pooling –Multi-client support Metadata Management –Declarative Specification

Server Architecture

Client-Server Interaction

Component Characteristics An enterprise bean contains business logic that operates on the enterprise’s data. An enterprise bean’s instances are created and managed at runtime by a Container. An enterprise bean can be customized by the customer at deployment time by editing the bean’s metadata Client access is indirect--it always is via the Container The EJB can be deployed in any compliant Container

EJB Topology An EJB may implement: –an object that represents a stateless (highly available) service a calculation algorithm (insurance, finance, trading, etc.) a lookup service a security manager that validates a user and returns a token pooled resource Stateless Session Bean

EJB Topology An EJB may implement: –an object that represents a conversational session with a particular client (contradistinguished from HTTP protocol) Extension of client business functionality on the server side –avoids Fat clients and 2-tier scenarios Typically will handle database operations on behalf of the client automated instance passivation and activation pooled resource Stateful Session Bean

EJB Topology An EJB may implement: –a high-level abstraction that represents a business entity that encapsulates business state and is accessible by multiple clients a “Customer” object a “Contract” object in futures trading a “Policy” object in insurance Entity Bean

EJB Topology An EJB may implement: –a middleware observer that listens for certain events in the system, and acts as a consumer of events it is interested in a “logger” object a “trade validator” object in futures trading a “claim processor” object in insurance Message-Driven Bean

Session Objects execute some business logic on behalf of a single client can be transaction enabled does not directly represent data in a database, but can access one are generally short-lived are removed when the Container crashes (client must reconnect) participate in a Container’s scalable runtime environment, executing concurrently with multiple instances

Entity Objects provide a class (object-encapsulated) view of data in a database allow keyed, shared access from multiple simultaneous clients are generally long-lived along with their primary keys and remote references survive the crash of the Container

Implementing an EJB Object Home Interface –The Client’s way of creating a local reference to a server –Defines a single create(…) method Remote Interface (think CORBA IDL) –This interface defines the client semantics for the bean –Here is where you declare the methods your bean will implement

Implementing an EJB Object Bean Implementation (think CORBA Impl) –Here is where you implement the methods in the Remote Interface. –Similar to a CORBA implementation implementing an IDL interface, the Bean implementation implements the Remote Interface’s declared methods.

Implementing an EJB Object The Bean implementation also defines callback methods that the Container will use to communicate with the bean. These include: –ejbPassivate() –ejbActivate() –ejbCreate() –ejbRemove() –ejbLoad(): entity –ejbStore(): entity –ejbFindByPrimaryKey(Primary key): entity

General Security 2 Levels of security that clients must pass in EJB: –client authentication verifies the client is indeed whom he claims to be username/password authentication after authentication, given a security identity for the rest of the session –client authorization grants permission to a security identity to perform certain operations occurs during an EJB method call supports both declarative (container-based) and programmatic authorization

General Security Security Roles –Security Roles are collections of client identities, such as “general user”, “privileged user”, “system administrator”, etc. –Every Security Role can be assigned method permissions, which grant certain roles the rights to access some defined group of methods on a home or remote interface –Roles are defined in the deployment descriptor

General Security Declarative Authorization (in deployment descriptor) –modifySystemProperties [administrator] –searchData [everyone] Programmatic Authorization (based on java.security.Principal and SessionContext) –isCallerInRole(securityRole) - checks to see that the current user (per the EntityContext) is a member of a role –getCallerPrincipal() - returns the secure name of the client user

Session Bean Persistence Stateful Session Bean Passivation and Activation –Since Stateful SessionBeans cannot be shared but are client-specific, their resources are limited and can, under load, be persisted to permanent storage and later recalled into memory –Passivation is the process whereby a stateful session bean’s non-transient conversational state is serialized to permanent storage. After the container has passivated the state, ejbPassivate() is called to allow the Bean to release any database or socket connections, etc.

Session Bean Persistence Stateful Session Bean Passivation and Activation –Activation is the process where the persisted state of a bean is deserialized due to client access on the persisted bean. The state is restored and ejbActivate() is called to notify the bean that it should re-establish connections, handles, etc. –Passivation is performed according to a Least Recently Used (LRU) strategy. The bean whose last client access was farthest back in time is the first to be passivated.

Container-Managed Persistence The container implicitly performs all database operations on behalf of the CMP entity bean Primary Key class must be serializable Object-Relational database mapping is done declaratively in the deployment descriptor Programmer generally writes little if any direct JDBC connection code (but is free to if he wishes)

Container-Managed Persistence finder functions are described in the deployment descriptor (ejb-jar.xml): – – findAccount – – double – – <![CDATA[SELECT OBJECT(a) FROM AccountBean AS a WHERE a.balance = ?1]] –> –

Entity Bean Persistence Bean-Managed Persistence –Bean developer, not the container, provides all data access logic –Developer implements callbacks such as ejbFind…(), ejbCreate(), ejbActivate(), ejbLoad(), ejbStore(), ejbPassivate(), ejbRemove() –Developer uses JDBC or SQL/J to interact with the database

Distributed Transaction Support JDBC provides default non-distributed transaction support with autocommit This is insufficient when dealing with distributed components which may severally be involved in a single transaction ACID Properties (Atomic, Consistent, Isolated, Durable)

Distributed Transaction Support Only flat transactions are supported currently in EJB, not nested transactions Multiple database can be updated automatically in a single transaction Transactions can be handled either declaratively or programmatically –Programmatically handled requires programmer to issue Begin, End, Commit, Rollback –Declaratively handled requires the EJBObject (container) to issue transaction boundaries on behalf of the implementation

Distributed Transaction Support EJB Transaction Attribute Values (set in Deployment Descriptor): –TX_BEAN_MANAGED: bean is programmatically handling all transaction boundaries –TXN_NOT_SUPPORTED: bean operates outside of any particular transactional context –TXN_REQUIRED: bean must always run within the context of a transaction –TXN_REQUIRES_NEW: bean must always have its own new transaction created, current transaction, if any, is suspended –TXN_SUPPORTS: bean only runs in a transaction if one is already present –TXN_MANDATORY: bean must run in a transaction, and that transaction must already be present and active (javax.ejb.TransactionRequired exception)

Distributed Transaction Support EJB Isolation Levels (set in Deployment Descriptor) –TRANSACTION_READ_UNCOMMITTED (no protection from dirty reads, repeatable reads, etc.) –TRANSACTION_READ_COMMITED (eliminates dirty reads, reading uncommited data) –TRANSACTION_REPEATABLE_READ (eliminates changing data during updates) –TRANSACTION_SERIALIZABLE (eliminates dirty reads, unrepeatable reads, and phantom (new) reads)

Resource Management/Load Balancing Mechanisms Instance pooling in EJB Servers reduces the number of component instances needed overall, by allowing clients to share components individually or collectively Pooling also reduces the frequency of component creation and removal Each instance of a component in a pool is equivalent, but some may have higher priority due to access algorithms (LRU, Round-Robin) New instances can be created and added to the pool, and other instances can be checked in and out for usage by clients Pool management is handled intelligently by the container Database ConnectionPools are supported and user- defined

Resource Management/Load Balancing Mechanisms EJB Servers/Containers provide Instance Swapping –Stateless SessionBeans can easily be swapped for client access because they maintain no client-specific state, they are truly equivalent, and one will work as well as another –Entity beans can also be swapped through the interaction of the container and the setEntityContext() and unsetEntityContext() methods EJB Servers/Containers provide management through activation and passivation

Failover Management Stateless Session Beans: On failure, bean is automatically reinstantiated in a different server process Stateful Session Beans: On failure, manual reconfiguration on another machine is required Entity Beans: On failure, Client application reacts to RemoteException by reinvoking findByPrimaryKey, which will automatically map to other supporting groups

Metadata Management Deployment Descriptors allow EJB containers to supply run-time middleware services (persistence, transaction, security, etc.) to a generic EJB, thus relieving the EJB from having to hard-code this support into the bean itself Entries in a Deployment Descriptor cumulatively make up the bean’s metadata

Metadata Management A bean’s metadata may also include bean-specific properties that are become Java properties, that are available to a bean at runtime With EJB 1.0, you had to write a single deployment descriptor for each bean, and that DD had to be a serializable Java class, based on a plain text file description, and a manifest file was needed to describe all the deployment descriptors in an ejb-jar file With EJB 1.1, you need only write a single deployment descriptor for each ejb-jar file, and this descriptor is written in XML. Since there is now only one deployment descriptor, manifest files are no longer needed

Deployment Description Overview Specify Home Interface Specify Remote Interface Specify Bean implementation class Specify Bean type (session or entity) Specify the JNDI name for the home interface for Clients to use Transaction support definition

Deployment Description Overview Transaction isolation level definition Access Control Lists (ACLs) and attributes Session Timeout (session beans only) Database member-Class attribute mapping (container-managed entity beans only) Reentrancy information (entity beans only) Primary Key class (entity beans only) Environment specifics

Abstracting Capabilities of the Container Multithreading Resource Pooling Scaling Distributed naming and location –Container is responsible for make the home interfaces of its deployed beans available via JNDI Automatic persistence –Bean-Managed Persistence –Container-Managed Persistence Transaction handling Distributed Transaction Management

Responsibilities of the Container for Session Beans Making the home interfaces of deployed beans available via JNDI Implementing the home interface of each installed EJB (EJBHome) –home interface allows a client to create a new session object (factory method) –home interface allows for the removal of a session object Implementing the remote interface of each installed EJB (EJBObject) –remote interface allows clients to make business method calls on a session objects

Responsibilities of the Container for Session Beans Implementing Handle (support) classes for the Home and Remote interfaces Implementing the EJBMetaData class Must ensure that only one thread can be executing an instance at any time (session objects are serialized, single-client servants)

Responsibilities of the Container for Entity Beans Making the home interfaces of deployed beans available via JNDI Implementing the home interface of each installed EJB (EJBHome) –home interface allows a client to create a new session object (factory method) –home interface allows for the removal of a session object Implementing the remote interface of each installed EJB (EJBObject) –remote interface allows clients to make business method calls on a session objects

Responsibilities of the Container for Entity Beans Implementing Handle (support) classes for the Home and Remote interfaces Implementing the EJBMetaData class Must ensure that reentrant rules are followed (intra-transactional legal loopback, illegal concurrent call) Implementation of robust (long-lived) object references. A client should be able to use an object reference across a server crash and restart

BEA Weblogic Enterprise (WLE) WLE combines an ORB and OLTP functionality within ATMI (Application- to-Transaction Manager Interface), CORBA and EJB CORBA and EJB objects share the same transaction, security, configuration, and monitoring infrastructure Native IIOP communication between RMI, EJB, CORBA Java/C++, and Tuxedo ATMI (Xopen XATMI compliant) WLE Domain Offerings: –CORBA –EJB –ATMI –Security –TP Monitor –Web Server & Servlet Engine –RMI –HTML/JSP