OSGi and Apache Felix 3.0 Beginner's Guide


OSGi and Apache Felix 3.0 Beginner's Guide
eBook: $26.99
Formats: PDF, PacktLib, ePub and Mobi formats
$22.94
save 15%!
Print + free eBook + free PacktLib access to the book: $71.98    Print cover: $44.99
$44.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Reviews
Support
Sample Chapters
  • Build a completely operational real-life application composed of multiple bundles and a web front end using Felix
  • Get yourself acquainted with the OSGi concepts, in an easy-to-follow progressive manner
  • Learn everything needed about the Felix Framework and get familiar with Gogo, its command-line shell to start developing your OSGi applications
  • Simplify your OSGi development experience by learning about Felix iPOJO
  • A relentlessly practical beginner's guide that will walk you through making real-life OSGi applications while showing you the development tools (Maven, Eclipse, and so on) that will make the journey more enjoyable

Book Details

Language : English
Paperback : 336 pages [ 235mm x 191mm ]
Release Date : November 2010
ISBN : 1849511381
ISBN 13 : 9781849511384
Author(s) : Walid Joseph Gédéon
Topics and Technologies : All Books, Application Development, Java, Open Source


Table of Contents

Preface
Chapter 1: Quick Intro to Felix and OSGi
Chapter 2: Setting Up the Environment
Chapter 3: Felix Gogo
Chapter 4: Let's Get Started: The Bookshelf Project
Chapter 5: The Book Inventory Bundle
Chapter 6: Using the OSGi Bundle Repository
Chapter 7: The Bookshelf: First Stab
Chapter 8: Adding a Command-Line Interface
Chapter 9: Improve the Bookshelf Service with iPOJO
Chapter 10: Improving the Logging
Chapter 11: How About a Graphical Interface?
Chapter 12: The Web Management Console
Chapter 13: Improving the Graphics
Chapter 14: Pitfalls and Troubleshooting
Appendix A: Eclipse, Maven, and Felix
Appendix B: Where to Go from Here?
Appendix C: Pop Quiz Answers
Index
  • Chapter 1: Quick Intro to Felix and OSGi
    • What is OSGi?
    • The framework layout
      • The functional layers
      • The bundle lifecycle states
      • Bundle wiring
    • The shared service registry
    • Working with bundles
      • Anatomy of a bundle
      • The OSGi headers
        • Mandatory headers
        • Functional headers
        • Information headers
    • Start levels
      • The Start Level Service
      • The active start level
      • Using start levels
    • Apache Felix and sub-projects
    • Summary
  • Chapter 2: Setting Up the Environment
    • Setting up the Felix framework
      • Checking that a JDK is installed
      • Download and unpack the Felix distribution
    • Time for action – downloading and installing Felix
      • What's in the box?
    • Time for action – starting Felix
    • Maven2 and Felix
      • Installing Maven2
      • Life-cycles and phases
      • Maven plugins
      • The POM
      • The Felix Maven Plugins
    • Summary
  • Chapter 3: Felix Gogo
    • The Tiny Shell Language
      • Chained execution
      • Variable assignment and referencing
      • Value types
      • Object properties and operations
      • Execution quotes
      • Commands and scopes
    • felix scope commands
      • Listing installed bundles: lb
      • help
      • install
      • update
      • resolve
      • stop and start
      • uninstall
      • refresh
      • headers and inspect
      • which
      • log
      • cd and ls
      • frameworklevel and bundlelevel
    • gogo scope commands
      • echo
      • grep
      • cat
      • tac
      • set
    • Summary
  • Chapter 5: 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 Bundle identity
      • More on bundle versions
      • Dependencies
      • Customizing the build
      • Defining the distribution parameters
    • The Book bean interface
      • The Book bean attributes
    • 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
      • The factory method
      • Implementing a mock getGoups()
      • Storing a book
      • Removing a stored book
      • Loading a stored book
      • Implementing the book search
    • Writing the Bundle Activator
    • Time for action – add a dependency to the OSGi Core library
    • Time for action – creating the Activator
      • More on Bundle Contexts
    • Time for action – declaring Bundle-Activator
    • Build and deploy the bundle
    • Summary
  • Chapter 6: Using the OSGi Bundle Repository
    • OBR, the OSGi Bundle Repository
      • The repository XML Descriptor
      • Updating the OBR repository
    • Using the OBR scope commands
      • obr:repos
      • obr:list
      • obr:info
      • obr:deploy
      • obr:source and obr:javadoc
      • Updating bundles in the repository
    • Installing the Book Inventory bundles to Felix
    • Time for action – install the book inventory bundles
    • On dependency management
    • Summary
  • Chapter 7: The Bookshelf: First Stab
    • The Bookshelf Service bundle
      • Define the main Bookshelf Service interfaces
    • Time for action – writing the APIs
      • The Authentication interface
      • The BookshelfService interface
      • Implementing the service
    • Time for action – writing BookshelfServiceImpl
    • Time for action – implementing the service activator
      • Framework service lookup
    • 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
  • Chapter 8: 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
      • On Converters
    • 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
    • Implementing the book:add command
    • 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
  • Chapter 9: Improve the Bookshelf Service with iPOJO
    • What is Inversion of Control?
      • The Service Locator pattern
      • The Dependency Injection pattern
      • The Whiteboard pattern
      • The Extender Pattern
    • The iPOJO Felix sub-project
      • Components and instances
      • iPOJO Maven plugin
        • The metadata file
        • Using the plugin
    • Injecting iPOJOs
      • Install the iPOJO service bundle
    • Let iPOJO register the inventory implementation
    • Time for action – creating the iPOJO metadata
      • Update the POM
      • Configure bundle for iPOJO
      • Build and test it
    • The Felix iPOJO Gogo Command bundle
      • ipojo scope commands usage
    • Migrate the bookshelf service
    • Time for action – removing lookups in the service implementation
    • Time for action – writing the bookshelf service iPOJO configuration
      • Update the POM
      • Deploy and check
    • iPOJO using annotations
      • Overview
      • Beginner's annotations
        • @Component
        • @Provides
        • @Requires
        • @ServiceProperty
        • @Property
        • @Instantiate
      • Instantiating annotated components
    • 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
  • Chapter 10: Improving the Logging
    • On logging
      • Logging levels
      • Who's listening?
    • The OSGi Log Service
      • The Service end
      • Usage of the Log Service
      • The service provider end
    • Apache Felix Log Service
      • The log command
    • Creating the log helper bundles
    • Time for action – creating the bookshelf-log-api bundle
    • Time for action – creating the log helper implementation
      • Implementing the BookshelfLogHelper service
    • 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
      • Update bookshelf-service-tui dependency
    • Trying it out
    • Using other Log Service implementations
    • Summary
  • Chapter 11: How About a Graphical Interface?
    • The OSGi HTTP Service
      • Component structure
      • Registration of servlets
    • iPOJO and the Whiteboard Extender
    • Http Service implementations
      • The Apache Felix Http Service
    • Time for action – installing the Apache Felix Http Service
    • A simple bookshelf web application
    • Time for action – implementing the servlet
      • The iPOJO configuration
      • Implementing the operations
    • Time for action – declaring the parameter constants
    • Time for action – implementing the operations
    • Trying it out
    • Summary
  • Chapter 12: The Web Management Console
    • Getting started
      • Installing the Web Console
    • 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
      • Bundles
      • Log Service
      • OSGi Repository
      • Services
      • Shell
      • System Information
    • Apache Felix iPOJO WebConsole Plugin
    • Summary
  • Chapter 13: Improving the Graphics
    • OSGi Web Containers
    • Pax Web
    • Time for action – installing the Pax Web bundles
      • Uninstall previous http support
      • Install PAX Web bundles
      • Double-check the http service implementation
    • 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
      • Complete the authentication pages
    • Time for action – using the service
    • A first smoke test
    • Implement the remaining pages
    • Time for action ­– implementing the list books by category page
      • A note on JSP imports
    • Time for action – explicit package imports
      • Search with authors
      • Add book
    • Summary
  • Chapter 14: Pitfalls and Troubleshooting
    • Common pitfalls
      • I start my bundle but nothing happens
        • Have you declared your bundle activator in the manifest?
        • Do you have the correct logging level set?
      • I update my bundle, but I can't see any change
        • Are you updating the right bundle?
        • Are you updating the right bundle location?
        • Have you refreshed the bundle dependencies?
      • I refresh my OBR but the bundles don't get updated
        • Is the remote OBR being updated?
      • The artifact JAR I need doesn't have OSGi entries in its manifest
        • Creating the bundle manually
        • Using the BND tool
      • I get a "No impl service available" error with any shell command
        • Re-initialize the environment
      • I get a "No LogReaderService available" error with the log command
        • Do you have a Log Service installed?
      • I can't add/connect to an OBR
        • Is that URL valid?
        • Does the OBR have the right format?
        • Do you need a proxy to access the Internet?
      • I'm getting a "Jsp support is not enabled" error message
        • Did you install JSP support?
      • My JSP can't find a class that it needs
        • Is that class on an exported package?
        • Does the web application bundle import the required class package?
    • Troubleshooting tips
      • How to get debug logs from the Felix Log Service
      • How can remote debugging help
      • Where to get answers online
    • Summary
  • Appendix A: Eclipse, Maven, and Felix
    • Productivity tools
      • An Integrated Development Environment
      • A build management system
    • Setting up Eclipse and plugins
      • Maven integration plugin
      • OSGi framework container plugin
      • Choosing the workspace
      • Installing the Eclipse plugins
        • Installing Pax Runner
        • Installing m2clipse
    • Setting up a new Maven project in Eclipse
      • Creating the Maven project
      • Customizing the build process
    • Time for action – completing the project
    • Importing a Maven project into Eclipse
    • Debugging with Eclipse
      • Remote debugging configuration
        • Setting up the remote application
    • Time for action – editing the Felix run script
      • Configuring the IDE for remote debugging
    • Connecting to Felix remotely
      • Set a breakpoint
      • Start the remote debugger
    • Running embedded Felix
      • Configuring embedded Felix
      • Taking it for a ride
      • Adding OBR repositories
      • Starting a test bundle
    • Debugging embedded
  • Summary
  • Appendix C: Pop Quiz Answers
    • Chapter 1: Quick intro to Felix and OSGi
    • Chapter 2: Setting up the Environment
    • Chapter 3: Felix Gogo
    • Chapter 5: The Book Inventory Bundle
    • Chapter 6: Using the OSGi Bundle Repository
    • Chapter 7: The Bookshelf: First Stab
    • Chapter 11: How About a Graphical Interface?
    • Chapter 13: Improving the Graphics

Walid Joseph Gédéon

Walid Joseph Michel Gédéon is a painter and sculptor living in the south of France. He is also a telecommunications network and OSS senior expert. Over the past decade, he has focused his attention on the design and integration of distributed operations support systems in the real world (and around it).

Code Downloads

Download the code and support files for this book.


Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


Errata

- 1 submitted: last submission 22 Dec 2011

Errata type: Code | Page numbers: 113

Install the bookshelf service bundle onto you Felix framework should be Install the bookshelf service bundle onto your Felix framework

 

Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

OSGi and Apache Felix 3.0 Beginner's Guide +    Spring Security 3.1 =
50% Off
the second eBook
Price for both: ₨351.00

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • Discover the practical implementations of important OSGi concepts
  • Install , configure, and learn how to operate Felix using Gogo
  • Understand how to use Maven to build and deploy OSGi bundles
  • Create an OSGi-compliant application, brick by brick
  • Learn how to implement JSP Web Application Bundles
  • Dive deep into Felix iPOJO
  • Understand Inversion of Control design patterns
  • Get an overview of the Felix Web Management Console
  • Get cozy with troubleshooting an OSGi application using Felix

 

In Detail

The OSGi specification is a module system and service platform that implements a complete and dynamic component model. Wasn't that a complicated definition! So how would you really use it in practical modular applications? Let this book break down the seemingly overwhelming OSGi standards for you by explaining Apache Felix's powerful architecture in a simple and easy-to-understand manner using Apache Felix framework to get you up and running sooner than you could expect.

The OSGi standards have found a wide range of applications in the context of the Enterprise, Telecommunications, Telematics, Smart Home, E-Health, and Mobile applications, to name just a few. Apache Felix is one of the most famous implementations of the OSGi framework specification. This book introduces OSGi on the simple and extensible Felix framework and guides you from the development environment setup to the troubleshooting of potential issues, walking you through the development of an OSGi-based application and explaining relevant software design concepts.

The book starts with an introduction to the OSGi Service Platform, its parts, and its bundle structure. It then walks you through setting up the Felix framework and your development environment. It describes the Felix Framework and how to operate it using Gogo. It will teach you everything possible about the practical implementation of OSGi using the Felix Framework as a launch pad.

The book then kicks off the Bookshelf project, a case study that will be used to progressively explain the important concepts around OSGi using the Felix framework. The Bookshelf project feature trail will set the context to explain OSGi headers, the bundle activator, the bundle context, and so on.

As you implement the bookshelf step by step, you learn about OBR repositories, dependency management, and bundle version management with Felix.

Moving ahead, a few more advanced topics are covered, such as using iPOJO for dependency injection and service registration; then the book moves on to the implementation of a web-based graphical interface, first using a simple Servlet, and then building a JSP-based Web Application Bundle.

OSGi service specifications such as the Log Service, Http Service, and Web Container are explained. Finally, the book describes some of the common pitfalls during bundle development, and gives hints on troubleshooting them in Felix.

A step-by-step beginner's guide to implementing a real-life OSGi application, with the Apache Felix 3.0 framework

Approach

This book is a step-by-step beginner's guide based on developing a case study (a book inventory) that walks the developer through the implementation while progressively explaining the surrounding concepts in context. Throughout the book, the author discusses software design concepts and introduces productivity tools that build up the reader's knowledge-base.

Who this book is for

This book is aimed at Java developers looking to learn about writing reusable and network distributable software following the OSGi standards using the famous Felix framework. If you are a developer who wants to focus on the business logic, and abstract away from the details of how to integrate with specific systems then this book is meant for you.

If you are a Java developer new to OSGi and don't really know where to start from to actually begin developing applications, just pick up this book and discover the ease with which you can start developing powerful, modular, and extensible applications. This book uses the Felix framework 3.0 as an OSGi service platform implementation and covers its usage to a level where it makes you comfortable enough to write your own enterprise-level applications.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software