Fuse available on java.net

I just released Fuse on java.net. It already changed a bit since the first time I talked about it. Now, here is how you load and inject resources:

// Can be an InputStream, a URL, a File, a String or a Class/String pair
ResourceInjector.load("/resources/theme.properties");
ResourceInjector.inject(componentInstance);

Fuse now handles component hierarchies as in the following example:

class MyComponent extends JComponent {
  @InjectedResource
  private Color background;
}

class MyCoolComponent extends MyComponent {
  @InjectedResource
  private Color foreground;
}

// Injects resources in MyCoolComponent and MyComponent
ResourceInjector.inject(myCoolComponentInstance, true);

Finally, you can prevent namespace collisions in the properties file by using the two annotation parameters I introduced in @InjectedResource:

class MyComponent extends JComponent {
  @InjectedResource(key="Common.foreground")
  private Color foreground;
        
  @InjectedResource(name="backgroundColor")
  private Color background;
}

Without parameters, both properties keys would be resolved by Fuse to MyComponent.background and MyComponent.foreground. The key parameter lets you override the property key, in this case MyComponent.background becomes Common.foreground. The second parameter, name, lets you override the right part of the key. Thus, MyComponent.background becomes MyComponent.backgroundColor. If you use both parameters, key will supercedes name.

Fuse is not available in a binary form yet. You can grab its source code from the CVS. The repository contains project files for NetBeans, IntelliJ IDEA and Eclipse. Enjoy!

Comments are closed.