You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Eliot Stock <el...@practiv.com> on 2000/09/12 00:04:41 UTC

task for spliiting source code file

I'm doing code generation for EJBs using XSL Transformations. The output of
my transform is five monolithic pieces of Java source code, each with about
60 class definitions in them.

I need a task to go through these files and split them into individual class
source files. I've just written one, but it doesn't generate a directory
tree that maps to the package hierarchy, it just throws all the source into
one directory. I realize now I need that directory tree.

Has anyone done this?

Cheers,

Eliot Stock
Practiv NZ


RE: task for spliiting source code file

Posted by Chris Todd <ct...@alabanza.com>.
This is a smidgeon off topic, but you mentioned auto-generating EJB code,
and i thought the following post to the jBoss-dev list seemed relevant, both
to what you are proposing, as well as ant (see the original post regarding
using doclets from ant...would anyone care to give Rickard an answer to his
question?).

Sincerest regards,
Chris Todd
Software Engineer
Alabanza Corporation

<originally posted to jboss-dev earlier today>

I was inspired by the latest JavaWorld article on code generation by
using javadoc Doclets, and decided to try it out.

I created a "simple" doclet that could read an EJB bean file and
generate the following:
* Remote interface (one can tag remote methods in bean. Only tagged
methods appear in remote interface)
* Home interface (one can tag create methods in bean. One can also
define finders in class-comments, e.g. "@ejb-finder Collection
findLargeAccounts(int balance)")
* If Entity CMP -> Data object class generated which holds CMP fields
* If Entity CMP -> Primary key consisting of all fields marked as
pk-fields (yes, hashCode and equals are automatically implemented
properly)
* If Entity CMP -> Generate EJB 2.0-ish layer, i.e. allow bean to have
abstract get/set methods and generate EJB 1.1-CMP bean on top. The layer
also keeps track of dirty flag, and allows bulk accessor setting from
data object

Kinda cool. There is a generated example available at
http://www.dreambean.com/download/rickard/bank.zip. AccountBean.java is
the *only*
hand-written code (it extends from a generic dummy Entity-impl. It is
trivial; ignore), and everything else is generated on the fly.

The version of Ant I had did not support doclets properly, but if the
latest
one does, this approach has huge potential. Simply create your bean
code,
run the doclet prior to compilation in the build script, and then
compile
it all. Presto. Nice and clean. It might even be possible to generate
ejb-jar.xml automatically! Talk about productivity booster!

I will submit the EJB doclet itself for public use once I've touched it
up a
bit.

Any comments?

regards,
  Rickard
--
Rickard Öberg

Email: rickard@telkel.com

</originally posted to jboss-dev earlier today>

-----Original Message-----
From: Eliot Stock [mailto:eliot.stock@practiv.com]
Sent: Monday, September 11, 2000 6:05 PM
To: ant-user@jakarta.apache.org
Subject: task for spliiting source code file


I'm doing code generation for EJBs using XSL Transformations. The output of
my transform is five monolithic pieces of Java source code, each with about
60 class definitions in them.

I need a task to go through these files and split them into individual class
source files. I've just written one, but it doesn't generate a directory
tree that maps to the package hierarchy, it just throws all the source into
one directory. I realize now I need that directory tree.

Has anyone done this?

Cheers,

Eliot Stock
Practiv NZ