A Case Study on the J2EE Platform CPSC550 Graduate Student Seminar Presentation by Jeffrey A. Brown.

Slides:



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

Introduction to Java 2 Enterprise Edition About myself –Neutrinos, Cancer Research, IT Applications Today’s topic: J2EE –Context –Advantages –Components.
Some of these slides were excerpted from: Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich, Jeffrey A. Hoffer.
Distributed System Using Java 2 Enterprise Edition (J2EE) B.Ramamurthy.
Introduction to Enterprise JavaBeans. Integrating Software Development Server-side Component Model Distributed Object Architecture –CORBA –DCOM –Java.
Overview of The Java Platform Solution for E-Business Applications : JSP, Servlet and EJB.
Enterprise Applications & Java/J2EE Technologies Dr. Douglas C. Schmidt Professor of EECS.
July 23 th, 2005 Software Architecture in Practice RiSE’s Seminars Bass’s et al. Book :: Chapter 16 Fred Durão.
J2EE Kenneth M. Anderson CSCI Web Technologies October 3, 2001.
CS 483 Enterprise and Web Application Programming
12-1 © Prentice Hall, 2004 Chapter 12: Design Elements Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich, Jeffrey.
Distributed System Using Java 2 Enterprise Edition (J2EE)
Distributed Multitiered Applications The J2EE platform uses a multitiered distributed application model. Application logic is divided into components 1.
EJB. Component Characteristics An enterprise Bean typically contains business logic that operates on the enterprise’s data. An enterprise Bean’s instances.
Web Services Mohamed Fahmy Dr. Sherif Aly Hussein.
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.
15 - RMI/EJBCSC4071 Distributed Objects Java Remote Method Invocation Enterprise Java Beans.
1 3. Implementing Web Services 1.Create SOAP proxy interfaces and WSDL based service descriptions 2.Register/publish services 3.Stores service descriptions.
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)
第十四章 J2EE 介绍 1.Java 2 Platform Enterprise Edition (J2EE) 1.3 API 2.J2EE Architecture 3.J2EE Application Development Lifecycle 4.JSP 5.Servlet 6.JavaBean.
CS 493/693: Distributed Systems Programming V. “Juggy” Jagannathan CSEE, West Virginia University March 21, 2005.
Advanced Java Session 7 New York University School of Continuing and Professional Studies.
Enterprise JavaBeans Umer Farooq CS6704: Design Patterns & Component FrameworksFebruary 25, 2002.
Distributed Systems 1 Master of Information System Management Distributed Systems Persistence.
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. What is EJB? l An EJB is a specialized, non-visual JavaBean that runs on a server. l EJB technology supports application development.
EJB Framework.  As we know, EJB is the center of the J2EE architecture that provides a sturdy framework for building enterprise applications. The major.
Enterprise Java Bean Computer Networks Natawut Nupairoj, Ph.D. Department of Computer Engineering Chulalongkorn University.
第十四章 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.
Web Services Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
A TUTORIAL TO USING EJBs by SHREERAM IYER 09/17/2001.
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.
Enterprise JavaBeans Understanding EJB Components Version 0.1 Kamal Wickramanayake
© jGuru.com Enterprise JavaBeans Fundamentals.
1 Java EE Programming Enterprise JavaBeans. 2 Topics J2EE Overview Enterprise JavaBeans Overview Enterprise Entity Beans Case Study How to build them.
Assignment of JAVA id : BSSE-F10-M-10-JAVA1 Overview of J2EE/Session 2/Slide 1 of 38.
© 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.
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.
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.
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: Fundamentals. EJB Fundamentals(c)CDAC(Formerly NCST)2 Contents Introduction Technology Overview EJB Architecture EJB Specification.
Middleware Technology (J2EE/EJB) EJB Fundamentals.
Advanced Java Session 7 New York University School of Continuing and Professional Studies.
Enterprise JavaBeans™ Trademark of Sun Microsystems, Inc.
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.
J2EE Lecture 10: EJB 3.0 Overview
Enterprise Java Beans Overview
Introduction to J2EE Architecture
Distributed System Using Java 2 Enterprise Edition (J2EE)
Objectives In this lesson, you will learn to:
Enterprise Java Beans Bina Ramamurthy 1/13/2019 B.Ramamurthy.
Understanding and Designing with EJB
Enterprise Java Beans Bina Ramamurthy 4/5/2019 B.Ramamurthy.
Enterprise Java Beans.
Introduction to Session beans
Knowledge Byte In this section, you will learn about:
Objectives In this lesson, you will learn about:
Presentation transcript:

A Case Study on the J2EE Platform CPSC550 Graduate Student Seminar Presentation by Jeffrey A. Brown

History

Mainframe To Enterprise Dumb Terminal Mainframe All programs and data reside on the same machine. –Scheme for handling many concurrent users efficiently was needed. SOLUTION: transaction processor Model #1 Client Database Server Model #2 Applications run on the client machine. –Typically contains both presentation and business rules logic. –Changes in business logic requires redistribution of client code. Client Database Server Middle Tier Model #3 Database server ultimate repository of information. Client remains responsible for presentation logic. Middle tier server responsible for business rules logic.

Transaction Processor Solves the following business needs: –Guarantees transactional integrity. Several statements executed together as a logical unit. Either all statements execute successfully or none are executed. Uses BEGIN, COMMIT, and ROLLBACK primitives. –Manages the execution of programs and the sharing of resources. Can maintain a pool of running program instances. –Hands instances out to users as needed. –Size of pool based on current user load. Allows a system to support many more concurrent users than possible if providing duplicate resources for each user.

From The Java Language: An Overview: What is Java? Java: A simple, object-oriented, network-savvy, interpreted, robust, secure, architecture neutral, portable, high-performance, multithreaded, dynamic language.

Designed to support applications on the network. Supports various levels of network connectivity. –URL class allows access to remote objects on the Internet. –Socket class supports creation of distributed clients and servers using reliable stream network connections. –DatagramPacket and DatagramSocket are used to send and receive datagrams. Java is Network-Savvy “Java offers the promise that the network will become the computer.”

Designed to support multiple threads of execution that can handle different tasks. Improves interactive performance of GUI apps. Provides built-in language support... –Thread class in java.lang package. used to start/run/stop/query threads. –Includes set of synchronization primitives... synchronized keyword. wait() and notify() methods. Java is Multithreaded “Java makes programming with threads much easier...”

Goal

The Goal of J2EE Enterprise application development is hard! J2EE comes to the rescue by simplifying enterprise application development!

Definitions

J2EE Definitions JavaServer Pages (JSP) –Provides the ability to “put snippets of Java code directly into a text-based document. A JSP page is a text-based document that contains two types of text: static template data, which can be expressed in any text-based format such as HTML, WML, and XML, and JSP elements, which determine how the page constructs dynamic content.” Servlets –Provides the ability to “define HTTP-specific servlet classes. A servlet class extends the capabilities of servers that host applications accessed by way of a request-response programming model.”

Selected J2EE Component Definitions Java Messaging Service (JMS) –“A messaging standard that allows J2EE application components to create, send, receive, and read messages. It enables distributed communication that is loosely coupled, reliable, and asynchronous.” Enterprise JavaBeans (EJB) –Components that implement the business logic of an enterprise application. They execute within a “container” which provides numerous services that simplify their development.

Selected J2EE Component Definitions Java Naming and Directory Interface (JNDI) –“Provides naming and directory functionality. It provides applications with methods for performing standard directory operations, such as associating attributes with objects and searching for objects using their attributes”. Remote Method Invocation (RMI) –Provides the ability for “an object running in one Java Virtual Machine (JVM) to invoke methods on an object running in another JVM. RMI provides for remote communication between programs written in the Java programming language”.

Selected J2EE Component Definitions Java API for XML – Remote Procedure Call (JAX-RPC) –“Uses the SOAP standard and HTTP so client programs can make XML-based remote procedure calls (RPCs) over the Internet. JAX-RPC also supports WSDL so you can import and export WSDL documents”. SOAP with Attachments API for Java (SAAJ) –Provides “a low-level API upon which JAX-RPC depends. It enables the production and consumption of messages that conform to the SOAP 1.1 specification and SOAP with Attachments note”.

Selected J2EE Component Definitions Java API for XML - Registries (JAXR) –Provides ability to “access business and general- purpose registries over the Web. JAXR supports the ebXML Registry/Repository standards and the emerging UDDI specifications. By using JAXR, developers can learn a single API and get access to both of these important registry technologies”. Java Management Extension (JMX) –Provides the tools “for building distributed, Web- based, modular and dynamic solutions for managing and monitoring devices, applications, and service- driven networks”.

Selected J2EE Component Definitions Common Object Request Broker Architecture (CORBA) –An open, vendor-independent architecture and infrastructure created by the Object Management Group (OMG) that allows a CORBA-based program from any vendor, on almost any computer, operating system, programming language, and network, can interoperate with another CORBA-based program from the same or another vendor, on almost any other computer, operating system, programming language, and network. A paraphrase taken from the CORBA FAQ See

Features

Features of J2EE The J2EE platform provides support for the following features: –Distributed processing. –Component life-cycle management. –Transaction processing. –Pooling of numerous resource types. –Security management. –Data persistence. –Interoperability with legacy systems.

Structure

J2EE Platform Architecture Diagram

How To Use

Enterprise Beans Overview Enterprise Bean Entity Bean Stateful or Stateless? Persistence? Bean Managed Transaction Support? Container Managed TX_NOT_SUPPORTED TX_BEAN_MANAGED TX_REQUIRED TX_REQUIRED_NEW TX_SUPPORTS TX_MANDATORY Models business concepts that can be expressed as nouns. Responsible for managing processes or tasks. Message-Driven Bean Session Bean Processes Asynchronous Messages

EJB Architectural Structure EJB Server EJB Container EJB developer EJB container EJB home Home interface Remote interface EJB object bean class Client EJB home stub EJB remote stub

EJB Classes and Interfaces Remote interface –defines the bean’s business methods. extends javax.ejb.EJBObject which extends java.rmi.Remote. Home interface –defines the bean’s life cycle methods. creating, removing, and finding beans. extends javax.ejb.EJBHome which extends java.rmi.Remote. Bean class –implements the bean’s business methods. Primary key class –provides a pointer into the database (entity beans only)

An Entity Bean Example package com.titan.cabin; import java.rmi.RemoteException; public interface Cabin extends javax.ejb.EJBObject { public String getName() throws RemoteException; public void setName(String str) throws RemoteException; public int getDeckLevel() throws RemoteException; public void setDeckLevel(int level) throws RemoteException; public int getShip() throws RemoteException; public void setShip(int sp) throws RemoteException; public int getBedCount() throws RemoteException; public void setBedCount(int bc) throws RemoteException; } Cabin bean remote interface

An Entity Bean Example package com.titan.cabin; import java.rmi.RemoteException; import javax.ejb.CreateException; import javax.ejb.FinderException; public interface CabinHome extends javax.ejb.EJBHome { public Cabin create(int id) throws CreateException, RemoteException; public Cabin findByPrimaryKey(CabinPK pk) throws FinderException, RemoteException; } Cabin bean home interface

An Entity Bean Example package com.titan.cabin; import javax.ejb.EntityContext; public class CabinBean implements javax.ejb.EntityBean { public int id; public String name; public int deckLevel; public int ship; public int bedCount; public CabinPK ejbCreate(int id){ this.id = id; return null; } Cabin bean class

An Entity Bean Example public void ejbPostCreate(int id){ // Do nothing. Required. } public String getName(){ return name; } public void setName(String str){ name = str; } public int getShip(){ return ship; } public void setShip(int sp) { ship = sp; } Cabin bean class (cont.)

An Entity Bean Example public int getBedCount(){ return bedCount; } public void setBedCount(int bc){ bedCount = bc; } public int getDeckLevel(){ return deckLevel; } public void setDeckLevel(int level ){ deckLevel = level; } public void setEntityContext(EntityContext ctx){ // Not implemented. } public void unsetEntityContext(){ // Not implemented. } Cabin bean class (cont.)

An Entity Bean Example public void ejbActivate(){ // Not implemented. } public void ejbPassivate(){ // Not implemented. } public void ejbLoad(){ // Not implemented. } public void ejbStore(){ // Not implemented. } public void ejbRemove(){ // Not implemented. } Cabin bean class (cont.)

An Entity Bean Example package com.titan.cabin; public class CabinPK implements java.io.Serializable { public int id; public int hashCode( ){ return id; } public boolean equals(Object obj){ if(obj instanceof CabinPK) return (id == ((CabinPK)obj).id); return false; } public String toString(){ return String.valueOf(id); } } Cabin bean primary key class

An Session Bean Example package com.titan.travelagent; import java.rmi.RemoteException; import javax.ejb.FinderException; public interface TravelAgent extends javax.ejb.EJBObject { // String elements follow the format "id, name, deck level" public String [] listCabins(int shipID, int bedCount) throws RemoteException; } TravelAgent bean remote interface

An Session Bean Example package com.titan.travelagent; import java.rmi.RemoteException; import javax.ejb.CreateException; public interface TravelAgentHome extends javax.ejb.EJBHome { public TravelAgent create() throws RemoteException, CreateException; } TravelAgent bean home interface

An Session Bean Example package com.titan.travelagent; import com.titan.cabin.Cabin; import com.titan.cabin.CabinHome; import com.titan.cabin.CabinPK; import java.rmi.RemoteException; import javax.naming.InitialContext; import javax.naming.Context; import java.util.Properties; import java.util.Vector; import javax.ejb.EJBException; public class TravelAgentBean implements javax.ejb.SessionBean { public void ejbCreate() { // Do nothing. } TravelAgent bean class

An Session Bean Example public String [] listCabins(int shipID, int bedCount) throws EJBException{ try { javax.naming.Context jndiContext = new InitialContext(); Object obj = jndiContext.lookup("ejb/CabinHome"); CabinHome home = (CabinHome) javax.rmi.PortableRemoteObject.narrow(obj, CabinHome.class); Vector vect = new Vector(); CabinPK pk = new CabinPK(); Cabin cabin; for(int i = 1; ; i++){ pk.id = i; try { cabin = home.findByPrimaryKey(pk); } TravelAgent bean class (cont.)

An Session Bean Example catch(javax.ejb.FinderException fe){ break; } // Check to see if the bed count and ship ID match. if (cabin.getShip() == shipID && cabin.getBedCount() == bedCount){ String details = i+","+cabin.getName()+","+cabin.getDeckLevel(); vect.addElement(details); } String [] list = new String[vect.size()]; vect.copyInto(list); return list; } TravelAgent bean class (cont.)

An Session Bean Example catch(javax.naming.NamingException ne){ throw new EJBException(ne); } catch(java.rmi.RemoteException re){ throw new EJBException(re); } private javax.naming.Context getInitialContext() throws javax.naming.NamingException{ Properties p = new Properties(); //... Specify the JNDI properties specific to the vendor. return new javax.naming.InitialContext(p); } public void ejbRemove(){} public void ejbActivate(){} public void ejbPassivate(){} public void setSessionContext(javax.ejb.SessionContext cntx){} } TravelAgent bean class (cont.)

An EJB Client Example package com.titan.travelagent; import com.titan.cabin.CabinHome; import com.titan.cabin.Cabin; import com.titan.cabin.CabinPK; import javax.naming.InitialContext; import javax.naming.Context; import javax.naming.NamingException; import javax.ejb.CreateException; import java.rmi.RemoteException; import java.util.Properties; public class Client { public static int SHIP_ID = 1; public static int BED_COUNT = 3;

An EJB Client Example public static void main(String [] args){ try { Context jndiContext = getInitialContext(); Object obj = jndiContext.lookup("ejb/TravelAgentHome"); TravelAgentHome home = (TravelAgentHome) javax.rmi.PortableRemoteObject.narrow(obj, TravelAgentHome.class); TravelAgent reserve = home.create(); // Get a list of all cabins on ship 1 with a // bed count of 3. String list [] = reserve.listCabins(SHIP_ID,BED_COUNT); for(int i = 0; i < list.length; i++){ System.out.println(list[i]); } } catch(java.rmi.RemoteException re){re.printStackTrace();} catch(Throwable t){t.printStackTrace();} }

An EJB Client Example static public Context getInitialContext() throws Exception { Properties p = new Properties(); //... Specify the JNDI properties specific to the vendor. return new InitialContext(); }

J2EE: Applications

Web Application Using J2EE UI Tier Middle Tier (Business Logic) EIS Tier Web Container Business Interface Implementation DBMS Legacy System Servlets / Web Tier Classes J2EE Container

Web Application Using J2EE Strengths of this approach: –Simplicity –Speed –Easy to test –Scales well Weaknesses of this approach: –Only supports web interface –Can’t use EJB transaction support –No built-in support for concurrent programming

Distributed Application Using J2EE UI Tier Middle Tier (Business Logic) EIS Tier DBMS Legacy System Web Container Business Interface Business Delegate Servlets / Web Tier Classes EJB Container Session EJB Entity EJB RMI J2EE Container

Distributed Application Using J2EE Strengths of this approach: –Supports all J2EE client types –Provides a shared middle tier –Permits distribution of application components across different physical servers Weaknesses of this approach: –Complex –Performance overhead –Hard to test and debug

J2EE: Significant Points

J2EE Significant Points J2EE simplifies enterprise development but it's still much harder than developing with POJO –Use XDoclet or EJBGen for help –Harder to test and debug EJBs than POJO Distributed or not distributed? –Use local interfaces with non-distributed approach Would be nice if EJB container could determine whether to use local or remote interfaces based on context! Design for scalability from start to finish –Keep state requirements small to non-existent Stateless components much more scalable!

J2EE: Summary

J2EE Summary J2EE helps simplify the development of enterprise applications. J2EE platform consists of numerous components including: –JSP, Servlets, EJB, and JMS J2EE provides helpful underlying services including: –life-cycle management, transaction processing, resource pooling, security, and data persistence. J2EE can be used to create distributed applications.

References

Java 2 Platform Enterprise Edition Specification, v1.4 The J2EE 1.4 Tutorial Enterprise JavaBeans, 3rd Edition Richard Monson-Haefel, O'Reilly & Associates, ISBN Enterprise Javabeans: Developing Component-Based Distributed Applications Thomas C. Valesky, Addison-Wesley, ISBN Expert One-on-One J2EE Design and Development Rod Johnson, WROX Press, ISBN Core J2EE Patterns: Best Practices and Design Strategies Deepak Alur, et. al., Prentice Hall, ISBN