tjwatson / atomos

Atomos - A Java Module Framework using OSGi Connect
Apache License 2.0
12 stars 6 forks source link

JavaFx with OSGi - An easy Example #19

Open stbischof opened 4 years ago

stbischof commented 4 years ago

One of ma long term Issues is to get JavaFx running with OSGi. Maybe there are better ways, but could you provide an easy example with Atomos? Or do you think it is not an good Usecase for Atomos?

tjwatson commented 4 years ago

Sorry I didn't respond earlier, but noticed you closed this issue. I don't have much experience with JavaFx. But I do know there are some things the eclipsefx (https://www.eclipse.org/efxclipse/index.html) project had to do to support OSGi by using Equinox internals to provide an extension to Equinox that made JavaFx available. I know I discussed this with @tomsontom in the past. From what I recall the work required was to be able to load the javafx library from a pre-ordained location and expose that inside of Equinox as a bundle. This does sound very similar to what OSGi Connect is trying enable the possibility for, but it is not something I have thought of for Atomos itself. I think we could look into what is needed and see if there is something for Atomos to do here.

tomsontom commented 4 years ago

@tjwatson is right what we do currently is to install a classloader-hook and spin up a new JPMS-Layer for you containing the javafx-modules. Our current implementation can be found at https://github.com/eclipse-efx/efxclipse-rt/blob/3.x/modules/core/org.eclipse.fx.osgi/src/main/java/org/eclipse/fx/osgi/fxloader/FXClassLoader.java#L207

What is quite interesting is that we support patching the loaded modules with the help of MANIFEST.MF headers so that you can eg add addExport/addOpens/... to the loaded JPMS-Modules.

The code is a little bit ackward as we have to use reflection (the EE for that bundle is still Java-8) but it works quite good and we rarely see complains that it breaks code.

stbischof commented 4 years ago

I closed it because I was not sure if this is in focus of atomos. (wouldn´t change your focus) I will have a look at this in the next days an give a report.

thx @tjwatson @tomsontom