Bndtools 101 - QCon New York...Bndtools 101 Getting Started with OSGi Development – Many Java...

20
Bndtools 101 Getting Started with OSGi Development

Transcript of Bndtools 101 - QCon New York...Bndtools 101 Getting Started with OSGi Development – Many Java...

Page 1: Bndtools 101 - QCon New York...Bndtools 101 Getting Started with OSGi Development – Many Java Developers “Why Use OSGi?” OSGi is From the Future • Microservices since 1998

Bndtools 101Getting Started with OSGi Development

Page 2: Bndtools 101 - QCon New York...Bndtools 101 Getting Started with OSGi Development – Many Java Developers “Why Use OSGi?” OSGi is From the Future • Microservices since 1998

– Many Java Developers

“Why Use OSGi?”

Page 3: Bndtools 101 - QCon New York...Bndtools 101 Getting Started with OSGi Development – Many Java Developers “Why Use OSGi?” OSGi is From the Future • Microservices since 1998

OSGi is From the Future

• Microservices since 1998

• Continuous delivery since 1999

• Software component repositories since 2003

• Runtime resolve/assemble since 2005

image credit: Sam Howzit (flickr.com/photos/aloha75/)

Page 4: Bndtools 101 - QCon New York...Bndtools 101 Getting Started with OSGi Development – Many Java Developers “Why Use OSGi?” OSGi is From the Future • Microservices since 1998

Why Aren’t We All Using It?

• Steep Learning Curve…?

• Complexity…?

• Weak Tools…?

Page 5: Bndtools 101 - QCon New York...Bndtools 101 Getting Started with OSGi Development – Many Java Developers “Why Use OSGi?” OSGi is From the Future • Microservices since 1998

Famous Dude

• “Things should be as simple as possible, but no simpler”

Page 6: Bndtools 101 - QCon New York...Bndtools 101 Getting Started with OSGi Development – Many Java Developers “Why Use OSGi?” OSGi is From the Future • Microservices since 1998

Actually He Said…

• “It can scarcely be denied that the supreme goal of all theory is to make the irreducible basic elements as simple and as few as possible without having to surrender the adequate representation of a single datum of experience.”

Page 7: Bndtools 101 - QCon New York...Bndtools 101 Getting Started with OSGi Development – Many Java Developers “Why Use OSGi?” OSGi is From the Future • Microservices since 1998

Inherent vs Accidental Complexity

Page 8: Bndtools 101 - QCon New York...Bndtools 101 Getting Started with OSGi Development – Many Java Developers “Why Use OSGi?” OSGi is From the Future • Microservices since 1998

OSGi Really Is “As Simple as Possible”

Holy Sh*t We Needed Better

Tools!

image credit: Uwe Schwarzbach (flickr.com/photos/uwebkk/)

Page 9: Bndtools 101 - QCon New York...Bndtools 101 Getting Started with OSGi Development – Many Java Developers “Why Use OSGi?” OSGi is From the Future • Microservices since 1998

Bndtools “One tool to bnd them all”

Page 10: Bndtools 101 - QCon New York...Bndtools 101 Getting Started with OSGi Development – Many Java Developers “Why Use OSGi?” OSGi is From the Future • Microservices since 1998

0. Initial Setup

• Create Workspace Config

• Setup Repository

image credit: Germán Poo-Caamaño (flickr.com/photos/gpoo/)

Page 11: Bndtools 101 - QCon New York...Bndtools 101 Getting Started with OSGi Development – Many Java Developers “Why Use OSGi?” OSGi is From the Future • Microservices since 1998

1. Define API

• Blog

• BlogListener

• Baseline

• Release

image credit: Jessica Spengler (flickr.com/photos/wordridden/)

Page 12: Bndtools 101 - QCon New York...Bndtools 101 Getting Started with OSGi Development – Many Java Developers “Why Use OSGi?” OSGi is From the Future • Microservices since 1998

2. Create Provider

• Add blog.api to build path.

• Add MongoDB client from JPM.

Page 13: Bndtools 101 - QCon New York...Bndtools 101 Getting Started with OSGi Development – Many Java Developers “Why Use OSGi?” OSGi is From the Future • Microservices since 1998

3. Run It!

• Add blog.provider to Run Requirements

• Resolve and Run

image credit: Dru Bloomfield (flickr.com/photos/athomeinscottsdale/)

Page 14: Bndtools 101 - QCon New York...Bndtools 101 Getting Started with OSGi Development – Many Java Developers “Why Use OSGi?” OSGi is From the Future • Microservices since 1998

4. Create Consumer

• Add blog.api and servlet 2.5 API to build path

• Publish Servlet service

• Add service property: alias=/blog

• Add HTTP whiteboard & event admin to Run Requirements

image credit: epSos .de (flickr.com/photos/epsos/)

Page 15: Bndtools 101 - QCon New York...Bndtools 101 Getting Started with OSGi Development – Many Java Developers “Why Use OSGi?” OSGi is From the Future • Microservices since 1998

5. Evolve the API

• Add deleteEntry() method to Blog

• Fix the baselining errors

• Release

Page 16: Bndtools 101 - QCon New York...Bndtools 101 Getting Started with OSGi Development – Many Java Developers “Why Use OSGi?” OSGi is From the Future • Microservices since 1998

6. Package and Ship It

• Export as standalone JAR

• Run from bash

image credit: Glyn Lowe Photoworks. (flickr.com/photos/glynlowe/)

Page 17: Bndtools 101 - QCon New York...Bndtools 101 Getting Started with OSGi Development – Many Java Developers “Why Use OSGi?” OSGi is From the Future • Microservices since 1998

What Did We Make?

BlogProvider

BlogConsumer

(REST)

Jetty

HTTPWhiteboard

Blog

Servlet

HttpService

Page 18: Bndtools 101 - QCon New York...Bndtools 101 Getting Started with OSGi Development – Many Java Developers “Why Use OSGi?” OSGi is From the Future • Microservices since 1998

What Did We Make?

• A modular, dynamically assembled, type-safe, versioned microservice.

• … in 45 minutes (give or take)

Page 19: Bndtools 101 - QCon New York...Bndtools 101 Getting Started with OSGi Development – Many Java Developers “Why Use OSGi?” OSGi is From the Future • Microservices since 1998

Over to You

• Bndtools 2.4 M1 Just Released: bndtools.org

• Demo Sources: github.com/bndtools/101

NEW

Page 20: Bndtools 101 - QCon New York...Bndtools 101 Getting Started with OSGi Development – Many Java Developers “Why Use OSGi?” OSGi is From the Future • Microservices since 1998

Thanks!

The Bndtools Team, Working Hard(ly)