Discussion:
[Middlegen-user] Separating generated CMP bean into different packages
John McLaughlin
2005-03-22 10:58:57 UTC
Permalink
Hi,

I'm using middlegen 2.1 to generate an EJB persistence layer, and have
been trying to separate the generated EJBs into separate packages, with
mixed success.

I've been using multiple <cmp20/> plugins with <fileproducer/> in the
middlegen task, which looks as follows (simplified):

<middlegen
appname="${name}"
prefsdir="${build.gen-src.dir}"
gui="${gui}"
databaseurl="${database.url}"
initialContextFactory="${java.naming.factory.initial}"
providerURL="${java.naming.provider.url}"
datasourceJNDIName="${datasource.jndi.name}"
driver="${database.driver}"
username="${database.userid}"
password="${database.password}"
schema="${database.schema}"
catalog="${database.catalog}"
includeViews="false"
<table name="users" generate="true" singular="User"
plural="Users"/>
<table name="address" generate="true" singular="Address"
plural="Addresses"/>

<cmp20
name="contact"
destination="${build.gen-src.dir}"
package="${app}.contact.ejb"
interfacepackage="${app}.contact.interfaces"
jndiprefix="${unique.name}"
valueobject="true"
sessionfacade="false"
viewtype="local"
mergedir="${basedir}/src/middlegen"
readonly="false"
fkcmp="true"
guid="false"
<fileproducer
template="${ifx.cmp.template}"
id="entity-cmp-20">
<table name="address"/>
</fileproducer>
</cmp20>

<cmp20
name="users"
destination="${build.gen-src.dir}"
package="${app}.user.ejb"
interfacepackage="${app}.user.interfaces"
jndiprefix="${unique.name}"
pkclass="false"
dataobject="false"
valueobject="true"
sessionfacade="false"
viewtype="local"
mergedir="${basedir}/src/middlegen"
readonly="false"
fkcmp="true"
guid="false"
<fileproducer
template="${ifx.cmp.template}"
id="entity-cmp-20">
<table name="users"/>
</fileproducer>
</cmp20>

</middlegen>

'address' has a one to many relationship to 'users'

With the above, the beans are generated
into .../user/ejb/UserBean.java, and .../contact/ejb/AddressBean.java,
but the CMR xdoclet for getAddress() markup in UserBean is looking
for .../user/interfaces/AddressLocal, and similarly getUsers() in
AddressBean refers to .../contact/interfaces/UserLocal.

I've searched the list archives, bug list etc, but haven't come across
any solution, though I did see it crop up as an RFE about 2 years ago.

Is there any reasonably easy way of doing this? Having looked through
the code, I'm not sure there is, but I hopefully stand to be corrected!

Thanks,

John

Loading...