Best Practices for Programming Eclipse and OSGi



Similar documents
Eclipse Summit Europe 2008

Building a Modular Server Platform with OSGi. Dileepa Jayakody Software Engineer SSWSO2 Inc.

Developing Eclipse Plug-ins* Learning Objectives. Any Eclipse product is composed of plug-ins

Eclipse 4 RCP application Development COURSE OUTLINE

Introduction to OSGi and Modularity. InfoSphere MDM, Version 11.x Dany Drouin, Senior Software Engineer MDM

Developing Service-Oriented Architecture Applications with OSGi

Equinox Framework: A Happier OSGi R6 Implementation

FUSE-ESB4 An open-source OSGi based platform for EAI and SOA

Duke University Program Design & Construction Course

GlassFish v3. Building an ex tensible modular Java EE application server. Jerome Dochez and Ludovic Champenois Sun Microsystems, Inc.

InfoSphere Master Data Management operational server v11.x OSGi best practices and troubleshooting guide

A Mechanism on OSGi Agent for Dynamic Monitoring Service Discovery Protocols in Local Network

Rich Client Application Development

SPRING INTERVIEW QUESTIONS

Introduction to Eclipse, Creating Eclipse plug-ins and the Overture editor. David Holst Møller Engineering College of Aarhus

The Enterprise Service Bus: Making Service-Oriented Architecture Real

Eclipse Rich Client Platform. Kai Tödter Karsten Becker et al. Organized by:

What means extensibility?

Living Architectures - from eclipse to jazz

Master Thesis. Arnold Kemoli. Design and Implementation of a Dynamic Component based Web Application Framework

Gyrex 0.10 Release Review

Converting Java EE Applications into OSGi Applications

Avoiding Web Services Chaos with WebSphere Service Registry and Repository

General Introduction to IBM (R) Rational (R) Asset Manager

Service-Oriented Software Testing Platform *

How To Develop An Open Play Context Framework For Android (For Android)

Leveraging the Eclipse TPTP* Agent Infrastructure

OSGi Service Platform Release 4

CQCON 2013: five Sling features you should know

Android Developer Fundamental 1

Apache Karaf in real life ApacheCon NA 2014

A Case Study on Software Evolution towards Service-Oriented Architecture

SUBSYSTEMS IN THE WILD

Service Oriented Architecture

Operations and Monitoring with Spring

BMC Software Inc. Technical Disclosure Publication Document Application Integration Manager (AIM) Author. Vincent J. Kowalski.

E4 development: examples, methods and tools. Eclipse Con France 2014

Configuring Situation Events in Action Manager for WebSphere Business Monitor Version 6.0

Rational Application Developer Performance Tips Introduction

Integrating SharePoint Sites within WebSphere Portal

NetBeans IDE Field Guide

SSC - Web development Model-View-Controller for Java web application development

Federated Portals. Subbu Allamaraju Staff Engineer BEA Systems Inc

JRefleX: Towards Supporting Small Student Software Teams

Aspect Weaving for OSGi. Martin Lippert (akquinet it-agile GmbH)

Service-Oriented Architectures

OSGi Technology for System and Network Architects DECEMBER 2013

ActiveVOS Server Architecture. March 2009

Swordfish SOA Runtime Framework

SOA Fundamentals For Java Developers. Alexander Ulanov, System Architect Odessa, 30 September 2008

TIBCO ActiveMatrix BPM SOA Concepts

Server-side OSGi with Apache Sling. Felix Meschberger Day Management AG 124

Securing your business

September 18, Modular development in Magento 2. Igor Miniailo Magento

Beyond the SOA/BPM frontiers Towards a complete open cooperative environment

Digital Asset Management Beyond CMIS

SAP Mobile Platform Intro

OSGi In Practice. Neil Bartlett. December 17, 2009

Introduction to IBM Worklight Mobile Platform

PTW Exchange Brasil de Setembro, São Paulo, SP, BR. 1

Change Management MANDATORY CRITERIA

Providing Load Balancing and Fault Tolerance in the OSGi Service Platform

FUSE ESB. Getting Started with FUSE ESB. Version 4.1 April 2009

Service Oriented Architecture 1 COMPILED BY BJ

Testing Web Services Today and Tomorrow

Distributed systems. Distributed Systems Architectures

Research on the Model of Enterprise Application Integration with Web Services

Framework Adoption for Java Enterprise Application Development

Dominic Betts Grigori Melnik Fernando Simonazzi Mani Subramanian

How To Integrate With An Enterprise Service Bus (Esb)

Government's Adoption of SOA and SOA Examples

Getting Started with Android Programming (5 days) with Android 4.3 Jelly Bean

Service-Oriented Computing: Service Foundations

Migration Eclipse 3 to Eclipse 4

Using OSGi as a Cloud Platform

Cost-optimized, Policy-based Data Management in Cloud Environments

Building Web Services with Apache Axis2

How To Build A Financial Messaging And Enterprise Service Bus (Esb)

PROGRAMMERS GUIDE. Version 1.x

Developer Tutorial Version 1. 0 February 2015

Efficient Monitoring of OSGi Applications

Meister Going Beyond Maven

Developing modular Java applications

Software Development Kit

Challenges in Building Service-Oriented Applications for OSGi

The Oracle Fusion Development Platform

Eclipse for Smalltalkers

SOACertifiedProfessional.Braindumps.S90-03A.v by.JANET.100q. Exam Code: S90-03A. Exam Name: SOA Design & Architecture

Understanding class paths in Java EE projects with Rational Application Developer Version 8.0

TOSCA Interoperability Demonstration

Demonstration of XML Validation Framework using OASIS CAM approach

Service-Oriented Architecture and Software Engineering

RFP EXHIBIT K. Corporations and Charities System. Logical Architecture Document

Database lifecycle management

Service Management-as-a-Service for Hybrid Cloud

Oracle Service Bus Examples and Tutorials

DEPLOYMENT ARCHITECTURE FOR JAVA ENVIRONMENTS

MDM and Data Warehousing Complement Each Other

FORMS & WORKFLOW SHAREPOINT Practical Discussion

TIBCO ActiveMatrix Service Bus Concepts. Software Release September 2013

Transcription:

Best Practices for Programming Eclipse and OSGi BJ Hargrave Jeff McAffer IBM Lotus IBM Rational Software 2006 by IBM; made available under the EPL v1.0 March 24, 2006

Introduction During the Eclipse 3.0 and OSGi R4 development cycles, OSGi and Eclipse began to influence each others work Eclipse 3.0 adopted the OSGi framework as the footing of the Eclipse platform OSGi R4 incorporated features to support important Eclipse use cases This led to the OSGi R4 Framework specification of which Eclipse Equinox is an implementation The Equinox code is currently being used by OSGi as the framework reference implementation for R4 2 Eclipse/OSGi Best Practices 2006 by IBM; made available under the EPL v1.0

Overview As a result of the incorporation of the OSGi framework into Eclipse, there are several additional capabilities now available to Eclipse plug-in writers that should be considered Today we will look at two areas Modularity Techniques for sharing classes and resources between bundles (aka. plug-in) Collaboration Techniques for inter bundle collaboration (which build upon class sharing) 3 Eclipse/OSGi Best Practices 2006 by IBM; made available under the EPL v1.0

Modularity (Desirable) property of a system, such that individual components can be examined, modified and maintained independently of the remainder of the system. Objective is that changes in one part of a system should not lead to unexpected behavior in other parts. www.maths.bath.ac.uk/~jap/math0015/glossary.html We need to be able to share classes and resource between bundles (modules) while supporting a proper level of modularity Eclipse and OSGi offers two main ways of sharing Require-Bundle Import-Package 4 Eclipse/OSGi Best Practices 2006 by IBM; made available under the EPL v1.0

Require-Bundle Mechanism for a bundle to gain access to all the packages exported by another bundle bulk import Advantages Can be used for non-code dependencies: e.g. Help Convenient shorthand for multiple imports Joins split packages Disadvantages Tight coupling can be brittle since it requires the presence of a specific bundle Split packages Completeness, ordering, performance Package shadowing Unexpected signature changes 5 Eclipse/OSGi Best Practices 2006 by IBM; made available under the EPL v1.0

Import-Package Mechanism for a bundle to import specific packages Advantages Loose coupling implementation independence Arbitrary attributes allow sophisticated export matching No issues with package splitting or shadowing whole package Disadvantages More metadata to be created and maintained each imported package must be declared Only useful for code (and resource) dependencies Can t be used for split packages 6 Eclipse/OSGi Best Practices 2006 by IBM; made available under the EPL v1.0

Best Practices: Modularity In general, Import-Package is recommended PDE (or other tools) can help with metadata management for packages used Loosest coupling More opportunities for resolver to successfully resolve Provides more information to management system Require-Bundle used for complex scenarios Refactoring bundles which results in splitting a package across more than one bundle Have dependencies on a specific bundle and version This could still be done with Import-Package Also is a simple place to start when first modularizing legacy code To some degree, the choice is a trade off that you must make Simplicity vs. flexibility 7 Eclipse/OSGi Best Practices 2006 by IBM; made available under the EPL v1.0

Collaboration Modularization is powerful Decouples elements More flexible configurations Dynamic behavior Decoupled components need a way of interacting and cooperating Our resolved bundles need to collaborate Eclipse includes three mechanisms for inter bundle collaboration Extension registry Service registry Declarative Services builds upon the service registry 8 Eclipse/OSGi Best Practices 2006 by IBM; made available under the EPL v1.0

Extension Registry Extension Registry : declarative relationships between plug-ins Extension Point : plug-ins open themselves for configuration/extension Extension : plug-in extends another by contributing an extension Plug-ins can contribute actionsets extensions that define actions with an id, a label, an icon, and a class that implements the interface IActionDelegate. The UI will present that label and icon to the user, and when the user clicks on the item, the UI will instantiate the given action class, cast it to IActionDelegate, and call its run() method. 9 Eclipse/OSGi Best Practices 2006 by IBM; made available under the EPL v1.0

Extension Registry The extension registry provides a per extension point list of contributed extensions Aggregates all the extensions for the extension point Provides a private context for the extension point and its extensions Only the extension point will call the extension Tightly coupled model Each extension is bound to a specific extension point Extension point are no longer bound to specific bundles Declarative plugin.xml Lazy loading of extension class Metadata enables registration and attribute interrogation Life cycle scoped to resolved state of bundle Lifecycle is highly dynamic Extension may be published or unpublished at any time (after bundle resolved) Lifecycle event notifications No security to control Which bundle can declare an extension point Which bundle can contribute an extension 10 Eclipse/OSGi Best Practices 2006 by IBM; made available under the EPL v1.0

Service Registry The service registry is a publish/find/bind model Public context Single service registry (within a framework instance) Loosely coupled model Any bundle can bind to a service API based non declarative Service can be published with key/value pair metadata Eager loading of service class Service object is published Life cycle scoped to started state of bundle Lifecycle is highly dynamic Service may be published or unpublished at any time (after bundle started) Lifecycle event notifications Permissions to control whether a bundle can publish, find or bind to a service 11 Eclipse/OSGi Best Practices 2006 by IBM; made available under the EPL v1.0

Declarative Services Declarative service model build upon service registry Adds a declarative mechanism specifying Provided service References services Simplified programming model POJO with dependency injection and contextualized lookup Can conceal dynamism of services from programmer Lazy loading of service class Lifecycle managed by central runtime Interoperates with service registry Vaguely similar to Spring but supports the dynamic component model of OSGi and Eclipse 12 Eclipse/OSGi Best Practices 2006 by IBM; made available under the EPL v1.0

Extensions Services extension point uses implements uses implements contributes binds consumer service extension = contract = consumer = provider 13 Eclipse/OSGi Best Practices 2006 by IBM; made available under the EPL v1.0

Example: Event Listeners Event listeners are connected to the event source An event is fired and the event source must notify each event listener Event listeners can supply metadata describing interest in event, for example: Event subtypes of interest Frequency of notification etc. 14 Eclipse/OSGi Best Practices 2006 by IBM; made available under the EPL v1.0

Extension Approach Event source Declaratively defines and exposes extension point (e.g. eventsource ) Defines the listener interface (e.g. IEventListener) Listener Implements IEventListener Declaratively contributes extension for the eventsource extension point that defines IEventListener class to run Listener metadata Event source extension point discovers each registered IEventListener extension When an event is fired, the event source Evaluates the event against each listener extension s metadata Can then load and run the listener s code to deliver the event 15 Eclipse/OSGi Best Practices 2006 by IBM; made available under the EPL v1.0

Extension Approach eventsource IEventListener Event Source Event Source contributes implements Extension ListenerImpl Listener Listener instantiates calls to notify 16 Eclipse/OSGi Best Practices 2006 by IBM; made available under the EPL v1.0

Services Approach: Whiteboard Event source Defines the listener interface (e.g. IEventListener) Listeners Implements IEventListener Registers an IEventListener instance as a service with properties containing listener metadata When an event is fired, event source Finds all registered IEventListener services Evaluates the event against each listener service s metadata Can then bind to and run the listener s code to deliver the event 17 Eclipse/OSGi Best Practices 2006 by IBM; made available under the EPL v1.0

Services Approach: Whiteboard Service Registry Service Registry finds instantiates publishes binds IEventListener Event Source Event Source implements ListenerImpl Listener Listener calls to notify 18 Eclipse/OSGi Best Practices 2006 by IBM; made available under the EPL v1.0

Services Approach: Registration Event source Defines the event source interface (e.g. IEventSource) Defines the listener interface (e.g. IEventListener) Implements IEventSource Registers an IEventSource instance as a service Listeners Implements IEventListener Finds and binds to the IEventSource service Registers an IEventListener instance with the IEventSource service along with listener metadata When an event is fired, event source Evaluates the event against each listener s metadata Can then run the listener s code to deliver the event 19 Eclipse/OSGi Best Practices 2006 by IBM; made available under the EPL v1.0

Services Approach: Registration Service Registry Service Registry instantiates publishes finds binds IEventSource IEventListener Event Source Event Source registers implements ListenerImpl Listener Listener calls to notify 20 Eclipse/OSGi Best Practices 2006 by IBM; made available under the EPL v1.0

Declarative Services Approach: IoC Whiteboard Event source Defines the listener interface (e.g. IEventListener) Declaratively defines component with a dynamic, 0..n cardinality, dependency injection reference to IEventListener services Listeners Implements IEventListener Declaratively defines component providing IEventListener service with listener metadata SCR will create and inject instance of IEventListener service into event source component When an event is fired, event source Queries listener for metadata and evaluates the event against metadata Can then run the listener s code to deliver the event 21 Eclipse/OSGi Best Practices 2006 by IBM; made available under the EPL v1.0

Declarative Services Approach: IoC Whiteboard Service Component Service Component Runtime Runtime setter injection instantiates IEventListener Event Source Event Source implements ListenerImpl Listener Listener calls to notify 22 Eclipse/OSGi Best Practices 2006 by IBM; made available under the EPL v1.0

Discussion In Extension and Service Registration approaches, the listener is able to select the specific event source with which it s listener will be registered Names extension point of extension/binds to event source service In the Service Whiteboard and Declarative Services, control is inverted and the event source select the listener Extension approach allows lazy loading of listener class The Services approaches require eager loading of listener class The Declarative Service with DI also requires eager loading but a variation can be made which allows lazy loading at the expense of using container API Contextualized lookup Injection of ServiceReference 23 Eclipse/OSGi Best Practices 2006 by IBM; made available under the EPL v1.0

Compare and Contrast Extensions Private contract with specific consumer (extension point) Can deliver data-only payload Lazily loaded and run Lifecycle scoped to resolved state of bundles Services Public contract No data-only payload Eager loading Lifecycle scoped to started state of bundles Declarative Services Public contract No data-only payload Lazily loaded and run Lifecycle scoped to started state of bundles 24 Eclipse/OSGi Best Practices 2006 by IBM; made available under the EPL v1.0

Best Practices: Collaboration Extension Registry Use when a tightly coupled relationship exists such as contributing UI elements Declarative Services Use when providing a service usable by any consumer (loosely coupled relationship) such as a data validation service Use when substitutability of service providers and consumers is desired Service Registry Same as Declarative Services But Declarative Services is preferred unless you have a complex need outside scope of Declarative Service s capabilities Useful for highly dynamic service such as publication upon external event 25 Eclipse/OSGi Best Practices 2006 by IBM; made available under the EPL v1.0