enterprise java bean technology briefing markus hebach

40
nterprise Java Bean Technology Briefin Markus Hebach

Upload: moris-bridges

Post on 19-Jan-2016

215 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Enterprise Java Bean Technology Briefing Markus Hebach

Enterprise Java Bean Technology Briefing

Markus Hebach

Enterprise Java Bean Technology Briefing

Markus Hebach

Page 2: Enterprise Java Bean Technology Briefing Markus Hebach

AgendaAgenda

The Need for a Server Side Component Model EJB 1.0 Architecture Overview Where does CORBA fit in? The Inprise EJB Solution - “Kodiak”

Page 3: Enterprise Java Bean Technology Briefing Markus Hebach

The Need for a Server Side The Need for a Server Side Component ModelComponent Model

Page 4: Enterprise Java Bean Technology Briefing Markus Hebach

Distributed TX’sDistributed TX’s

SecuritySecurity

AuthorizationAuthorization

Data AccessData Access

Legacy IntegrationLegacy Integration

Developing a Distributed ObjectDeveloping a Distributed Object

BusinessLogic

BusinessLogic

Page 5: Enterprise Java Bean Technology Briefing Markus Hebach

Business Logic Developer

==

Afte

r Tax

Ope

ratin

g C

ash

Flow

Afte

r Tax

Ope

ratin

g C

ash

Flow

P/E RatioP/E Ratio

CF = (R - O)(1 - T) + Dep(T) - NWCCF = (R - O)(1 - T) + Dep(T) - NWC

Net Present ValueNet Present Value

Holding Period Returns

Holding Period Returns Salil “Number Crunch” DeshpandeSalil “Number Crunch” Deshpande

Page 6: Enterprise Java Bean Technology Briefing Markus Hebach

System Developer

==

Distributed Transactions

Distributed Transactions

PersistencePersistence

Auth

entic

atio

n

Auth

entic

atio

n

AuthorizationAuthorization

ConcurrencyConcurrency

Geoff “Codermaniac” BullenGeoff “Codermaniac” Bullen

Page 7: Enterprise Java Bean Technology Briefing Markus Hebach

Productive Distributed Developer???

BusinessLogic

BusinessLogic

SecuritySecurity

Distributed TX’sDistributed TX’s

Data AccessData Access

Legacy IntegrationLegacy Integration

AuthorizationAuthorization

==

Page 8: Enterprise Java Bean Technology Briefing Markus Hebach

EJB Acknowledges “Roles”EJB Acknowledges “Roles”

Bean ProviderBean Provider AssemblerAssembler DeployerDeployer Sys AdminSys Admin

Logic DeveloperNo Transaction CodeNo Concurrency CodeNo Security CodeNo Distribution of Beans

Logic DeveloperNo Transaction CodeNo Concurrency CodeNo Security CodeNo Distribution of Beans

Composes ApplicationsGenerally Understands LogicExpert at Apps, Applets Servlets etc..Usually builds GUI

Composes ApplicationsGenerally Understands LogicExpert at Apps, Applets Servlets etc..Usually builds GUI

Deployment to Operational EnvironmentDefines Security RolesDefines TransactionsA Systems Expert

Deployment to Operational EnvironmentDefines Security RolesDefines TransactionsA Systems Expert

System ManagerKeeps System OperationalTypically a good cardplayer

System ManagerKeeps System OperationalTypically a good cardplayer

Page 9: Enterprise Java Bean Technology Briefing Markus Hebach

The EJB Development FlowThe EJB Development Flow

JBuilderJBuilderJBuilderJBuilder

EJBEJB EJBEJB EJBEJB

JBuilderJBuilderJBuilderJBuilder ServletServlet

HTMLJSP

HTMLJSP

EJB ServerEJB Server

EJBEJB

EJB ServerEJB Server

EJBEJB

HTMLJSP

HTMLJSP ServletServlet

Page 10: Enterprise Java Bean Technology Briefing Markus Hebach

EJB Architecture & RolesEJB Architecture & Roles

EJB ServerEJB Server

Client AppClient AppClient AppClient App

EJBEJBEJBEJB

ContainerContainerContainerContainerEJBEJBEJBEJB

Bean ProviderBean Provider

EJB Server ProviderEJB Server Provider

AssemblerAssembler

DeployerDeployer

System AdminSystem Admin

Page 11: Enterprise Java Bean Technology Briefing Markus Hebach

EJB Architecture OverviewEJB Architecture Overview

Page 12: Enterprise Java Bean Technology Briefing Markus Hebach

Enterprise Java BeansEnterprise Java Beans

“The Enterprise Java Beans Architecture

is a component architecture for the development

and deployment of object oriented distributed

enterprise-level applications”.

“The Enterprise Java Beans Architecture

is a component architecture for the development

and deployment of object oriented distributed

enterprise-level applications”.

- Sun Microsystems EJB 1.0 Specification March 1998- Sun Microsystems EJB 1.0 Specification March 1998

Page 13: Enterprise Java Bean Technology Briefing Markus Hebach

Responsibilities of the ContainerResponsibilities of the Container

Proper creation, initialization, and removal of beans Ensuring that methods run in the proper transaction context Visibility of the home object in a JNDI-accessible namespace Swapping to and from secondary storage (for session beans) Persistence management (for container managed entity

beans) Availability of a home object implementing creation and

lookup services Implementation of certain basic security services

Page 14: Enterprise Java Bean Technology Briefing Markus Hebach

Identifying an EJBIdentifying an EJB

EJB (ejb-jar)EJB (ejb-jar)

EJB HomeEJB Home EJB Remote

EJB Remote

Bean Instance

Bean Instance

Deployment DescriptorDeployment Descriptor

Page 15: Enterprise Java Bean Technology Briefing Markus Hebach

Bean ArchitectureBean Architecture

EJB HomeEJB HomeEJB HomeEJB Home

Bean InstanceBean InstanceBean InstanceBean Instance

RemoteRemoteInterfaceInterfaceRemoteRemoteInterfaceInterface

Con

tain

erC

onta

iner

Page 16: Enterprise Java Bean Technology Briefing Markus Hebach

EJB HomeEJB Home

The Home Interface contains the signatures of the creation methods for the given bean. Each Create

method must have a corresponding ejbCreate method in the bean. Remember - Only the container can actually

create the instances!

The Home Interface contains the signatures of the creation methods for the given bean. Each Create

method must have a corresponding ejbCreate method in the bean. Remember - Only the container can actually

create the instances!

public interface myHome extends EJBHome { public myObject create() throws RemoteException; public myObject create(String str) throws RemoteException;}

public interface myHome extends EJBHome { public myObject create() throws RemoteException; public myObject create(String str) throws RemoteException;}

Page 17: Enterprise Java Bean Technology Briefing Markus Hebach

EJB RemoteEJB Remote

In a similar fashion, the developer must create a “Remote Interface” which describes thebusiness methods (signatures) of the bean that the developer would like the client to have access to.

In a similar fashion, the developer must create a “Remote Interface” which describes thebusiness methods (signatures) of the bean that the developer would like the client to have access to.

public interface Account extends javax.ejb.EJBObject { public void deposit(double amount) throws RemoteException; public void withdraw(double amount)throws RemoteException; public double balance() throws RemoteException;}

public interface Account extends javax.ejb.EJBObject { public void deposit(double amount) throws RemoteException; public void withdraw(double amount)throws RemoteException; public double balance() throws RemoteException;}

Page 18: Enterprise Java Bean Technology Briefing Markus Hebach

EJB ObjectEJB Object

The methods in your bean will NEVER be invoked directly from the client.

The client calls the bean’s methods indirectly through the EJBObject, which acts as a proxy.

The methods in your bean will NEVER be invoked directly from the client.

The client calls the bean’s methods indirectly through the EJBObject, which acts as a proxy.

public interface javax.ejb.EJBObject extends java.rmi.Remote { public EJBHome getEJBHome() throws RemoteException; public Object getPrimaryKey() throws RemoteException; public Handle getHandle() throws RemoteException; public void remove() throws RemoteException, public boolean isIdentical(EJBObject other) throws RemoteException;}

public interface javax.ejb.EJBObject extends java.rmi.Remote { public EJBHome getEJBHome() throws RemoteException; public Object getPrimaryKey() throws RemoteException; public Handle getHandle() throws RemoteException; public void remove() throws RemoteException, public boolean isIdentical(EJBObject other) throws RemoteException;}

Page 19: Enterprise Java Bean Technology Briefing Markus Hebach

Bean TypesBean Types

Session Beans (Required for EJB 1.0)Entity Beans (Optional for EJB 1.0)

Types differentiated by Interface implemented and by the type declaration in the deployment descriptor.

Types differentiated by Interface implemented and by the type declaration in the deployment descriptor.

Page 20: Enterprise Java Bean Technology Briefing Markus Hebach

Bean TypesBean Types

Session Beans Execute on behalf of single client Can be transaction aware Does not represent directly shared data in a database Are relatively short lived Are removed when the EJB server crashes

Page 21: Enterprise Java Bean Technology Briefing Markus Hebach

Bean TypesBean Types

Entity BeansRepresents data in a databaseAre transactionalAllows shared access by multiple usersSurvives crash of EJB server

Page 22: Enterprise Java Bean Technology Briefing Markus Hebach

Session Bean Types Session Bean Types

Stateless SessionThe bean does not contain conversational state between method invocations - as a consequence any session bean instance can be used for any client. Stateless beans are designed to be pooled.

Stateless SessionThe bean does not contain conversational state between method invocations - as a consequence any session bean instance can be used for any client. Stateless beans are designed to be pooled.

Page 23: Enterprise Java Bean Technology Briefing Markus Hebach

Session Bean Types Session Bean Types

Stateful Session The bean contains conversational state which is kept across method invocations and transactions. Once a client has obtained a specific session bean it must use this instance for the life of the session.

Stateful Session The bean contains conversational state which is kept across method invocations and transactions. Once a client has obtained a specific session bean it must use this instance for the life of the session.

Page 24: Enterprise Java Bean Technology Briefing Markus Hebach

EJB ServerEJB Server

Clients View of Session Bean

EJB ContainerEJB Container

Thin ClientThin Client

WindowsWindowsClientClient

WindowsWindowsClientClient

JavaJavaClientClientJavaJavaClientClient

BrowserBrowserClientClient

BrowserBrowserClientClient

MobileMobileClientClientMobileMobileClientClient

CartCart

CartHomeCartHome

CartBeanCartBean

JNDIJNDI

CartHome cartHome = javax.rmi.Portable RemoteObject.narrow( initialContext.lookup(...), CartHome.class);

CartHome cartHome = javax.rmi.Portable RemoteObject.narrow( initialContext.lookup(...), CartHome.class); Cart cart = cartHome.create(…);Cart cart = cartHome.create(…);

cart.addItem(66);cart.addItem(66);cart.addItem(22);cart.addItem(22);cart.purchase()cart.purchase()cart.remove()cart.remove()

Page 25: Enterprise Java Bean Technology Briefing Markus Hebach

Entity Bean TypesEntity Bean Types

Bean Managed PersistenceThe entity bean implementation is responsible for implementing persistence. The bean provider writes the code to access the underlying database or application. These calls are placed in the methods ejbCreate(), ejbFind(), ejbRemove(), ejbLoad() and ejbStore().

Bean Managed PersistenceThe entity bean implementation is responsible for implementing persistence. The bean provider writes the code to access the underlying database or application. These calls are placed in the methods ejbCreate(), ejbFind(), ejbRemove(), ejbLoad() and ejbStore().

Page 26: Enterprise Java Bean Technology Briefing Markus Hebach

Entity Bean TypesEntity Bean Types

Container Managed PersistenceThe container is responsible for implementing the persistence. Instead of the bean provider implementing the database access code, the container is responsible for generating the appropriate code and its execution. The fields of the entity bean, which are managed by the container are specified in the deployment descriptor.

Container Managed PersistenceThe container is responsible for implementing the persistence. Instead of the bean provider implementing the database access code, the container is responsible for generating the appropriate code and its execution. The fields of the entity bean, which are managed by the container are specified in the deployment descriptor.

Page 27: Enterprise Java Bean Technology Briefing Markus Hebach

EJB ServerEJB Server

DBDB

Session Bean Interacting with Entity Bean

EJB ContainerEJB Container

Thin ClientThin Client

WindowsWindowsClientClient

WindowsWindowsClientClient

JavaJavaClientClientJavaJavaClientClient

BrowserBrowserClientClient

BrowserBrowserClientClient

MobileMobileClientClientMobileMobileClientClient

CartCart CartBeanCartBean

JNDIJNDI

OrderHomeOrderHome

OrderOrderOrderBeanOrderBean

order.findByPrimaryKey(orderNo);order.findByPrimaryKey(orderNo);

SQLSQL

ejbLoad();ejbLoad();placeOrder();placeOrder();orderComplete();orderComplete();

ejbStore();ejbStore();

Page 28: Enterprise Java Bean Technology Briefing Markus Hebach

The Session Bean InterfaceThe Session Bean Interface

package javax.ejb;public interface SessionBean extends EnterpriseBean { void setSessionContext(SessionContext s) throws

RemoteException; void ejbRemove() throws RemoteException; void ejbActivate() throws RemoteException; void ejbPassivate() throws RemoteException;}

Page 29: Enterprise Java Bean Technology Briefing Markus Hebach

package javax.ejb;public interface EntityBean extends EnterpriseBean { void setEntityContext(EntityContext e) throws RemoteException; void unsetEntityContext() throws RemoteException; void ejbRemove() throws RemoteException; void ejbActivate() throws RemoteException; void ejbPassivate() throws RemoteException; void ejbLoad() throws RemoteException; void ejbStore() throws RemoteException;}

The Entity Bean InterfaceThe Entity Bean Interface

Page 30: Enterprise Java Bean Technology Briefing Markus Hebach

Holes in the EJB 1.0 SpecificationHoles in the EJB 1.0 Specification

No definition of Interoperability between containers. Does not prescribe which RMI implementation should

be used. No definition for propagating Transaction Contexts No recommendations for bridging security domains No standard Container API

Page 31: Enterprise Java Bean Technology Briefing Markus Hebach

Where does CORBA fit in?Where does CORBA fit in?

Page 32: Enterprise Java Bean Technology Briefing Markus Hebach

The role of CORBA in EJBThe role of CORBA in EJB

“The Enterprise Java Beans Architecture

will be compatible with CORBA.

“The Enterprise Java Beans Architecture

will be compatible with CORBA.

- EJB 1.0 Specification Section 2.1 Overall Goals- EJB 1.0 Specification Section 2.1 Overall Goals

Page 33: Enterprise Java Bean Technology Briefing Markus Hebach

EJB 1.0 Section 4.4 Standard CORBA MappingEJB 1.0 Section 4.4 Standard CORBA Mapping

“To ensure interoperability for multi-vendor environments, we define a standard mapping of the Enterprise JavaBean client’s view contract to CORBA.”

The mapping to CORBA covers:1. Mapping of the EJB Client interfaces to CORBA IDL2. Propagation of transaction context3. Propagation of security context

“To ensure interoperability for multi-vendor environments, we define a standard mapping of the Enterprise JavaBean client’s view contract to CORBA.”

The mapping to CORBA covers:1. Mapping of the EJB Client interfaces to CORBA IDL2. Propagation of transaction context3. Propagation of security context

Page 34: Enterprise Java Bean Technology Briefing Markus Hebach

Results of the CORBA MappingResults of the CORBA Mapping

On the wire interoperability between EJB Servers from multiple vendors.

Enables non-Java clients to access EJB’s. CORBA Object Services allow security and transactions

to be handled in a distributed vendor independent manner.

Page 35: Enterprise Java Bean Technology Briefing Markus Hebach

“Open” implementation choices“Open” implementation choices

RMI/IIOPJNDI over COSNaming and/or LDAPJTS/COSTransactions and IIOPX.509 certificates/IIOP over SSL

Page 36: Enterprise Java Bean Technology Briefing Markus Hebach

The Inprise EJB Solution “Kodiak”The Inprise EJB Solution “Kodiak”

Page 37: Enterprise Java Bean Technology Briefing Markus Hebach

Inprise EJB Infrastructure

Language Independent ClientLanguage Independent ClientLanguage Independent ClientLanguage Independent ClientATMATM

SessionSessionBeanBean

ATMATMSessionSession

BeanBean

Java DBJava DBJava DBJava DBJTSJTS

2 Phase 2 Phase CommitCommit

JTSJTS2 Phase 2 Phase CommitCommit

JNDIJNDINamingNamingJNDIJNDI

NamingNamingContainerContainerContainerContainerAcctAcctEntityEntityBeanBean

AcctAcctEntityEntityBeanBean

DatabaseDatabase

RMI/IIOPRMI/IIOP

CosNamingLDAP

CosNamingLDAP

CosTransactionsDistributed

2 Phase Commit

CosTransactionsDistributed

2 Phase Commit

CORBA 2.3Objects By Value

CORBA 2.3Objects By Value

Can generate IDL from the Home andRemote Interfaces.

Can generate IDL from the Home andRemote Interfaces.

IIOP/SSLAccess Control

IIOP/SSLAccess Control

Complete Java DatabaseComplete Java Database

Page 38: Enterprise Java Bean Technology Briefing Markus Hebach

Inprise EJB Server Operation ModesInprise EJB Server Operation Modes

Development Mode All services will run together in a single process JNDI/Lightweight Naming Service Lightweight JTS Implementation All Java Database for Container Managed Persistence

Operations Mode Fully Distributed Service JNDI/COSNaming ITS/COSTransaction implementation

Page 39: Enterprise Java Bean Technology Briefing Markus Hebach

A Fully Distributed EJB Solution

ContainerContainerContainerContainer

ContainerContainerContainerContainer

JNDIJNDINamingNamingJNDIJNDI

NamingNaming

StorageStorageStorageStorage

JTS/ITSJTS/ITSJTS/ITSJTS/ITS

JTS/ITSJTS/ITSJTS/ITSJTS/ITS

Distributed TransactionsDistributed Security Domains

Language Interoperability

Distributed TransactionsDistributed Security Domains

Language Interoperability

Page 40: Enterprise Java Bean Technology Briefing Markus Hebach