Hi,
We wish to extend the standard JAXB code generation process such that the generated classes can have additional methods that are not specified in the original XML document. The additional methods' signatures come from interfaces. Those additional methods' code will be generated by JAXB, which specify delegate objects to do the task. Similar to partial classes in C#.
Currently, we are enhancing the Interface Insertion Plugin for our own project. We were curious if there was a better way to do things. Specifically:
1. Currently we are pre-compiling the interface and then having JAXB pick it up from a jar. Is it possible to insert interfaces, without needing them to be pre-compiled. i.e. have JAXB find a source Interface to insert, rather than requiring it to exist in a Jar / .class file.
2. Currently we are unable to utilize JAXB generated classes inside the interface that we are going to be inserting. Given that we have to pre-compile the interface, we are unable to determine that the class exists in the JAXbcompiled classes (see above). Is it possible to utilize classes that JAXB will generate inside our source-code as a parameter.
3. Currently JAXB is generating code that looks like this:
<code>
public void total() {
try {
Class delegateClass = null;
delegateClass = Class.forName("ItemsDelegate");
Object delegateObject = null;
delegateObject = delegateClass.newInstance();
Method delegateMethod = null;
delegateMethod = delegateClass.getMethod("total", Items.class);
Object returnObject = null;
returnObject = delegateMethod.invoke(delegateObject, this);
} catch (ClassNotFoundException e) {
throw new RuntimeException((e));
} catch (InstantiationException e) {
throw new RuntimeException((e));
} catch (IllegalAccessException e) {
throw new RuntimeException((e));
} catch (NoSuchMethodException e) {
throw new RuntimeException((e));
} catch (InvocationTargetException e) {
throw new RuntimeException((e));
}
}
</code>
We would like to have JAXb generate code to look like this:
<code>
public void total() {
ItemsDelegate delegate = new ItemsDelegate();
delegate.total();
}
</code>
"ItemsDelegate" is the delegate object. Rather than use reflection we would much rather have it construct the delegate and utilize its methods, which is currently only possible if ItemsDelegate is precompiled.
Cheers,
Chin-Yuan Cheng
Risk Focus Inc.
Mobile: 201-965-6929
New York Office: + 1 917 591 1616 Fax: + 1 917 591 4563
London Office: +44 (0) 207 980 8855 Fax: +44 (0) 207 691 7942