Simplify component accessibility.
One Facade to rule them all
JRebirth uses a global facade automatically created by JRebirth AbstractApplication class.
The global facade create automatically the JRebirth notification engine. You should read the Notifier page to have more informations.
The global facade also allow to communicate with the Application class and therefore with its stage and scene.
It allows to manage the three main facades:
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(); |
There are 4 LocalFacade, each one is responsible of its layer components.
Each Facade can manage its components (also called readyObject) throught some public methods.
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); |
Each Component (CSM) are registered into the facade using a UniqueKey, there are 2 options:
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).
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.
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) { |