Wednesday, December 30, 2009

EventBus Event Notification Framework

EventBus is an Event Notification Framework.

Following example is from EventBus Getting Started guide.

Statusbar that updates based on published events, and no need to register statusbar control/widget as listener of publisher(s). Without EventBus, statusbar will need to be added as listener to many classes. Statusbar can also be created and destroyed at any time.

public StatusBar extends JLabel {
    public StatusBar() {
        AnnotationProcessor.process(this);
    }
    @EventSubscriber(eventClass=StatusEvent.class)
    public void updateStatus(StatusEvent statusEvent) {
        this.setText(statusEvent.getStatusText();
    }
}

A similar project is ELF (Event Listener Framework) but it seems to be less mature.

Taken from my StackOverflow answer about Generic annotation-driven event notification framework.

1 comment: