Fork me on GitHub

Facades Layer

Simplify component accessibility.

Facade(s)

JRebirth provide 4+1 Facades used to manage its dedicated pattern wB-CS-Mvc.

Overview

Short UML Diagram:

Global Facade

One Facade to rule them all

JRebirth uses a global facade automatically created by JRebirth AbstractApplication class.

Internal Communication

The global facade create automatically the JRebirth notification engine. You should read the Notifier page to have more informations.

Linked with Application

The global facade also allow to communicate with the Application class and therefore with its stage and scene.

Manage Local Facades

It allows to manage the three main facades:

  • CommandFacade
  • ServiceFacade
  • UiFacade
  • BehaviorFacade

The GlobaleFacadeBase allow to get each of these facades by calling appropriate getters:

52
57
62
67
LocalFacade<Model> getUiFacade();
LocalFacade<Service> getServiceFacade();
LocalFacade<Command> getCommandFacade();
LocalFacade<Behavior<?>> getBehaviorFacade();

This link is bidirectionnal because global facade is accessible from the 3 main facades by calling : getGlobalFacade() (each facade extends the AbstractGlobalReady abstract class which implement GlobalReady interface.

35
GlobalFacade getGlobalFacade();

Local Facades

There are 4 LocalFacade, each one is responsible of its layer components.

Basic Features

Each Facade can manage its components (also called readyObject) throught some public methods.

  • register : store a pre-built component
  • unregister : remove a component
  • exists : check if the component is already registered, it could be released
  • retrieve : used to get a component (build and register it if needed)
43
53
62
72
83
95
107
120
131
<E extends R> void register(final UniqueKey<E> uniqueKey, final E readyObject);
<E extends R> void register(final E readyObject, final Object... keyPart);
<E extends R> void unregister(final UniqueKey<E> uniqueKey);
<E extends R> void unregister(final E readyObject, final Object... keyPart);
<E extends R> boolean exists(final UniqueKey<E> uniqueKey);
<E extends R> boolean exists(final Class<E> clazz, final Object... keyPart);
<E extends R> E retrieve(final UniqueKey<E> uniqueKey);
<E extends R> E retrieve(final Class<E> clazz, final Object... keyPart);
<E extends R> List<E> retrieveAll(UniqueKey<E> uniqueKey);

Component Key

Each Component (CSM) are registered into the facade using a UniqueKey, there are 2 options:

ClassKey

The simplest key is the ClassKey, it's only composed by the class object of the component, thus the can only be stored once into the facade (=singleton).

MultitonKey

The MultitonKey uses also the class of the component but add a variable part to be able to store several instances of a same Component.

Convenient Builder

JRebirth API have a lot of method that take the Component Class with additional objects as key parts.
But the API also has a convenient class that provides method tused to build key.

41
63
84
98
113
static <C> UniqueKey<C> create(final Class<C> clazz, final Object... keyPart) {
static <C> UniqueKey<C> create(final Class<C> clazz, final Object[] optionalData, final Object... keyPart) {
static <C> UniqueKey<C> createSingle(final Class<C> clazz, final Object... optionalData) {
static <C> UniqueKey<C> createMulti(final Class<C> clazz, final Object... keyPart) {
static <C> UniqueKey<C> createMulti(final Class<C> clazz, final Object[] keyPart, final Object... optionalData) {

Provide Tracking

JRebirth allows to track all creation & finalization of each component (Command, Service, Model, View) and also track the emission of waves and their path.

They are logged in order to be processed by the JRebirthAnalyzer tool.