Messaging is an essential part of JacpFX. JacpFX components (workbench, perspectives, components) have no direct reference to each other and communicate via messages.
Every component has a message box and handles it's messages sequential, similar to an actor.
@Resource private Context context; ... context.send("message");
This can be interesting when you want to execute methods in a worker thread. (see non blocking UI)
context.send(ComponentIds.COMPONENT_ONE,"message");
To handle a message, the JacpFX Component interfaces defines two methods which will be called sequential:
public Node handle(final Messagemessage) { // runs in worker thread return null; }
and
public Node postHandle(final Node arg0, final Messagemessage) { // runs in FX application thread return null; }
While the "handle" method will be executed in a worker thread, the "postHandle" method is always executed on the FX application thread. For details about the Component lifecycle see the documentation about async execution