Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[equinox-dev] Proposal: declarative event notification mechanism


While discussing some ongoing work, Pascal came up with a very interesting idea: why won't we create a generic mechanism for "declarative" registration of listeners?

The proposed event notification mechanism would be:
  • based on the "whiteboard" pattern [1], plus
  • a declarative way to register listeners, plus
  • ideas and implementation pieces from OSGi's EventAdmin [2].

To me, this sounds like a great idea. Listeners are ubiquitous and so are the problems associated with their life cycle.

Details

In theory, OSGi's EventAdmin service should help work with listeners. Implementations details aside (it is not in the SDK and needs to be tested for scalability), it suffers from the same problem as OSGi services in general: a listener's bundle has to be started and needs to register listener with OSGi. This creates startup order problems and works against lazy activation of bundles. For OSGi services add-on pieces that allow declarative registration of services (Declarative Servieces, SPring, This startup problem sounds similar to the OSGi services registration problem for which we are starting to get "declarative" adds-ons such as DS and Springs.

The solution to the listener mechanism proposed here is similar – to have a declarative way to describe listeners via XML or manifest file.

In this model listeners are likely would have to be singletons ("simple" approach), or we could support user-provided factories to create listeners ("advanced" approach). We could add a flag to the declaration of the listener to indicate if it should receive events in case its bundle has not been activated yet. Most likely we'll need to support both synchronous and asynchronous events, just like EventAdmin does.

To me, the declarative event processing mechanism truly sounds like a component that would be used by a number of projects. What do you think about this idea?

Sincerely,
Oleg Besedin

[1] The description of the "whiteboard" pattern can be found at http://www.osgi.org/documents/osgi_technology/whiteboard.pdf .
[2] The OSGi specification can be downloaded from http://www.osgi.org/ ; EventAdmin’s Javadoc can be found at http://www2.osgi.org/javadoc/r4/org/osgi/service/event/EventAdmin.html .

Back to the top