osgi in the enterprise

40
OSGi in the Enterprise Filippo Diotalevi Knokode Ltd [email protected]

Upload: filippo-diotalevi

Post on 10-May-2015

5.962 views

Category:

Technology


3 download

DESCRIPTION

Using OSGi in enterprise applications: technologies, motivations, case studies.Presented at JaxItalia 2009, Milano, October 13th 2009

TRANSCRIPT

Page 1: OSGi in the Enterprise

OSGi in the EnterpriseFilippo DiotaleviKnokode Ltd

[email protected]

Page 2: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

About

OSGi and Java Enterprise consultant

Java User Group Milano founder and coordinator

Apache Felix committer

http://www.diotalevi.com [email protected]

http://www.osgilook.com

Page 3: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

OSGi

OSGi in the Enterprise

Case Studies

OSGi - A developer’s quiickstartSaturday 11.30 - 12.00

Summary

Page 4: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

OSGi

A dynamic module system for Java

Page 5: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

OSGi

1999 - OSGi Alliance founded, JSR 8

2000 - R1 published

2003 - Eclipse choose OSGi for the plugin

architecture

2007 - R4.1 published (JSR 291)

2009 - R4.2 published

2010 - Enterprise OSGi

Page 6: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

OSGi

1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010

Page 7: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

OSGi

Building system from smaller components

Components working together

Managing components

Page 8: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

OSGi

Service Layer

Lifecycle Layer

Module Layer

Page 9: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

Module System

Clear boundaries

Dependencies

Metadata

Lifecycle

Page 10: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

Lifecycle of bundle

Page 11: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

Service System

Service Oriented Architecturein the JVM

Page 12: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

Bundle Provider Bundle Consumer

Service Registry

RegisterService

RetrieveService

Service System

Page 13: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

A collection of bundles interacting via Service interfaces

Bundles developed and installed independently

Bundle and services can appear and disappear

What’s an OSGi Application?

Page 14: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

Demo

Page 15: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

What’s behind the demo

Bundle Host

Provide the Frame and

define the Shape interface

Service Registry

Listen forand

retrieveShapes

Bundle Triangle

Provide the Triangle

implementation

Bundle Circle

Provide the Circle

implementation

RegisterTriangle

RegisterCircle

Page 16: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

OSGi in the Enterprise

Why?

Create modular and reusable software

Create evolvable software

Create line of products

Page 17: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

OSGi in the Enterprise

What?

Desktop Applications

Web Applications

Service Layers

Content Management System

Embedded/Mobile Applications

Cloud Applications

Page 18: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

Examples:

Page 19: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

OSGi in the Enterprise

How?Desktop Applications

Eclipse

Rich Client Platform

Page 20: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

OSGi in the Enterprise

How?Web Applications

Spring Dynamic ModulesApache Sling

Apache Felix Karaf + Pax Web (Jetty)

Page 21: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

Spring Dynamic Modules

Part of the Spring open source portfolio

Formerly known as Spring-OSGi

Works with every OSGi container

Allows you to implement Spring applicationson top of any OSGi framework

Page 22: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

Java Virtual Machine

OSGi Container

Spring + Spring DM

Application Context

Application Context

Application Context

Spring Bean

Exported Service

Imported Service

Bundle ABundle B

Bundle C

Spring DM idea

Page 23: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

One application context per bundle

When a bundle is started, its application contextis discovered and instantiated

Bundles can export Spring beans as OSGi services

Bundles can import OSGi services

Spring vs OSGi

Page 24: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

Blueprint Service

Blueprint, dependency injectiona-la-Spring

Apache Geronimo Blueprint (may change in the future...)

Page 25: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

OSGi in the Enterprise

How?Service Layers

Spring Dynamic ModulesApache Felix

Apache ServicemixOSGi Remote Services

Page 26: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

Coming soon...

Enterprise OSGi

Full Web Application Support (RFC 66)

JDBC integration

JNDI/LDAP integration

.....

look for Apache Aries (http://incubator.apache.org/aries)

Page 27: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

OSGi in the Enterprise

Challenges and Opportunities

Modular Design

Development process and tools

Quality Assurance

Versioning and Dynamic Updates

Provisioning

Page 28: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

Case Studies

Page 29: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

Case Study 1: Service Layer

Goal

Create a service layer where services

- can be deployed/updated at runtime without causing service disruptions - can be customized for specific customers - (possibly) reusing some existing components

Page 30: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

Case Study 1: Service Layer

Solution: architecture

Generic REST API

WeatherService

NewsService

Embedded Jetty ServerPOJO -> XML transformation

Spring DMSpring

Page 31: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

Case Study 1: Service Layer

Solution: evolution

Generic REST API

WeatherService

NewsService V.2

NewsService

(BBC only)Twitter

Page 32: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

Case Study 1: Service Layer

Lessons learned

“Right” modularization is hard, and there is no fixed rule

Spring DM gets developers back in their confort zone (and hides OSGi APIs)

Deployment loves it (dynamicity, console, modularity)

Page 33: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

Case Study 2: OSGi in the Cloud

Goal

Manage completely the deployment of a Web Application in a cluster of Amazon virtual machines

Applications are modular, modules can be updated without causing service disruption

Page 34: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

Case Study 2: OSGi in the Cloud

Goal

“Cloud console” ?

Page 35: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

Case Study 2: OSGi in the Cloud

Solution: architecture

WebConsole

Amazon EC2 ClusterWeb Application based on Apache Felix Karaf

BundleRepository

UploadDefine packages

Start

Provision (SSH)

Load

Start

MySQL (Amazon EBS or RDS)

Start

Amazon Elastic Load Balancer

EC2

EBS/RDS

ELB

Page 36: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

Case Study 2: OSGi in the Cloud

Page 37: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

Case Study 3: Float management

Goal

Manage a float of Java-enabled devices

- check the software installed

- push software updates

Page 38: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

Case Study 3: Float management

Solution: Apache ACE

Page 39: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

Conclusion

OSGi is an enabling technology

that opens up new opportunities

Page 40: OSGi in the Enterprise

OSGi in the Enterprise - Filippo Diotalevi

Questions?