4061cd240c21c840ed626dd413d2f5d5.ppt
- Количество слайдов: 61
EJB and CCM Analysis of two Component models Jaime Davila, Ayferi Kutlu, German Finez Computer Science & Engineering Department The University of Connecticut ayferi@engr. uconn. edu gfinez@acm. org jdavila@engr. uconn. edu EJB&CCM--1
Motivation m Corba Component Model is a new technology, implementations have just arrived q We like to make first experience with CCM q Point out differences to EJB beyond the language independency q Point out its benefits by comparing it to another component model (EJB) EJB&CCM--2
EJB - An introduction m Basic Architecture q EJB server q EJB container q EJB client q EJBs m Contracts q Container Responsibilities q Beans Responsbilities m Packaging and Deployment m A sample client session EJB&CCM--3
EJB Architecture EJB&CCM--4
EJB server m provides the environment that enables the execution of applications using EJB components m provides required concepts of naming and transaction management as well as vendor specific features such as optimized data access m May host one or multiple EJB containers EJB&CCM--5
EJB container m acts as the runtime environment for EJB components m Host one or multiple Enterprise Java Beans m Makes services of EJBs accessible to clients EJB&CCM--6
What is an Enterprise Bean an enterprise bean is a server-side component that encapsulates the business logic of an application EJB&CCM--7
Benefits m the EJB container provides system-level services to enterprise beans q the bean developer can concentrate on solving business problems. The EJB container -not the bean developer- is responsible for system-level services such as transaction management and security authorization. q the client developer can focus on the presentation of the client. As a result, the clients are thinner EJB&CCM--8
EJBs - different flavours m Entity beans q represent business objects on the server, e. g Customer, Products m Session Beans q perform business methods for clients, e. g buying items m Message-Driven Beans q consumers of asynchroneous messages EJB&CCM--9
Session Beans m associated with one EJB Client. q performs business tasks for the client inside the server. q Two categories of Session Beans: Ø Stateful: no internal state (current values of variables) for the client – e. g sending an email to confirm an order Ø Stateless: state is retained for the duration of the client-bean session – e. g buying items into shopping cart EJB&CCM--10
Entity Beans m represent business objects such as customer or products m Are persistent, i. e state is store to database m May be shared by multiple clients m Example: Customer bean EJB&CCM--11
Persistence m Bean managed persistence q Bean must implement the database access itself Ø additional responsibility in each Bean Ø but : more control over how the entity bean accesses a database q Container managed persistence Ø The EJB container handles all database access required by the entity bean. The bean's code contains no database access calls Ø the bean's code is not tied to a specific persistent storage mechanism (database) EJB&CCM--12
Message Driven Beans m serves as a consumer for asynchronous messages m is created by the container as a result to incoming messages m no interfaces for client, no “identity” EJB&CCM--13
EJB Client m locate the specific EJB container that contains the enterprise Bean through the Java Naming and Directory Interface m accesses a session bean or an entity bean through the bean’s home and component interfaces. m The bean that implements business method is never accessed directly by the client EJB&CCM--14
Workflow EJB&CCM--15
Contracts m ensure uniform implementation models, and hence, increase the reusability of components m Client-View contract describes how a client is allowed to obtain access to services provided by EJBs m component contract specifies services of container for beans as well as responsibilities of bean provider EJB&CCM--16
Client View includes m Home Interface q defines the methods to create and remove instances of beans m Component Interface q business methods callable by the client m Handle q serializable reference to an EJB object EJB&CCM--17
Bean Responsibilities m m m implement method for the creation, removal, and, if the bean is an entity with bean-managed persistence, the location of a bean. (The requirement for the container is to invoke these methods during an EJB object creation, removal, and lookup) the requirement to define the enterprise bean’s home and component interfaces, if the bean is an entity bean or a session bean. (The requirement for the container is to provide classes that implement these interfaces) the requirement to implement the business methods in the enterprise bean class EJB&CCM--18
Container Responsibilities m the requirement to delegate the client method invocation to the bean class that implements the required business method m the requirement to implement persistence for entity beans with container- managed persistence m the requirement to manage transactions, security, and exceptions on behalf of the enterprise bean instances EJB&CCM--19
Deployment & Packaging m ejb-jar file: standard format for packaging EJBs. Includes: q Java class files for the enterprise Beans and their home and component interfaces q An XML deployment descriptor Ø provides both the structural and application assembly information about the enterprise beans in the ejb-jar file. EJB&CCM--20
Deployment Descriptor – Structural Information e. g m m m Enterprise bean’s name: <ejb-name> Enterprise bean’s class <ejb-class> Enterprise bean’s remote interface <remote> Enterprise bean’s remote home interface <home> Session bean’s state management type <session-type> Entity bean’s persistence management <persistence-type> EJB&CCM--21
Deployment Descriptor Example <enterprise-beans> <session> <description> Shoppingcart bean </description> <ejb-name> Cart. Bean </ejb-name> <home> Cart. Home </home> <remote> Cart </remote> <ejb-class> Cart. EJB </ejb-class> <session-type> Stateful </session-type>. . . </session> </enterprise-beans> EJB&CCM--22
A sample client session The Client looks up the Bean‘s home interface: Context initial. Context = new Initial. Context(); Cart. Home cart. Home = javax. rmi. Portable. Remote. Object. narrow(initial. Context. lookup („cart. Application/cart“), Cart. Home. class); Creating an EJB object: Cart cart = cart. Home. create(„Customer XYZ“, „ 123 -456“); Using the remote bean: cart. add. Item(2); // call business method cart. add. Item(3); // call another business method cart. checkout(); // one more business method Handle cart. Handle = cart. get. Handle(); //serialize handle cart. remove(); // remove session object EJB&CCM--23
CORBA Component Model (CCM) m m m Component-oriented Middleware Specification Proposed by Object Management Group (OMG) q First/current release: June 2002 q Version number: 3. 0 (conformance to v 3. 0 CORBA/IIOP) Motivation: overall conception of a distributed application q Design q Production q Deployment q Execution q Administration EJB&CCM--24
CCM Antecedents m Common Object Request Broker Architecture (CORBA). q Object-oriented middleware q Proposed by OMG q Versions: Ø CORBA/IIOP v 3. 0: June 2002 Ø CORBA/IIOP v 2. 0: July 1996 m Benefits of CCM vs CORBA q More comprehensive (deployment, administration) q Functional and non-functional kept separate (components and containers) q Connections defined by component interfaces EJB&CCM--25
CCM Competitors m Object-oriented middleware proposals q Distributed Component Object Model (DCOM) q Java Remote Method Invocation (RMI) q CORBA (without components) m Component-oriented middleware alternatives q Enterprise Java Beans (EJB) EJB&CCM--26
CCM Overview m Abstract model m Programming model m Packaging model m Deployment model m Execution model EJB&CCM--27
Abstract Model m Element definitions: Component types Ø Interfaces (ports) Ø Properties (attributes) q m Component instance managers (homes) Interface Definition Language (IDL) q Currently: IDL 3 mapped to IDL 2 q Generation of skeletons EJB&CCM--28
Ports Provided by component Used by component Synchronous Facets Receptacles Asynchronous Sinks Sources EJB&CCM--29
Programming Model m Implementation of component types m Component Implementation Framework (CIF) q Functional and non-functional integration q Component-container interactions m Component Implementation Definition Language (CIDL) q Implementation structure q Superset of Persistent State Definition Language (PSDL) EJB&CCM--30
Composition m CIDL Metatype m Basic elements: q Component home (component type) q Component and home executors m Optional elements: q Abstract storage q Delegation specification q Proxy home EJB&CCM--31
Component classification m m Service q Stateless and without identity q Life cycle: single operation Session q Transient state and identity q Life cycle: sequence of operations Process q Persistent state and identity q Clients unaware of persistence Entity q Persistent state and identity q Clients aware of persistence EJB&CCM--32
Packaging Model m Packaging of component implementations m Package: q Set of related files q Package Descriptors m Open Software Descriptor (OSD) language (extended) q XML Data Type Definition (DTD) EJB&CCM--33
Software Packages m Set of related files m Software Package Descriptor q General information Ø Author, company, title, description, human language, usage license… q Implementation specific information Ø Operating system, programming language, compiler version, processor type… EJB&CCM--34
Component Packages m Software Package specialization q <descriptor type=“CORBAComponent”> m Component Package Descriptor q Component structure (interfaces) q Deployment information: container type Ø Persistence Ø Thread policy Ø Port quality of service EJB&CCM--35
Component Assemblies m Set of related Component Packages m Assembly Descriptor q Components q Connections q Logical partitioning of instances m Property Descriptor q Configuration of components and homes q Attribute types: Ø Simple Ø Sequence Ø Struct EJB&CCM--36
Deployment Model m Definition of execution sites m Installation of implementations m Instantiation of serves and containers m Instantiation of homes and components m Connection and configuration of components EJB&CCM--37
Execution Model m m Containers provide execution environment q Transient q Persistent Non-functional aspects q Low level: Ø CPU resources, memory access… q High level Ø Persistence, life cycle managing… m Container servers q Factory of containers (arbitrary number) q Operational at deployment time EJB&CCM--38
CCM Implementations m m m Open. CCM Mico. CCM EJCCM Qedo K 2 -CCM EJB&CCM--39
Comparison EJB&CCM--40
Qualitative comparison m m General Architectural Concept q Basic Container vs Extended Container. Interfaces q One Interface vs Multiple Interfaces Communication q Naming vs explicit invocation Component Types q Use of Process Component in CCM EJB&CCM--41
Qualitative comparison m m Life Time Policy: q Container Managed vs Several Policies Persistence q Serialization vs PSS Events q Message Beans vs Sinks and Sources of events Interoperability q Java based vs Full Interoperability. EJB&CCM--42
Quantitative Analysis m The Shopping Cart Application developed in implementations of EJB and CCM. EJB&CCM--43
Choice of Implementations m EJB container: q JBoss, an Open Source full implementation of the EJB 2. 0 standard. m CCM container: q MICO-CCM, an Open Source partial implementation of the CCM standard based on C++. q Supports IDL 3. 0 and deployment, but not CIDL or Entity Component EJB&CCM--44
CCM Application Design UML Class Diagram: EJB&CCM--45
EJB Design m Design of the EJB&CCM--46
CCM IDL File #include <mico/CCM. idl> #include "checkout. idl" interface Shopping. Cart. Intf { void set. Cust (in Customer cust); void add. Item (in Cart. Item item); double buy. Contents (); }; component Shopping. Cart supports Shopping. Cart. Intf{ uses Check. Out. Intf Check; }; home Shopping. Home manages Shopping. Cart { factory new (in Customer id); }; local interface My. Shopping. Cart : CCM_Shopping. Cart, Components: : Session. Component { }; EJB&CCM--47
EJB IDL equivalent Cart. java. util. *; import javax. ejb. EJBObject; import java. rmi. Remote. Exception; public interface Cart extends EJBObject { public void set. Customer(Customer customer) throws Remote. Exception; public void add. Item(int itemid) throws Remote. Exception; public double buy. Contents() throws Remote. Exception; } jboss. xml <jboss> <enterprise-beans> <session> <ejb-name>Cart. EJB</ejb-name> <jndi-name>cart/Cart</jndi-name> </session>. . . <jboss> EJB&CCM--48
Implementation of CCM Component CORBA: : Double buy. Contents () { Cart. Item. List_var items = new Cart. Item. List(_items. size()); Check. Out. Intf_var co = _ctx->get_connection_Check(); /* We create the itemlist */ items->length(_items. size()); for (int i=0; i < _items. size(); i++) items[i] = _items[i]; return co->buy(_cust, items); } EJB&CCM--49
Implementation of EJB Bean public double buy. Contents() { double bill = 0; try { Object ref = jndi. Context. lookup("checkout/Checkout"); Checkout. Home home = (Checkout. Home) Portable. Remote. Object. narrow(ref, Checkout. Home. class); Checkout check = home. create(); bill = check. buy(customer. get. Id(), items); } catch (Exception ex) { System. err. println("Caught an unexpected exception!"); ex. print. Stack. Trace(); } return bill; } EJB&CCM--50
Home in CCM class My. Shopping. Cart. Home_impl : virtual public CCM_Shopping. Home { public: Components: : Enterprise. Component_ptr create() { return new My. Shopping. Cart_impl; } }; extern "C" { Components: : Home. Executor. Base_ptr create_Shopping. Home (CORBA: : ORB_ptr orb) { return new My. Shopping. Cart. Home_impl; } } EJB&CCM--51
Home in EJB import java. io. Serializable; import java. rmi. Remote. Exception; import javax. ejb. Create. Exception; import javax. ejb. EJBHome; public interface Cart. Home extends EJBHome { Cart create() throws Remote. Exception, Create. Exception; } EJB&CCM--52
Client in CCM CORBA: : ORB_var orb; orb = CORBA: : ORB_init (argc, argv); CORBA: : Object_var obj = orb>resolve_initial_references ("Name. Service"); Cos. Naming: : Naming. Context. Ext_var nc = Cos. Naming: : Naming. Context. Ext: : _narrow (obj); … obj = nc->resolve_str ("Shopping. Home"); Shopping. Home_var sh = Shopping. Home: : _narrow (obj); … Shopping. Cart_var sc = sh->create (); sc->set. Cust(cust->get. Id()); sc->connect_Check(ch); sc->configuration_complete(); … sc->add. Item (item); EJB&CCM--53
Client in EJB Initial. Context jndi. Context = new Initial. Context(); Object ref = jndi. Context. lookup("cart/Cart"); Cart. Home home = (Cart. Home) Portable. Remote. Object. narrow(ref, Cart. Home. class); Cart shopping. Cart = home. create(); … Customer cust = custhome. create(); shopping. Cart. set. Customer(cust); … shopping. Cart. add. Item(item); EJB&CCM--54
Line Count of Both Applications Component SLOC (JBoss) SLOC (Mico) Client Side Client 85 96 Server Side Customer 63 90 Shopping Cart 68 72 Checkout 41 49 257 307 Total EJB&CCM--55
Performance Test Environment m m m CPU: q TI Ultra. Sparc Iii Total Memory: q 60536 k. B Operating System q Debian GNU/Linux 3. 0, kernel 2. 4. 18. Java Virtual Machine q 1. 4. 1 Blackdown JBoss: 3. 0. 4 MICO-CCM: 2. 3. 7 EJB&CCM--56
Test Set First Test: In the first test set we simulate the situation of a client, which buys a specific amount of items, without a delay between two consecutive buys of articles. We increment the number of items from 10 to 200 using steps of 10. m Second Test: In this test we decided to fix the amount of articles that the client buys (10 items), and the amount of time they wait after they buy each item (1 second). m EJB&CCM--57
Results for Test 1, CCM Application EJB&CCM--58
Results for Test 1 EJB&CCM--59
Results for Test 2, CCM application EJB&CCM--60
Results for Test 2 EJB&CCM--61
4061cd240c21c840ed626dd413d2f5d5.ppt