Upload
others
View
7
Download
0
Embed Size (px)
Citation preview
CS486: Tutorial on SOC, OSGi, and Knopflerfish
Ryan Babbitt ([email protected])
(props to Dr. Hen-I Yang, CS415X)
Feb. 3, 2011
Basic Concepts
• Service-oriented computing (SOC)
• Service-oriented architectures (SOA)
– OSGi and Web Services
• Knopflerfish – OSGi implementation in SHL
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.
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?
Canonical Exercise: ATM Service
• Interface (= methods)?
• Meta-data (= properties)?
• Possible applications?
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
SOA Components
12
3
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
OSGi Layers
Class loading policies and dependency resolution
Runtime bundle management
Publish, query, etc. service events
Bundle, package, user permissions
Unpacking an OSGi Bundle
Bundle
Activator
Service Implementation
ManifestComponent ResourcesService
Interface
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”>
*/
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 ... */
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();
}
}
Lifecycle of an OSGi Bundle
Load
Unload
Unload
Activator
Lifecycle of an OSGi Service
REGISTERED MODIFIED
UNREGISTERING
RegisterModify
Unregister
Activator
Deploying a Bundle: CheapMovies
Registry
?
Event: BUNDLE INSTALLED!
?
BUNDLE RESOLVED!
ATM
ATM
Theater
Activating the Bundle
Registry
Event: BUNDLE STARTING!
getServiceReference(…)
ServiceReference
BUNDLE STARTED!
getService (…)
Service Object
registerService(…)
SERVICE REGISTERED!
“filter”
ATM
ATM
TheaterCheapMovies
Deactivating a Bundle
Registry
Event: BUNDLE STOPPING!
ungetService()
BUNDLE STOPPED!
unregister (…)
SERVICE UNREGISTERING!
ungetService()
ATM
ATM
TheaterCheapMovies
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
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
The Knopflerfish Desktop
Knopflerfish Desktop Walkthrough
• Starting the framework…
• Monitor bundles/services …
• Examining the manifest file…
• Controlling bundles …
• Refreshing the framework…
• Exiting the framework…
Questions?
• SOC/SOA – www.google.com
• OSGi – www.osgi.org
• Knopflerfish – www.knopflerfish.org
Current Applications
• Current applications
– Home automation
– Health management
– Home security
– ADL support
• Possible extensions?
Possible New Applications
• Generic voice interface
• Prescription conformance monitor
• Exercise monitor
• Universal WebRemote
• EnergySaver
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,]