1 / 11

Getting Started with the Open Services Gateway Initiative (OSGi) CNT 5517

Getting Started with the Open Services Gateway Initiative (OSGi) CNT 5517. Dr. Sumi Helal, Ph.D. Professor Computer & Information Science & Engineering Department University of Florida, Gainesville, FL 32611 helal@cise.ufl.edu Most of this presentation was developed by Hen-I Yang. Outline.

cbennett
Download Presentation

Getting Started with the Open Services Gateway Initiative (OSGi) CNT 5517

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Getting Started with the Open Services Gateway Initiative (OSGi)CNT 5517 Dr. Sumi Helal, Ph.D. Professor Computer & Information Science & Engineering Department University of Florida, Gainesville, FL 32611 helal@cise.ufl.edu Most of this presentation was developed by Hen-I Yang

  2. Outline • Introduction to OSGi • Introduction to the Knopflerfish reference implementation

  3. 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

  4. OSGi ™ Platform http://www.osgi.org/osgi_technology/index.asp?section=2

  5. OSGi Bundles • Bundles: Basic components in OSGi environment • Standard Bundle Composition: • Manifest • Code • Interface class • Methods that will be exposed to other bundles • Defines the visible external behavior of the bundle • Methods that would allow other bundles to invoke • Activator class • Life cycle management • The class that 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

  6. OSGi Bundles -- Interface package demo.test; import com.pervasa.atlas.dev.service.AtlasClient; public interface Demo extends AtlasClient { public void shutdown(); }

  7. OSGi Bundles -- Activator public class DemoActivator extends AtlasActivator { private DemoImpl service = null; public void start(BundleContext context) throws Exception { final String c[] = {Demo.class.getName()}; service = new DemoImpl(context, this); //Registering the Demo Service context.registerService(c, service, new Properties()); new Thread(service).start(); } public void stop(BundleContext context) throws Exception { service.shutdown(); } public void serviceChanged(ServiceEvent event) { ... } }

  8. OSGi Bundles -- Implementation public class DemoImpl extends AtlasImpl implements Demo { protected InterlinkPressureSensor ps; protected LED led; protected HS322Servo servo; protected boolean running; public void assignEntity(Object obj) { if (obj instanceof InterlinkPressureSensor) { this.ps = (InterlinkPressureSensor) obj; } else if (obj instanceof HS322Servo) { this.servo = (HS322Servo) obj; } else if (obj instanceof LED) { this.led = (LED) obj; } } public void unassignEntity(Object obj) { … } public void ReceivedData(String arg0, Properties props) { // Real Application Logic Comes Here } }

  9. OSGi Bundles – Manifest Bundle-Name: Demo Bundle-Activator: demo.test.impl.DemoActivator Device-Type: Application Import-Package: org.osgi.framework,com.pervasa.atlas.dev.service,org.sensorplatform.sensors.pressure,org.sensorplatform.actuators.servo.hs322 Bundle-Vendor: Pervasa Bundle-Author: Pervasa Bundle-SymbolicName: Demo Bundle-Category: application Bundle-Version: 1.0.0

  10. Download Knopflerfish • Knopflerfish is an open source OSGi reference implementation • The goal with the Knopflerfish project is to develop and distribute easy to use open source code, build tools and applications, related to the OSGi framework. • http://www.knopflerfish.org/download.html • Download Knopflerfish 1.3.5 • http://www.knopflerfish.org/releases/1.3.5/knopflerfish_fullbin_osgi_1.3.5.jar • Self extracting and easy installation

  11. Exercise 2: Implementing an Application Bundle • Work in groups of 2 – 3 • Download the sample Atlas Application from: http://www.cise.ufl.edu/~helal/classes/AtlasKitSampleApp.zip • It is an Eclipse project so, use the File→Import option in the Eclipse IDE. • Implement the Interface • Implement the Activator class • Implement the Implementation class • Try to compile and deploy the bundle to verify if that it actually works!

More Related