Fork me on GitHub

Wave Layer

Allow asynchronous communication between components

Wave Overview

What's a Wave

A Wave is a temporary object created to carry data througt CS-MVC components.

They allow JRebirth to handle application internal events asynchronously between each components, at the opposite you can use getModel, getCommand and getService method to perform synchronous operations.

Waves are handled by the notifier engine which are running within the JRebirthThread .

Short UML Diagram:

Wave Group

There are 4 main group of waves :

  1. Call Command : used to trigger a command action
  2. Call Service : used to call a service, later another wave will be used
  3. Attach Ui : used to link two JavaFX nodes
  4. Undefined : to handle all other waves, the wave type must be defined

Wave Type

The wave type is where black magic resides. It defines a contract between the emitter (the one who creates the wave) and the receiver (the one who handles the waves).

This contract is dynamic because it relies on a String and WaveItem objects.

A WaveType has a unique name and a set of WaveItem objects. It must be created and stored like this:

    • Into an Interface to define wave contract (here without argument)
38
39
40
41
42
/** Trigger a Unload wave. */
WaveTypeBase DO_UNLOAD = WaveTypeBase.build("UNLOAD");
 
/** Trigger a Play wave. */
WaveTypeBase DO_PLAY = WaveTypeBase.build("PLAY");
    • Into a service class (here with on argument) :
46
47
48
49
50
/** Wave type use to load events. */
public static final WaveTypeBase DO_LOAD_EVENTS = WaveTypeBase.build("LOAD_EVENTS", EditorWaves.EVENTS_FILE);
 
/** Wave type to return events loaded. */
public static final WaveTypeBase RE_EVENTS_LOADED = WaveTypeBase.build("EVENTS_LOADED", EditorWaves.EVENTS);

WaveType name

This string is used to link to a component method , this call is made by reflection when the wave is processed.

WaveItem List

Each WaveItem will be passed to the method as an argument

Wave argument

Each wave procesing method must add a least argument : the source wave, thus it will be possible to know the handling context for this method call.

The wave argument is useful to access to wave bean or other information like source wave.

Wave Lifecycle

Wave lifecycle are defined by the Status enumeration:

  1. Created : The Wave object has just been built by someone.
  2. Sent : The wave has been sent to the JRebirth Notifier Engine
  3. Processing : The wave is being dispatched
  4. Cancelled : The wave has been cancelled by an user action
  5. Consumed : The wave task is achieved and is marked as consumed
  6. Failed : The wave process has generated an error
  7. Destroyed : the wave is available for garbage collection

How they are consumed

Chained Wave

It's possible to chain command by using the ChainWaveCommand class. A sample is used into the JRebirthThread.bootUp() method.