Com S/Geron 415X Gerontechnology in Smart Home Environments Lecture 9 Intro to Service Computing Dr. Hen-I Yang ComS Dept., ISU Feb. 22, 2011
Reflection
Peeking Ahead Today (2/22) Introduction to Service Computing Thursday (2/24) Introduction to Design Next Tuesday (3/1) Midterm Next Thursday (3/3) OSGi Service Programming Workshop Smart Home Lab
Midterm Next Tuesday (March 1, 2011) in class 80 minutes Reviews materials covered until today s lecture You can bring One page single-sided hand-written lettersize crib sheet
Midterm Review Aging Optimal, Normal and Pathological Aging ADL and IADL Field trip experience Assistive Technology Various functional impairments associated with aging Seven assistive functions Examples of assistive technology/device/service Theories of Assistive Technology Adoption Person-Environment (P-E) Fit Congruence Theory Adoption Lags Introduction to Service Computing
Service Oriented Architecture (SOA) A group of services which communicate with each other. The process of communication involves either simple data passing or it could involve two or more services coordinating some activities. Some means of connecting services to each other is needed. www.webit.com.my/www/lang/en/show.do?page=154&articleid=3137
Service Computing Specialization is one of the defining characterization of modern society People don t do everything by themselves anymore Better quality, lower cost, higher availability Services are based on contract Services are interchangeable Services can be composed Feel Sick Go to the hospital Check-in Initial Evaluation X-ray and chem panel Diagnosis Get Prescription Render payment Fill Prescription Go home and bed rest Patient EMT EMT1, EMT2, Receptionist Amy, Joe, Jane, Doctor Lab Scientist Doctor Doctor Cashier Pharmacist Mom
Planning A Trip Book a flight. Airline Reserve a hotel room. Hotel Reserve a rental car. Rental car company Reserve tickets to events of interest. Box office Get foreign currency. Bank
Planning A Trip Talk to a Travel Agent (or Concierge Service) Book a flight Reserve a hotel room Reserve a rental car Reserve tickets to events of interest Get foreign currency
Illustration of a Service Reserve a flight Query flight status Cancel a flight Airline Service Service Area: U.S. Domestic Hub: Des Moines, IA Planes: Jets
Illustration of a Composite Service Travel Agent Service Airline Service Foreign Currency Exchange Service Hotel Service Car Rental Service Box Office Service
Service Every function is implemented as a service Often a single service provides a single action Interfaces are provided to let other services know how to utilize them Metadata Contains characteristics Describes data that drives the service Can be used to compose dynamically by discovery and incorporation of defined services, to maintain coherence and integrity Allow system designers to understand and manage with a reasonable expenditure of cost and effort XML is frequently used as description container
Services Interface Define the type of services offered Define the inputs and outputs Implementation Often is kept secret as a black box Meta-data Describe any information that s relevant to the service, can be Human readable Machine readable Attributes and Emergent Properties (sometimes described in the meta-data)
Example of a Service: Thermometer Interface: read return temperature Implementation: mercury, bi-metallic, spring Meta-data: return readings in Fahrenheit, located in Smart Home Lab owned by Bob
Exercise: ATM Interface: Withdraw return bills or error message query return balance of the account Implementation Known only to the Manufacturer of the ATM Meta-data Name of the bank Serial number Which currency is available
Example of a Service: Chef Interface: order, cash return dishes Implementation: Trainings at professional culinary schools Collection of family recipes Personal culinary artistic talents Hard-earned experience from years of torturing family and neighbors Meta-data: name location Expertise/style of food
Service Composition If the weather gets too hot (temperature is higher than 95 ), I am going to get some cash and buy myself a banana splits from that fancy restaurant Query 96 Withdraw(20) $$$ Order(banana splits) dish
Service Oriented Architecture Revisit Loosely-integrated suite of services that can be used within multiple business domains. Services communicate with each other and coordinate some activities to provide certain service. Provide means of searching and connecting services to each other. Platform (OS, programming language, medium) independent Encapsulation: services not originally designed for SOA can be wrapped and consolidated to appear as a service Abstraction: internal logic is hidden from the users other than those specified in the contract
Advantages of SOA Reuse Lower cost Better quality Faster development Flexibility Adaptive Tolerance to failures Composability Obfuscation Don t care about how it is done, as long as it is done Compartimization Outsourced and Specialization Reduce local resource requirement Less maintenance overhead
Case Study: OSGi Platform A dynamic module system for Java. It provides the standardized primitives that allow applications to be constructed from small, reusable and collaborative components. Components can be composed into an application and deployed. Allow changing of the composition dynamically on the device of a variety of networks, without requiring restarts. A service-oriented architecture that decouples components, and enables these components to dynamically discover each other for collaboration. Many standard component interfaces for common functions like HTTP servers, configuration, logging, security, user administration, XML and many more are available and well-tested. http://www.osgi.org/osgi_technology/index.asp?section=2
OSGi Platform http://www.osgi.org/osgi_technology/index.asp?section=2
OSGi Bundle Life Cycle Management Activator
OSGi Bundles Bundles: Basic components in OSGi environment Standard Bundle Composition: Manifest Code Interface class Defines the visible external behavior of the bundle Methods that will be exposed to other bundles, and allow other bundles to invoke Activator class Life cycle management Gets invoked first when an bundle becomes active Handles details such as a) The starting condition b) The cleanup actions c) The plan of action when other bundles joins or leaves d) bind the local variables to instances of the bundles that would be used later Implementation class The real deal: the actual implementation of the functionalities/methods specified in the interface class Actual usage of the variables specified and bound in the activator class Where the real application logic is
OSGi Manifest (Meta Data) Bundle-Name: Bundle-SymbolicName: Bundle-Description: Bundle-ManifestVersion: 1 ATM Bundle-Version: 1.0.0 Bundle-Activator: Export-Package: Import-Package: edu.isu.atm An ATM bundle edu.isu.atm.activator edu.isu.atm;version="1.0.0" edu.isu.dispenser;version="1.3.0 ; edu.isu.db;version="1.3.0"
OSGi Bundles Interface public interface ATMService { public int withdraw(int account, int public int query(int account); } amount);
OSGi Bundles Activator public class ATMActivator { } private ATMImpl service = null; public void start(bundlecontext context) throws Exception { } service = new DemoImpl(context, this); new Thread(service).start(); public void stop(bundlecontext context) throws Exception { } service.shutdown(); public void serviceaddition(serviceevent event) { } public void servicemodification(serviceevent event) { } public void serviceremove(serviceevent event) { }
OSGi Bundles Implementation public class ATMImpl implements ATMService { protected Dispenser out; protected AccountDatabase db; protected boolean running; } public void processwithdrawrequest(int account, int amount) { accountinfo = db.retrieveaccountinfo(account); if (accountinfo == null) { error( Invalid account info); } else { if (accountinfo.balance > amount) { out.dispense(amount/20); } } }