Welcome to BeanGen, the enterprise java bean generator and openEJB configurator that makes j2ee look like a piece of cake :-)
So you want to try it out... well it's very easy, first download a binary version, (if you want you can download the source directly from CVS and compile it yourself), however in this howto i'm assuming you have a binary jar file
Now you can execute it like this:
java -jar beangen-<version>.jar input_file.txt output_file.jar
don't forget that output is a jar file so don't use other extension than
Right now you have always to use the two parameters, if you don't you'll have problems because beangen will try to use some hardcoded path's (used in development).
Ok, you can run it but you don't have a input file... i'll explain how to generate one in the next step...
XML file format is great and takes alot to write a simple file, so... i don't use it :-P I'll support XML files in a later version but it's not implemented at the present.
You may be asking... so how do i write my input file? quite easy! You have only 11 commands, every line that start's with a
is a comment. Now about the commands...
This is a setup command, it informs where's your tomcat or openejb installed. You should have two of these commands per file. Don't forget that
is the special character that separates the fields. No there's no escape sequence for now, there will be later...
PROJECT:<unix_name>:<Project Full Name>
This command is used for documentation and war file generation only. There should only be one per file. unix_name is a single word that identifies your project, project full name you should have already found what it means...
If you want lazy loading (cache of data) as defined at sun's best practices for ejb's your should tell what you want to cache. Right now it can cache Collections, Fields and Foreign Keys. If you don't one of these to be cached just remove it from the list
RESOURCE:DATASOURCE:<unix_name>:<jndi path>:<sql server>:<key generator>
You define here the resources you want to make available in our project, right now only DATASOURCES are supported. For information about key generator, server types see www.castor.org
ENTITY:[CMP|BMP]:<table name>:<java name>:<java package>
Simple isn't it? Define an entity bean you can choose CMP or BMP (BMP not tested as CMP)
For each entity you should define one of these commands. You need to inform where you want this bean inside JNDI. (Optional)
This description will be used to document your bean, if you need to write big comments, just write lot's of these commands inside an entity and they will be appended with each other. (optional)
Your name, just for javadocs. (Optional)
FIELD:<type>:<db field name>:<java name>:[null|not null]:[ro|rw]:[pk|fk]
You need to define as many as you want for each entity. the read/write option and pk/fk option are optional if you don't need them. You should have a pk field for every entity. The field types supported are the same supported by castor, see www.castor.org
Complex keys (keys composed with more than one field aren't supported yet...
RESOURCE-LINK:<name from resources above>
Where can we get the database? this will tell the bean wich resource to use.
In this release only one to many and one to one relationships are supported. one to one are automatically found because of fk keywork in field command, one to many have to be defined this way.
So you know the commands but want to see them in action? ok, this is the Titan example:
# Define the project name
# Enable Lazy loading (not fully functional)
# Define a global DataSource Resource
# define a CMP entity bean
# inside jndi, this bean will be located under titan folder (optional)
DESCRIPTION:Define a Cabin Object...
# i changed char(30) to varchar
# this bean will have a datasource resource
# I don't like BigDecimal... so i'll trick Castor
# define collections here...
The latest input file sample is here