Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

This document explains how developers can use iPOJO extensibility mechanism. This tutorial shows two small examples: a Log Handler logging messages inside the OSGiâ„¢ OSGiâ?¢ log service and a Property Handler injecting properties values inside fields.
This document is organized as follow. First, iPOJO concepts are briefly explained. The next section explains the first step to create a handler. The two last sections describe the implementation and the usage of two example handlers.

...

iPOJO is a service component model aiming to simplify OSGiâ„¢ OSGiâ?¢ applications development. iPOJO is based on the POJO concepts. A POJO is a simple Java class without any dependency on its runtime environment. In iPOJO, POJO are encapsulated in a container managing the relation between the POJO and the external world. This container keeps separate the POJO from the external world. Moreover, this container is flexible and extensible.
Basically, iPOJO contains two main concepts: Component Type and Component Instance. A component type is a type of component. A component type defines its implementation class, its creation policy, and its container. A component instance is a configured instance of a component type. This instance is created with the component type factory. A component instance inherits of all component type characteristics but has a unique name, and owns a configuration (set of <key, value>).

...

This section describes how to create a simple handler. This handler logs a message in the OSGiâ„¢ OSGiâ?¢ log service when the component instance state changes. It participates to the component instance lifecycle (the handler in not valid when there is no log service available).

...

  • The bundle context (context)
  • The instance manager (manage)
  • The service reference of the actual used Log Service (ref)
  • The used log service (log)
  • The level of the log (level)

Note: Handler code is OSGiâ„¢ OSGiâ?¢ standard code. A handler cannot be a POJO.

...

This handler is available here : http://cwiki.apache.org/confluence/download/attachments/35380/log_handler.zip.
The archive file contains the log handler implementation and a simple component using this handler. To work, you need to deploy an implementation of the Log Service. An implementation is available inside the Felix trunk.

...