SeamFramework.orgCommunity Documentation

Chapter 10. Weld-OSGi events

10.1. CDI container lifecycle events
10.2. Bundle lifecycle events
10.3. Service lifecyle events
10.4. Bean bundle required service dependency validation events
10.5. Intra and inter bundles communication events

Weld-OSGi provides numerous events about OSGi events and bean bundle lifecycle events. It also allows decoupled bean bundle communication.

All these features uses CDI events mechanisms:

Weld-OSGi provides a CDI event notification for bean bundle about bean bundle CDI container lifecycle events:

Weld-OSGi provides a CDI event notification for bean bundle about bundle lifecycle events:

It is possible to filter the listened source bundle by bundle symbolic name and version (optional)

public void bindBundle(@Observes @BundleName("com.sample.gui") @BundleVersion("4.2.1") AbstractBundleEvent event) {
}
public void bindBundle(@Observes @BundleName("com.sample.gui") BundleInstalled event) {
}

Only the events from the corresponding bundle are listened.

If a BundleVersion annotation is provided without a BundleName annotation Weld-OSGi detects the problem and treats it as an error.

Weld-OSGi provides a CDI event notification for bean bundle about service lifecycle events:

It is possible to filter the listened source service by specification and or OSGi LDAP properties and filter

public void bindService(@Observes @Specification(MyService.class) AbstractServiceEvent event) {
}
public void bindService(@Observes @AnyQualifier ServiceArrival event) {
}
public void bindService(@Observes @Specification(MyService.class) @Filter("(&(lang=EN)(country=US))") ServiceChanged event) {
}

Only the corresponding service events are listened.

Weld-OSGi provides a CDI event notification for bean bundle about bean bundle required service dependency validation:

Weld-OSGi provides a way to communicate within and between bean bundles:

It is possible to filter the listened source message by message type and ignoring the events from the current bundle

public void listenAllEventsFromOtherBundles(@Observes @Sent InterBundleEvent event) {
}
public void listenMyMessageEvents(@Observes @Specification(MyMessage.class) InterBundleEvent event) {
}
public void listenMyMessageEventsFromOtherBundles(@Observes @Sent @Specification(MyMessage.class) InterBundleEvent event) {
}

Only the corresponding events are listened.