Enterprise JavaBeans (I) K.P. Chow University of Hong Kong

Similar documents
presentation DAD Distributed Applications Development Cristian Toma

Chapter 6 Enterprise Java Beans

Introduction. Enterprise Java Instructor: Please introduce yourself Name Experience in Java Enterprise Edition Goals you hope to achieve

UNIT-III EJB APPLICATIONS

Application Servers in E-Commerce Applications

EJB ENTERPRISE JAVA BEANS INTRODUCTION TO ENTERPRISE JAVA BEANS, JAVA'S SERVER SIDE COMPONENT TECHNOLOGY. EJB Enterprise Java

Appendix A - Glossary(of OO software term s)

Designing a Distributed System

Deccansoft Software Services. J2EE Syllabus

Enterprise JavaBeans. Layer:01. Overview

Enterprise JavaBeans Technology

Implementing a Web Service p. 110 Implementing a Web Service Client p. 114 Summary p. 117 Introduction to Entity Beans p. 119 Persistence Concepts p.

Distributed Multitiered Application

Stateless Session Bean

The Developer s Guide to Understanding Enterprise JavaBeans. Nova Laboratories

History of Enterprise Java

Conception of Information Systems Lecture 8: J2EE and EJBs

Enterprise JavaBeans TM

Enterprise Java Unit 1-Chapter 2 Prof. Sujata Rizal Java EE 6 Architecture, Server and Containers

Enterprise JavaBeans. Session EJBs

jar command Java Archive inherits from tar : Tape Archive commands: jar cvf filename jar tvf filename jar xvf filename java jar filename.

WebSphere 4.0 General Introduction

NetBeans IDE Field Guide

PLATFORM TECHNOLOGY UNIT-5

Enterprise JavaBeans. Layer:07. Entity

Client/Server-Architecture

Overview p. 1 Server-side Component Architectures p. 3 The Need for a Server-Side Component Architecture p. 4 Server-Side Component Architecture

Using JNDI from J2EE components

The Details of Writing Enterprise Java Beans

Enterprise Java and Rational Rose -- Part I

Distributed Applications (RMI/JDBC) Copyright UTS Faculty of Information Technology 2002 EJB EJB-3

Experiences in the management of an EJB-based e- commerce application. Abstract

Creating Commercial Components (J2EE 1.3)

Introduction to componentbased software development

Master Thesis An Introduction to the Enterprise JavaBeans technology and Integrated Development Environments for implementing EJB applications

Application Servers G Session 11 - Sub-Topic 2 Using Enterprise JavaBeans. Dr. Jean-Claude Franchitti

J2EE Interview Questions

Vision of J2EE. Why J2EE? Need for. J2EE Suite. J2EE Based Distributed Application Architecture Overview. Umair Javed 1

COURSE 9 DESIGN PATTERNS

In the most general sense, a server is a program that provides information

Enterprise JavaBeans. Layer:03. Session

Enterprise JavaBeans (EJB) security

Outline. Project Goal. Overview of J2EE. J2EE Architecture. J2EE Container. San H. Aung 26 September, 2003

Developing Portable Applications for the Java 2 Platform, Enterprise Edition (J2EE )

8. Component Software

Enterprise Java Beans

TOPLink for WebLogic. Whitepaper. The Challenge: The Solution:

J2EE Development. Course Detail: Audience. Duration. Course Abstract. Course Objectives. Course Topics. Class Format.

Objectives. Software Development using MacroMedia s JRun. What are EJBs? Topics for Discussion. Examples of Session beans calling entity beans

Component-Based Platform for a Virtual University Information System

Building the Enterprise

(9A05803) WEB SERVICES (ELECTIVE - III)

Java Enterprise Edition

ITdumpsFree. Get free valid exam dumps and pass your exam test with confidence

Technologies leading up to EJB. Goals of EJB. EJB architecture. How do you develop, assemble, and deploy enterprise beans? Who supports EJB?

Chapter 2 FEATURES AND FACILITIES. SYS-ED/ Computer Education Techniques, Inc.

A General ecommerce Platform with Strong International and Local Aspects

Exam Actual. Higher Quality. Better Service! QUESTION & ANSWER

Borland Application Server Certification. Study Guide. Version 1.0 Copyright 2001 Borland Software Corporation. All Rights Reserved.

Enterprise Java (EAI) WebSphere z/os & JCA

Commercial Component Creation (EJB 2.0)

Introduction To Web Architecture

What we need. Agenda. What s J2EE. Challenges of Enterprise Application Development

Selecting Enterprise JavaBeans Technology

index_ qxd 7/18/02 11:48 AM Page 259 Index

Enterprise JavaBeans. Layer 05: Deployment

Enterprise Java and Rational Rose - Part II

J2EE - Version: 25. Developing Enterprise Applications with J2EE Enterprise Technologies

Enterprise Java Security Fundamentals

Component-Based Software Engineering. ECE493-Topic 5 Winter Lecture 26 Java Enterprise (Part D)

Java EE Patterns 176

Oracle 10g: Build J2EE Applications

Agenda. Summary of Previous Session. Extreme Java G Session 3 - Main Theme Java Core Technologies (Part I)

Problems in Scaling an Application Client

Outline. Introduction to Java. What Is Java? History. Java 2 Platform. Java 2 Platform Standard Edition. Introduction Java 2 Platform

Teamcenter Global Services Customization Guide. Publication Number PLM00091 J

BEAWebLogic. Server. Introduction to WebLogic Server and WebLogic Express. Version 8.1 Revised: June 28, 2006 Part Number:

Introduction to Web Application Development Using JEE, Frameworks, Web Services and AJAX

Java Training For Six Weeks

Outline. Chapter 5 Application Server Middleware. Types of application server middleware. TP monitors CORBA Server-side components and EJB Summary

Notes. Submit homework on Blackboard The first homework deadline is the end of Sunday, Feb 11 th. Final slides have 'Spring 2018' in chapter title

IBD Intergiciels et Bases de Données

Developing Java TM 2 Platform, Enterprise Edition (J2EE TM ) Compatible Applications Roles-based Training for Rapid Implementation

BEAWebLogic Server and WebLogic Express. Programming WebLogic JNDI

[Course Overview] After completing this module you are ready to: Develop Desktop applications, Networking & Multi-threaded programs in java.

Course Content for Java J2EE

Outline. Chapter 5 Application Server Middleware WS 2010/11 1. Types of application server middleware

Copyright UTS Faculty of Information Technology 2002 EJB2 EJB-3. Use Design Patterns 1 to re-use well known programming techniques.

BEA WebLogic Server. Programming WebLogic Enterprise JavaBeans

PSD1B Advance Java Programming Unit : I-V. PSD1B- Advance Java Programming

CAS 703 Software Design

Topexam. 一番権威的な IT 認定試験ウェブサイト 最も新たな国際 IT 認定試験問題集

JBuilder. JBuilder 6 features and benefits. Developer productivity Support for the latest Java standards

Advanced Java Programming

BEA WebLogic Server. and BEA WebLogic Express. Introduction to BEA WebLogic Server 6.1

3C05 - Advanced Software Engineering Thursday, April 29, 2004

SCBCD EXAM STUDY KIT. Paul Sanghera CX JAVA BUSINESS COMPONENT DEVELOPER CERTIFICATION FOR EJB MANNING. Covers all you need to pass

IBM Rational Application Developer for WebSphere Software, Version 7.0

Enterprise JavaBeans. Layer:08. Persistence

KINGS COLLEGE OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING ACADEMIC YEAR (ODD SEMESTER) QUESTION BANK

Transcription:

Enterprise JavaBeans (I) K.P. Chow University of Hong Kong

JavaBeans Components are self contained, reusable software units that can be visually composed into composite components using visual builder tools. Builder tools include web page builder, visual application builder, GUI layout builder, server application builder, A component model defines an environment supporting reusable application components, e.g. servlets and JSP pages Sun Microsystems defines a generic Java component model: JavaBean (JavaBean API 1.01 specification) for linking pieces of code to form an applet or application A component conforms to this application is called a JavaBean (or a Bean). A JavaBean must be developed in Java but can be used by any application on any platform

Enterprise JavaBeans The Enterprise JavaBeans (EJB) architecture is a component architecture for the development and deployment of object oriented distributed enterprise level applications. EJB is not JavaBean at the enterprise level, EJB is used to implement transactional middleware Applications written using the Enterprise JavaBeans architecture are scalable, transactional, and multi user secure. These applications may be written once, and then deployed on any server platform that supports the Enterprise JavaBeans specification. (EJB 2.0 Specification)

Java Platform for Enterprise EJB was designed to satisfy the two industry themes: components and multi tier paradigm JavaBeans Components HTML IIOP, other protocols Servlets Enterprise JavaBeans components Server Platform JTS JMAPI JNDI JIDL JMS JDBC IIOP (Internet InterORB Protocol) is a stream protocol used to encode requests from a client to a server object and results returned from the server object.

Component Architecture Each component has a defined and published interface that provides application functionality Components are combined to produce a new application Component environment Supports the following services: multi threading, concurrency control, resource management, security, and transaction management Provides runtime services by component containers: the container insulates the component from the runtime platform and manages the use of resources, such as execution threads, memory, and CPU When a client invokes a server component, the container allocates the resources and initiates the component, and manages all interactions between the component and the external systems

Component Environment To achieve Plug and Play assembly: Purchase a component, install it, and integrates it into their system with minimal or no effort Standardizing the contracts (interfaces) Market availability: Fairly rich supply of off theshelf client products Server side components are limited Presentation Glue Code Component A Component B Component C Component Environment Operating Systems CPU Memory Comms

Multi Tier Paradigm (1) Web based Application Partitioning Client Workstation Web Server Business Logic Data Access Internet DBMS

Applications can be partitioned into 4 layers: presentation, business logic, data access, data management These layers can be distributed between the client and the server in various ways, e.g. Two tier model: Fat Client 3 tier model Multi tier Paradigm (2) Integrating different types of client systems and server systems is often quite complex Client Presentation Logic Client Presentation Logic Business Logic Server Business logic Server Data Access logic Database DBMS

EJB Model EJB defines an architecture for the development and deployment of transactional, applications based, server side software components The server side components are called enterprise beans: they are distributed objects, which implement the business logic and provide remote services for clients distributed throughout the network Java 2 Platform, Enterprise Edition (J2EE) supports web based enterprise applications: a platform for the design, development, assembly and deployment of enterprise applications J2EE defines the following components: Client components: client applications and applets Web components: Servlet and JSP Business components: EJB components (enterprise beans)

EJB Model Key Elements (1) Server Client EJB Container transaction control persistence management security services Transaction System Interface to DB and Backend system EJB Home Interface DBMS Enterprise Services and API JNDI JTS Security Messaging

EJB Model Key Elements (2) Server: Provides a standard set of services (distributed transaction management and security) for the container Provides at least one container for enterprise beans (the EJB container) EJB container: provides the environment for the deployment and runtime environment for the enterprise beans Security: protect system resources against unauthorized access Transaction: specify relationship among methods within a single transaction so that all methods in a transactions are treated as a single unit Access naming and directory service: JNDI Deployment of enterprise beans Persistence of enterprise bean state information Concurrency control over enterprise bean access Remote connectivity between clients and enterprise beans to achieve remote invocation Manage the life cycle of an enterprise bean instance Client interface Interface to backend systems and DB

EJB Container Request from client Transaction management Persistence management Security management Enterprise Bean EJBContext, JNDI ENC Callback Methods The container isolates the enterprise beans from direct access by client applications. Enterprise bean developers are insulated from platform dependent APIs and therefore can focus on encapsulating business rules while the EJB container takes care of the rest, e.g. security

Container and Bean Interactions (1) Callback methods: Each bean implements a subtype of EnterpriseBean interface, which defines several methods called callback methods Each callback method alerts the enterprise bean to a different event and the container will invoke these methods to notify the enterprise bean when it encounters the events, such as: activates the enterprise bean persists the enterprise bean state to DB ends a transaction removes the enterprise bean from the memory EJBContext: Every enterprise bean obtains an EJBContext object, which is a reference directly to the container The EJBContext object provides methods for interacting with the container to request information about its environment, e.g. identity of the client, status of a transaction, its own remote references

Container and Bean Interactions (2) Java Naming and Directory Interface (JNDI) Every enterprise bean can use JNDI to access a special naming system called the Environment Naming Context (ENC), managed by the container The default context is in the name space (directory) called java:comp/env and its subdirectories When an enterprise bean is deployed, any beans it uses are mapped into the subdirectory java:comp/env/ejb, and bean references can be obtained at runtime through the default context JNDI ENC also allows an enterprise bean to access resources like JDBC connections, other enterprise beans, and properties specific to that bean EJB specification defines a bean container contract Include the above interaction mechanisms and a set of strict rules describes the various behavior of the enterprise beans and their containers Design to make an enterprise bean portable among containers so that an enterprise bean once developed can be deployed to any EJB container

EJB Runtime Environment EJB models are implemented on standards based scalable platform: Based on industry standard protocols: TCP/IP, IIOP Appropriate for small scale applications to large scale business transaction systems Supports Internet based application Interoperability with heterogeneous clients: use EJB to CORBA mapping, IIOP EJB containers provide transparent attachment to vendor specific backend systems Supports higher level of integration and interoperability: EJB applications can be developed in any EJB compliant environment EJB applications can be deployed in any EJB compliant environment Allows customization without access to source code Application behaviors and runtime settings can be changed at development and deployment time (by modifying the bean properties)

EJB Products Products that support EJB architecture: TP monitors, e.g. BEA Tuxedo or IBM TXSeries Component Transaction Servers, e.g. Sybase Jaguar CTS, Microsoft Transaction Server CORBA, e.g. Borland VisiBroker/ITS Web platforms, e.g. IBM WebSphere Application Server DBMS, e.g. IBM DB2 JBoss (open source)

EJB Lifecycle EJB Server Provider EJB User / GUI programmer EJB Server EJB Application EJB Container Provider EJB Container EJB Developer Enterprise JavaBean EJB Deployer

EJB Core Elements EJB Server EJB Client Locate, Create and Remove instance of EJB Home Interface Home Object EJB Container Enterprise JavaBeans Invoke Business methods of EJB Remote Interface EJB Object Databases Enterprise Services and API JNDI JTS Security Messaging

EJB Server side Component 2 interfaces defining the EJB server side component s business methods: home interface and remote interface: use to access the enterprise bean Home interface: for methods with life cycle behaviors of an enterprise bean that are not specific to a single bean instance, e.g. create and locate the bean Remote interface: for methods with behaviors that are specific to a single bean instance, e.g. exposed business methods for the bean Actual implemented class of the bean: instantiated to become a distributed object during run time

EJB Client Home interface: CustomerHome Remote interface: Customer // get the JDNI naming context Context initialctx = new InitialContext(); // use the context to lookup the EJB home interface CustomerHome CustomerHome home=(customerhome)initialctx.lookup( /Customer ); // Use the home interface to create a new instance of customer bean Customer customer = home.create(customerid); // Use business method in the customer remote interface Customer customer.changepassword(somepassword);

EJB Home Interface and Home Objects The home interface of an enterprise bean is used to control the life cycle of its bean objects by providing the methods: create, find and remove Home object is the implementation of the home interface A home interface extends the interface javax.ejb.ejbhome, which defines a standard set of utility methods and provide a common base type for all home interfaces A home interface is defined by the enterprise bean provider and implemented by the enterprise bean container, i.e. EJB programmer defines the home interface EJB container vendor provides tools that automatically generates the EJBHome object that implements home interface Home Interface <Interface> java.rmi.remote extends <Interface> javax.ejb.ejbhome extends <Interface> CustomerHome

Example of Home Interface Home interface provides life cycle methods for creating, destroying and locating beans package com.club.customer; import java.ejb.*; import java.rmi.remoteexception; public interface CustomerHome extends EJBHome { } public Customer create (String lastname, String firstname, String middleinitial) throws RemoteException, CreateException, NameException; public Customer create (String preapprovalcode) throws RemoteException, CreateException, CodeException; public Customer findbyname (String name) throws RemoteException, FinderException;

Methods in Home Interface In the example, CustomerHome has 2 create methods: Which create method to invoke depends on the type and number of arguments The create methods return the enterprise bean remote interface, Customer The create methods throw EJB exceptions and application specific exceptions: NameException and CodeException, and the exceptions are defined in an exception class as part of the package com.club.customer The name of a find methods always begins with find, e.g. findbyname to obtain an enterprise bean remote interface The remove method is defined in the superinterface EJBHome Not all EJB have all the types of the methods Home interface itself is a valid remote interface for the Java RMI IIOP in the sense that its method throws java.rmi.remoteexception and the types of arguments and return values are legal for RMI IIOP

EJB Remote Interface and EJBObjects The enterprise bean remote interface defines the business methods that a client can invoke on an individual enterprise bean object Clients use the bean s home interface to obtain references to the bean s remote interface A remote interface extends the interface javax.ejb.ejbobject, which defines a standard set of utility methods and provides a common base class for all remote interfaces EJB programmer defines the remote interface EJB container vendor provides tools that generates the code for the EJBObject that implements the remote interface The client makes a call to a method in the remote interface, which is then forwarded to the corresponding method of the enterprise bean EJBObjects are managed by the EJB container Remote Interface <Interface> java.rmi.remote <Interface> javax.ejb.ejbobject <Interface> Customer extends extends

package com.club.customer; Example of Remote Interface import java.ejb.*; import java.rmi.remoteexception; public interface Customer extends EJBObject { } public Float getbalance ( ) throws RemoteException; public void changepassword (String newpassword) throws RemoteException, PasswordException; 2 methods are shown in the above remove interface Customer: these are the exposed methods Note that the arguments and the return values must be legal types for RMI IIOP Applications access enterprise beans using the remote and home interfaces at run time

EJB Client Locate the specific EJB container through JNDI Use home object to locate, create or destroy instances of Enterprise Beans remote EJB Container Make use of the EJBObject to invoke bean methods Only get reference to EJBObject When client invokes a method, the EJBObject receives the request, delegates to the corresponding bean instance Client home remote home HotelClerk Customer

Example of EJB Client Home interface is CustomerHome Remote interface Customer // get the JDNI naming context Context initialctx = new InitialContext(); // use the context to lookup the EJB home interface CustomerHome CustomerHome home=(customerhome)initialctx.lookup( /Customer ); // Use the home interface to create a new instance of customer bean Customer customer = home.create(customerid); // Use business method in the Customer remote interface customer.changepassword(somepassword);

EJB Runtime Behavior 1. Lookup( /Customer ) 2. create() find () JNDI Home Interface EJBHome 3. 5. Deployment Descriptor 7. ejbcreate() ejbfind () EJBean Instance EJB Jar Client 4. new() 9. bean methods 8. bean methods EJBObject EJB Context Remote Interface 6. EJB Server/Container