Butterfly is a simple Code Generator using XMI as the input and XSLT templates to generate any type of code. Several templates are provided including EJB, JDO and Struts. Users may use the templates, modify them or create new ones using XSL.
Butterfly uses the KISS principal. The Java code consists of one file that reads in
the XMI file, creates a transformer and streams the output to the appropriate files.
There are two phases to the processing:
1. An initial XSL template is applied against the XMI file to simplify future
phases.
2. Templates are applied against each package that has XSL templates configured
for it.
An xml configuration file (config.xml) determines the stylesheets to apply and determines the
order in which that are applied.
1. Create a class diagram using your favorite UML Modeling tool (Rational
Rose,Object Domain, ArgoUML)
- Packages named 'entity' will generate BMP entity beans with matching
DDL.
- Packages named 'jdo' will generate JDO classes that can be used with
Forte4Java persistence capability.
- Packages named 'ui' will generate Struts classes that access corresponding
entity bean classes.
2. Export diagrams to XMI file using UML Modeling tool.
(ArgoUML has an XMI file in the zipped zargo file. Unfortunately Object Domain
and ArgoUML store the data types in two different locations. Modify the
config.xml and uncomment the phase1 template called argo-transform.xsl. comment
out the transform.xsl. the phase1 xsl will handle the differences between the
xmi files.)
3. Execute run.bat or run.sh and specify the path to the XMI file used for code
generation as the first argument,
and the output path as the second parameter (defaults to 'output'
directory)
The generated files will be placed in the output directory.
4. Execute ant in the output directory. This will build a deployable EAR file,
WAR file,
EJB JAR file, and SQL DDL Schema.
5. Modify any of the xsl-templates to generate your own code. phase1.xml shows example xml to build your own.
1. Execute ant in the root directory
1. Ant and optional.jar are required to compile the source code.
2. jdk1.4.0 was used for all compilation and testing.
To deploy to the Reference Implementation you need to download it from java.sun.com and install it. It comes with Cloudscape which can be launched from the bin directory with the command cloudscape -start. Next run cloudscape -isql and at the prompt type run '{location of schema.sql}'; This will create the database schema for the appliation. Next launch the application server by running j2ee.sh from the bin directory and finally launch the deploytool.sh, open an application and select the deploy.ear file. deploy the ear to the localhost. Now you can hit the application with http://localhost:8000 You will need to run the policytool from the java/bin directory and give full access rights to ALL CodeBase in the {J2EE_HOME}/lib/security/server.policy file. Also in the deployment tool, you need to create a cloudscape datasource that is named 'jdbc/mydb' under Server Configurations.
Download Butterfly Code Generator version 0.18
Go to Project page on the SourceForge