PacktLib: OSGi and Apache Felix 3.0 Beginner's Guide

OSGi and Apache Felix 3.0

Credits

About the Author

About the Reviewers

Preface

Quick Intro to Felix and OSGi

What is OSGi?

The framework layout

The shared service registry

Working with bundles

Start levels

Apache Felix and sub-projects

Summary

Setting Up the Environment

Setting up the Felix framework

Time for action - downloading and installing Felix

Time for action - starting Felix

Maven2 and Felix

Summary

Felix Gogo

The Tiny Shell Language

felix scope commands

gogo scope commands

Summary

Let's Get Started: The Bookshelf Project

A simple Bookshelf project

OSGi, Felix, and...

Taking it step-by-step

Some conventions

Summary

The Book Inventory Bundle

Set up the Book Inventory API Bundle project

Time for action - setting up the project skeleton

Time for action - creating the project POM

The Book bean interface

Time for action - creating the Book bean interface

The Book Inventory interface

Time for action - writing the BookInventory interface

Build and deploy the bundle

Time for action - building and deploying the bundle

Let's implement those interfaces

Time for action - creating the POM

Time for action - implementing a mutable book

Time for action - implementing the mock (memory-stored) Book Inventory

Writing the Bundle Activator

Time for action - add a dependency to the OSGi Core library

Time for action - creating the Activator

Time for action - declaring Bundle-Activator

Build and deploy the bundle

Summary

Using the OSGi Bundle Repository

OBR, the OSGi Bundle Repository

Using the OBR scope commands

Installing the Book Inventory bundles to Felix

Time for action - install the book inventory bundles

On dependency management

Summary

The Bookshelf: First Stab

The Bookshelf Service bundle

Time for action - writing the APIs

Time for action - writing BookshelfServiceImpl

Time for action - implementing the service activator

Trying the BookshelfService

Time for action - building the bundle

Time for action - installing and testing the service

Time for action - fulfilling the missing dependency

On class visibility

Summary

Adding a Command-Line Interface

The Apache Felix Gogo Shell Service

Time for action - creating the Bookshelf Service TUI bundle

Implementing a Gogo Shell Service command

Implementing the book:search command

Time for action - adding the required dependencies

Time for action - writing the BookshelfServiceProxy

Time for action - implementing a bundle activator

Time for action - packaging and installing

Time for action - trying out the book:search command

Time for action - cleaning up the bookshelf-service activator

Time for action - implementing the book-add command

Updating an installed bundle

Trying the commands

Sourcing scripts

Time for action - creating a book population script

Summary

Improve the Bookshelf Service with iPOJO

What is Inversion of Control?

The iPOJO Felix sub-project

Injecting iPOJOs

Let iPOJO register the inventory implementation

Time for action - creating the iPOJO metadata

The Felix iPOJO Gogo Command bundle

Migrate the bookshelf service

Time for action - removing lookups in the service implementation

Time for action - writing the bookshelf service iPOJO configuration

iPOJO using annotations

Update the text UI bundle

Time for action - updating the BookshelfServiceProxyImpl

Time for action - writing the iPOJO meta.xml

Time for action - updating the POM

Summary

Improving the Logging

On logging

The OSGi Log Service

Apache Felix Log Service

Creating the log helper bundles

Time for action - creating the bookshelf-log-api bundle

Time for action creating the log helper implementation

Add logging to the bookshelf-service

Time for action updating the bundle POM

Time for action - updating the bookshelf service logging calls

Time for action - logging to BookshelfLogHelper

Trying it out

Using other Log Service implementations

Summary

How About a Graphical Interface?

The OSGi HTTP Service

iPOJO and the Whiteboard Extender

Http Service implementations

Time for action - installing the Apache Felix Http Service

A simple bookshelf web application

Time for action - implementing the servlet

Time for action - declaring the parameter constants

Time for action - implementing the operations

Trying it out

Summary

The Web Management Console

Getting started

Time for action - installing commons-fileupload and commons-io

Time for action - installing json

Time for action - installing and starting the Web Console

A quick overview

Apache Felix iPOJO WebConsole Plugin

Summary

Improving the Graphics

OSGi Web Containers

Pax Web

Time for action - installing the Pax Web bundles

Our bookshelf-webapp

Time for action - creating the bookshelf-webapp bundle

Web application registration

Time for action - setting up the web application bundle

Time for action - specifying dependencies

Getting a service reference in JSP

Time for action - ­ writing the session bean

Time for action - using the service

A first smoke test

Implement the remaining pages

Time for action - ­ implementing the list books by category page

Time for action - explicit package imports

Summary

Pitfalls and Troubleshooting

Common pitfalls

Troubleshooting tips

Summary

Eclipse, Maven, and Felix

Eclipse, Maven, and Felix

Eclipse, Maven, and Felix

Eclipse, Maven, and Felix

Eclipse, Maven, and Felix

Eclipse, Maven, and Felix

Eclipse, Maven, and Felix

Eclipse, Maven, and Felix

Eclipse, Maven, and Felix

Where to Go from Here?

Where to Go from Here?

Where to Go from Here?

Where to Go from Here?

Where to Go from Here?

Where to Go from Here?

Where to Go from Here?

Pop Quiz Answers

Pop Quiz Answers

Pop Quiz Answers

Pop Quiz Answers

Pop Quiz Answers

Pop Quiz Answers

Pop Quiz Answers

Pop Quiz Answers

Pop Quiz Answers