cs486: tutorial on soc, osgi, and...
TRANSCRIPT
![Page 1: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/1.jpg)
CS486: Tutorial on SOC, OSGi, and Knopflerfish
Ryan Babbitt ([email protected])
(props to Dr. Hen-I Yang, CS415X)
Feb. 3, 2011
![Page 2: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/2.jpg)
Basic Concepts
• Service-oriented computing (SOC)
• Service-oriented architectures (SOA)
– OSGi and Web Services
• Knopflerfish – OSGi implementation in SHL
![Page 3: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/3.jpg)
Services in the Real World
• Specialization is a defining characteristic of modern society– Narrow breadth and high depth of knowledge/skills – Higher quality at lower cost with better availability
• Services in the real world are– Interchangeable (functionally - individual
goods/providers don’t matter)– Contract-driven (well-known interaction points)– Mechanism independent (black box principle)
• Examples:– Banking, healthcare, restaurants, etc.
![Page 4: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/4.jpg)
Service-Oriented Computing• Service-oriented computing (SOC) applies specialization
and design by contract to design complex software systems– Handles heterogeneous components (interoperability)– Simpler design, reuse, and faster development time
(composition)– Improved fault tolerance and adaptation (interchangeability)
• A software service is an artifact that performs some meaningful function for its client– Well-defined interface (set of methods)– Meta-data to describe the service (set of properties)– Implementation is hidden from clients
• What are some example software services and service-based systems?
![Page 5: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/5.jpg)
Canonical Exercise: ATM Service
• Interface (= methods)?
• Meta-data (= properties)?
• Possible applications?
![Page 6: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/6.jpg)
Service-Oriented Architectures
• SOA is a framework and environment for managing and connecting services– Platform independent API– Execution environment for providers and clients
• Service registry - stores service descriptions and binding information (e.g. phone book)– Providers publish services and descriptions (e.g.
name, interface, endpoint, protocol, etc.)– Clients query for services, filter meta-data, and obtain
binding information for desired services– Execution/invocation not included
![Page 7: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/7.jpg)
SOA Components
12
3
![Page 8: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/8.jpg)
SOA Specifications: OSGi and WS
• OGSi - The Open Service Gateway initiative
– Java-based, centralized SOA standard
– Targets dynamic, collaborative, reactive environments
• WS – Web Services
– XML/HTTP based, decentralized SOA standard
– Composed of three standards: WSDL, SOAP, and UDDI
– Targets business activities and workflows
![Page 9: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/9.jpg)
OSGi Layers
Class loading policies and dependency resolution
Runtime bundle management
Publish, query, etc. service events
Bundle, package, user permissions
![Page 10: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/10.jpg)
Unpacking an OSGi Bundle
Bundle
Activator
Service Implementation
ManifestComponent ResourcesService
Interface
![Page 11: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/11.jpg)
Example Service Interface and Metadata
package edu.iastate.cs.sh.atm;
public interface ATM {
int deposit(int account, int amount);
int withdraw(int account, int amount);
int checkBalance(int account)
}
/* Example property values
-----------------
<“Banks”, “WellsFargo, United Bank of Ryan”>
<“CurrencyType”, “USD”>
<“SOAP.service.name”, “ATM”>
<“SOAP.service.methods” “deposit, withdraw, checkBalance”>
*/
![Page 12: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/12.jpg)
Example Manifest File/* Bundle information
Bundle-Name: ATM /* Human readable */
Bundle-SymbolicName: edu.iastate.cs.sh.atm /*machine-
readable*/
Bundle-Description: service for depositing, withdrawing, and
querying from a bank account
Bundle-Version: 1.0.0
/*Package dependencies */
Import-Packages: …
Export-Packages: edu.iastate.cs.sh.atm
/* Bundle resources */
Bundle-Activator: edu.iastate.edu.sh.ATMActivator
Bundle-Classpath: /* resources inside the bundle */
/* Others ... */
![Page 13: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/13.jpg)
Example Activatorpackage edu.iastate.cs.sh.atm;
public ATMActivator implements BundleActivator {
private ATM atm = null;
private Dictionary props = null;
private ServiceRegistration reg = null;
public void start(BundleContext bc){
atm = new ATM(“ISU Savings”);
props = new Dictionary();
props.add(“BankName”, “ISU Savings”);
props.add(“Currency”, “USD”);
reg = bc.registerService(ATM.class.getName, atm, props);
…
}
public void stop(BundleContext bc){
reg.unregister();
}
}
![Page 14: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/14.jpg)
Lifecycle of an OSGi Bundle
Load
Unload
Unload
Activator
![Page 15: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/15.jpg)
Lifecycle of an OSGi Service
REGISTERED MODIFIED
UNREGISTERING
RegisterModify
Unregister
Activator
![Page 16: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/16.jpg)
Deploying a Bundle: CheapMovies
Registry
?
Event: BUNDLE INSTALLED!
?
BUNDLE RESOLVED!
ATM
ATM
Theater
![Page 17: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/17.jpg)
Activating the Bundle
Registry
Event: BUNDLE STARTING!
getServiceReference(…)
ServiceReference
BUNDLE STARTED!
getService (…)
Service Object
registerService(…)
SERVICE REGISTERED!
“filter”
ATM
ATM
TheaterCheapMovies
![Page 18: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/18.jpg)
Deactivating a Bundle
Registry
Event: BUNDLE STOPPING!
ungetService()
BUNDLE STOPPED!
unregister (…)
SERVICE UNREGISTERING!
ungetService()
ATM
ATM
TheaterCheapMovies
![Page 19: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/19.jpg)
Review: Important Tasks
• Service providers– Define service interface and metadata– Develop an implementation (hidden)– Register a service object with the OSGi framework – Update a service’s properties– Unregister a service with the OSGi framework
• Service consumers– Query the service registry– Examine a service’s properties – Bind to the service object– Invoke the service methods– Release the service
![Page 20: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/20.jpg)
What is Knopflerfish?
• Open source implementation of the OSGi standard– Apache Felix, (Android),
– Equinox (Eclipse)
• Desktop application for graphical monitoring and controlling bundles
• Eclipse plug-in for facilitated development– Generate/edit manifest files, compile source,
– Automatically build and package jar files
![Page 21: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/21.jpg)
The Knopflerfish Desktop
![Page 22: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/22.jpg)
Knopflerfish Desktop Walkthrough
• Starting the framework…
• Monitor bundles/services …
• Examining the manifest file…
• Controlling bundles …
• Refreshing the framework…
• Exiting the framework…
![Page 23: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/23.jpg)
Questions?
• SOC/SOA – www.google.com
• OSGi – www.osgi.org
• Knopflerfish – www.knopflerfish.org
![Page 24: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/24.jpg)
Current Applications
• Current applications
– Home automation
– Health management
– Home security
– ADL support
• Possible extensions?
![Page 25: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/25.jpg)
Possible New Applications
• Generic voice interface
• Prescription conformance monitor
• Exercise monitor
• Universal WebRemote
• EnergySaver
![Page 26: CS486: Tutorial on SOC, OSGi, and Knopflerfishweb.cs.iastate.edu/~cs486/notes/OSGi-tutorial-486-S11.pdfCS486: Tutorial on SOC, OSGi, and Knopflerfish Ryan Babbitt (rbabbitt@iastate.edu)](https://reader033.vdocuments.mx/reader033/viewer/2022042023/5e7b9edef600916f376b7148/html5/thumbnails/26.jpg)
Existing Services (Javadocs soon!)
• Device services– Temperature, humidity, pressure, light level, motion– Touch sensor, pressure sensor, dial, microphone, speakers, barcode,
RFID, network camera, LCD, [biomedical!]– Lamp and appliance control, remote control, [door opener!]– Fridge, microwave, blinds
• Data services– Food, medication, health conditions, medical conflicts, user profile
• Utility services– Speech, notification, [timer, calendar, logging]
• Monitoring services– Diet, inventory, shopping list, expiration date, [prescription, physical
activity,]