Package org.bushe.swing.event.annotation

EventBus annotations to make it much simpler to publish and subscribe to events.

See: Description

Package org.bushe.swing.event.annotation Description

EventBus annotations to make it much simpler to publish and subscribe to events.

Subscription annotations remove the boilerplate inner classes that often used for subscribers, especially when one class subscribes to multiple events.

When using annotations, the AnnotationProcessor must be used to create proxy subscribers.

An annotation example:


class MySubscriber {
   @EventSubscriber(eventClass=HelloEvent.class)
   public void printOutHelloWorld(HelloEvent event) {
        System.out.println("Hello"+helloEvent.getWorld());
   }
   @EventTopicSubscriber(topic="Hello");
   public void printOutHelloWorld(String topic, Object event) {
        System.out.println(topic+" "+event);
   }
}

class HelloEventBus {
   public static void main(String args[]) {
      MySubscriber subscriber = new MySubscriber();
      AnnotationProcessor.process(subscriber);//makes a proxy subscribers
      EventBus.publish(new HelloEvent());
      EventBus.publish("Hello", "World");
   }
}

Copyright © 2013 Bushe Enterprises, Inc.. All rights reserved.