[REVIEW] Make controller instantiation customizable

Tom Schindl tom.schindl at bestsolution.at
Tue Dec 13 14:54:33 PST 2011


Am 13.12.11 22:33, schrieb Greg Brown:
>> Any chance we could have the method take the string exactly as it is defined in the FXML, rather than have FXML create a class and pass that in? I'm thinking of two scenarios for this: 1) the class being loaded is via a different classloader (i.e. my controllers and FXML are coming from a repository somewhere and loaded on demand via a custom URL classloader),
> 
> Two reasons why I'm not sure this is the right solution:
> 
> 1) The current design is consistent with the BuilderFactory interface, which also takes a Class.
> 
> 2) Since FXMLLoader uses the current thread context class loader, your app has control over how the class will be loaded.
> 

My vote would have been also on the String instead of a Class but
because the Builder API also works like this I think we should stay
consitent.

I agree with Daniel that changing the Thread-Context-Classloader feels
really dirty.

The whole Class loading thing was also a problem to OSGi where there's
nothing like a global classpath and so I had to set and reset the
context classloader.

Might I suggest that you add the possibility to set a custom classloader
to FXMLLoader (FXMLLoader#setClassloader(Classloader)) which is used for
the class look up?

IMHO this would solve the OSGi and Daniels use case.

Tom

-- 
B e s t S o l u t i o n . a t                        EDV Systemhaus GmbH
------------------------------------------------------------------------
tom schindl                 geschäftsführer/CEO
------------------------------------------------------------------------
eduard-bodem-gasse 5-7/1   A-6020 innsbruck     fax      ++43 512 935833
http://www.BestSolution.at                      phone    ++43 512 935834


More information about the openjfx-dev mailing list