0
votes

The Gluon Samples show us how we can dependency-inject (DI) our classes into others by using the @Inject annotation. We also see methods annotated with @PostConstruct allowing us to initialize a class that the "Application Context" instantiates on our behalf before injecting references to it elsewhere.

Before coming to JavaFX/Gluon for mobile development, my experience has been server-side applications, using the SpringFramework for DI. But here now, I don't understand how to get a handle/reference to the Bean Context of my application whereby I can fetch a singleton bean for use in static code that lives outside the context of managed beans.

I don't see an explanation about how CDI is done in the Gluon Developer Documentation. I found tutorials like this one that explain Weld is the Java EE reference implementation for CDI, even working in Java SE. But trying to begin with this in my code:

private Weld weld;

doesn't result in my IDE allowing me to import the class from my application's list of maven dependencies. So, the magic of DI in Gluon isn't from the use of Weld? Some independent explanations of using Weld in JavaFX seem to all be very old articles, implying nobody does CDI this way anymore.

I then found this 6 year old Gluon announcement about Gluon Ignite. Reading what I can find about it, including the README at GitHub, I think this may not be what I'm looking for either. It seems to be related to those that are implementing Guice, or Spring, or other DI frameworks into their Gluon applications. But I have not introduced any of those into my work - yet still, DI already works in my Gluon mobile app as I noted here at the top of this post.

I'd be interested in making use of one of the industry's well known DI frameworks but the Gluon tutorial documentation (and sample applications) about it is absent. So, I'm content with simply continuing to make use of whatever it is we get already in Gluon that accommodates DI behavior. What is it though? Where can we read more about it to make more control use of it?

2

2 Answers

1
votes

JavaFX does not prescribe any DI framework and you technically also do not need one. But if you want to use one you can use whatever you want and what makes sense in a client application. (Which specific example are you actually referring to?)

0
votes

In some of the examples they use http://afterburner.adam-bien.com/ I guess that is what you mean.