Hi all,
in most IDEs there's an option to generate an empty implementation for
a given interface, or at least to fill in the implementation with a
skeleton.
I was wondering whether there was something like that in Ant, either
by default or developed somewhere by some talented open-sourcer. :-)
The idea would be to generate an empty class with the specified full
name, keeping all annotations and stuff.
(what for? Well, to help use JAXWS from interfaces, waiting for it to
provide utilities for interfaces instead of implementation classes...
but one never knows, it may be useful elsewhere)
Something like:
------------------------
<generateImpl
fromInterface="jrobinss.IMadCoder"
toImplementation="jrobinss.JavaCoder"
keepAnnotations="true"/><!-- optional arg -->
------------------------
...where IMadCoder would look like this...
------------------------
package jrobinss;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService
public interface IMadCoder {
public void code(@WebParam(name = "problemDescr") String pd);
}
--------------------
...and would generate this...
--------------------
package jrobinss;
import javax.jws.WebParam;
import javax.jws.WebService;
@WebService
public class JavaCoder implements IMadCoder {
public void code(@WebParam(name = "problemDescr") String pd) {
throw new UnsupportedOperationException("this is an empty
implementation generated by the Ant generateImpl tool");
}
}
--------------------
So, anything, anyone?
(I realize it's probably simple to code, I haven't yet really looked
into it)
--
JRobinss
Martin Gregorie - 14 Jan 2008 22:35 GMT
> So, anything, anyone?
>
> (I realize it's probably simple to code, I haven't yet really looked
> into it)
I've had a C utility generator for years that:
- generates a commented header file
- generates a commented source file containing code to display help
and parse the command line plus a main() to knit this all together.
- generates a manpage
- generates a Makefile
Running the generator followed by "make all" compiles the set of files
to produce a useless program, but one that displays help, validates its
command line and is documented. Useless, because although it runs, it
needs code added to make it useful.
I swiped the idea from the Sculptor 4GL, which accepts a file definition
and then generates an online program to update and display it plus a
reporting program. The generated sources can then be edited to do what
you really need, e.g. using lookup files, etc.
My utility generator was implemented using cvs (that's where the
template files live), gawk (applies name changes, etc. to the four
files) and a bash script.
It should be pretty trivial to extend this to generate Java as well as
C, but so far I've not felt the need to do it.

Signature
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |