comparing javabeans and osgi towards an integration of two complementary component models humberto...

37
Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Upload: delilah-lawrence

Post on 01-Jan-2016

214 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Comparing JavaBeans and OSGi

Towards an Integration of Two Complementary Component Models

HUMBERTO CERVANTESJEAN-MARIE FAVRE 09/02

Page 2: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Who I Am

Humberto Cervantes3d year PhD at Adèle team, LSR, Grenoble

www-adele.imag.fr

Collaborators: Jean-Marie Favre : PhD supervisorJacky Estublier : Team directorRichard S. Hall : Visitor

Work area: Applying Component-Based Technologies to build Software Environments

Page 3: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Comparing OSGi and JavaBeans

Two component technologies:JavaBeans: visual assembly of applicationsOpen Services Gateway Initiative (OSGi): service deployment in home gateways.

Richard S. Hall, implementor of OSCAR

How do these two technologies support a set features that characterize component models?Since some aspects are complementary, how can they be integrated?

Page 4: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Points of Comparison

Components :Have a clear and explicit boundary

Well specified interface and explicit dependencies

Can be customizedCan be assembledAre reusableAre units of substitutionAre units of delivery and deploymentHave certified properties*

Component FrameworkRuntime services to support the model

Page 5: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

JAVABEANS

Page 6: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

JavaBeans

Sun’s technology oriented towards visual assembly of applications

Introduced in 1996Client-sideRelatively simple compared to EJB

Page 7: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

JavaBeans in a Builder Tool

Bean Palette

Assembly canvas Selected instanceSelected instance properties

Running application

Page 8: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

What is a JavaBean ?

JavaBean: Standard Java class that follows certain naming conventions

Express properties, receptacles, events.

JAR: Package file for JavaBeans Along with an optional class that provides information, the BeanInfo class

Difference between design-time and run-time

Page 9: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Life-cycle

Serialized beans become prototypes Instantiation occurs either inside builder tools or in ‘real’ applications.

Compilation

Packaging

Instantiation Customization

Serialization Storage of assembly

.class .ser

.jar

.xml.java

Manifest.mf

Page 10: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Boundary and Dependencies

Interface is well defined

DependenciesWith respect to the runtime and imported packages: not explicitTowards other beans, classes or resources: can be described if they occur in the same JAR file.

EventSource addEvtListenerEventSink

implements EvtListener

Properties getName/setName

InterfacesReceptacle

getName/setName

Page 11: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Customization

Properties are persistent attributes

Changing value of properties Build-time activityCalls to setter methodsCan be done at the component or instance level

Page 12: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Assembly

Assembly: graph of inter-connected instances.

References are transient

An assembly cannot directly become itself a Bean.

Storage and retrieval of graphs is available.

XML Encoder / Decoder

Page 13: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Reusability and Substitution

JavaBeans promote reuseHowever, all the dependencies of the Bean must be known.

A JavaBean can be substituted by another if it provides the exact same interfaces.

Page 14: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Delivery and Deployment

JAR file is the unit of delivery and deployment for JavaBeans.

A manifest file inside the JAR provides simple information about the JavaBeans it contains

There is no component registry, Beans are loaded from the classpath

Only one version can be available

Page 15: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

OSGI

Page 16: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

OSGi

Open Services Gateway InitiativeFounded in 1999 (more than 70 companies)Goal is to define a set of Java APIs that specify a services gateway architecture .

OSGi specification:1st rel: May 2000, 2d rel: October 2001A service platform that includes:

A minimal component-like modelA lightweight framework to manage the components.

Source: www.osgi.org

Page 17: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Global View

Source: java.sun.com

Services Gateway

Bundles

FrameworkJVM

Registry

Services

Services Gateway

OSGi Framework :

• Service registry and request facilities

• Bundle management facilities

Page 18: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Services and Bundles

Service: A Java interfaceRegistered in the framework along with an object that implements it and a set of properties of type name,value

Bundle: Delivery and deployment units (JAR file)Contains services: interfaces, implementations and resourcesManifest file contains meta-data

Page 19: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Boundary and Dependencies

Services have a clearly defined interfaceNo dependencies at service level

Bundle Bundle-to-package depencies

Code inside the bundle imports packages exported by other bundlesManaged by the framework

Bundle-to-Service dependenciesCode inside the bundle uses servicesUnmanaged but can be described

Runtime dependenciesUnmanaged but can be described

Page 20: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Customization

Services that implement a particular interface can be customized.

Through getter/setter methodsServices are shared, a change in the state affects all of the clients.

Page 21: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Assembly

No concept of assemblyApplications are dynamically created by bundles that connect to servicesA service request includes the name of the service plus a filter

(&(manufacturer=sun)(version>=1.0))

Might return several responses

Page 22: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Units of delivery and deployment

The Bundle is the unit of delivery and deployment.

JAR fileState INSTALLED

RESOLVED

STOPPING STARTING

ACTIVE

UNINSTALLED

install

uninstall

uninstall

update

start

stop

Explicit Transition

Automatic transition

INSTALLED

RESOLVED

STOPPING STARTING

ACTIVE

UNINSTALLED

install

uninstall

uninstall

update

start

stop

Explicit Transition

Automatic transition

Page 23: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Reusability and Substitution

Bundles can be reused in different frameworks

In a framework at any moment, however, only one bundle from a particular location can exist.

Substitution can occur during runtime.

Page 24: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Comparison

Page 25: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Comparison

JavaBean component vs. OSGi serviceJavaBean : can be instantiatedOSGi service : shared by multiple clients

AssembliesJavaBeans: graphs and hierarchies are supportedOSGi: No concept of assembly.

Page 26: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Comparison

FrameworkOSGi: Explicit framework to manage delivery units

ServiceRegistry

JavaBeans: Several classes provide runtime services

ClassPath

Page 27: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Comparison

Support for customizationOSGi: Services are shared.

Delivery unitsOSGi: well managed package dependenciesJavaBeans: poor dependency management

Page 28: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Conclusion

Page 29: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Conclusion

Two complementary modelsDifferent concept of ‘component’

JavaBeans OSGi

Beans + Services

JAR file Bundle +

Assembly unit

Delivery unit

Page 30: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Integration of JavaBeans and OSGi

OSGi used as an infrastructure for managing delivery units.A special factory service is registered to create instances of JavaBeansFactory patternOSGi registry becomes a component registryFactories are located with LDAP filters

Page 31: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Current Work

Beanome=JavaBeans+OSGi

A prototype:www-adele.imag.fr/BEANOME

Page 32: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02
Page 33: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02
Page 34: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Services Gateway & Framework

Gateway: embedded server that stands between ‘external’ internet and local network.

Framework : Java infrastructure contained inside the gateway that provides:

Service registry and request facilities.Bundle management facilites.

Page 35: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

Bundle lifecycle

INSTALLED

RESOLVED

STOPPING STARTING

ACTIVE

UNINSTALLED

install

uninstall

uninstall

update

start

stop

Explicit Transition

Automatic transition

Page 36: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

JavaBeans Framework

java.beans.BeansInstantiationResource loading

java.beans.IntrospectorUse beaninfo or standard reflection

java.beans.beancontext.BeanContextHierarchy of JavaBean instancesComposite patternContext can provide services

Java.beans.Encoder/DecoderStorage/retrieval of a graph of JavaBeans

Page 37: Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02

OSGi Framework

A bundle can contain an optional Activator class

Called when the bundle starts and stopsReceives a BundleContext:

Bundle ManagementService registrationService requestReception of framework events