Agile Development with OSGi

42
Agile Development with OSGi Matt Stine

description

Blast from the past that looks an awful lot like microservices...

Transcript of Agile Development with OSGi

Page 1: Agile Development with OSGi

Agile Development with OSGiMatt Stine

Page 2: Agile Development with OSGi

About your speaker...IT Manager / Business Analyst / Software Architect by Day

Speaker (JavaOne, SpringOne/2GX, Lambda Lounge, NFJS, RWX, PAX)

Author (GroovyMag, NFJS the Magazine)

President of the Memphis/Mid-South Java User Group

Agile Zone Leader @ DZone

OSGi Enthusiast

Page 3: Agile Development with OSGi

A Tale of Two Cities:

Tracer Bullet Development OSGi

Page 4: Agile Development with OSGi

Where it all began...

Page 5: Agile Development with OSGi

...OK, really this time!

Page 6: Agile Development with OSGi

A rose by any other name...Walking Skeleton (Alistair Cockburn) http://alistair.cockburn.us/Walking+skeleton

Spanning Application/Matrix (Mary & Tom Poppendieck) Lean Software Development: An Agile Toolkit

Nested Synchronization (Mary & Tom Poppendieck) Implementing Lean Software Development

Hudson River Company Start (Johanna Rothman) Manage It!

Thread (Matt Simons)“Big and Agile?” Cutter IT Journal 15(1): January 2002.

Spike (Luke Hohmann) Beyond Software Architecture: Creating and Sustaining Winning Solutions

Page 7: Agile Development with OSGi

Propose System Objects

Tracer Bullet

Development

Inspired by Ship It! (Richardson/Gwaltney), page 127

Page 8: Agile Development with OSGi

Propose System Objects

Identify application layers/modules

e.g. Client, Server, Database

Must be able to stand alone

Keep as coarse grained as possible

Must be able to justify isolated developer/team

Page 9: Agile Development with OSGi

Propose System Objects

Propose Interfaces

Tracer Bullet

Development

Inspired by Ship It! (Richardson/Gwaltney), page 127

Page 10: Agile Development with OSGi

Propose InterfacesDefine contract between system objects

Collaborative effort

Agree on method names, signatures

Stub out implementations (canned data)

Define how layers will talk (e.g. direct API calls, RMI, SOAP, OSGi, JMS)

System architecture “emerges”

Page 11: Agile Development with OSGi

Propose System Objects

Propose Interfaces

Connect Interfaces

Tracer Bullet

Development

Inspired by Ship It! (Richardson/Gwaltney), page 127

Page 12: Agile Development with OSGi

Connect Interfaces

Implement interobject communication

Many issues will emerge - resolve them!

Now the tracer bullet can be fired!

Page 13: Agile Development with OSGi

Propose System Objects

Propose Interfaces

Connect Interfaces

Add Functions

Tracer Bullet

Development

Inspired by Ship It! (Richardson/Gwaltney), page 127

Page 14: Agile Development with OSGi

Add Functions

Finally time to add real production code!

Developers/teams can work in isolation now

Work from high priority/high risk to low priority/low risk

Start to address performance problems

Page 15: Agile Development with OSGi

Propose System Objects

Propose Interfaces

Connect Interfaces

Add Functions

Refactor, Refine, Repeat

Tracer Bullet

Development

Inspired by Ship It! (Richardson/Gwaltney), page 127

Page 16: Agile Development with OSGi

Refactor, Refine, Repeat

Interfaces will evolve

Add/change at any time, but...

No broken windows!!!

Within module, refactor mercilessly!

Between modules, must communicate!

Page 17: Agile Development with OSGi

Propose System Objects

Propose Interfaces

Connect Interfaces

Add Functions

Refactor, Refine, Repeat

Tracer Bullet

Development

Inspired by Ship It! (Richardson/Gwaltney), page 127

Page 18: Agile Development with OSGi

TBD BenefitsTeams can work in parallel, independently

Can demonstrate “working” system earlier, providing feedback to you sooner

New features can be demonstrated immediately

Loosely coupled, highly cohesive modules

Encapsulation of module details

Enables automated integration testing

Enables interteam communication

Enables staff reallocation

Page 19: Agile Development with OSGi

OSGiThe Dynamic Module system for Java

Page 20: Agile Development with OSGi

OSGi Architecture

HardwareOperating SystemJava Virtual Machine

ModulesLifecycle

Service RegistryServices

Secu

rity

Application/Bundles

OSG

i Plat

form

Java

Plat

form

Inspired by Modular Java (Craig Walls), page 16

Page 21: Agile Development with OSGi

SOA in a JVM!

Service Bundle

Consumer Bundle

Regis

ters S

erviceDiscovers Service

Consumes Service

Inspired by Modular Java (Craig Walls), page 17

OSGi Service Registry

Page 22: Agile Development with OSGi

Modularity...how?

Encapsulation

Service Registry

Versioning

Page 23: Agile Development with OSGi

Bundle Versioning

Bar 1.0.2

Zab 2.1.3

Inspired by Modular Java (Craig Walls), page 18

Foo 1.0.0

Zab 1.0.4

Qib 2.0.1

Page 24: Agile Development with OSGi

Modularity...how?

Encapsulation

Service Registry

Versioning

Dynamism/Lifecycle

Page 25: Agile Development with OSGi

OSGi Implementations

Equinox

Page 26: Agile Development with OSGi

PAX Tools for OSGi

Page 27: Agile Development with OSGi

PaxConstruct

Script-oriented toolkit for OSGi development

Similar to Rails/Grails development model

Built on Maven 2

Page 28: Agile Development with OSGi

PaxRunner

OSGi framework launcher

Facilitates quick start OSGi exploration

Facilitates swapping OSGi platforms (works with all major open source implementations)

Facilitates provisioning OSGi bundles from multiple sources

Magic behind “pax-provision” and PaxExam

Page 29: Agile Development with OSGi

PaxExamTesting toolkit for OSGi

Facilitates in-container integration testing of bundles

Flow:

Starts OSGi container of choice

Provisions and starts selected bundles

Injects OSGi BundleContext to your JUnit test

Executes a test method

Rinse and repeat until done!

Page 30: Agile Development with OSGi

Why TBD+OSGi?

Connect Interfaces

Page 31: Agile Development with OSGi

Why TBD+OSGi?Connect Interfaces

Client Object

Client Module

Service Interface

Service Implementation

Server Module

Page 32: Agile Development with OSGi

Case Study

Page 33: Agile Development with OSGi

As a customer I can browse for speakers and select one so that I can reserve him/her.

As a customer I can reserve my chosen speakers at any Fluffbox location at which he/she is available so that I can pick him/her up.

As a kiosk, I can notify the reservation system when speakers are picked up/returned so that customers will have an up-to-date view of what speakers are available.

Online Reservation System for Speaker Rental Kiosks

Page 34: Agile Development with OSGi

System ObjectsWeb UI

Business Services

Data Access Outbound Messaging

Database Kiosk

Inbound Messaging

Page 35: Agile Development with OSGi

Business Services InterfaceList<Speaker> browse();!!Speaker get(Long id);!!List<Kiosk> findKiosksWhereAvailable(Speaker speaker);!!Kiosk get(Long id);!!Rental reserve(Speaker speaker, Kiosk kiosk, Customer customer);!!void pickup(Rental rental);!!void returnRental(Rental rental, Kiosk kiosk);!

Page 36: Agile Development with OSGi

Data Access InterfaceList<Speaker> findAll();!!Speaker get(Long id);!!List<Kiosk> findKiosksWhereAvailable(Speaker speaker);!!Kiosk get(Long id);!!Rental create(Rental rental);!!void pickup(Rental rental);!!void returnRental(Rental rental);!

Page 37: Agile Development with OSGi

Outbound Messaging Interface

void notifyKioskOfRental(Kiosk kiosk, Rental rental);

Page 38: Agile Development with OSGi

Inbound Messaging Interface

void notifyHqOfRentalPickup(Rental rental);!!void notifyHqOfRentalReturn(Rental rental, Kiosk kiosk);

Page 39: Agile Development with OSGi

Connect InterfacesWeb UI

Business Services

Data Access Outbound Messaging

Database Kiosk

Spring DM/OSGi

OSGi

JDBC

Spring DM/OSGi

JMS JMS

Spring DM/OSGi

Inbound Messaging

Page 40: Agile Development with OSGi

Add Functions

On to the code...

Code available at: http://github.com/

mstine/fluffbox

Page 41: Agile Development with OSGi

Refactor, Refine, RepeatMaybe change out plain JMS for Spring Integration solution

Maybe track spatial data on locations to enable mapping

Still need to add a payment system - another system object?

Our TBD system puts us in great position to address any of these and more!

Page 42: Agile Development with OSGi

Please fill out your evaluations!

Matt Stine [email protected]

Twitter: mstine http://www.mattstine.com