Hi Arjay,

I'm not very familiar with iPojo, but I did recently do some JavaFX in
OSGi. One approach that works reasonably well is using static
initialisation using a JFXPanel:
https://github.com/sandermak/carprov/blob/master/carprov.dashboard/src/carprov/dashboard/Dashboard.java#L39
.

I've also written a blog with a slightly different approach:
http://paulonjava.blogspot.nl/2014/11/making-javafx-better-with-osgi.html

Cheers,

Paul

On Wed Feb 04 2015 at 2:29:09 PM Arjay Sitoy <sitoy.ar...@gmail.com> wrote:

> I am doing a Javafx application in Apache Felix along with some experiments
> using iPOJO.
>
> First is I called the Application.launch() method in a different class and
> then start an another class containing the iPOJO @Requires like this:
>
> public class JavafxApp extends Application {
>     @Override
>     public void start(Stage primaryStage){
>         /* Do nothing here because I thought I can initialize JavaFX
> in a different class */
>     }
>
>     public void start(){
>         Platform.runLater(() -> {
>             launch(JavafxApplication.class);
>         });
>     }}
> public class MyApplication {
>     @Requires
>     LibraryClass class;
>
>     @Validate
>     public void start(){
>         JavafxApp.start();
>         class.someMethod();
>     }
> }
>
> This implementation throws this exception, java.lang.
> IllegalStateException:
> Toolkit not initialized but the iPOJO located the implementation class of
> the LibraryClass interface.
>
> After some research I found out that the application should be inside the
> class that extends the javafx.application.Application so I did some
> restructuring.
>
> public class JavafxApp extends Application {
>
>     @Requires
>     LibraryClass class;
>
>     @Override
>     public void start(Stage primaryStage){
>         class.someMethod();
>     }
>
>     @Validate
>     public void start(){
>         launch(JavafxApp.class);
>     }
> }
>
> Now the iPOJO throws a RuntimeException and the LibraryClass becomes null
> and
> the application throws a NullPointerException.
>
> My questions are:
>
>    - Is it possible to use iPOJO in this situation?
>    - If it is what is the right way to use iPOJO in a JavaFX application?
>
> Thanks in advance! :D
>
> P.S.
>
> I also posted the same question in *StackOverflow*
>
> http://stackoverflow.com/questions/28289948/using-
> ipojo-in-a-javafx-application
>

Reply via email to