95-702 Organizational Communication Technologies 1 Enterprise Java Beans Overview.

Slides:



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

16 Copyright © 2005, Oracle. All rights reserved. Developing Message-Driven Beans.
11 Copyright © 2005, Oracle. All rights reserved. Creating the Business Tier: Enterprise JavaBeans.
Web Service Architecture
JNDI Java Naming Directory Interface JNDI is an API specified in Java that provides naming and directory functionality to applications written in Java.
Remote Method Invocation
An architecture for webb applications, J2EE
OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 14: Naming.
Introduction to Enterprise JavaBeans. Integrating Software Development Server-side Component Model Distributed Object Architecture –CORBA –DCOM –Java.
EJB Design. Server-side components Perform –complex algorithms –high volume transactions Run in –highly available environment (365 days/year) –fault tolerant.
Basics of JNDI Alessio Bechini June Naming and Directory Services: Rationale A fundamental element in every application is the capability to find.
JMS Java Message Service Instructor Professor: Charles Tappert By Student: Amr Fouda.
ECSE Software Engineering 1I HO 7 © HY 2012 Lecture 7 Publish/Subscribe.
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.
JNDI Java Naming and Directory Interface See also:
EJB Fundamentals Celsina Bignoli
Enterprise Java Beans CS-422. Application Servers In the late 1980s and though the mid 1990s a number of corporations (Broadvision, Netscape…) marketed.
1 3. Implementing Web Services 1.Create SOAP proxy interfaces and WSDL based service descriptions 2.Register/publish services 3.Stores service descriptions.
Seminar: Enterprise JavaBeans. Agenda Agenda Java™ 2 Platform Java™ 2 Platform Java™ 2 Platform,Enterprise Edition(J2EE) Java™ 2 Platform,Enterprise Edition(J2EE)
Corso di Formazione Sodalia “Enterprise Java Beans” JNDI Java Naming and Directory Interface.
Java Message Service - What and Why? Bill Kelly, Silvano Maffeis SoftWired AG, Zürich
1 G52IWS: Distributed Computing Chris Greenhalgh.
Distributed Systems 1 Master of Information System Management Distributed Systems Persistence.
Enterprise Java Bean Matt. 2 J2EE 3 J2EE Overview.
1 SOA and Enterprise Computing Enterprise Java Beans.
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.
EJB Framework.  As we know, EJB is the center of the J2EE architecture that provides a sturdy framework for building enterprise applications. The major.
第十四章 J2EE 入门 Introduction What is J2EE ?
J2EE Structure & Definitions Catie Welsh CSE 432
Topic : JNDI Kaster Nurmukan. JNDI2(c)CDAC(Formerly NCST) What is JNDI? Naming and Directory Services Naming Concepts Issues JNDI Architecture Programming.
Java Naming and Directory Interfaces. A naming service is an entity that performs the following tasks:  It associates names with objects. Similar to.
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.
OCT 1 Master of Information System Management Organizational Communications and Distributed Object Technologies Lecture 5: JMS.
1 Java Message Service Манин П Enterprise messaging Key concept: 1. Messages are delivered asynchronously 2. Sender is not required to wait for.
Ch 2 – Application Assembly and Deployment COSC 617 Jeff Schmitt September 14, 2006.
Spring/2002 Distributed Software Engineering C:\unocourses\4350\slides\DefiningThreads 1 RMI.
RMI remote method invocation. Traditional network programming The client program sends data to the server in some intermediary format and the server has.
Databases JDBC (Java Database Connectivity) –Thin clients – servlet,JavaServer Pages (JSP) –Thick clients – RMI to remote databases –most recommended way.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Spring Remoting Simplifying.
XML and Web Services (II/2546)
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.
AMQP, Message Broker Babu Ram Dawadi. overview Why MOM architecture? Messaging broker like RabbitMQ in brief RabbitMQ AMQP – What is it ?
OCT 1 Master of Information System Management Distributed Systems Lecture 19: Enterprise Java Beans.
Session Beans Based on: Patel, Brose, Silverman, Mastering Enterprise JavaBeans 3.0.
Enterprise JavaBeans 3.0. What is EJB 3.0 -Reusable server-side component framework-technology -Designed to support building demanding enterprise – level.
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.
©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.
September 28, 2010COMS W41561 COMS W4156: Advanced Software Engineering Prof. Gail Kaiser
©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
Master of Information System Management
Remote Method Invocation
Java Messaging Service (JMS)
Java Messaging Service (JMS)
Java Messaging Service (JMS)
Understanding and Designing with EJB
Harjutus 3: Aünkroonne hajussüsteemi päring
Inventory of Distributed Computing Concepts
Understanding and Designing with EJB
J2EE Lecture 13: JMS and WebSocket
Knowledge Byte In this section, you will learn about:
Presentation transcript:

Organizational Communication Technologies 1 Enterprise Java Beans Overview

Organizational Communication Technologies 2 Notes from: “Advanced Java 2 Platform How to Program” Deitel Deitel Santry “Thinking in Enterprise Java” Bruce Eckel et. Al. Sun downloadable documentation EJB 2.1 API

Organizational Communication Technologies 3 Interposition Application stub skeleton examine security credentials start or join transaction call any necessary persistence functions trigger various callbacks call business logic more work with transactions, persistence and callbacks send back result or an exception EJB Container

Organizational Communication Technologies 4 Enterprise Java Beans Server-Side EJB objects may offer a remote view (via a remote procedure call protocol) a local view (direct procedure call) or both Managed EJB container services are more involved than the plain old JVM Components distributed in binary format and are configurable

Organizational Communication Technologies 5 Server-Side Implications In order to pull off the RPC trick we need: A naming service -- e.g. RMI clients make requests on the rmiregistry RPC proxies -- communications code along with the appropriate interface

Organizational Communication Technologies 6 Managed: EJB Container Services Object Persistence and Synchronization Declarative Security Control Declarative Transaction Control Concurrency Management Scalability Management

Organizational Communication Technologies 7 EJB Types Entity Beans Session Beans Message-Driven Beans

Organizational Communication Technologies 8 EJB Types Entity Beans Session Beans Message-Driven Beans } } RMI-based server side components Accessed using distributed object Protocols (RMI IIOP) New in EJB 2.0 Asynchronous server side component that responds to JMS asynchronous messages (Think provider like JAXM)

Organizational Communication Technologies 9 Entity Beans Represent real world entities (customers, orders, etc.) Persistent Objects typically stored in a relational database using CMP (Container Managed Persistence) or BMP (Bean Managed Persistence) The client sees no difference between CMP and BMP beans CMP promotes component portability (less reliant on the container)

Organizational Communication Technologies 10 Session Beans Are an extension of the client application Manage processes or tasks Are not persistent Often employ several different kinds of entity beans Implement business logic Come in two types (which can be more easily shared?) –Stateless session beans (no memory between calls) purchase(severalIems,creditCardNo); –Stateful session beans (remember earlier calls) addToCart(item); purchase(creditCardNo);

Organizational Communication Technologies 11 Message-Driven Beans Work in cooperation with Java Messaging System (JMS) JMS is an abstraction API on top of Message-Oriented Middleware (MOM) – like JDBC is an abstraction API on top of SQL databases Each MOM vendor implements things differently MDB’s allow the developer to program using the publish- subscribe messaging model based on asynchronous, distributed message queues The MOM vendor need only provide a service provider for JMS (IBM’s MQSeries or Progress’ SonicMQ)

Organizational Communication Technologies 12 Message-Driven Beans Are like session beans Have no persistent state Coordinate tasks involving other session beans or entity beans Listen for asynchronous messages Unlike Session beans, provide no remote interface describing the methods that can be called

Organizational Communication Technologies 13 Message-Driven Beans Are receivers of MOM messages coming through the JMS API. Usually take action when a message is received. Unlike session and entity beans, Message-Driven Beans expose no remote or local view. They are not called directly by a client.

Organizational Communication Technologies 14 Before working with EJB’s Understand the role of JNDI (Java Naming and Directory Interface)

Organizational Communication Technologies 15 Naming Concepts from the JNDI Tutorial Java Naming and Directory Interface

Organizational Communication Technologies 16 Naming Concepts We need to map people friendly names to objects Examples -> Mike’s -> cnn’s web serverwww.cnn.com c:\somedir\f1.dat -> a file on a C drive

Organizational Communication Technologies 17 Naming Conventions Different naming systems use different conventions (or syntax) for names Examples: DOS uses slashes and colons and periods c:\some\f.dat Unix uses slashes /usr/local/filename DNS uses dots LDAP (The lightweight directory access protocol) uses name, value pairs cn=Rosanna Lee, o=Sun, c=US

Organizational Communication Technologies 18 Bindings A binding is the association of a name with an object or an object reference. Examples: is bound to an IP addresswww.cnn.com c:\exam1.doc is bound to a file a phone number is bound to a phone

Organizational Communication Technologies 19 Bindings A binding is the association of a name with an object or object reference. The phone book maps names to numbers which act as references to objects. The number is a communication endpoint. A communication endpoint is specific information on how to access an object

Organizational Communication Technologies 20 Context A context is a set of name-to-object bindings. Every context has an associated naming convention. A context may allow operations such as bind, unbind, lookup. A context may associate a name with another context (subcontext, or subdirectory)

Organizational Communication Technologies 21 Naming System A naming system is a connected set of contexts of the same type (they have the same naming convention) and provides a common set of operations. DNS and LDAP, for example, are two naming system. A naming system provides a naming service to its customers for performing naming-related operations. For example, associate a new name with an IP address. A namespace is the set of names in a naming system.

Organizational Communication Technologies 22 Directory Service A Directory Service is an extension of a naming service that allows one to lookup objects based on names or based on attributes. Attributes have attribute identifiers and a set of attribute values. For example, UDDI - Universal Description, Discovery and Integration is a Directory Service.

Organizational Communication Technologies 23 Reverse lookup or content-based searching Example queries to directory services: Find all machines whose IP address begins with Find all companies that provide hardware support services.

Organizational Communication Technologies 24 Directory Enabled Applications A directory-enabled application is an application that uses a naming or directory service. Applications can share the common infrastructure provided by the directory. Example: A mail client, scheduling systems and mail forwarding program might all use the same address book stored in a common directory. The directory may also be used as an Object store for programs needing the same object.

Organizational Communication Technologies 25 Java Naming and Directory Interface JNDI

Organizational Communication Technologies 26 Java Naming and Directory Interface (JNDI) An abstraction API (like JDBC handles different RDBMS databases) The JNDI API handles or sits on top of different naming services. Java Application JNDI API LDAPDNSrmiregistry Service Providers File System must Be downloaded File System

Organizational Communication Technologies 27 JNDI The javax.naming packages contains mostly Java interfaces. Some vendor implements the interface to provide JNDI support for their service. To use the service, you need a JNDI Service Provider that implements the interface JDK1.4 comes with RMI, DNS, COS, and LDAP Service providers. Sun’s web site has an additional JNDI Service Provider that works with the local file system

Organizational Communication Technologies 28 JNDI A namespace is a logical space in which names can be defined. The same names in different namespaces cause no collisions. Namespaces can be nested: - file system directories are nested - the Internet DNS domains and sub-domains are nested

Organizational Communication Technologies 29 Namespaces are represented by the Context Interface Different classes implement this interface differently depending on which naming service they are accessing. Has methods to - bind and unbind objects to names - create and delete sub-contexts - lookup and list names Since a Context is a Java object it can be registered in another Context with its own name.

Organizational Communication Technologies 30 The Context Interface Start from some “root” context. Get the “root” from the InitialContext class Examples LookUp.java ListCurrentDirectory.java

Organizational Communication Technologies 31 LookUp.java // before running download JNDI provider from Sun // add.jar files to classpath import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import java.util.Hashtable; import java.io.File;

Organizational Communication Technologies 32 public class LookUp { public static void main(String args[]) throws NamingException { try { System.out.println("Using a file system (FS) provider"); // initialize the context with properties for provider // and current directory Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory"); env.put(Context.PROVIDER_URL, "file:D:\\McCarthy\\www\\95-702\\examples\\JNDI"); Context ctx = new InitialContext(env); Object obj = ctx.lookup(args[0]);

Organizational Communication Technologies 33 if(obj instanceof File) { System.out.println("Found a file object"); System.out.println(args[0] + " is bound to: " + obj); File f = (File) obj; System.out.println(f + " is " + f.length() + " bytes long"); } // Close the context when we're done ctx.close(); } catch(NamingException e) { System.out.println("Naming exception caught" + e); }

Organizational Communication Technologies 34 D:\McCarthy\www\95-702\examples\JNDI>java LookUp LookUp.java Using a file system (FS) provider Found a file object LookUp.java is bound to: D:\McCarthy\www\95-702\examples\JNDI\LookUp.java D:\McCarthy\www\95-702\examples\JNDI\LookUp.java is 1255 bytes long

Organizational Communication Technologies 35 ListCurrentDirectory.java // Use JNDI to list the contents of the current // directory import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.naming.NamingEnumeration; import javax.naming.NameClassPair; import java.util.Hashtable; import java.io.File;

Organizational Communication Technologies 36 public class ListCurrentDirectory { public static void main(String args[]) throws NamingException { try { Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory"); env.put(Context.PROVIDER_URL, "file:D:\\McCarthy\\www\\95-702\\examples\\JNDI");

Organizational Communication Technologies 37 Context ctx = new InitialContext(env); NamingEnumeration list = ctx.list("."); while (list.hasMore()) { NameClassPair nc = (NameClassPair)list.next(); System.out.println(nc); } ctx.close(); } catch(NamingException e) { System.out.println("Naming exception caught" + e); }

Organizational Communication Technologies 38 D:\McCarthy\www\95-702\examples\JNDI>java ListCurrentDirectory ListCurrentDirectory.class: java.io.File ListCurrentDirectory.java: java.io.File LookUp.java: java.io.File SimpleJNDI.java: java.io.File x: javax.naming.Context x is a DOS directory

Organizational Communication Technologies 39 // Use JNDI to change to a sub directory and list contents import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.naming.NamingEnumeration; import javax.naming.NameClassPair; import java.util.Hashtable; import java.io.File; public class ChangeContext { public static void main(String args[]) throws NamingException { try { Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.fscontext.RefFSContextFactory"); env.put(Context.PROVIDER_URL, "file:D:\\McCarthy\\www\\95-702\\examples\\JNDI");

Organizational Communication Technologies 40 Context ctx = new InitialContext(env); // a subdirectory called x contains a file f.txt and a subdirectory t Context sub = (Context)ctx.lookup("x"); NamingEnumeration list = sub.list("."); while (list.hasMore()) { NameClassPair nc = (NameClassPair)list.next(); System.out.println(nc); } ctx.close(); sub.close(); } catch(NamingException e) { System.out.println("Naming exception caught" + e); }

Organizational Communication Technologies 41 D:\McCarthy\www\95-702\examples\JNDI>java ChangeContext f.txt: java.io.File t: javax.naming.Context

Organizational Communication Technologies 42 Back to EJB Implementing session and entity beans Implementing message-driven beans

Organizational Communication Technologies 43 Implementing Entity and Session Beans Define the component interfaces – You may choose to define all or only some of these depending on how you want your bean used – local interfaces do not require RMI overhead Define a bean class For entity beans define a primary key

Organizational Communication Technologies 44 Implementing Entity and Session Beans Define the component interfaces –The remote interface specifies how the outside world can access the bean’s business methods –The remote home interface specifies how the outside world can access the bean’s life-cycle methods (for creating, removing and finding) –The local interface specifies how the inside world (same EJB container) can access the bean’s business methods –The local home interface specifies how the inside world can access the bean’s life-cycle methods

Organizational Communication Technologies 45 Implementing Entity and Session Beans Implement the bean –Fill in the code for the business and life-cycle methods –It’s not normal to directly implement the interfaces as we do in standard Java (though you must provide many of the methods). The calls to methods are not normal Java calls. They first go through the container. –Session beans implement javax.ejb.SessionBean –Entity beans implement javax.ejb.EntityBean –Both beans extend javax.ejb.EnterpriseBean

Organizational Communication Technologies 46 For Entity Beans Define a primary key class –Required for entity beans –Provides a pointer into the database –Must implement Java.io.Serializable The EJB instance represents a particular row in the corresponding database table The home interface for the entity EJB represents the table as a whole (has finder methods.)

Organizational Communication Technologies 47 Implementing a Message-Driven Bean Has no local, local home, remote, or remote home interfaces to define. The container will call the onMessage() method when an asynchronous message arrives. (Like JAXM message provider.) Extends the EnterpriseBean class and implements the javax.ejb.MessageDrivenBean and javax.jms.MessageListener interfaces

Organizational Communication Technologies 48 Implementing a Message-Driven Bean Two basic messaging-system models (1) point-to-point model allows messages to be sent to a message queue to be read by exactly one message consumer (2) publish/subscribe model allows components to publish messages on a topic to a server to be read by zero or more subscribers

Organizational Communication Technologies 49 In both models The messages hold -- a header containing the destination and the sending time. -- message properties to allow the receiver to select which messages they would like to receive. These may be set by the sender. -- the message body itself

Organizational Communication Technologies 50 Point-to-point On the client side import javax.jms.*; QueueConnection qCon; QueueSession qSes; QueueSender qSen; Through JNDI get access to a QueueSender. Build messages and send.

Organizational Communication Technologies 51 Point-To-Point On the server side import javax.jms.*; QueueConnection qCon; QueueSession qSes; QueueReceiver qRec; Through JNDI get access to a QueueSender. Build a MessageListener with an onMessage method.