----- Original Message -----
From: Jason Essington <[EMAIL PROTECTED]>
Date: Wednesday, August 28, 2002 8:45 pm
Subject: [Middlegen-user] Generating beans into different packages
> Aslak what a great tool, thanks!
>
> Everyone, for discussion:
>
> I am trying to divide my tables (actually their generated beans)
> into
> multiple packages that represent their real purpose in life.
>
If you put {0} in the package attribute, the {0} will be substituted
with the table name. You'll end up with one package per bean/table.
Maybe that's too fragmented for you?
http://boss.bekk.no/boss/middlegen/plugins/java.html
> currently I have an ejb.entity and an ejb.reporting.entity package
> and I
> am sure I'll have more as I go on.
>
> So here is what I have found:
> I can't use multiple <cmp20> elements in the build.xml file as the
> name=
> attribute doesn't seem to take effect until too late and middlegen
> assumes both have a name of cmp20 then fails.
I have fixed the bug. Will commit it when I get near a network that
allows me to connect to CVS. Probably tomorrow.
> I did work around this by creating multiple <plugin> references in
> the
> plugins/entitybean/classes/META-INF/middlegen.xml file that just
> had
> different name attributes. This allowed me to acces the cmp20
> plugin as
> <cmp20> , <cmp20-2>, etc. Then used embeded <fileproducer> with
> embeded
> <table> tags to limit which plugin produced which tables.
>
> This works but of course in the gui you are presented with 2
> plugin tabs
> and when a table is selected you are allowed to set its properties
> in
> each tab weather or not that plugin is going to generate the file
> for
> the table. This isn't currently an issue for me as I am only
> generating
> beans from say 14 tables, but when my table count gets too much
> over 50
> tables and I am trying to put the resulting beans into 3 or more
> packages, my brain won't be able to remember which tab I should be
> setting the properties on.
>
> Would it be possible to for a plugin to check which tables the it
> is
> actually going to generate files for, and only display(allow the
> editing
> of) information on its gui tab for tables it is actually going to
> generate a file for?
>
Anything is possible. But this is currently not implemented. Currently
you can make a copy of the entity-cmp-20.vm template as a file, use
<fileproducer> and tell the plugin to use that template. Inside the
<fileproducer> element you can put several <table> elements, telling
the <fileproducer> to generate only for those tables.
Ideally you would be able to put <table> elements directly under the
<cmp20> element.
I could add a new feature that would visually gray out all visual
tables that are not part of the <table> elements corresponding to the
plugin on the selected tab.
> Or, perhaps, there would be value in making multiple
> <fileproducer>
> elements inside the <cmp20> element that could override many of
> the
> attributes that are currently set in the cmp20 element (package,
> interfacepackage, jndiprefix, etc). This would allow the plugin to
> define several fileproducers to write the beans out to different
> packages, or different jndi contexts, or whatever. This would also
> leave
> only 1 tab in the gui for this plugin thus reducing the possiblity
> of
> configuring a table in a tab that isn't going to produce a file
> for it
> anyway.
>
That's a bit tricky. Keep in mind that Middlegen (and <fileproducer>)
has nothing EJB-specific to them. So I will not introduce anything EJB-
specific in them either. You see, Middlegen's ultimate goal is to be a
generic database driven code generator.
> for instance if I wanted some of my tables generated into the
> .ejb.reporting.entity package but others in the .ejb.entity
> package.
> something like this could be done.
>
> <cmp20
> name="cmpEntityBeans"
> destination="${build.gen-src.dir}"
> package="${name}.ejb.entity"
> interfacepackage="${name}.ejb.local"
> jndiprefix="ejb"
> generatepk="false"
> dataobject="true"
> viewtype="local"
> mergedir="${basedir}/src/middlegen"
> readonly="false"
> fkcmp="true"
> >
> <!-- this fileproducer would just use the values from
> the
> cmp20 element (current behavior)-->
> <fileproducer
> id="entity-cmp-20"
> template="${template.dir}/entity-cmp-20.vm"
> >
> <table name="tclients"/>
> <table name="tcodes"/>
> </fileproducer>
>
> <!-- multiple fileproducers are not currently
> possible, nor
> is overriding attributes of the parent plugin element -->
> <!-- but this fileproducer overrides package,
> interfacepackage, and jndiprefix -->
> <fileproducer
> id="entity-cmp-20"
> template="${template.dir}/entity-cmp-20.vm"
> package="${name}.ejb.reporting.entity"
> interfacepackage="${name}.ejb.reporting.local"
> jndiprefix="ejb/reporting"
> >
> <table name="treportbatches"/>
> <table name="treportcmds"/>
> </fileproducer>
> </cmp20>
>
>
It would be better to use multiple <cmp20> elements.
> Maybe I am trying to do something that has no value to anyone
> else, or
> maybe there is a better way to do this altogether.
>
>
> -jason
>
>
Let me know if this would work for you.
Aslak
>
> -------------------------------------------------------
> This sf.net email is sponsored by: Jabber - The world's fastest
> growing
> real-time communications platform! Don't just IM. Build it in!
> http://www.jabber.com/osdn/xim
> _______________________________________________
> middlegen-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/middlegen-user
>
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
middlegen-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/middlegen-user