org.bushe.swing.event.annotation
Annotation Type VetoTopicSubscriber


@Retention(value=RUNTIME)
@Target(value=METHOD)
public @interface VetoTopicSubscriber

An Annotation for adding VetoTopicListener subscriptions to EventService Events.

This annotation simplifies much of the repetitive boilerplate used for adding veto topic listeners (which in EventBus 2.0 will be called VetoTopicSubscribers, thus this annotation name difference) to EventService Events. Example:

 public class MyAppController {
   public MyAppController {
       AnnotationProcessor.process(this);//this line can be avoided with a compile-time tool or an Aspect
   }
   @EvenTopicSubscriber(topic="App.Close")
   public void onAppClosingEvent(String topic, Object payload) {
      //close connections, close windows
   }
 }

 public class MyDocumentController {
   @VetoTopicSubscriber(topic="App.Close")
   public boolean ensureDocumentIsSaved(String topic, Object payload) {
      if (docHasUnsavedChanges()) {
         boolean answer = MyModalDialog.show("Are you sure you want to close and lose your changes?");
         if (answer == StandardButtonValues.Cancel) {
            //stop processing this event
            return true;
         }
      }
      //It's OK to close
      return false;
   }
 }
 


Required Element Summary
 String topic
          The topic to subscribe to
 
Optional Element Summary
 Class<? extends EventService> autoCreateEventServiceClass
          Whether or not to autocreate the event service if it doesn't exist on subscription, default is true.
 String eventServiceName
          The event service to subscribe to, default to the EventServiceLocator.SERVICE_NAME_EVENT_BUS.
 int priority
          Determines the order in which this veto subscriber is called, default is FIFO.
 ReferenceStrength referenceStrength
          Whether to subscribe weakly or strongly.
 

Element Detail

topic

public abstract String topic
The topic to subscribe to

priority

public abstract int priority
Determines the order in which this veto subscriber is called, default is FIFO.

Default:
0

referenceStrength

public abstract ReferenceStrength referenceStrength
Whether to subscribe weakly or strongly.

Default:
org.bushe.swing.event.annotation.ReferenceStrength.WEAK

eventServiceName

public abstract String eventServiceName
The event service to subscribe to, default to the EventServiceLocator.SERVICE_NAME_EVENT_BUS.

Default:
"EventBus"

autoCreateEventServiceClass

public abstract Class<? extends EventService> autoCreateEventServiceClass
Whether or not to autocreate the event service if it doesn't exist on subscription, default is true. If the service needs to be created, it must have a default constructor.

Default:
org.bushe.swing.event.ThreadSafeEventService.class


Copyright © 2011 Bushe Enterprises, Inc.. All Rights Reserved.