passing Context into Application?

tomas.brandalik tomas.brandalik at oracle.com
Mon Feb 24 01:06:12 PST 2014


Another way to get context would be from glass but I also prefer having 
another launch method on Application.

-Tomas

On 02/24/2014 09:52 AM, Tom Schindl wrote:
> Maybe some code makes that more clear.
>
> See
> http://git.eclipse.org/c/efxclipse/org.eclipse.efxclipse.git/tree/bundles/runtime/org.eclipse.fx.ui.workbench.fx/src/org/eclipse/fx/ui/workbench/fx/E4Application.java
>
> If I got Johan right he'd like to have an additional Application.lauch
> method with takes a context
>
> Application.launch(Class<? extends Application> clazz, Object
> applicationContext, String... args)
>
> and then on Application a method named getApplicationContext() : Object
> to retrieve the passed in value.
>
> Tom
>
>
> On 24.02.14 09:47, Tom Schindl wrote:
>> The problem is that the instance is created by Application.launch and
>> this call returns only when the application is stopped!
>>
>> Tom
>>
>> On 24.02.14 09:45, Richard Bair wrote:
>>> What if you had an AndroidApplication extends Application that added the new APIs, such that somebody could specialize behave by using the AndroidApplication subclass?
>>>
>>> On Feb 24, 2014, at 9:03 AM, Johan Vos <johan at lodgon.com> wrote:
>>>
>>>> I've been working on using the Android API's in a JavaFX application. As
>>>> explained in my blog post at
>>>> http://www.lodgon.com/dali/blog/entry/Using_Android_APIs_in_JavaFX we're
>>>> using a (imo) rather dirty trick.
>>>> The problem is that all Android API's need to be accessed via a Context
>>>> instance. The Java FXActivity that we use to bootstrap the JavaFX
>>>> Application extends Context, but it is only accessible in the JavaFX app
>>>> since we add it as a static field on FXActivity. When FXActivity calls the
>>>> LauncherImpl to start the application, we can't pass context information.
>>>> We can pass String[] but that is not useful here.
>>>>
>>>> In general, I think the environment that launches a JavaFX Application
>>>> (Android, iOS, script, JNLP, management software,...) may want to pass some
>>>> context information. Of course this context information is very specific,
>>>> with Object being the ugly common denominator.
>>>>
>>>> I realize it goes against the wora principles, but having the possibility
>>>> to either inject or set a context on javafx.application.Application would
>>>> definitely help using JavaFX in other environments.
>>>>
>>>> - Johan



More information about the openjfx-dev mailing list