15Dec/090
File attributes on layer.xml
When registering files on NBM's layer file, you can define attributes, too:
<file name="my-pkg-MyClass.instance"> <attr name="mystr" stringvalue="value"/> <attr name="myint" intvalue="1"/> <attr name="mymethod" methodvalue="my.pkg.MyClass.myMethod"/> </file>
They are avaliable as attributes of FileObject (through getAttribute). You can also use special attributes "instanceClass" to define a different class to instantiate or "instanceCreate" to define a factory method. This factory method can receive a map of attributes. I'm using it to customize a generic DataLoader:
public class MyLoader extends MultiDataLoader { private MyDataLoader(String secondaryExt) { super("MyObject"); this.secondaryExt = secondaryExt; } public static build(Map<String, Object> attrs) { return new MyLoader(attrs.get("ext").toString()); } ... }