For my OSGi based JavaFX solution on the Udoo Quad (ARM based Linux) I created a service that publishes the application in the context.The application does as little as possible. It sets up the primary stage as fullscreen and puts a stackpane in it. Initially the stackpane displays a 'boot logo', until the actual desktop bundle is started and registered with the application. Note that you have to start the application on a separate thread, as the thread will be blocked.

On Java 8 this means that although the application bundle can't be updated in a running OSGi container, but that is why the desktop exists. On startup it registers itself, and thus the application content, with the application, and when it is stopped it removes the content from the application. The application has thus rarely to be updated itself.

Regards,
Maurice.



public class UdooActivator implements BundleActivator {
    private static UdooActivator activator;
    private BundleContext context;

    static UdooActivator bundleActivator() {
        return requireNonNull(activator, "activator not set");
    }

    @Override
    public void start(BundleContext context) throws Exception {
        this.context = context;
        activator = this;
new Thread(() -> Application.launch(Udoo15App.class), "JavaFX Desktop launcher").start();
    }

    @Override
    public void stop(BundleContext context) throws Exception {
        Platform.exit();
    }

    public BundleContext getBundleContext() {
        return context;
    }
}

Op 20-02-16 om 01:28 schreef Stephen Winnall:
Anirvan, Kevin

Thanks for this.

I’m an expert neither in JavaFX nor in OSGi, but I think the basis of the 
JavaFX/OSGi incompatibility is control. To work with OSGi, JavaFX has to 
relinquish control of its startup sequence to OSGi in such a way that 
javafx.application.Application (or its proxy) is instantiated by OSGi and 
submits to OSGi’s bundle/service lifecycle. AN OSGi expert can probably 
formulate this better…

Platform.startup(runnable) /might/ do it. Platform.launch(class) doesn’t 
because the object thereby instantiated is always under the control of JavaFX - 
and thus not of OSGi.

I’m not comfortable using JFXPanel: if I wanted to use Swing I wouldn’t be 
trying to use JavaFX. But thank you for the hint.

Steve

On 19 Feb 2016, at 16:41, Kevin Rushforth<kevin.rushfo...@oracle.com>  wrote:

And for JDK 9 there is now:

     Platform.startup(Runnable);

-- Kevin


Anirvan Sarkar wrote:
Hi Stephen,

FYI, there is another way of initializing JavaFX runtime. Just use:

new JFXPanel();

It is documented[1] that FX runtime is initialized when the first JFXPanel
instance is constructed.

Also JavaFX 9 will provide an official API to start the FX platform [2] [3].


[1]
https://docs.oracle.com/javase/8/javafx/api/javafx/application/Platform.html#runLater-java.lang.Runnable
  
<https://docs.oracle.com/javase/8/javafx/api/javafx/application/Platform.html#runLater-java.lang.Runnable>-
[2]https://bugs.openjdk.java.net/browse/JDK-8090585  
<https://bugs.openjdk.java.net/browse/JDK-8090585>
[3]
http://download.java.net/jdk9/jfxdocs/javafx/application/Platform.html#startup-java.lang.Runnable
  
<http://download.java.net/jdk9/jfxdocs/javafx/application/Platform.html#startup-java.lang.Runnable>-


On 18 February 2016 at 20:08, Stephen Winnall<st...@winnall.ch>  
<mailto:st...@winnall.ch>  wrote:

As I understand it, there are two ways of activating JavaFX:

1) sub-class javafx.application.Application or
2) call javafx.application.Application.launch()




Op 20-02-16 om 01:28 schreef Stephen Winnall:
Anirvan, Kevin

Thanks for this.

I’m an expert neither in JavaFX nor in OSGi, but I think the basis of the 
JavaFX/OSGi incompatibility is control. To work with OSGi, JavaFX has to 
relinquish control of its startup sequence to OSGi in such a way that 
javafx.application.Application (or its proxy) is instantiated by OSGi and 
submits to OSGi’s bundle/service lifecycle. AN OSGi expert can probably 
formulate this better…

Platform.startup(runnable) /might/ do it. Platform.launch(class) doesn’t 
because the object thereby instantiated is always under the control of JavaFX - 
and thus not of OSGi.

I’m not comfortable using JFXPanel: if I wanted to use Swing I wouldn’t be 
trying to use JavaFX. But thank you for the hint.

Steve

On 19 Feb 2016, at 16:41, Kevin Rushforth <kevin.rushfo...@oracle.com> wrote:

And for JDK 9 there is now:

     Platform.startup(Runnable);

-- Kevin


Anirvan Sarkar wrote:
Hi Stephen,

FYI, there is another way of initializing JavaFX runtime. Just use:

new JFXPanel();

It is documented[1] that FX runtime is initialized when the first JFXPanel
instance is constructed.

Also JavaFX 9 will provide an official API to start the FX platform [2] [3].


[1]
https://docs.oracle.com/javase/8/javafx/api/javafx/application/Platform.html#runLater-java.lang.Runnable
 
<https://docs.oracle.com/javase/8/javafx/api/javafx/application/Platform.html#runLater-java.lang.Runnable>-
[2] https://bugs.openjdk.java.net/browse/JDK-8090585 
<https://bugs.openjdk.java.net/browse/JDK-8090585>
[3]
http://download.java.net/jdk9/jfxdocs/javafx/application/Platform.html#startup-java.lang.Runnable
 
<http://download.java.net/jdk9/jfxdocs/javafx/application/Platform.html#startup-java.lang.Runnable>-


On 18 February 2016 at 20:08, Stephen Winnall <st...@winnall.ch> 
<mailto:st...@winnall.ch> wrote:

As I understand it, there are two ways of activating JavaFX:

1) sub-class javafx.application.Application or
2) call javafx.application.Application.launch()




Reply via email to