EJB generator

The general focus of this generator is to automatic create EJB classes. The input of the EJB generator is an existing simple interface or class (a remote interface is NOT required!). The generator creates the home interface, remote interface and the bean implemenation class. Additional the generator creates proxy and junit testclasses to each generated EJB.

The EJB generator can also create DAO classes! Have a look at here.

The next simple example shows the mechanism:

Input file:

public interface EJBTestFile
{
...
    public void create();
    public void update();
    public void delete();
    public void run();
...
}

The generator will create the following files (depending on the configuration):

The xxxHome class defines the EJB home interface and the xxx class the EJB remote interface. The class xxxBean implements the concrete statless session EJB. The selected method like update in the example is the public method in the EJB. Additional throws each EJB method the RemoteException to be compatible with EJB. The EJB generator creates or updates also the ejb deployment descriptor (META-INF/ejb-jar.xml)!

The proxy classes are handy to use the EJB. The user of the EJB has not to care about J2EE stuff like lookup, just use the bean.

The junit testcases will also generated by the EJB generator. The testcase files of each package are placed in the subdirectory tests as default. The testcase file test.conf will also be created which can used by the TestFramework.


Using EJB generator

To use te EJB generator you can use the script file ejbgenerator.bat or ejbgenerator.sh. You have probably some hands on the files to work with your environment.

The usage is the following:

Usage:  jptools.j2ee.util.generator.EJBGenerator [OPTIONS]
OPTIONS:
  -o [path]                       Sets the output path
  -i [path or file]               Sets the input file (directory or a file)
    
OPTIONAL OPTIONS:
  -c [configuration.properties]   Reads the generator and formatter base configuration. This file defines the global settings.
  -pc [configuration.properties]  Reads the additional or project specific generator and formatter configuration.
  -verbose                        Sets on the verbose mode
  -t [testcase configuration]     Sets the testcase file
  -dd [deployment-descriptor]     Sets the EJB deployment descriptor
  -dao                            Enables DAO generation
  -daoEJB                         Enables the generation of DAO as EJB
  -processor                      Enables processor generation
  -sqlInputPath [path]            Sets the sql base path
  -d [configuration.properties]   Defines the database configuration file

The input definition defines either one or multiple files or a directory followed by the names of the files in the directory to consider.


Configuration

The generator can be configured over a properties file. Additional the javadoc will be used to define some special behavior. The description of the configuration is here available.