Even More Fuse

Following Alex suggestions I updated Fuse. Actually it's more an upheaval than anything else. First, ResourceInjector is not static anymore. Here is how to use it now:


Calling get() returns the default instance of ResourceInjector, always guaranteed to exist. You can also pass a key to get/create another injector: ResourceInjector.get("my_ui"). Two new methods are also available to better manage injectors life cycle: reset() to clear all the properties and dispose() to clear the properties and remove the injector from the internal registry. It is advised not to keep track of injectors yourself. This new API should be thread safe (I wrote the code but I need to test it). You can have multiple threads calling inject() but only one calling load() (not injection is allowed while a thread has the lock on the load method).

Type loaders have also been updated. The now use a third parameter to load the values, a Class representing the object in which you inject the value. This parameter can be used to resolve resources in the appropriate class loader. It is used for instance by the image and font type loaders. Finally, you can use a specific type loader in lieu of the default one to inject a resource:

class TextEditor {
  private String defaultTextContent;

I updated and extended the documentation on the project page to take into account these changes. I still need to write the section explaining how to create a custome type loader but it's pretty straightforward.

Comments are closed.