Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2008

Tip: Looking for answers? Try searching our database.

generation of implementation using Ant

Thread view: 
jrobinss - 14 Jan 2008 15:02 GMT
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       |



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.