What we need is a Mapper+fileset+dyanmicRoots. See the attached file. You might want to do some weird stuff, say you want to iterate over all entity EJB's in one package and generate a HomeLookupUtil class which has some lookup methods for each bean, and you wan it generated into .util package in .subsystem package:
<mapper type="package" from="*"
to="{1}.util.{last-node-package-name-here}HomeLookupUtil"/>
So for com.foo.warehouse.MyBean/YouBean/etc classes you'll end up having
a com.foo.util.WarehouseLookupUtil class. Things like that or a factory
class for a set of beans and so on. So it's complicated. Michael Szlapa
wants to create a mapping from classes to some jsps, so need to provide
a programmable way and Mappers are the way to go.
A single "*" character is little help. I'm not yet sure about the
semantics let alone the implementation strategy! It should be easy to
use and intuitive.
Unfortunately we've gone the nonstandard way, using
destinationFile/pattern/packageSubstitution (though I argue that it's
easier to use than a mapper). XDoclet currently uses
destinationFile/pattern attributes for the output name (the class name,
the dd file name) and uses packageSubstitution for the package part of
it. packageSubstitution is similar to a Mapper but only deals with
package name, not the class name. I think it's easier this way to not
mix them and use of a Mapper needs some changes to Ant's Mapper class
(again a bad design, referring from the abstract Mapper class to
concrete mapper classes, hardcoding them there, etc). Probably for now
I'll keep packageSubstitution as is, so user will use
<packagaeSubstitution/> instead of <mapper/> (it's clearer because it
maps package names only), but I'll changes its "packages" attribute to
"from" and "substituteWith" to "to", so later when Ant 1.5/* adds
support for the mapper I'm searching for I'll simply change the inner
data type of the packagesubstitution to Mapper and users won't notice
it.
Ara.
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:xdoclet-user-
> [EMAIL PROTECTED]] On Behalf Of Erik Hatcher
> Sent: Sunday, January 06, 2002 12:35 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [Xdoclet-user] NullPointer in <packageSubstitution> - How
to
> achieve package substitution in <template/> subtask
>
> I'm coming into this thread a little late, and not sure I fully
understand
> the complete picture, but as far as Ant mappers go, I just added a new
> mapper type called "package" that maps a package path (with directory
> separators) to a package name (with dots). It is in Ant's CVS. Usage
is:
>
> <mapper type="package"
> from="*Test.java" to="TEST-*Test.xml"/>
>
> It is similar to the "glob" mapper in that the "*" is substituted from
the
> 'from' pattern to the 'to' pattern, with the directory separator
replaced
> with dots. The above example is useful for mapping Java code to its
> <junit>
> test results.
>
> Is this at all relevant to this thread? If not, nevermind! :)
>
> But if there are Ant limitations that are affecting XDoclet, by all
means
> bring them up to me.
>
> Erik
>
>
> > Message: 1
> > From: "Ara Abrahamian" <[EMAIL PROTECTED]>
> > To: "'Michael Szlapa'" <[EMAIL PROTECTED]>,
> > <[EMAIL PROTECTED]>
> > Subject: RE: [Xdoclet-user] NullPointer in <packageSubstitution> -
How
> to
> achieve package substitution in <template/> subtask
> > Date: Sat, 5 Jan 2002 01:20:54 +0330
> >
> > This is a multi-part message in MIME format.
> >
> > ------=_NextPart_000_0007_01C19587.48190F50
> > Content-Type: text/plain;
> > charset="US-ASCII"
> > Content-Transfer-Encoding: 7bit
> >
> > >From the Ant task, but I'm afraid not from the templatedoclet
because
> of
> > some limitations in Ant (though there's always some workarounds,
but.).
> > Let's see what the design evolves to :o)
> >
> > Ara.
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED]] On Behalf Of
Michael
> > Szlapa
> > Sent: Saturday, January 05, 2002 12:37 AM
> > To: [EMAIL PROTECTED]
> > Subject: Re: [Xdoclet-user] NullPointer in <packageSubstitution> -
How
> > to achieve package substitution in <template/> subtask
> >
> >
> > That would be great. Would it be possible to pass the parameters to
the
> > mapper either from ANT task or even better from the template ?
> >
> > For now I have moving/cleaning tasks as part of the the ANT
ejbdoclet
> > target.
> >
> > Thanks,
> > Michael
>
>
>
>
> _______________________________________________
> Xdoclet-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/xdoclet-user
--- Begin Message --- Title: [Xdoclet-devel] packageSubstitution> > The best solution is something like Ant's **/*.java blabla stuff of
> > filesets. But what does <packageSubstitution packages="**.ejb.**"
> > substituteWith="interfaces"/> mean?! Should it result in
> > com.foo.ejb.subsystem.interfaces or com.foo.ejb.interfaces? I mean
the
> > "root" is not clear. So I propose something like this:
> > "{1}" means current package minus last sub-package: com.foo->com
> >
> > So for com.foobar.somebean.ejb->com.foobar.somebean.interfaces:
> > <packageSubstitution packages="" substituteWith="{1}.interfaces"/>
> >
> > And for com.foobar.somebean.impl->com.foobar.somebean:
> > <packageSubstitution packages="" substituteWith="{1}"/>
> >
> > And for com.foobar.somebean.impl->com.foobar.intf:
> > <packageSubstitution packages="" substituteWith="{2}.intf"/>
> >
> > And for com.foobar.somebean->com.foobar.interfaces.somebean:
> > <packageSubstitution packages=""
substituteWith="{1}.interfaces.{L0}"/>
> > Where L0 mean Last sub-package.
> >
> > Or maybe a separate root=".." parameter where .. mean {2}?
> >
> > Ara.
>
> How about just using something like
> <packageSubstitution packages="{0}.impl" substituteWith="{0}"/>
> <packageSubstitution packages="{0}" substituteWith="{0}.interfaces"/>
> <packageSubstitution packages="{0}.ejb,{0}.beans"
> substituteWith="{0}.interfaces"/>
> i.e. don't worry about substituting different levels {1}, {2}, {LO}
etc.
> just have something there as a placeholder for the matched text so we
> don't have an empty string for either of the parameters? That keeps
it
> relatively simple. It gets a bit ambiguous with
packages="{0},{0}.impl",
> but I guess we'd just take the first match and skip the rest.Well, the only drawback of your proposal is that you have to list the
package names if you want to ../ in package hierarchy:<packageSubstitution packages="{0}.impl" substituteWith="{0}"/>
Now what if you have com.foo.wareouse, com.foo.bookkeeping and so on and
want to put interfaces in com.foo.interfaces? You have to list them all
like this:<packageSubstitution packages="{0}.warehouse,{0}.bookkeeping"
substituteWith="{0}.interfaces"/>I really think it's a common practice to put interfaces in a core
package and put implementations somewhere else. So I don't think this
proposal is good enough (yet). And what if you want it one level higher
(say com.interfaces)? You can't.Thoughts? Ideas?
Ara.
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
_______________________________________________
--- End Message ---
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel
