Platform#runLater Question
Florian Brunner
fbrunner at gmx.ch
Wed Apr 3 14:29:56 PDT 2013
Hi Mark,
I'm not sure if it fits your needs exactly, but I've implemented something like this for Drombler FX.
The JavaFX agnostic interface is here:
http://sourceforge.net/p/drombler/drombler-acp/ci/f2c9da0d549677805fbcb3c5250e139a5d8925fb/tree/drombler-acp-core-application/src/main/java/org/drombler/acp/core/application/ApplicationExecutorProvider.java
The JavaFX specific implementation class and helpers are here:
http://sourceforge.net/p/drombler/drombler-fx/ci/9639d43d9c015b15f770df1b92c716c8d86def46/tree/drombler-fx-core-application/src/main/java/org/drombler/fx/core/application/impl/FXApplicationExecutorProvider.java
http://sourceforge.net/p/drombler/drombler-fx/ci/9639d43d9c015b15f770df1b92c716c8d86def46/tree/drombler-fx-core-application/src/main/java/org/drombler/fx/core/application/impl/FXApplicationExecutor.java
http://sourceforge.net/p/drombler/drombler-fx/ci/9639d43d9c015b15f770df1b92c716c8d86def46/tree/drombler-fx-core-commons/src/main/java/org/drombler/fx/core/commons/fx/application/PlatformUtils.java
So instead of calling Platform.runLater() directly, I inject an implementation of ApplicationExecuterProvider and call ApplicationExecuterProvider.getApplicationExecutor().execute().
Here is an example how you can use it with OSGi Declarative Services (using the Apache Felix SCR annotations):
http://sourceforge.net/p/drombler/drombler-acp/ci/f2c9da0d549677805fbcb3c5250e139a5d8925fb/tree/drombler-acp-core-action-spi/src/main/java/org/drombler/acp/core/action/spi/impl/ToolBarsHandler.java#l41
(The reason I'm doing this is because Drombler ACP, the base framework of Drombler FX, is GUI-toolkit agnostic and thus doesn't know anything about JavaFX.)
-Florian
Am Montag, 1. April 2013, 12.05:03 schrieb Mark Fortner:
> In the past, I've found the *Platform#runLater* method to be a useful way
> to run tasks. However, I've noticed that the code that runs my thread is
> not really configurable or accessible. For example, it would be nice to be
> able to specify and configure a top-level *ThreadPoolExecutor* to handle my
> tasks. Or be able to switch out *Executor* implementations.
>
> I was wondering if there was some reason for implementing runLater this
> way, or if there are any plans to change it in the future?
>
>
> Cheers,
>
> Mark
More information about the openjfx-dev
mailing list