[REVIEW] Make controller instantiation customizable

Greg Brown greg.x.brown at oracle.com
Wed Dec 14 06:16:22 PST 2011


This seems pretty complex to me. Again, the design philosophy we have tried to apply here is "making simple things easy and difficult things possible". You can do quite a few "difficult" things with a custom class loader and the proposed ControllerFactory interface. For example, if an include needs a different class loader from its parent, your custom class loader can handle that by composition.

G

On Dec 13, 2011, at 10:27 PM, Tom Schindl wrote:

> Hi,
> 
> Having thought about this even more I think classloading is not the only
> thing people might customize, the same goes for event and field binding,
> all what I'd summerize below resolving and wireing.
> 
> I think we could address some of Daniel's requests and the classloading
> with one delegating class people could customize.
> 
> It could look like this:
> 
> FXMLLoader f ....
> f.setWireing(new DefaultWireing() {
> 
>  @Override
>  public Class<?> loadClass(String fxmlFileId, String name) {
> 
>  }
> 
>  @Override
>  public ElementBinder getControllerElementBinder(
>    String fxmlFileId,
>    Object controller, // might be null
>    String elementId) {
> 
>  }
> 
>  @Override
>  public MethodBinder getControllerMethodBinder(
>     String fxmlFileId,
>     Object controller, // might be null
>     String methodName,
>     Class<?>... arguments) {
> 
>  }
> 
>  @Override
>  public String loadIncludeFile(
>      String fxmlFileId,
>      String includeFilePath) {
> 
>  }
> 
> });
> 
> The reason I think FXMLLoader#setClassloader(Classloader)) is not enough
> is that one could include a child fxml-Files who might need a complete
> different Classloader.
> 
> To identify a fxml-File I'd suggest to add something like fx:componentid
> but this is not a must and we could also pass the FQN-Name of the
> fxml-File to identify it.
> 
> Tom
> 
> Am 14.12.11 00:50, schrieb Greg Brown:
>>> 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?
>> 
>> This might be a good alternative. Let me give that some thought.
>> 
>> Thanks,
>> G
>> 
> 
> 
> -- 
> 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