enterprise javabeans fundamentals n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Enterprise JavaBeans: Fundamentals PowerPoint Presentation
Download Presentation
Enterprise JavaBeans: Fundamentals

Loading in 2 Seconds...

play fullscreen
1 / 42

Enterprise JavaBeans: Fundamentals - PowerPoint PPT Presentation


  • 134 Views
  • Uploaded on

Enterprise JavaBeans: Fundamentals. Contents. Introduction Technology Overview EJB Architecture EJB Specification Sample Application. Sun’s Definition. EJB architecture is a component architecture for the development and deployment of component based distributed business applications .

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Enterprise JavaBeans: Fundamentals' - faxon


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
contents
Contents
  • Introduction
  • Technology Overview
  • EJB Architecture
  • EJB Specification
  • Sample Application

(c)CDAC(Formerly NCST)

sun s definition
Sun’s Definition
  • EJB architecture is a component architecture for the development and deployment of component based distributed business applications.
  • Applications written using EJB architecture are scalable, transactional, and multi-user secure.
  • These applications may be write once, and then deployed on any server platform that supports the EJB specification.

(c)CDAC(Formerly NCST)

short definition
Short Definition
  • EJB is a server-side component architecture that simplifies the process of building enterprise-class distributed component applications in Java.
  • EJB provides standard for component architecture.

(c)CDAC(Formerly NCST)

enterprise bean
Enterprise Bean
  • Server side software components that can be deployed in distributed multi tier environment.
  • They encapsulate business logic of an application.
  • Consists of one or more java objects.

(c)CDAC(Formerly NCST)

types of beans
Types of Beans
  • Session Bean
  • Entity Bean
  • Message driven Bean

(c)CDAC(Formerly NCST)

session bean
Session Bean
  • Session beans model business processes.
  • They are like ‘verbs’ because they are actions.
  • E.g. billing engine, catalog engine etc:

(c)CDAC(Formerly NCST)

entity bean
Entity Bean
  • Entity Bean Models business data.
  • They are like ‘nouns’ because they are data objects
  • E.g. product, an order, an employee etc:
  • Session beans typically calls entity beans to perform business goals.

(c)CDAC(Formerly NCST)

message driven bean
Message Driven Bean
  • Message driven beans are similar to session beans.
  • They are actions.
  • They are called only when they receive some message.
  • E.g. : stock trade message.

(c)CDAC(Formerly NCST)

ejb architecture
EJB Architecture

HTML

Client

Business

Partner System

Presentation

Tier

HTTP

SOAP,UDDI

WSDL,ebXML

Firewall

Messaging

Client

C/C++

Client

Java Applet

Java Appl

Servlet

JSP

Web

Server

CORBA-IIOP

RMI-IIOP

RMI-IIOP

RMI-IIOP

Messaging

Application Server

EJB Message

Driven Bean

EJB Session

Bean

EJB Session

Bean

Business

Tier

EJB Session

Bean

EJB Entity

Bean

EJB Session

Bean

(c)CDAC(Formerly NCST)

ejb foundation distributed objects
EJB Foundation: Distributed Objects

Client

Distributed

Object

Remote Interface

Remote Interface

Skeleton

Stub

Network

(c)CDAC(Formerly NCST)

what do we need to worry about now
What do we need to worry about now?

We take a monolithic application and break it into distributed system with multiple clients connecting to multiple servers and databases over network.

(c)CDAC(Formerly NCST)

services
Remote Method Invocation

Load Balancing

Transparent Fail Over

Back end integration.

Clustering

Dynamic Re deployment

Object life cycle

Caching

Security

Resource Pooling

System Management

Message Oriented Middleware

And many more…..

Services

Middleware

(c)CDAC(Formerly NCST)

explicit middleware
Explicit Middleware

Transaction API

Transaction

Services

Security API

Client

Distributed

Object

Security

Services

Remote

Interface

Database API

Remote Interface

Database

drivers

Skeleton

Stub

Network

(c)CDAC(Formerly NCST)

example bank account obj
Example – Bank account obj
  • Transfer(Acct acc1, Acct acc2,long amt)

//1.Call middleware API to perform security check.

//2.Call middleware API to start a trans

//3.Call middleware API to load rows from db.

//4.perform trans.

//5.Call middleware API to store rows in db

//6.Call middleware API to end the trans.

(c)CDAC(Formerly NCST)

explicit middleware1
Explicit Middleware
  • Difficult to Write.
  • Difficult to Maintain.
  • Difficult to Support.

(c)CDAC(Formerly NCST)

implicit middleware
Implicit Middleware

Distributed

Object

Client

Transaction API

Remote

Interface

Transaction

Services

Security API

Request

Interceptor

Security

Services

Remote

Interface

Remote Interface

Database API

Database

drivers

Skeleton

Stub

Network

(c)CDAC(Formerly NCST)

example bank account obj1
Example – Bank account obj
  • Transfer(Acct acc1,Acct acc2,long amt)

//1. Perform trans.(subtract bal from one account and add to other).

(c)CDAC(Formerly NCST)

implicit middleware1
Implicit Middleware
  • Easy to Write.
  • Easy to Maintain.
  • Easy to Support.

(c)CDAC(Formerly NCST)

ejb container
EJB Container
  • House enterprise bean and makes them available to the client to invoke them remotely.
  • It intercepts the client request and delegates them to corresponding bean class.
  • It automatically performs implicit middleware that the distributed object needs.
  • EJB object is the physical part of the container.

(c)CDAC(Formerly NCST)

ejb component ingredients
EJB Component Ingredients
  • Enterprise Bean Class
  • Interfaces
    • Remote and Home interface for remote access.
    • Local and Local Home interface for local access.
  • Deployment Descriptor.
  • Vendor Specific files.

(c)CDAC(Formerly NCST)

enterprise bean class
Enterprise Bean Class
  • It conforms to a well defined interface.
  • It contains business implementation details of our component.
  • Each bean type has more specific interface that extends javax.ejb.EnterpriseBean interface.
  • Bean class implements the interface corresponding to the bean type.

(c)CDAC(Formerly NCST)

ejb object
EJB Object
  • Client request interceptor.
  • It duplicates all the business logic methods that the corresponding bean class exposes.
  • Proprietary and specific to each EJB container.

(c)CDAC(Formerly NCST)

remote interface
Remote Interface
  • Interface to request interceptor.
  • Informs EJB Object auto generator which methods to clone.
  • All remote interfaces must derive from javax.ejb.EJBObject.
  • EJB remote interfaces must confirm to RMI rules.

(c)CDAC(Formerly NCST)

home object
Home Object
  • EJB object factory.
  • Creates,finds and destroys EJB objects.
  • Proprietary and specific to each EJB container.
  • Home objects implements Home Interface.

(c)CDAC(Formerly NCST)

home interface
Home Interface
  • EJB Object factory interface.
  • They define methods for creating,destroying and finding EJB Objects.
  • All home interfaces must extend javax.ejb.EJBHome.
  • EJB remote interfaces must confirm to RMI rules.

(c)CDAC(Formerly NCST)

local access
Local Access
  • Local objects make enterprise bean calls fast and efficient.
  • Local objects implements Local Interface.
  • Local home objects creates beans fast.
  • Local home object implements Local Home interface.

(c)CDAC(Formerly NCST)

deployment descriptor
Deployment Descriptor
  • Declare how the container should perform middleware services for the EJB component.
  • In EJB 2.0 deployment descriptor is a XML file.
  • Key to implicit middleware.

(c)CDAC(Formerly NCST)

vendor specific files
Vendor Specific Files
  • All vendors have proprietary value added features.
  • Include files specific to that vendor.

(c)CDAC(Formerly NCST)

package
Package

Remote

Interface

Local

Interface

EJB jar file

Jar file creator

Enterprise

Bean

Home

Interface

Deployment

Descriptor

Vendor

Specific

(c)CDAC(Formerly NCST)

sample application my first bean
Sample ApplicationMy First Bean!

(c)CDAC(Formerly NCST)

session bean firstbean
Session Bean : FirstBean

package example;

public class FirstBean implements javax.ejb.SessionBean{

private SessionContext ctx;

public void ejbCreate() {

System.out.println(“ejbCreate()”);

}

public void ejbRemove() {

System.out.println(“ejbRemove()”);

}

public void ejbActivate() {

System.out.println(“ejbActivate()”);

}

(c)CDAC(Formerly NCST)

slide33

public void ejbPassivate()

{

System.out.println(“ejbPassivate()”);

}

public void setSessionContext(javax.ejb.SessionContext ctx)

{

this.ctx=ctx;

}

public String first()

{

System.out.println(“first()”);

return “My First Bean”;

}

}

(c)CDAC(Formerly NCST)

remote interface first java
Remote Interface : First.java

package example;

public interface First extends javax.ejb.EJBObject

{

public String first() throws java.rmi.RemoteException;

}

(c)CDAC(Formerly NCST)

home interface firsthome
Home Interface : FirstHome

package example;

public interface FirstHome extends javax.ejb.EJBHome

{

First create() throws java.rmi.RemoteException,

javax.ejb.CreateException;

}

(c)CDAC(Formerly NCST)

deployment descriptor1
Deployment Descriptor

<ejb-jar>

<enterprise-bean>

<session>

<ejb-name>First</ejb-name>

<home>example.FirstHome</home>

<remote>example.First</remote>

<ejb-class>example.FirstBean<ejb-class>

<session-type>Stateless</session-type>

<transaction-type>Container</transaction-type>

</session>

</enterprise-bean>

</ejb-jar>

(c)CDAC(Formerly NCST)

client application
Client Application

package example;

import javax.naming.*;

Import java.util.*;

public class FirstClient{

public static void main(String[] arg) throws Exception{

Properties props=System.getProperties();

Context ctx=new InitialContext(props);

Object obj=ctx.llokup(“FirstHome”);

FisrtHome home=(FirstHome)

javax.rmi.RemotePortableObject.narrow

(obj,FirstHome.class);

(c)CDAC(Formerly NCST)

slide38

First first=home.create();

System.out.println(first.first());

first.remove();

}

}

(c)CDAC(Formerly NCST)

ejb object model
EJB Object Model

<<interface>>

java.rmi.Remote

<<interface>>

java.io.Serializable

Comes with Java2 platform

<<interface>>

javax.ejb.EJBObject

<<interface>>

Javax.ejb.EJBHome

<<interface>>

javax.ejb.EnterpriseBean

<<interface>>

javax.ejb.SessionBean

Comes with EJB Distribution

<<interface>>

Remote Interface

<<interface>>

Home Interface

Bean Implement

Class

Written by developer

EJB Object

Home Object

(c)CDAC(Formerly NCST)

Generated by Componet Vendor Tool

slide40

EJB Container

3: Create a new

EJB Object

Home

Interface

Client

Home

Object

5: Return EJB

Object Reference

4: Create a new

EJB Object

6: Invoke Business

Method

2 : Return

Home object

Reference

1 : Retrieve

Home object

Reference

EJB

Object

Enterprise

Bean

Remote

Interface

7: Delegate Request to Bean

JNDI

Naming

Service

(c)CDAC(Formerly NCST)

advantages of ejb
Advantages of EJB
  • Helps to write scalable,reliable and secure applications.
  • Provides distributed component framework and hence supports rapid application development.
  • Supports application portablility and reusability across any vendor’s enterprise middleware services.
  • It is agreed upon by industry.

(c)CDAC(Formerly NCST)

references
References
  • Mastering Enterprise Java Beans
  • J2EE 1.4 Tutorials
  • Professional Java Server Programming, J2EE Edition

(c)CDAC(Formerly NCST)