Title: Message
I second the middlegen motion. Generates the Bean classes with XDoclet tags and XDoclet does the rest: homes, remotes, descriptors. The sample is rather involved so here are the basic components for your own ant script: a classpath, a Middlegen task and an XDoclet task. I think this will save you some time in creating your own stipped down ANT script for midlegen.
 
1. Reference the database config and table list for later inclusion:
 
<?xml version="1.0"?>

    <!DOCTYPE project [ <!ENTITY database   SYSTEM "file:./config/oracle.xml"> <!ENTITY tables     SYSTEM "file:./config/tables.xml">]>
 
 
2. Have a classpath similar to the the following, also include the database config:
 
  <path id="classpath">
      <pathelement path="../common/apache/log4j.jar"/>
      <pathelement path="../common/apache/velocity.jar"/>
      <pathelement path="../common/apache/commons-collection.jar"/>
      <pathelement path="../common/apache/commons-logging.jar"/>
      <pathelement path="../common/jboss/jboss-common.jar"/>
      <pathelement path="../common/jboss/weblogic.jar"/>
      <pathelement path="../common/misc/middlegen.jar"/>
      <pathelement path="../common/misc/middlegen-entity-plugin.jar"/>
      <pathelement path="../common/oracle/ojdbc14.jar"/>
      <pathelement path="../common/sun/j2ee.jar"/>
      <fileset dir="${xdoclet.lib}">
              <include name="*.jar"/>
      </fileset>
  </path>
 
    &database
 
3. Have a Middlegen target as follows, key is to point to your own entity-cmp-20.vm velocity script and you can start with a copy from the middlegen source.
 
  <target name="generate-beans">
    <taskdef name="middlegen" classname="middlegen.MiddlegenTask" classpathref="classpath"/>
    <middlegen appname="${title}" prefsdir="${config}"  gui="false"  databaseurl="${database.url}"  datasourceJNDIName="DefaultDS"  driver="${database.driver}"
          username="${database.userid}"  password="${database.password}"  schema="${database.schema}"  initialContextFactory="nop"  providerURL="nop"  >
      <!-- Include table list -->
      &tables;
       <cmp20 destination="${build.source}" package="${package}" interfacepackage="${package}" localsuffix="Local" beansuffix="Bean"  localhomesuffix="Home" pkclass="false" viewtype="local"
        mergeDir="./velocity"  readonly="false"  fkcmp="false"   guid="false">
 
        <fileproducer id="entity-cmp-20" template="./scripts/entity-cmp-20.vm"/>
 
         <jboss/>
        <weblogic/>
      </cmp20>
  </middlegen>
 
4. Have an XDoclet target as follows:
 
  <target name="generate-interface">
     <taskdef name="ejbdoclet" classname="xdoclet.modules.ejb.EjbDocletTask" classpathref="classpath"/>
     <ejbdoclet destdir="${build.source}" mergedir="${config}"  excludedtags="@version,@author" ejbspec="2.0">
        <fileset dir="${build.source}">   <include name="**/entity/**/*Bean.java" />  </fileset>
        <localinterface pattern="{0}Local"/>
        <localhomeinterface pattern="{0}Home"/>
        <deploymentdescriptor xmlencoding="ISO-8859-1"  destdir="${build.entity.meta}"  validatexml="true" />
        <jboss version="3.0" xmlencoding="ISO-8859-1" destdir="${build.entity.meta}" validatexml="true"  datasource="java:/DefaultDS"  datasourcemapping="Oracle9i" />
        <weblogic  version="6.1" xmlencoding="ISO-8859-1" destdir="${build.entity.meta}" validatexml="true" datasource="DefaultDS" createtables="false" />
     </ejbdoclet>
 </target>
 
 
-----Original Message-----
From: Eric J Kaplan [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 29, 2003 6:06 AM
To: [EMAIL PROTECTED]
Subject: [JBoss-user] a to cmp

All

 

Anyone know of a good product (or eclipse plugin) that I can point at my database and have it generate cmp entity beans (files with xdoclet tags would be ok).  Yes, I realize I’ll have to tweak the files afterward, but there’s a lot of this that can be automated.

 

Regards

 

Eric J. Kaplan

Armanta, Inc.

350 Mt. Kemble Ave.

Morristown, NJ 07960

 

Reply via email to