Agile Development with OSGi

Post on 27-Aug-2014

209 views 10 download

Tags:

description

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

Transcript of Agile Development with OSGi

Agile Development with OSGiMatt Stine

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

A Tale of Two Cities:

Tracer Bullet Development OSGi

Where it all began...

...OK, really this time!

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

Propose System Objects

Tracer Bullet

Development

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

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

Propose System Objects

Propose Interfaces

Tracer Bullet

Development

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

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”

Propose System Objects

Propose Interfaces

Connect Interfaces

Tracer Bullet

Development

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

Connect Interfaces

Implement interobject communication

Many issues will emerge - resolve them!

Now the tracer bullet can be fired!

Propose System Objects

Propose Interfaces

Connect Interfaces

Add Functions

Tracer Bullet

Development

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

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

Propose System Objects

Propose Interfaces

Connect Interfaces

Add Functions

Refactor, Refine, Repeat

Tracer Bullet

Development

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

Refactor, Refine, Repeat

Interfaces will evolve

Add/change at any time, but...

No broken windows!!!

Within module, refactor mercilessly!

Between modules, must communicate!

Propose System Objects

Propose Interfaces

Connect Interfaces

Add Functions

Refactor, Refine, Repeat

Tracer Bullet

Development

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

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

OSGiThe Dynamic Module system for Java

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

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

Modularity...how?

Encapsulation

Service Registry

Versioning

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

Modularity...how?

Encapsulation

Service Registry

Versioning

Dynamism/Lifecycle

OSGi Implementations

Equinox

PAX Tools for OSGi

PaxConstruct

Script-oriented toolkit for OSGi development

Similar to Rails/Grails development model

Built on Maven 2

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

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!

Why TBD+OSGi?

Connect Interfaces

Why TBD+OSGi?Connect Interfaces

Client Object

Client Module

Service Interface

Service Implementation

Server Module

Case Study

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

System ObjectsWeb UI

Business Services

Data Access Outbound Messaging

Database Kiosk

Inbound Messaging

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);!

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);!

Outbound Messaging Interface

void notifyKioskOfRental(Kiosk kiosk, Rental rental);

Inbound Messaging Interface

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

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

Add Functions

On to the code...

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

mstine/fluffbox

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!

Please fill out your evaluations!

Matt Stine matt.stine@gmail.com

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