Fork me on GitHub

Command Layer

Reuse common code and don't be scared by threading issue

Commands

Command Lifecycle

A command is an atomic action reusable or not that can be run into any thread. A command provides specific features:

  • A component key, built with Class Name and an addtionnal string
  • An action to process
  • A property indicating in which thread it must be run
  • A parent command for chained one
  • A WaveBean that will hold all required data to process the action

UML Class Diagram:

Component

Commands are designed to be disposable after usage, but they could be retained by strong references to be executed twice or more.
You can call a command by tree differents ways:

  • Synchronous way : getCommand()
  • Asynchronous way : CALL_COMMAND WaveType
  • Listener Callback : processAction(), require pre-registration

Please note that Commands are JRebirth main components, they follow the component lifecycle as described in (TODO link to Facade Page).
Thus AbstractBaseCommand extends AbstractWaveReady and their descendants must provide ready() and processAction() methods.

Synchronous way

It's possible to call a command from any JRebirth component (Command, Service, Model).

callCommand(TestCommmand.class)
getLocalFacade().getGlobalFacade().getCommandFacade().retrieve(TestCommmand.class)

Action to process

Run Into

Parent command

WaveBean

Single Commands

Multi Commands

Interal Commands are automatically run into the JET, if you want to do some tasks in background you should use these.

UI Commands are automatically run into the JAT, if you want to update scene nodes.