Previous Topic

Next Topic

Book Contents

Book Index

Event Collector Developer Guide

Overview

The OSGi Event Admin service dispatches events to the registered event handlers. An event handler is a routine allowing a developer to write code to be executed when an event occurs. There is no defined mechanism to inspect the events, that were sent before a handler was registered. The Event Collector service catches the dispatched events and makes them available to applications installed later.

This functionality is optional and configured with proper event limit, discarding the oldest events. It is enabled by setting mbs.events.collector.enabled to true. Then, the OSGi Event Admin bundle registers a com.prosyst.mbs.services.event.tracker.EventCollector service, which provides two options of accessing already dispatched events:

Configuring the Service

  1. To use this optional functionality, set the system property mbs.events.collector.enabled to true.
  2. A reasonable event limit should be configured via system property mbs.events.collector.limit. If not set, the default value is 1000. This means that only the last n events are being cached and the older events are discarded.

Using the Service

The examples below show the couple of ways to collect cached events.