Errai 3.0.1-SNAPSHOT

org.jboss.errai.ioc.client.lifecycle.api
Interface LifecycleEvent<T>

All Known Subinterfaces:
Access<T>, Creation<T>, Destruction<T>, StateChange<T>
All Known Implementing Classes:
AccessImpl, CreationImpl, DestructionImpl, LifecycleEventImpl, StateChangeImpl

public interface LifecycleEvent<T>

The base interface for IOC Lifecycle events. Components may fire IOC Lifecycle events to broadcast events to interested listeners that do not perfectly map to one of the supported IOC scopes. The general usage for firing an event is:

 Access event = IOC.getBeanManager().lookup(Creation.class).getInstance();
 // Need to set an instance for the event.
 event.setInstance("String Instance!");
 
 event.fireAsync(new LifecycleCallback() {
      @Override
      public void callback(boolean success) {
          if (success) {
              // Go through with the action
          }
      }
 });
 
LifecycleListeners can access the event instance or veto the event.

Author:
Max Barkley

Method Summary
 void fireAsync(T instance)
          Fire this event, notifying any listeners for this event type by calling the respective LifecycleListener.observeEvent(LifecycleEvent) methods.
 void fireAsync(T instance, LifecycleCallback callback)
          Fire this event, notifying any listeners for this event type by calling the respective LifecycleListener.observeEvent(LifecycleEvent) methods.
 T getInstance()
          This method should only be called from within LifecycleListener.observeEvent(LifecycleEvent).
 void veto()
          Veto this event.
 

Method Detail

fireAsync

void fireAsync(T instance)
Fire this event, notifying any listeners for this event type by calling the respective LifecycleListener.observeEvent(LifecycleEvent) methods.

Parameters:
instance - The bean instance associated with this event.

fireAsync

void fireAsync(T instance,
               LifecycleCallback callback)
Fire this event, notifying any listeners for this event type by calling the respective LifecycleListener.observeEvent(LifecycleEvent) methods.

Parameters:
instance - The bean instance associated with this event.
callback - A callback for receiving the result of a fired event (whether or not any listeners vetoed.

veto

void veto()
Veto this event. If this method is called by a LifecycleListener during the LifecycleListener.observeEvent(LifecycleEvent) then:

getInstance

T getInstance()
This method should only be called from within LifecycleListener.observeEvent(LifecycleEvent). The instance is set immediately before calling listeners and unset immediately after.

Returns:
The instance for which this event has been fired or null if this event is not actively being fired.

Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.