A new, improved version of seam-gen is now included in the JBoss Seam distribution
This page describes the original seam-gen
JBoss seam-gen
Overview
I've created a set of Seam code generation commands that allow a developer to get up and running with Seam quickly. At some point, the seam-gen commands will be extended into IDE plugins but they are very useful today. This command line interface is for developers that want productive tooling for Seam today. With seam-gen, you don't have to:
Copy/paste your way into a working Seam project
Figure out the proper location/syntax for application configuration files
Write your own build script (seam-gen creates a pretty straightforward one for you)
Hand write or copy/paste stub SFSBs, SLSBs, Entity Beans, Facelets, BPM Actions, TestNG testcases or MDBs. seam-gen will stub out these components for you
Configure embedded-ejb for server-less testing
Seam Gen Command Guide
NAME seam - execute seam code generation. There is a seam.bat(windows) and seam.sh(linux/unix) that make calls to ANT targets for seam project setup and seam source code generation commands. You must have Ant 1.6 and jbossAS with EJB3 installed. SYNOPSIS seam [COMMAND] [PROJECT NAME] [OPTIONS]... SEAM PROJECT SETUP/DEPLOYMENT COMMANDS setup Set various seam-gen properties in build.properties. This task sets the various source code packages, target directories and jboss home. You can hand edit build.properties. There is support for generating eclipse WTP compliant EAR, JAR, WAR projects. If you select 'Y' for WTP, then some build tasks, like "compile", "build", "deploy" will not work. Example: seam setup new-project Create a new seam project that has all dependencies and minimal configuration. Refers to build.properties for project attributes. Example: seam new-project [PROJECT NAME] scaffold-project Create a new seam project that has all dependencies and a working entity bean, page-flow, BPM and a TestNG example. Example: seam scaffold-project [PROJECTNAME] deploy-project Deploy the project EAR and datasource to JBoss. This command will not work if you created a WTP project. Example: seam deploy-project [PROJECTNAME] SEAM CODE GENERATION COMMANDS new-action Create a new Java interface and SFSB with key Seam/EJB3 annotations. Example: seam new-action [PROJECT NAME] [SFSB NAME] new-conversation Create a new Java interface and SFSB with key Seam/EJB3 annotations. Adds annotations and stub methods for @Begin and @End. Example: seam new-conversation [PROJECT NAME] [SFSB NAME] new-stateless-action Create a new Java interface and SLSB with key Seam/EJB3 annotations. Example: seam new-stateless-action [PROJECT NAME] [SLSB NAME] new-page Create a new facelet that refers to template.xhtml for its layout. If no template.xhtml exists, create one. Example: seam new-page [PROJECT NAME] [PAGE NAME] new-action-page Create a new facelet that refers to template.xhtml for its layout. If no template.xhtml exists, create one. And, add a form with a submit button that executes a POJO/EJB3 method. The POJO/EJB3 must implement doAction(). Example: seam new-action-page [PROJECT NAME] [PAGE NAME] [EJB3 NAME] new-testcase Create a new TestNG test case that can be used to simulate a JSF request/response and standard JUnit type tests. Example: seam new-testcase [PROJECT NAME] [TESTCASE NAME] new-bpm-action Create a new POJO that implements jBPM's ActionHandler interface. This action class can be bound to a jBPM business process. Example: seam new-bpm-action [PROJECT NAME] [BPM ACTION NAME] new-entity Create a new EJB3 entity bean with key Seam/EJB3 annotations and a couple stub attributes (column1, column2). Example: seam new-entity [PROJECT NAME] [ENTITY NAME] new-mdb Create a new EJB3 MDB with key Seam/EJB3 annotations. Input prompt for destination type (Topic or Queue). Input prompt for JMS destination. Example: seam new-mdb [PROJECT NAME] [MDB NAME]
Seam-Gen creates a fully functional build script for your project
Build script targets include the following:
compile - compiles the java classes
build-jar - compiles your source files and packages them as a JAR
build-war - grabs images, stylesheets, facelets, web.xml etc... and packages a WAR
build-ear - hibernate, jbpm, ejb deployment descriptors, along with the JAR and WAR combined into an EAR that can be deployed to an application server.
depoy - build the EAR and deploy to jboss' deploy directory. Will also deploy a datasource for this project.
test - will run any TestNG scripts server-less using embedded-ejb.
WARNING - These tasks do not work for a WTP eclipse project. It is assumed that you will be building/deploying and testing via the WTP eclipse plugins.
Quick Start Guide
Download the seam-gen.zip file attached to this wiki
Unzip seam-gen.zip in the root directory of the latest version of Seam (I tested with 1.0.1.GA).
For example, if you have unzipped the Seam binary distribution to: C:\jboss-seam-1.0.1.GA, you will place seam-gen.zip in C:\jboss-seam-1.0.1.GA and unzip the archive.
I did this so I wouldn't have to re-distribute the Seam jars that you need to run/code the project
Run the jboss installer located at: http://sourceforge.net/project/showfiles.php?group_id=22866&package_id=193295, and create an ejb3 (non-clustered) app server instance
Open a command prompt (windows) or command shell (linux)
cd $SEAM_HOME/seam-gen
type: seam set-properties
this command will prompt you to input project setup info, hand-editing build.properties is also acceptable.
type seam new-project myProjectName (This will create a brand new seam-shell project that you can use to begin coding your app).
Open a second command prompt (windows) or command shell (linux)
cd to $PROJECT_HOME
type 'ant deploy'
This will build and deploy the seam-shell app
Open Browser to: http://localhost:8080/myProjectName
Tips/Tricks
Keep that seam-gen is meant to be a command line interface for generating Seam stub code, much like an IDE would. If you need to compile, build, deploy or test your seam generated application, you must cd to the project directory and use build.xml.
You can edit the code generation templates. They are in $SEAM_GEN/gen-templates.
You can edit the build.xml and build.properties file that seam-gen places in $PROJECT_HOME. It is located in $SEAM_GEN/build-scripts.
WTP provides nice application deployment, called "Publish/Re-publish". Also, it handles EAR compile/build, so a build.xml file isn't needed. Getting the WTP compliant project setup in eclipse inovolves a few steps, but it's not all that difficult and is standard eclipse project setup stuff.
For IDEs
Attached a modified (and reduced to file generation) Ant build file which allows entering the needed parameters with Ant inputs. By adding it to the IDE's build-script collection, one can easily generate classes and pages per click on the desired task.
Tip for IntelliJ IDEA:
Check all targets on the filters-tab in your ant options. That way you can easily execute them from within the build menu.
Suggestions / Wish-list
Please add suggestions and ideas for features on this page.
Comments