EJB&CCM--1 EJB and CCM Analysis of two Component models Jaime Davila, Ayferi Kutlu, German Finez...
-
date post
20-Dec-2015 -
Category
Documents
-
view
215 -
download
0
Transcript of EJB&CCM--1 EJB and CCM Analysis of two Component models Jaime Davila, Ayferi Kutlu, German Finez...
EJB&CCM--1
EJB and CCM EJB and CCM Analysis of two Component modelsAnalysis of two Component models
Jaime Davila,Ayferi Kutlu,
German Finez Computer Science & Engineering Department
The University of Connecticut
[email protected]@acm.org
EJB&CCM--2
MotivationMotivation
Corba Component Model is a new technology, Corba Component Model is a new technology, implementations have just arrivedimplementations have just arrived
We like to make first experience with CCM
Point out differences to EJB beyond the language independency
Point out its benefits by comparing it to another component model (EJB)
EJB&CCM--3
EJB - An introductionEJB - An introduction
Basic ArchitectureBasic Architecture EJB server EJB container EJB client EJBs
ContractsContracts Container Responsibilities Beans Responsbilities
Packaging and DeploymentPackaging and Deployment
A sample client sessionA sample client session
EJB&CCM--5
EJB serverEJB server
provides the environment that enables the provides the environment that enables the execution of applications using EJB componentsexecution of applications using EJB components
provides required concepts of naming and provides required concepts of naming and transaction management as well as vendor specific transaction management as well as vendor specific features such as optimized data accessfeatures such as optimized data access
May host one or multiple EJB containersMay host one or multiple EJB containers
EJB&CCM--6
EJB containerEJB container
acts as the runtime environment for EJB acts as the runtime environment for EJB componentscomponents
Host one or multiple Enterprise Java Beans Host one or multiple Enterprise Java Beans
Makes services of EJBs accessible to clientsMakes services of EJBs accessible to clients
EJB&CCM--7
What is an Enterprise BeanWhat is an Enterprise Bean
an enterprise bean is a server-side an enterprise bean is a server-side component that encapsulates the component that encapsulates the business logic of an applicationbusiness logic of an application
EJB&CCM--8
BenefitsBenefits
the EJB container provides system-level services the EJB container provides system-level services to enterprise beansto enterprise beans
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.
the client developer can focus on the presentation of the client. As a result, the clients are thinner
EJB&CCM--9
EJBs - different flavoursEJBs - different flavours
Entity beansEntity beans represent business objects on the server,e.g
Customer, Products
Session BeansSession Beans perform business methods for clients, e.g
buying items
Message-Driven BeansMessage-Driven Beans consumers of asynchroneous messages
EJB&CCM--10
Session BeansSession Beans
associated with one EJB Client. associated with one EJB Client. performs business tasks for the client inside the
server.
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--11
Entity BeansEntity Beans
represent business objects such as customer or represent business objects such as customer or productsproducts
Are persistent, i.e state is store to databaseAre persistent, i.e state is store to database
May be shared by multiple clientsMay be shared by multiple clients
Example: Customer beanExample: Customer bean
EJB&CCM--12
PersistencePersistence
Bean managed persistenceBean managed persistence Bean must implement the database access itself
additional responsibility in each Bean but : more control over how the entity bean
accesses a database 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--13
Message Driven BeansMessage Driven Beans
serves as a consumer for asynchronous messagesserves as a consumer for asynchronous messages
is created by the container as a result to incoming is created by the container as a result to incoming messagesmessages
no interfaces for client, no “identity”no interfaces for client, no “identity”
EJB&CCM--14
EJB ClientEJB Client
locate the specific EJB container that contains the locate the specific EJB container that contains the enterprise Bean through the Java Naming and enterprise Bean through the Java Naming and Directory InterfaceDirectory Interface
accesses a session bean or an entity bean through accesses a session bean or an entity bean through the bean’s home and component interfaces.the bean’s home and component interfaces.
The bean that implements business method is The bean that implements business method is never accessed directly by the clientnever accessed directly by the client
EJB&CCM--16
ContractsContracts
ensure uniform implementation models, and ensure uniform implementation models, and hence, increase the reusability of componentshence, increase the reusability of components
Client-View contract describes how a client is Client-View contract describes how a client is allowed to obtain access to services provided by allowed to obtain access to services provided by EJBsEJBs
component contract specifies services of container component contract specifies services of container for beans as well as responsibilities of bean for beans as well as responsibilities of bean providerprovider
EJB&CCM--17
Client View includesClient View includes
Home InterfaceHome Interface defines the methods to create and remove
instances of beans
Component InterfaceComponent Interface business methods callable by the client
HandleHandle serializable reference to an EJB object
EJB&CCM--18
Bean ResponsibilitiesBean Responsibilities
implement method for the creation, removal, and, implement method for the creation, removal, and, if the bean is an entity with bean-managed if the bean is an entity with bean-managed persistence, the location of a bean. (The persistence, the location of a bean. (The requirement for the container is to invoke these requirement for the container is to invoke these methods during an EJB object creation, removal, methods during an EJB object creation, removal, and lookup)and lookup)
the requirement to define the enterprise bean’s the requirement to define the enterprise bean’s home and component interfaces, if the bean is an home and component interfaces, if the bean is an entity bean or a session bean. (The requirement for entity bean or a session bean. (The requirement for the container is to provide classes that implement the container is to provide classes that implement these interfaces)these interfaces)
the requirement to implement the business the requirement to implement the business methods in the enterprise bean classmethods in the enterprise bean class
EJB&CCM--19
Container ResponsibilitiesContainer Responsibilities
the requirement to delegate the client method the requirement to delegate the client method invocation to the bean class that implements the invocation to the bean class that implements the required business methodrequired business method
the requirement to implement persistence for entity the requirement to implement persistence for entity beans with container- managed persistencebeans with container- managed persistence
the requirement to manage transactions, security, the requirement to manage transactions, security, and exceptions on behalf of the enterprise bean and exceptions on behalf of the enterprise bean instancesinstances
EJB&CCM--20
Deployment & PackagingDeployment & Packaging
ejb-jar ejb-jar filefile: standard format for packaging EJBs. : standard format for packaging EJBs. Includes:Includes: Java class files for the enterprise Beans and
their home and component interfaces An XML deployment descriptor
provides both the structural and application assembly information about the enterprise beans in the ejb-jar file.
EJB&CCM--21
Deployment Descriptor – Deployment Descriptor – Structural InformationStructural Information
e.g e.g Enterprise bean’s nameEnterprise bean’s name:: <ejb-name> Enterprise bean’s classEnterprise bean’s class <ejb-class> Enterprise bean’s remote interfaceEnterprise bean’s remote interface <<remote>> Enterprise bean’s remote home interfaceEnterprise bean’s remote home interface
<home><home> Session bean’s state management typeSession bean’s state management type
<session-type><session-type> Entity bean’s persistence managementEntity bean’s persistence management
<persistence-type><persistence-type>
EJB&CCM--22
Deployment Descriptor Deployment Descriptor ExampleExample
<<enterprise-beans>enterprise-beans><session><session><description><description> Shoppingcart bean Shoppingcart bean </description></description><ejb-name><ejb-name> CartBean CartBean </ejb-name></ejb-name><home><home> CartHome CartHome </home></home><remote><remote> Cart Cart </remote></remote><ejb-class><ejb-class> CartEJB CartEJB </ejb-class></ejb-class><session-type><session-type> Stateful Stateful </session-type></session-type>......</session></session></enterprise-beans</enterprise-beans>>
EJB&CCM--23
A sample client sessionA sample client session
The Client looks up the Bean‘s home interface:The Client looks up the Bean‘s home interface:Context initialContext = newContext initialContext = new InitialContext();InitialContext();CartHome cartHome =CartHome cartHome =javax.rmi.PortableRemoteObject.narrow(initialContext.lookupjavax.rmi.PortableRemoteObject.narrow(initialContext.lookup(„cartApplication/cart“), CartHome.class);(„cartApplication/cart“), CartHome.class);
Creating an EJB object:Creating an EJB object:Cart cart = cartHome.create(„Customer XYZ“, „123-456“);Cart cart = cartHome.create(„Customer XYZ“, „123-456“);
Using the remote beanUsing the remote bean::cart.addItem(2); cart.addItem(2); // call business method// call business methodcart.addItem(3); cart.addItem(3); // call another business method// call another business methodcart.checkout(); cart.checkout(); // one more business method// one more business methodHandle cartHandle = cart.getHandle(); //Handle cartHandle = cart.getHandle(); //serialize handleserialize handlecart.remove(); cart.remove(); // remove session object// remove session object
EJB&CCM--24
CORBA Component Model (CCM)CORBA Component Model (CCM)
Component-oriented Middleware SpecificationComponent-oriented Middleware Specification Proposed by Object Management Group (OMG)Proposed by Object Management Group (OMG)
First/current release: June 2002 Version number: 3.0 (conformance to v3.0
CORBA/IIOP) Motivation: overall conception of a distributed Motivation: overall conception of a distributed
applicationapplication Design Production Deployment Execution Administration
EJB&CCM--25
CCM AntecedentsCCM Antecedents
Common Object Request Broker Architecture Common Object Request Broker Architecture (CORBA).(CORBA). Object-oriented middleware Proposed by OMG Versions:
CORBA/IIOP v3.0: June 2002 CORBA/IIOP v2.0: July 1996
Benefits of CCM vs CORBABenefits of CCM vs CORBA More comprehensive (deployment,
administration) Functional and non-functional kept separate
(components and containers) Connections defined by component interfaces
EJB&CCM--26
CCM CompetitorsCCM Competitors
Object-oriented middleware proposalsObject-oriented middleware proposals Distributed Component Object Model (DCOM) Java Remote Method Invocation (RMI) CORBA (without components)
Component-oriented middleware alternativesComponent-oriented middleware alternatives Enterprise Java Beans (EJB)
EJB&CCM--27
CCM OverviewCCM Overview
Abstract modelAbstract model
Programming modelProgramming model
Packaging modelPackaging model
Deployment modelDeployment model
Execution modelExecution model
EJB&CCM--28
Abstract ModelAbstract Model
Element definitions:Element definitions:Component types
Interfaces (ports) Properties (attributes)
Component instance managers (homes)
Interface Definition Language (IDL)Interface Definition Language (IDL) Currently: IDL3 mapped to IDL2 Generation of skeletons
EJB&CCM--29
PortsPorts
Provided by component
Used by component
Synchronous Facets Receptacles
Asynchronous Sinks Sources
EJB&CCM--30
Programming ModelProgramming Model
Implementation of component typesImplementation of component types
Component Implementation Framework (CIF)Component Implementation Framework (CIF) Functional and non-functional integration Component-container interactions
Component Implementation Definition Language Component Implementation Definition Language (CIDL)(CIDL) Implementation structure Superset of Persistent State Definition
Language (PSDL)
EJB&CCM--31
CompositionComposition
CIDL MetatypeCIDL Metatype
Basic elements:Basic elements: Component home (component type) Component and home executors
Optional elements:Optional elements: Abstract storage Delegation specification Proxy home
EJB&CCM--32
Component classificationComponent classification
ServiceService Stateless and without identity Life cycle: single operation
SessionSession Transient state and identity Life cycle: sequence of operations
ProcessProcess Persistent state and identity Clients unaware of persistence
EntityEntity Persistent state and identity Clients aware of persistence
EJB&CCM--33
Packaging ModelPackaging Model
Packaging of component implementationsPackaging of component implementations
Package:Package: Set of related files Package Descriptors
Open Software Descriptor (OSD) language Open Software Descriptor (OSD) language (extended)(extended) XML Data Type Definition (DTD)
EJB&CCM--34
Software PackagesSoftware Packages
Set of related filesSet of related files
Software Package DescriptorSoftware Package Descriptor General information
Author, company, title, description, human language, usage license…
Implementation specific information Operating system, programming language,
compiler version, processor type…
EJB&CCM--35
Component PackagesComponent Packages
Software Package specializationSoftware Package specialization <descriptor type=“CORBAComponent”>
Component Package DescriptorComponent Package Descriptor Component structure (interfaces) Deployment information: container type
Persistence Thread policy Port quality of service
EJB&CCM--36
Component AssembliesComponent Assemblies
Set of related Component PackagesSet of related Component Packages
Assembly DescriptorAssembly Descriptor Components Connections Logical partitioning of instances
Property DescriptorProperty Descriptor Configuration of components and homes Attribute types:
Simple Sequence Struct
EJB&CCM--37
Deployment ModelDeployment Model
Definition of execution sitesDefinition of execution sites
Installation of implementationsInstallation of implementations
Instantiation of serves and containersInstantiation of serves and containers
Instantiation of homes and componentsInstantiation of homes and components
Connection and configuration of componentsConnection and configuration of components
EJB&CCM--38
Execution ModelExecution Model
Containers provide execution environmentContainers provide execution environment Transient Persistent
Non-functional aspectsNon-functional aspects Low level:
CPU resources, memory access… High level
Persistence, life cycle managing… Container serversContainer servers
Factory of containers (arbitrary number) Operational at deployment time
EJB&CCM--39
CCM ImplementationsCCM Implementations
OpenCCMOpenCCM MicoCCMMicoCCM EJCCMEJCCM QedoQedo K2-CCMK2-CCM
EJB&CCM--41
Qualitative comparisonQualitative comparison
General Architectural ConceptGeneral Architectural Concept Basic Container vs Extended Container.
InterfacesInterfaces One Interface vs Multiple Interfaces
CommunicationCommunication Naming vs explicit invocation
Component TypesComponent Types Use of Process Component in CCM
EJB&CCM--42
Qualitative comparisonQualitative comparison
Life Time Policy:Life Time Policy: Container Managed vs Several Policies
PersistencePersistence Serialization vs PSS
Events Events Message Beans vs Sinks and Sources of events
Interoperability Interoperability Java based vs Full Interoperability.
EJB&CCM--43
Quantitative AnalysisQuantitative Analysis
The Shopping Cart Application developed in The Shopping Cart Application developed in implementations of EJB and CCM.implementations of EJB and CCM.
EJB&CCM--44
Choice of ImplementationsChoice of Implementations
EJB container: EJB container: JBoss, an Open Source full implementation of
the EJB 2.0 standard.
CCM container:CCM container: MICO-CCM, an Open Source partial
implementation of the CCM standard based on C++.
Supports IDL 3.0 and deployment, but not CIDL or Entity Component
EJB&CCM--47
CCM IDL FileCCM IDL File
#include <mico/CCM.idl>#include <mico/CCM.idl>#include "checkout.idl"#include "checkout.idl" interface ShoppingCartIntf {interface ShoppingCartIntf { void setCust (in Customer cust);void setCust (in Customer cust); void addItem (in CartItem item);void addItem (in CartItem item); double buyContents ();double buyContents ();};}; component ShoppingCart supports ShoppingCartIntf{component ShoppingCart supports ShoppingCartIntf{ uses CheckOutIntf Check;uses CheckOutIntf Check;};}; home ShoppingHome manages ShoppingCart {home ShoppingHome manages ShoppingCart { factory new (in Customer id);factory new (in Customer id);};}; local interface MyShoppingCart :local interface MyShoppingCart :CCM_ShoppingCart, Components::SessionComponent {CCM_ShoppingCart, Components::SessionComponent {};};
EJB&CCM--48
EJB IDL equivalent EJB IDL equivalent
Cart.javaCart.javajava.util.*;java.util.*;import javax.ejb.EJBObject;import javax.ejb.EJBObject;import java.rmi.RemoteException;import java.rmi.RemoteException; public interface Cart extends EJBObject {public interface Cart extends EJBObject { public void setCustomer(Customer customer) throws public void setCustomer(Customer customer) throws
RemoteException;RemoteException; public void addItem(int itemid) throws RemoteException;public void addItem(int itemid) throws RemoteException; public double buyContents() throws RemoteException;public double buyContents() throws RemoteException;}} jboss.xmljboss.xml<jboss><jboss> <enterprise-beans><enterprise-beans> <session><session> <ejb-name>CartEJB</ejb-name><ejb-name>CartEJB</ejb-name> <jndi-name>cart/Cart</jndi-name><jndi-name>cart/Cart</jndi-name> </session></session>......<jboss><jboss>
EJB&CCM--49
Implementation of CCM ComponentImplementation of CCM Component
CORBA::Double buyContents ()CORBA::Double buyContents () {{ CartItemList_var items = new CartItemList_var items = new
CartItemList(_items.size());CartItemList(_items.size()); CheckOutIntf_var co =CheckOutIntf_var co = _ctx->get_connection_Check();_ctx->get_connection_Check(); /* We create the itemlist *//* We create the itemlist */ items->length(_items.size());items->length(_items.size()); for (int i=0; i < _items.size(); i++)for (int i=0; i < _items.size(); i++) items[i] = _items[i];items[i] = _items[i]; return co->buy(_cust, items);return co->buy(_cust, items); }}
EJB&CCM--50
Implementation of EJB BeanImplementation of EJB Bean
public double buyContents() {public double buyContents() { double bill = 0;double bill = 0; try {try { Object ref = Object ref =
jndiContext.lookup("checkout/Checkout");jndiContext.lookup("checkout/Checkout"); CheckoutHome home = (CheckoutHome)CheckoutHome home = (CheckoutHome) PortableRemoteObject.narrow(ref, PortableRemoteObject.narrow(ref,
CheckoutHome.class);CheckoutHome.class);
Checkout check = home.create();Checkout check = home.create(); bill = check.buy(customer.getId(),items);bill = check.buy(customer.getId(),items); } catch (Exception ex) {} catch (Exception ex) { System.err.println("Caught an unexpected System.err.println("Caught an unexpected
exception!");exception!"); ex.printStackTrace();ex.printStackTrace(); }} return bill;return bill;}}
EJB&CCM--51
Home in CCMHome in CCM
class MyShoppingCartHome_impl : virtual public class MyShoppingCartHome_impl : virtual public CCM_ShoppingHome {CCM_ShoppingHome {
public:public: Components::EnterpriseComponent_ptr create()Components::EnterpriseComponent_ptr create() {{ return new MyShoppingCart_impl;return new MyShoppingCart_impl; }}};}; extern "C" {extern "C" { Components::HomeExecutorBase_ptrComponents::HomeExecutorBase_ptr create_ShoppingHome (CORBA::ORB_ptr orb)create_ShoppingHome (CORBA::ORB_ptr orb) {{ return new MyShoppingCartHome_impl;return new MyShoppingCartHome_impl; }}}}
EJB&CCM--52
Home in EJBHome in EJB
import java.io.Serializable;import java.io.Serializable;import java.rmi.RemoteException;import java.rmi.RemoteException;import javax.ejb.CreateException;import javax.ejb.CreateException;import javax.ejb.EJBHome;import javax.ejb.EJBHome; public interface CartHome extends EJBHome {public interface CartHome extends EJBHome { Cart create() throws RemoteException, Cart create() throws RemoteException,
CreateException;CreateException;}}
EJB&CCM--53
Client in CCMClient in CCM
CORBA::ORB_var orb;CORBA::ORB_var orb; orb = CORBA::ORB_init (argc, argv);orb = CORBA::ORB_init (argc, argv); CORBA::Object_var obj = orb-CORBA::Object_var obj = orb-
>resolve_initial_references ("NameService");>resolve_initial_references ("NameService"); CosNaming::NamingContextExt_var nc =CosNaming::NamingContextExt_var nc = CosNaming::NamingContextExt::_narrow (obj);CosNaming::NamingContextExt::_narrow (obj); … … obj = nc->resolve_str ("ShoppingHome");obj = nc->resolve_str ("ShoppingHome"); ShoppingHome_var sh = ShoppingHome::_narrow ShoppingHome_var sh = ShoppingHome::_narrow
(obj);(obj);… … ShoppingCart_var sc = sh->create ();ShoppingCart_var sc = sh->create (); sc->setCust(cust->getId());sc->setCust(cust->getId());sc->connect_Check(ch);sc->connect_Check(ch); sc->configuration_complete();sc->configuration_complete();……sc->addItem (item);sc->addItem (item);
EJB&CCM--54
Client in EJBClient in EJB
InitialContext jndiContext = new InitialContext();InitialContext jndiContext = new InitialContext(); Object ref = jndiContext.lookup("cart/Cart");Object ref = jndiContext.lookup("cart/Cart");CartHome home = (CartHome) CartHome home = (CartHome)
PortableRemoteObject.narrow(ref,CartHome.class);PortableRemoteObject.narrow(ref,CartHome.class);Cart shoppingCart = home.create();Cart shoppingCart = home.create();……Customer cust = custhome.create();Customer cust = custhome.create();shoppingCart.setCustomer(cust);shoppingCart.setCustomer(cust); ……shoppingCart.addItem(item);shoppingCart.addItem(item);
EJB&CCM--55
Line Count of Both ApplicationsLine 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
Total
257 307
EJB&CCM--56
Performance Test EnvironmentPerformance Test Environment
CPU:CPU: TI UltraSparc Iii
Total Memory:Total Memory: 60536 kB
Operating SystemOperating System Debian GNU/Linux 3.0, kernel 2.4.18.
Java Virtual MachineJava Virtual Machine 1.4.1 Blackdown
JBoss: 3.0.4JBoss: 3.0.4 MICO-CCM: 2.3.7MICO-CCM: 2.3.7
EJB&CCM--57
Test SetTest Set
First Test: First Test: In the first test set we simulate the situation of a client, In the first test set we simulate the situation of a client,
which buys a specific amount of items, without a which buys a specific amount of items, without a delay between two consecutive buys of articles. delay between two consecutive buys of articles. We increment the number of items from 10 to 200 We increment the number of items from 10 to 200 using steps of 10.using steps of 10.
Second Test: Second Test: In this test we decided to fix the amount of articles In this test we decided to fix the amount of articles
that the client buys (10 items), and the amount of that the client buys (10 items), and the amount of time they wait after they buy each item (1 second). time they wait after they buy each item (1 second).
EJB&CCM--58
Results for Test 1, CCM ApplicationResults for Test 1, CCM Application
Results of test 1 for CCM Application
0.00
0.10
0.20
0.30
0.40
0.50
0.60
0.70
0 50 100 150 200 250
Number of Items
Tim
e (s
eco
nd
s)
EJB&CCM--59
Results for Test 1Results for Test 1
Results of test 1
0.002.00
4.006.008.00
10.0012.0014.00
16.0018.00
0 50 100 150 200 250
Number of Items
Tim
e (s
eco
nd
s)
CCM
EJB
EJB&CCM--60
Results for Test 2, CCM applicationResults for Test 2, CCM application
Results of Test Set 2 for CCM
024
681012
141618
0 50 100 150 200 250
Number of clients
Tim
e (s
eco
nd
s)
CCM