Presentation is loading. Please wait.

Presentation is loading. Please wait.

OSGi Service Platform Open Service Gateway initiative.

Similar presentations


Presentation on theme: "OSGi Service Platform Open Service Gateway initiative."— Presentation transcript:

1 OSGi Service Platform Open Service Gateway initiative

2 Core Product RBCRBC CI B C IN G SYMCO R KINKOS...

3 Core Product 2.0 Core Product V 1.2 Core Product v1.0 RBCRBC CI B C IN G SYMCO R KINKOS...

4 Topics to cover ● Introduction ● Programming Model  Fundamentals  Collaboration ● Eclipse Equinox ● Market Interests

5 What is OSGi? ● A specification of a component based service oriented platform ● A Java Framework for developing Service Applications that requires:  Reliability  Large scale distribution  Wide range of devices  Collaborative development ● Created by collaboration of industry leaders (OSGi Alliance).

6 Industry Driven ● Home automation vendors (2000 - 2002) ● Automotive Infotainment and Telematics vendors (2002 - 2004) ● Mobile device vendors (2004 - now) ● Many other vertical markets (now)

7

8 Ever wonder... Eclipse IDE Quantum Plugin Mylar Plugin Commons Collections 2.1.1 Commons Collections 3.2 ?

9 Original Motivations ● Binary software portability  Low reusability of software components ● Software engineering is HARD  Software is complex  Collaboration helps ● Deployment is error prone  Deployment scripts are often too complicated and unreliable  Too much drama!!!

10 Fundamentals

11 Layering Services Life-cycle Module (bundle) Execution Environment Application s Securit y

12 Bundle

13 DictionaryService.jar (Bundle) src META-INF lib *.class *.dll, *.so, etc... *.jar MANIFEST.MF *.java

14 Bundles ● Packaging of Java library/service/application for deployment ( a jar file ) ● Registers zero or more services ● Services (Java interfaces) may be implemented by multiple bundles ● Search for services registered via a (LDAP-based query language. ● Fragment bundles are like attachments to a bundle-host. ● Manifest contains important information about its bundle.

15 Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: DictonaryService Plug-in Bundle-SymbolicName: DictonaryService Bundle-Version: 1.0.0 Bundle-Activator: ca.intelliware.osgi.bundle.dictionary.Activator Bundle-Localization: plugin Import-Package: org.osgi.framework;version="1.3.0" Export-Package: ca.intelliware.osgi.bundle.dictionary.service Bundle-RequiredExecutionEnvironment: CDC-1.0/Foundation-1.0, OSGi/Minimum-1.1 MANIFEST.MF Sample

16 package ca.intelliware.osgi.bundle.dictionary; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext;... import ca.intelliware.osgi.bundle.dictionary.service.DictionaryService; public class Activator implements BundleActivator { public void start(BundleContext context) throws Exception { Properties properties = new Properties(); properties.put("Language", "English"); context.registerService(DictionaryService.class.getName(), new DictionaryServiceImpl(), properties); } public void stop(BundleContext context) throws Exception { } >

17 Registering a Service package ca.intelliware.osgi.bundle.dictionary; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration;... import ca.intelliware.osgi.bundle.dictionary.service.DictionaryService; public class Activator implements BundleActivator { public void start(BundleContext context) throws Exception { Properties properties = new Properties(); properties.put("Language", "English"); ServiceRegistration registration = context.registerService(DictionaryService.class.getName(), new DictionaryServiceImpl(), properties); } public void stop(BundleContext context) throws Exception { }

18 Locating and using a Service public class ClientActivator implements BundleActivator { public void start(BundleContext context) throws Exception { ServiceReference[] serviceReferences = context.getServiceReferences(DictionaryService.class.getName(), "(Language=*)");... ServiceReference firstServiceReference = serviceReferences[0]; DictionaryService service = (DictionaryService)context.getService(firstServiceReference); if (service.checkWord(word)) { System.out.println(word + " was correct."); } else { System.out.println(word + " was incorrect."); } context.ungetService(firstServiceReference); }...

19 Listening to ServiceEvent public class ServiceListenerActivator implements BundleActivator, ServiceListener { public void start(BundleContext context) throws Exception { context.addServiceListener(this); } public void stop(BundleContext context) throws Exception { context.removeServiceListener(this); } public void serviceChanged(ServiceEvent event) { int eventType = event.getType(); String serviceName = ((String[])event.getServiceReference().getProperty("objectClass"))[0]; switch (eventType) { case ServiceEvent.MODIFIED: System.out.println("service: " + serviceName + "has been modified."); case ServiceEvent.REGISTERED: System.out.println("service: " + serviceName + "has been registered."); case ServiceEvent.UNREGISTERING: System.out.println("service: " + serviceName + "has been unregistered."); default: break; }

20 Service Layer ● SOA Service Oriented Architecture Clarification:  OSGi Services != Web Services  OSGi Services are in-VM services ● Service Model  Services are POJO's in a bundle  Its interface is exported and registered in a Service Registry.  Discover and gets notified about services based on their interfaces and properties  Different bundles can register different implementations of the same interface. ● The OSGi Alliance provides many standardized services  Device Manager, Declarative Services, Event Admin, HTTP Service, Log Service, Metatype Service, Preferences Service, User Admin, Wire Admin, etc... Life- cycle Servic e Executi on module

21 Demo

22 Life Cycle Layer ● Controlled by the System Bundle ● Provides an API for managing bundles  Install  Resolve  Start  Stop  Refresh  Update  Uninstall Module Life- cycle Servic e Executi on

23 Life of a Bundle Installed Uninstalled Resolved Stopping Starting Active Bu ndl e ● Bundle started by an object of BundleActivator Type ● Manifest Header refer to this class ● BundleActivator Interface has 2 methods: start() and stop() ● BundleActivator gets a BundleContext provides access to the framework ● Framework provides Start Level Service to control start/stop of groups of applications

24 Traditional Class loading User-Defined ClassLoader User-Defined ClassLoader System ClassLoader Extension ClassLoader Single Parent Delegation Model Bootstrap ClassLoader classpath jre/ext java.lang.*

25 Class loading OSGi Style Delegation Model Bundle ClassLoader Bundle ClassLoader Bundle ClassLoader Bundle ClassLoader Parent System ClassLoader System Bundle ClassLoader importerExporter Bundle Space Boot Classpath (java.lang.*) Framework Classpath

26 Module Layer ● Applications and libraries are packaged in bundles (jar file) ● A classloader is assigned to each bundle for loading its classes and resources. ● Modularized Classloading  Traditional Single Parent Delegation Classloading model is inflexible ● Versioning  Raw Java cannot handle multiple versions of the same package Life cycle Module Servic e Executi on

27 Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: DictonaryService Plug-in Bundle-SymbolicName: DictonaryService Bundle-Version: 1.0.0 Bundle-Activator: ca.intelliware.osgi.bundle.dictionary.Activator Bundle-Localization: plugin Import-Package: org.osgi.framework;version="1.3.0" Export-Package: ca.intelliware.osgi.bundle.dictionary.service Bundle-RequiredExecutionEnvironment: CDC-1.0/Foundation-1.0, OSGi/Minimum-1.1 MANIFEST.MF Sample

28 Execution Environments ● CDC-1.0/Foundation-1.0  Equals to J2ME Foundation Profile ● OSGi/Minimum-1.1  OSGi EE that is a minimal set that allows the implementation of an OSGi Framework. ● JRE-1.1, J2SE-1.2, J2SE-1.3, J2SE-1.4 ● PersonalJava-1.1, PersonalJava-1.2 ● CDC-1.0/PersonalBasis-1.0  J2ME Personal Basis Profile ● CDC-1.0/PersonalJava-1.0  J2ME Personal Java Profile Life- cycle Executi on Servic e Module

29 Programming Model

30 Object Oriented Model ● One of the challenges is managing dependencies, if we are not careful our objects can get quite tangled.

31 Object Oriented Model ● Coupling severely limits reuse.  Using a generic object can drag in a large number of other objects. ● Flexibility must be built by programmer  Plugin architectures

32 Service Oriented Architecture ● Separation of interface and implementation ● Allows swapping in alternative implementation ● Dynamically discover and bind object implementations ● Components are not coupled with implementation Client Component Implementation Component Service Contract...

33 Framework ● Allows applications to share a single JVM ● Dynamic classloading  Dependencies are “wired” at runtime  Compares to static classpaths ● Declarative Security  Java Security Model ● Declarative bundle dependency  Coordinated via manifest headers ● Independent life-cycle management of applications and services on a single JVM instance.

34 Framework and Bundles ● The framework at bundle installation time:  Security check the bundle  Reads the bundle's manifest  Installs code and resources  Resolve dependencies ● The framework at bundle runtime:  Calls the bundle's Activator to start the bundle  Manages classpath  Handles service dependencies  Calls the bundle's Activator to stop the bundle

35 Layering – Bigger Picture Courtesy of Michael Grammling

36 Collaborate or else...

37 Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: DictonaryService Plug-in Bundle-SymbolicName: DictonaryService Bundle-Version: 1.0.0 Bundle-Activator: ca.intelliware.osgi.bundle.dictionary.Activator Bundle-Localization: plugin Import-Package: org.osgi.framework;version="1.3.0" Export-Package: ca.intelliware.osgi.bundle.dictionary.service Bundle-RequiredExecutionEnvironment: CDC-1.0/Foundation-1.0, OSGi/Minimum-1.1 MANIFEST.MF Sample

38 Component Interaction ● Bundles collaborate through:  Service objects  Package sharing ● Bundle Registry allows bundles to find and track service objects ● Framework manages the collaboration

39 Dependencies ● OSGi framework is a network of class loaders (one class loader per bundle). ● Complicated dependencies are “resolved” by the framework behind the scene. CommonsCollections Xerces JavaMail CommonsCollections-1.0 Xerces Commons Collections CommonsCollections-2.0 version=1.0 version=2.0 Bundle Exported package imported package Wire Constraint

40 Equinox

41 What is Equinox ● Eclipse Project  Complete implementation of OSGi R4 ● Provides the base for Eclipse plug-in Architecture  Since Eclipse 3.0 ● Eclipse 3.2 provides additional services  Device Manager, HTTP Service, Log Service, Preferences Service,... ● Eclipse Plug-in Development Environment (PDE) provides a environment for developing OSGi bundles.

42 Other OSGi implementations ● ProSyst ● Knopflerfish ● Gatespace Telematics – KnopflerfishPro ● Eclipse - Equinox ● Objectweb - Oscar ● Apache - Felix ● Concierge ● Oxygen ● osxa

43 Bundle Repositories ● OSGi Alliance  http://bundles.osgi.org/Main/Repository http://bundles.osgi.org/Main/Repository ● Oscar OBR  http://oscar-osgi.sourceforge.net http://oscar-osgi.sourceforge.net ● Knopflerfish bundle repository  http://www.knopflerfish.org/repo/index.html http://www.knopflerfish.org/repo/index.html

44 Market Interests

45 OSGi + ● OSGi + BMW = iDrive (In-car Infotainment system) ● OSGi + Siemens VDO = RIO (In-car Infotainment system) ● OSGi + Websphere = Websphere Application Server (WAS) 6.1 ● OSGi + JOnAS = JOnAS5 ● OSGi + Spring = ?... A much more comprehensive list of Markets and Solutions can be found at http://osgi.org/markets

46 My thoughts on OSGi ● Evolved WAY beyond the embedded markets ● Version management ● Encourages decoupling and collaboration ● Encourages reuse ● Think Product not Project ● Important role technologies

47 OSGi + Portugese Chicken = Lunch & Learn

48 FIN

49 Questions?


Download ppt "OSGi Service Platform Open Service Gateway initiative."

Similar presentations


Ads by Google